compression: lead with methods on Bytes (slice of #146) #175

Closed
opened 2026-10-08 07:03:41 +00:00 by orion · 3 comments
Collaborator

Goal

std/compression is used as methods on the bytes it works on: bytes.inflated(), bytes.deflated(), bytes.gzipped(), bytes.gunzipped(), bytes.crc32().

Part of #146 (methods are the preferred API style; owner direction 2026-10-06, first applied in #96 as Digest.equalsConstantTime with constantTimeEqual kept as a thin wrapper). This slice follows exactly that pattern.

Functions in scope

inflated, deflated, gzipped, gunzipped, crc32 in std/compression (all take Bytes first). Keep as free functions (internal buffer helpers, not API): inflateInto, deflateInto, crcValue, crcBetween.

Source (pinned record)

  • docs/standard-library/compression.md, BINARY.md; no design record fixes the API shape
  • Extension members are named where they are used (CONCEPT, "Extension Methods", pinned); callers use the method like any member. If an extend without a trait on a type of another package turns out not to work in std/, stop and re-plan instead of working around it.

Acceptance criteria

  • std/compression provides the methods Bytes.inflated(), .deflated(), .gzipped(), .gunzipped() and .crc32() with the result types of the current free functions
  • Tests (std/compression test file): for each method, the method result equals the free function result on the existing test vectors (empty, small, multi-block input, corrupt input for the Result ones)
  • Each free function stays and becomes a thin wrapper that only calls the method; its signature, behaviour and existing tests are unchanged. It is not marked deprecated here (the deprecation path is an open owner decision on #146).
  • The module's documentation page under docs/standard-library/ leads with the method in every example; the wrapper is listed as the older spelling. Examples are checked with trb check; skills/ is regenerated.
  • No caller outside the module changes (compiler/src and tools/ keep calling the wrapper).

Seed

No. Ordinary TorbScript in std/ only: no syntax change, no new native, no driver flag, no std name the compiler looks up by string. If that turns out wrong, stop and re-plan (two commits, seed refresh).

Size

One PR, one Conventional Commit (refactor(<module>): ... or feat(<module>): ...), tests and docs in the same commit.

Dependencies

Tracking epic: #146. No other dependency; independent of the other module slices.

## Goal `std/compression` is used as methods on the bytes it works on: `bytes.inflated()`, `bytes.deflated()`, `bytes.gzipped()`, `bytes.gunzipped()`, `bytes.crc32()`. Part of #146 (methods are the preferred API style; owner direction 2026-10-06, first applied in #96 as `Digest.equalsConstantTime` with `constantTimeEqual` kept as a thin wrapper). This slice follows exactly that pattern. ## Functions in scope `inflated`, `deflated`, `gzipped`, `gunzipped`, `crc32` in `std/compression` (all take `Bytes` first). Keep as free functions (internal buffer helpers, not API): `inflateInto`, `deflateInto`, `crcValue`, `crcBetween`. ## Source (pinned record) - [docs/standard-library/compression.md](https://git.torb.dev/torbscript/language/src/commit/129f1574e8ad4c9c691306808eb39900e77d4fc2/docs/standard-library/compression.md), [BINARY.md](https://git.torb.dev/torbscript/language/src/commit/129f1574e8ad4c9c691306808eb39900e77d4fc2/docs/design/BINARY.md); no design record fixes the API shape - Extension members are named where they are used (CONCEPT, "Extension Methods", [pinned](https://git.torb.dev/torbscript/language/src/commit/129f1574e8ad4c9c691306808eb39900e77d4fc2/CONCEPT.md)); callers `use` the method like any member. If an `extend` without a trait on a type of another package turns out not to work in `std/`, stop and re-plan instead of working around it. ## Acceptance criteria - [ ] `std/compression` provides the methods `Bytes.inflated()`, `.deflated()`, `.gzipped()`, `.gunzipped()` and `.crc32()` with the result types of the current free functions - [ ] Tests (`std/compression` test file): for each method, the method result equals the free function result on the existing test vectors (empty, small, multi-block input, corrupt input for the `Result` ones) - [ ] Each free function stays and becomes a thin wrapper that only calls the method; its signature, behaviour and existing tests are unchanged. It is **not** marked `deprecated` here (the deprecation path is an open owner decision on #146). - [ ] The module's documentation page under `docs/standard-library/` leads with the method in every example; the wrapper is listed as the older spelling. Examples are checked with `trb check`; `skills/` is regenerated. - [ ] No caller outside the module changes (`compiler/src` and `tools/` keep calling the wrapper). ## Seed No. Ordinary TorbScript in `std/` only: no syntax change, no new native, no driver flag, no std name the compiler looks up by string. If that turns out wrong, stop and re-plan (two commits, seed refresh). ## Size One PR, one Conventional Commit (`refactor(<module>): ...` or `feat(<module>): ...`), tests and docs in the same commit. ## Dependencies Tracking epic: #146. No other dependency; independent of the other module slices.
Author
Collaborator

[loop:torbscript] scope update from the owner decision on #146 (torben, 2026-10-08): the free functions covered by this slice are removed in the same PR that adds the methods, not kept as wrappers and not marked deprecated. Migrate every caller in the repo (std, tests, examples, docs) to the method in the same PR. No lint migration rule needed.

[loop:torbscript] scope update from the owner decision on #146 (torben, 2026-10-08): the free functions covered by this slice are **removed** in the same PR that adds the methods, not kept as wrappers and not marked `deprecated`. Migrate every caller in the repo (std, tests, examples, docs) to the method in the same PR. No lint migration rule needed.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261008 until 2026-10-08T13:15:00Z

[loop:torbscript] claim implement by session:loop-torbscript-20261008 until 2026-10-08T13:15:00Z
argus closed this issue 2026-10-08 08:09:33 +00:00
Author
Collaborator

[loop:torbscript] implement: PR #181 is open (one commit refactor(compression): ...), forge CI green (gates, tier A, bootstrap, docs and skills checks; tier B skipped as not applicable). inflated, deflated, gzipped, gunzipped and crc32 are now methods of Bytes; the free functions are removed and all callers (std/archive, compiler/src, compiler tests, benchmarks, docs, regenerated skills) are migrated. The methods are declared in std/compression/src/lib.trb, because a re-exported extension member cannot be imported through the re-exporting module (path mismatch in bindMemberImport/memberImportOf); filed as #182 (label loop). Worker token usage: not metered in-session. next: review

[loop:torbscript] implement: PR https://git.torb.dev/torbscript/language/pulls/181 is open (one commit `refactor(compression): ...`), forge CI green (gates, tier A, bootstrap, docs and skills checks; tier B skipped as not applicable). `inflated`, `deflated`, `gzipped`, `gunzipped` and `crc32` are now methods of `Bytes`; the free functions are removed and all callers (std/archive, compiler/src, compiler tests, benchmarks, docs, regenerated skills) are migrated. The methods are declared in `std/compression/src/lib.trb`, because a re-exported extension member cannot be imported through the re-exporting module (path mismatch in `bindMemberImport`/`memberImportOf`); filed as https://git.torb.dev/torbscript/language/issues/182 (label loop). Worker token usage: not metered in-session. next: review
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#175
No description provided.