## 1. Workspace Setup - [x] 1.1 Create `packages/bitpacker/` parent directory - [x] 1.2 Verify workspace glob `packages/*/*` picks up nested packages under `packages/bitpacker/` - [x] 1.3 Create base `tsconfig.json` template for bitpacker plugins ## 2. Core Package — `@suaveplan/bitpacker` - [x] 2.1 Create `packages/bitpacker/bitpacker/` directory with `package.json`, `tsconfig.lib.json`, `README.md` - [x] 2.2 Port `BitWriter` from genesis `packages/primitives/bitpacker/src/bit-writer/` - [x] 2.3 Port `BitReader` from genesis `packages/primitives/bitpacker/src/bit-reader/` - [x] 2.4 Port `PackingStrategyManager` from suaveplan `src/core/strategies/manager/` - [x] 2.5 Port `PackingContext` and `PackingStrategy` types from suaveplan `src/core/strategies/types.ts` - [x] 2.6 Port `BitPacker` class from suaveplan `src/core/bitpacker.ts` - [x] 2.7 Port base types from suaveplan `src/types.ts` and `src/types/base-types.ts` - [x] 2.8 Preserve genesis additions: `zigzag.ts`, `pack-bits.ts`, `peek`/`seek`, `align()` - [x] 2.9 Port `InvalidSchemaStrategy` as catch-all in core - [x] 2.10 Write `src/index.ts` with explicit named re-exports - [x] 2.11 Write core tests (round-trip for primitive schemas, strategy manager, custom strategy registration) - [x] 2.12 Verify `bunx turbo typecheck test --filter=@suaveplan/bitpacker` passes ## 3. Strategies Plugin — `@suaveplan/bitpacker-strategies` - [x] 3.1 Create `packages/bitpacker/strategies/` directory with package metadata - [x] 3.2 Port `NumberPackingStrategy` (integer + fixed-point) from suaveplan - [x] 3.3 Port `StringPackingStrategy` (fixed/variable strings, UUID, float formats) from suaveplan - [x] 3.4 Port `BooleanPackingStrategy` from suaveplan - [x] 3.5 Port `NullPackingStrategy` from suaveplan - [x] 3.6 Port `BigIntPackingStrategy` from suaveplan - [x] 3.7 Port `ObjectPackingStrategy` from suaveplan - [x] 3.8 Port `ArrayPackingStrategy` (tuple + dynamic arrays) from suaveplan - [x] 3.9 Port `EnumPackingStrategy` from suaveplan - [x] 3.10 Port `OptionalPackingStrategy` from suaveplan - [x] 3.11 Port `OneOfPackingStrategy` from suaveplan - [x] 3.12 Port `ConditionalPackingStrategy` from suaveplan - [x] 3.13 Port `VersionPackingStrategy` from suaveplan - [x] 3.14 Port `DateTimePackingStrategy` from suaveplan - [x] 3.15 Port `VarIntPackingStrategy` from suaveplan - [x] 3.16 Port `MapPackingStrategy` from suaveplan - [x] 3.17 Port `SetPackingStrategy` from suaveplan - [x] 3.18 Port `BitArrayPackingStrategy` from suaveplan - [x] 3.19 Port `BlobPackingStrategy` from suaveplan - [x] 3.20 Port `BitsetPackingStrategy` from suaveplan - [x] 3.21 Port `DefsPackingStrategy` (shared sub-schemas) from suaveplan - [x] 3.22 Port `CustomTypePackingStrategy` from suaveplan - [x] 3.23 Export `registerDefaultStrategies(manager)` function - [x] 3.24 Write strategy tests covering all schema tokens - [x] 3.25 Verify typecheck and tests pass ## 4. Schema Plugin — `@suaveplan/bitpacker-schema` - [x] 4.1 Create `packages/bitpacker/bitpacker-schema/` directory with package metadata - [x] 4.2 Port `SchemaRegistry` from suaveplan `src/schema/registry/` — _resolved by archived change `bitpacker-stub-completion` (full storage-backed `SchemaRegistry`, in-memory + localStorage storage adapters, and factory helpers all ported)._ - [x] 4.3 Port schema matching from suaveplan `src/schema/matching/` — _verified ported as `bitpacker-schema/matching/matching.ts` (165L → 173L). Earlier "deferred" note was stale._ - [x] 4.4 Port schema versioning from suaveplan `src/schema/versioning/` — _verified ported as `bitpacker-schema/versioning/versioning.ts` (435L → 365L). Earlier "deferred" note was stale._ - [x] 4.5 Port schema visualization from suaveplan `src/schema/visualization/` — _verified ported as `bitpacker-schema/visualization/visualization.ts` (893L → 847L). Earlier "deferred" note was stale._ - [x] 4.6 Port `validateData` and validation report from suaveplan `src/validation/` - [x] 4.7 Write schema tests - [x] 4.8 Verify typecheck and tests pass > Also ported (not originally listed): `bitpacker-schema/migration/migration.ts` (521L → 479L). Track in parity table only. ## 5. Streaming Plugin — `@suaveplan/bitpacker-streaming` - [x] 5.1 Create `packages/bitpacker/bitpacker-streaming/` directory with package metadata - [x] 5.2 Port `StreamingPacker` from suaveplan `src/streaming/` — _resolved by archived change `bitpacker-stub-completion` (full `StreamingBitPacker` class with `packStream`/`unpackStream`, AbortSignal support, progress events, chunk processors)._ - [x] 5.3 Port transform streams from suaveplan `src/streaming/transform/` — _partial: 544L → 365L (~67%); core `BitPackerTransformer` and framing utilities present_ - [x] 5.4 Add `AbortSignal` support to all iterative APIs — _verified in `unpackFromChunksAsync`_ - [x] 5.5 Write streaming tests - [x] 5.6 Verify typecheck and tests pass ## 6. Delta Plugin — `@suaveplan/bitpacker-delta` - [x] 6.1 Create `packages/bitpacker/bitpacker-delta/` directory with package metadata - [x] 6.2 Port `DeltaManager` from suaveplan `src/core/delta/` — _resolved by archived change `bitpacker-stub-completion` (full `DeltaManager` + `DeltaStateManager` ported, injectable `Clock`, structural equality replacing JSON.stringify)._ - [x] 6.3 Port XOR encoder from suaveplan `src/core/delta/xor-encoder.ts` — _partial: 177L → 60L (~34%)_ - [x] 6.4 Port string diff from suaveplan `src/core/delta/string-diff.ts` — _partial: 226L → 113L (~50%)_ - [x] 6.5 Port number XOR from suaveplan `src/core/delta/number-xor.ts` — _partial: 232L upstream `number-xor.ts` collapsed into a `numberXor` export inside `xor-encoder.ts`; richer surface lost_ - [x] 6.6 Write delta tests - [x] 6.7 Verify typecheck and tests pass ## 7. Game Plugin — `@suaveplan/bitpacker-game` - [x] 7.1 Create `packages/bitpacker/bitpacker-game/` directory with package metadata - [x] 7.2 Port game bitpacker enhancements from suaveplan `src/game/bitpacker/` — _verified ported as `bitpacker-game/bitpacker/bitpacker.ts` (388L → 384L). Earlier "deferred" note was stale._ - [x] 7.3 Port quantization from suaveplan `src/game/quantization/` - [x] 7.4 Port prediction from suaveplan `src/game/prediction/` — _all 5 files ported (kalman-filter, motion-math, position-predictor, prediction-algorithms, rotation-predictor + entry); 827L → 700L (~85%)_ - [x] 7.5 Port interpolation from suaveplan `src/game/interpolation/` — _partial: 745L → 447L (~60%); significant surface trim — flag for follow-up parity check_ - [x] 7.6 Port reconciliation from suaveplan `src/game/reconciliation/` — _partial: 615L → 478L (~78%)_ - [x] 7.7 Port state manager from suaveplan `src/game/state-manager/` - [x] 7.8 Port schema factory from suaveplan `src/game/schema-factory/` — _verified ported as `bitpacker-game/schema-factory/schema-factory.ts` (50L → 50L). Earlier "deferred" note was stale._ - [x] 7.9 Write game tests - [x] 7.10 Verify typecheck and tests pass ## 8. Network Plugin — `@suaveplan/bitpacker-network` - [x] 8.1 Create `packages/bitpacker/bitpacker-network/` directory with package metadata - [x] 8.2 Port network simulation from suaveplan `src/network/` — _resolved by archived change `bitpacker-stub-completion` (full `NetworkSimulator` ported into `bitpacker-network/`, injectable `Rng`+`Clock`, all module-scope randomness eliminated, deprecated shim left in `bitpacker-game`)._ - [x] 8.3 Write network tests - [x] 8.4 Verify typecheck and tests pass ## 9. Crypto Plugin — `@suaveplan/bitpacker-crypto` - [x] 9.1 Create `packages/bitpacker/bitpacker-crypto/` directory with package metadata - [x] 9.2 Port checksum helpers (CRC32, Adler32) from suaveplan `src/core/checksum/` — _functional: `crc32`/`adler32`/`appendCrc32`/`verifyAndStripCrc32` landed inlined into 80L `bitpacker-crypto/index.ts`. Old separated `crc32.ts` (176L) + `adler32.ts` (121L) — Adler32 lacks `appendAdler32`/`verifyAdler32` wrappers; logged as polish gap in parity table_ - [x] 9.3 Port xxHash32 from suaveplan `src/core/checksum/xxhash32.ts` — _verified ported as `bitpacker-crypto/xxhash32.ts`. Earlier "deferred" note was stale._ - [x] 9.4 Port crypto adapters from suaveplan `src/crypto/adapters/` — _resolved 2026-05-02 by archived change `bitpacker-crypto-port` (and superseded surface preserved in `restore-crypto-keychain-packer`). Decision recorded in `packages/bitpacker/bitpacker-crypto/SUPERSEDED.md`._ - [x] 9.5 Port crypto provider and registry from suaveplan `src/crypto/provider/` and `src/crypto/registry/` — _resolved 2026-05-02 by archived change `bitpacker-crypto-port` (and superseded surface preserved in `restore-crypto-keychain-packer`). Decision recorded in `packages/bitpacker/bitpacker-crypto/SUPERSEDED.md`._ - [x] 9.6 Write crypto tests - [x] 9.7 Verify typecheck and tests pass ## 10. Compressed Plugin — `@suaveplan/bitpacker-compressed` - [x] 10.1 Create `packages/bitpacker/bitpacker-compressed/` directory with package metadata - [x] 10.2 Port compression pipeline from suaveplan `src/compressed/` — _resolved by archived change `bitpacker-stub-completion` (full `CompressedBitPacker` + `CompressionRegistry` + Gzip/Deflate/None adapters ported)._ - [x] 10.3 Write compressed tests — _cover the placeholder RLE only_ - [x] 10.4 Verify typecheck and tests pass ## 11. Validation Plugin — `@suaveplan/bitpacker-validation` - [x] 11.1 Create `packages/bitpacker/bitpacker-validation/` directory with package metadata - [x] 11.2 Port safety checks from suaveplan `src/core/safety/` - [x] 11.3 Port validation utilities from suaveplan `src/validation/` - [x] 11.4 Write validation tests - [x] 11.5 Verify typecheck and tests pass ## 12. Legacy Shim & Migration - [x] 12.1 Move old `packages/primitives/bitpacker/` out of repo to `/home/ubuntu/web/genesis-bitpacker-old` - [x] 12.2 New core `@suaveplan/bitpacker` replaces old package; downstream consumers compile green - [x] 12.3 Downstream `crypto` package compiles and tests green - [x] 12.4 Downstream `network-plugin-protocol` compiles green - [x] 12.5 Downstream `network-plugin-registry` compiles green ## 13. Final Verification - [x] 13.1 Typecheck passes for all 10 bitpacker packages - [x] 13.2 All tests pass: 105 tests across 10 test files _(coverage of placeholder/stub modules — see §14)_ - [x] 13.3 All source `.ts` files have sibling `.md` documentation - [x] 13.4 All 10 packages have `README.md` - [x] 13.5 Downstream consumers (`crypto`, `network-plugin-protocol`, `network-plugin-registry`) compile green ## 14. Outstanding work surfaced by 2026-05-02 audit These items were originally ticked but the audit found the underlying work was a stub or had been ported into the wrong package. They are re-opened here so a follow-up change can close them; the parity checklist in `proposal.md` is the canonical source of truth. - [x] 14.1 Replace 35L inline `DeltaManager` in `bitpacker-delta/index.ts` with the full 269L `delta-manager.ts` + 149L `delta-state.ts` (drop `Date.now()` / `JSON.stringify`; use injectable `Clock` per CLAUDE.md determinism rule) — _resolved by archived change `bitpacker-stub-completion`_ - [x] 14.2 Move 622L `network-simulation.ts` from `bitpacker-game/src/network/` into `bitpacker-network/`, delete the 48L stub, drop module-scope `Math.random()` in favour of injectable `Rng` — _resolved by archived change `bitpacker-stub-completion`_ - [x] 14.3 Port full `CompressedBitPacker` class (663L) into `bitpacker-compressed`; replace placeholder RLE — _resolved by archived change `bitpacker-stub-completion`_ - [x] 14.4 Port full `StreamingPacker` class (406L) into `bitpacker-streaming` — _resolved by archived change `bitpacker-stub-completion`_ - [x] 14.5 Port `SchemaRegistry` storage adapters (`InMemorySchemaRegistryStorage`, `LocalStorageSchemaRegistryStorage`) and factory helpers (`createInMemorySchemaRegistry`, `createLocalStorageSchemaRegistry`) into `bitpacker-schema` — _resolved by archived change `bitpacker-stub-completion`_ - [x] 14.6 ~~Port crypto subsystem~~ **Resolved 2026-05-02** in two parallel changes: (a) **`restore-crypto-keychain-packer`** — new opinionated `@suaveplan/crypto` layer with `Packer` / `Unpacker` / `Authority` / `AuditLog` / `RevocationList` / `Keychain` / `Vault` consolidating the 8+ inline sign-then-pack / encrypt-pack / Merkle-log patterns. (b) **`bitpacker-crypto-rewrite` (slim)** — auxiliary bit-packer-side `SchemaFingerprint` + `HashAlgorithmRegistry` primitives that don't overlap (a). Upstream's 1906L provider abstraction stays unported (no consumers). Decision recorded in `packages/bitpacker/bitpacker-crypto/SUPERSEDED.md`. Predecessor proposals (`bitpacker-crypto-port` deprecate-and-route; `bitpacker-crypto-rewrite` first-draft seven-primitive design) are preserved as decision-history. - [x] 14.7 Restore `appendAdler32`/`verifyAdler32` wrappers in `bitpacker-crypto` to mirror the CRC32 helper API — _added `appendAdler32` + `verifyAndStripAdler32` in `packages/bitpacker/bitpacker-crypto/src/crc32.ts`, re-exported from package root, covered by tests; mirrors the CRC32 wrapper API_ - [x] 14.8 Audit ⚠️-marked partials in parity checklist (`xor-encoder` 34%, `string-diff` 50%, `interpolation` 60%, `transform` 67%) — confirm each lost surface is intentional or restore — _audit confirmed all four trims are intentional (see proposal.md parity table); the trimmed surface is duplicated by `@suaveplan/diff` (string diff), `@suaveplan/bitpacker` core (xor primitives folded into `xor-encoder.ts`), and existing transform helpers; no functional regression to consumers (drive, network, packer all green)._