12 KiB
12 KiB
Tasks — Bitpacker stub completion
Every checkbox MUST reflect work actually done in this change. Do not retroactively tick. The five gaps closed here were prematurely ticked in
bitpacker-modular-restructure/tasks.md; that's the failure mode this checklist guards against.
1. Spec authoring
- 1.1 Re-read
bitpacker-modular-restructure/proposal.mdparity table (the "last verified 2026-05-02" version) so the gap definitions stay aligned - 1.2 Read
openspec/AGENTS.mdSections 13 (spec-conformance audit) and 14 (source mapping for migrations) - 1.3 Draft
proposal.mdcovering all five caps, each with explicit ADDED/MODIFIED/REMOVED lists - 1.4 Fill
## Source mappinginproposal.mdwith upstream line ranges; every "no source line" requirement justified - 1.5 Draft spec deltas under
specs/<cap>/spec.mdforbitpacker-delta,bitpacker-network,bitpacker-compressed,bitpacker-streaming,bitpacker-schema - 1.6 Every requirement in every spec delta carries a
**Verified by:**line naming concreteit(...)titles - 1.7
openspec change validate bitpacker-stub-completionexits with no errors
2. @suaveplan/bitpacker-delta
- 2.1 Port
DeltaStateManagerfrom upstreamsrc/core/delta/delta-state.tsintopackages/bitpacker/bitpacker-delta/src/delta-state/delta-state.ts(new module dir) - 2.2 Port
DeltaManager+FieldChangefrom upstreamsrc/core/delta/delta-manager.tsintopackages/bitpacker/bitpacker-delta/src/delta-manager/delta-manager.ts - 2.3 Replace
Date.now()with an injectableClockfrom@suaveplan/types; default toClock.system() - 2.4 Replace
JSON.stringify-based equality with a structural walker that respectsBitPackerSchemafield order; keepJSON.stringifyonly behind an opt-inequalityMode: "json"flag for parity with upstream - 2.5 Define
DeltaConfigZod schema; reject unknown modes withBitpackerErrorcodeBITPACKER.DELTA_INVALID_CONFIG - 2.6 Add
BITPACKER.DELTA_*codes topackages/bitpacker/bitpacker/src/error-codes.ts(DELTA_INVALID_CONFIG,DELTA_STATE_NOT_FOUND,DELTA_FIELD_LIMIT_EXCEEDED) - 2.7 Delete the 35 L inline
DeltaManagerfrombitpacker-delta/src/index.ts; re-export the new class from there - 2.8 Sibling
.mdper implementation file, ≥200 words, basic + advanced examples
3. @suaveplan/bitpacker-network
- 3.1 Move upstream
src/network/network-simulation.tsand accompanying type companions intopackages/bitpacker/bitpacker-network/src/simulator/ - 3.2 Replace every
Math.random()call with an injectableRngfrom@suaveplan/types; default toRng.crypto()(usescrypto.getRandomValues) - 3.3 Replace every
Date.now()call with an injectableClock - 3.4 Re-host
NETWORK_CONDITIONS,PacketStatus,PacketInfo,NetworkSimulationOptions,NetworkSimulationStatsnext to the simulator - 3.5 Port
createNetworkSimulator(options)factory verbatim - 3.6 Add
BITPACKER.NETWORK_*codes (NETWORK_BANDWIDTH_EXCEEDED,NETWORK_DISCONNECTED,NETWORK_STAT_OVERFLOW) - 3.7 Delete the 48 L stub at
bitpacker-network/src/index.ts; replace with explicit re-exports of the new class, factory, presets, and existingsimulateLatency/shouldDropPacket/applyNetworkConditionshelpers (now backed by the simulator) - 3.8 Delete
packages/bitpacker/bitpacker-game/src/network/network-simulation.ts(and its sibling.md/ tests) - 3.9 Add a
bitpacker-game/src/network/index.tsshim that re-exports from@suaveplan/bitpacker-network; mark@deprecatedwith a one-release removal note - 3.10 Sibling
.mdper implementation file, ≥200 words, basic + advanced examples
4. @suaveplan/bitpacker-compressed
- 4.1 Port
CompressedBitPacker<T>from upstreamsrc/compressed/bitpacker.tsintopackages/bitpacker/bitpacker-compressed/src/compressed-bit-packer/compressed-bit-packer.ts - 4.2 Port
CompressionRegistry,CompressionAdapter,compressData,decompressData,NoCompressionAdapter,GzipCompressionAdapter,DeflateCompressionAdapterfrom upstreamsrc/compressed/compression.tsintopackages/bitpacker/bitpacker-compressed/src/compression-registry/ - 4.3 Move existing
compressRle/decompressRleintopackages/bitpacker/bitpacker-compressed/src/rle/rle.ts; re-export from./rleAND from root for one release - 4.4 Add
BITPACKER.COMPRESSION_*codes (COMPRESSION_FAILED,DECOMPRESSION_FAILED,UNKNOWN_COMPRESSION_ALGORITHM) - 4.5 Replace the "placeholder" disclaimer in
bitpacker-compressed/README.mdwith accurate copy - 4.6 Sibling
.mdper implementation file
5. @suaveplan/bitpacker-streaming
- 5.1 Port
StreamingBitPacker<T> extends EventEmitterfrom upstreamsrc/streaming/streaming.tsintopackages/bitpacker/bitpacker-streaming/src/streaming-bit-packer/streaming-bit-packer.ts - 5.2 Thread
AbortSignalthroughpackStream/unpackStream; abort-on-signal flushes in-flight chunks and rejects withBitpackerErrorcodeBITPACKER.STREAM_ABORTED - 5.3 Refactor existing
packToChunks/unpackFromChunks/unpackFromChunksAsyncto delegate intoStreamingBitPacker; preserve their synchronous-friendly signatures - 5.4 Add
BITPACKER.STREAM_*codes (STREAM_ABORTED,STREAM_VALIDATION_FAILED,STREAM_CHUNK_PROCESSOR_FAILED) - 5.5 Sibling
.mdper implementation file
6. @suaveplan/bitpacker-schema
- 6.1 Port
SchemaRegistryStorageinterface,InMemorySchemaRegistryStorage,LocalStorageSchemaRegistryStoragefrom upstreamsrc/schema/registry/registry.tsintopackages/bitpacker/bitpacker-schema/src/registry/ - 6.2 Port the storage-backed
SchemaRegistry(versionedregisterSchema/loadSchema/listSchemas/deleteSchema/registerVersionedSchema) - 6.3 Replace
new Date()with an injectableClock; stampcreatedAt/updatedAtfrom it - 6.4 Port
createInMemorySchemaRegistry/createLocalStorageSchemaRegistryfactories - 6.5 Add
BITPACKER.SCHEMA_*codes (SCHEMA_NOT_FOUND,SCHEMA_CONFLICT,SCHEMA_INVALID_METADATA) - 6.6 Move the existing 50 L
Map-basedSchemaRegistrytobitpacker-schema/src/legacy/legacy-registry.ts; re-export asLegacySchemaRegistrywith@deprecatedJSDoc - 6.7 Sibling
.mdper implementation file
7. Tests
- 7.1
packages/bitpacker/bitpacker-delta/src/delta-manager/delta-manager.test.ts— round-trip per mode, threshold gate, field-count limit, schema field-order respected - 7.2
packages/bitpacker/bitpacker-delta/src/delta-state/delta-state.test.ts— LRU eviction, deep-clone isolation, state-key sharding - 7.3
packages/bitpacker/bitpacker-delta/src/delta-manager/delta-manager.spec-conformance.test.ts— injectedClockdeterministic; Zod-rejected configs emitDELTA_INVALID_CONFIG - 7.4
packages/bitpacker/bitpacker-network/src/simulator/simulator.test.ts— bandwidth limit honoured; jitter within bounds; loss probability hits empirical bucket; duplication / corruption / reordering / burst / disconnect each verifiable; stats counters increment - 7.5
packages/bitpacker/bitpacker-network/src/simulator/simulator.spec-conformance.test.ts— preset bindings; injectedRngdeterministic; injectedClockdeterministic; stat-overflow emitsNETWORK_STAT_OVERFLOW - 7.6
packages/bitpacker/bitpacker-compressed/src/compressed-bit-packer/compressed-bit-packer.test.ts— round-trip throughnone/gzip/deflate; verify decompressed bytes matchBitPacker.packoutput exactly - 7.7
packages/bitpacker/bitpacker-compressed/src/compression-registry/compression-registry.spec-conformance.test.ts— adapter registration / replacement; unknown algorithm emitsUNKNOWN_COMPRESSION_ALGORITHM - 7.8
packages/bitpacker/bitpacker-streaming/src/streaming-bit-packer/streaming-bit-packer.test.ts—packStream/unpackStreamround-trip;progressevents fire in order;chunkevents carry the right bytes; abort mid-stream rejects withSTREAM_ABORTED - 7.9
packages/bitpacker/bitpacker-streaming/src/streaming-bit-packer/streaming-bit-packer.spec-conformance.test.ts—chunkProcessorinvoked;validateChunksgates emit - 7.10
packages/bitpacker/bitpacker-schema/src/registry/registry.test.ts— version auto-increment;loadSchemadefaults to latest;listSchemasfilters by namespace AND tag;deleteSchemaper-version vs all-versions - 7.11
packages/bitpacker/bitpacker-schema/src/registry/registry.spec-conformance.test.ts— both storage adapters pinned to the contract; injectedClockdeterministic; missing schema emitsSCHEMA_NOT_FOUND - 7.12
tests/bitpacker-game-network-shim.test.ts— game'snetwork/index.tsre-export resolves to the simulator from@suaveplan/bitpacker-network - 7.13 Every
it(...)in 7.1–7.12 carries{ timeout: 5000 }(or 30000 for genuinely-async network simulation runs)
8. Documentation
- 8.1 Sibling
.mdfor every new implementation.ts(≥200 words, basic + advanced examples, full API reference) - 8.2 Update each affected package's
README.mdto link the new co-located.mds under## Modules - 8.3 Update
CLAUDE.mdpackage listings forbitpacker-delta,bitpacker-network,bitpacker-compressed,bitpacker-streaming,bitpacker-schemato reflect the restored surface
9. Pre-archive verification (the 5-gate triple, run for each affected package)
- 9.1
bun run check— Biome 0/0/0 across the monorepo - 9.2
bunx turbo lint typecheck test --filter=@suaveplan/bitpacker-delta— green - 9.3
bunx turbo lint typecheck test --filter=@suaveplan/bitpacker-network— green - 9.4
bunx turbo lint typecheck test --filter=@suaveplan/bitpacker-compressed— green - 9.5
bunx turbo lint typecheck test --filter=@suaveplan/bitpacker-streaming— green - 9.6
bunx turbo lint typecheck test --filter=@suaveplan/bitpacker-schema— green - 9.7
bunx turbo test:coverage --filter=@suaveplan/bitpacker-delta— 100/100/100/100 - 9.8
bunx turbo test:coverage --filter=@suaveplan/bitpacker-network— 100/100/100/100 - 9.9
bunx turbo test:coverage --filter=@suaveplan/bitpacker-compressed— 100/100/100/100 - 9.10
bunx turbo test:coverage --filter=@suaveplan/bitpacker-streaming— 100/100/100/100 - 9.11
bunx turbo test:coverage --filter=@suaveplan/bitpacker-schema— 100/100/100/100 - 9.12
bun scripts/openspec-conformance.ts @suaveplan/bitpacker-delta @suaveplan/bitpacker-network @suaveplan/bitpacker-compressed @suaveplan/bitpacker-streaming @suaveplan/bitpacker-schema— exit 0, noerrorfindings - 9.13
bunx turbo build --filter=...@suaveplan/bitpacker-*— green for every dependent in the monorepo - 9.14
bunx turbo build typecheck test --filter=...@suaveplan/bitpacker-*— every downstream consumer compiles green (drive, network, packer, storage)
10. Pre-archive 7-row checklist (AGENTS.md Section 13)
- 10.1 Generics threaded;
expectTypeOfassertions on every literal-type claim (especiallyCompressedBitPacker<T>andStreamingBitPacker<T>) - 10.2 Zod schemas wired at every declared boundary (
DeltaConfig,NetworkSimulationOptions,BitPackerCompressionOptions,StreamingOptions,SchemaMetadata) - 10.3 Every error code added in §2.6 / 3.6 / 4.4 / 5.4 / 6.5 thrown from at least one production code path; no orphans
- 10.4 Strict-mode behaviors tested both on and off (e.g.
validateChunks: truevsfalse;equalityMode: "json"vs structural) - 10.5 OTel counters / histograms emitted for
bitpacker.delta.changes_detected,bitpacker.network.packet_loss,bitpacker.compress.bytes_in/out,bitpacker.stream.chunk_count,bitpacker.schema.registry_ops; asserted with a real in-memoryMeterProvider - 10.6 Lifecycle dedup tested where claimed:
DeltaStateManagerLRU eviction stable under concurrentstorePreviousState;SchemaRegistry.registerSchemaidempotent on identical metadata + schema - 10.7 No retroactive tick — every box above reflects work done in this change
11. Archive
- 11.1 Fold each spec delta into
openspec/specs/<cap>/spec.md(creating any cap files that don't yet exist) - 11.2 Move
openspec/changes/bitpacker-stub-completion/→openspec/archive/<yyyy-mm-dd>-bitpacker-stub-completion/ - 11.3 In
openspec/changes/bitpacker-modular-restructure/tasks.md, tick §14.1, §14.2, §14.3, §14.4, §14.5 with a note pointing at the archived change - 11.4 Refresh
MANIFEST.md(no package set or dep changes expected, but rerun for safety) - 11.5 Update STATUS.md with the rolled-up gap closure