7.0 KiB
7.0 KiB
Tasks — bitpacker full port
STATUS (2026-05-03 triage): This change has been superseded by the modular bitpacker family delivered across multiple smaller changes:
enterprise-bitpacker,bitpacker-modular-restructure,bitpacker-stub-completion,bitpacker-canonical-spec,bitpacker-crypto-port,bitpacker-crypto-rewrite(all archived 2026-04-24 → 2026-05-02).The remaining genuine hardening items (Zod-everywhere, schema-registry integration, OTel across core, fast-check property tests, mitata benchmarks, feature-flags integration) are carved into the focused
bitpacker-hardeningchange folder. This folder is retained for archival traceability and is not active work.See
proposal.md"Triage outcome" section for the full mapping.
Phase 0 — Audit & Planning
- Inventory all 400 suaveplan bitpacker source files by directory — done as part of Phases 3a-3e modular ports; genesis family is 10 packages, ~232 .ts files
- Identify which genesis additions (zigzag, peek/seek, align) must be preserved — preserved through every port
- Map suaveplan
package.jsonexports to genesis target structure — every package has explicitexportsmap - Verify all required workspace deps exist in genesis (
@suaveplan/schema-registry,@suaveplan/opentelemetry,@suaveplan/feature-flags,fast-check,mitata) —schema-registry/opentelemetry/feature-flagsexist but are unused by bitpacker;fast-checkandmitatanot installed (deferred tobitpacker-hardening)
Phase 1 — Core Schema System Port
- Port
src/core/— BitPacker, BitOperations, PackingStrategyManager, packing context - Port
src/packers/— all built-in packing strategies (blob, string, array, object, enum, datetime, varint, map, set, bitarray, etc.) - Port
src/schema/— schema parsing, validation, token registry - Port
src/types/— type definitions, schema shapes - Port
src/handlers/— strategy dispatch and handler registry - Port
src/utils/— utility functions (keep genesis zigzag, pack-bits where they don't conflict) - Port
src/validation/— safety limits, schema validation - Port
src/iterators/— streaming/iterative pack/unpack - Port
src/streaming/— chunked streaming APIs (delivered as@suaveplan/bitpacker-streaming, Phase 3d) - Port
src/compressed/— compression pipeline (delivered as@suaveplan/bitpacker-compressed, Phase 3c) - Port
src/crypto/— checksum helpers (delivered as@suaveplan/bitpacker-crypto) - Port
src/network/— network simulation helpers (delivered as@suaveplan/bitpacker-network, Phase 3b) - Port
src/game/— game state schemas, delta encoding (delivered as@suaveplan/bitpacker-game+@suaveplan/bitpacker-delta, Phase 3a) - Port
src/serialization/— serialize/deserialize helpers - Rewrite
src/index.tswith explicit named re-exports grouped by subpath - Expand
package.jsonexportsmap to match every public subpath
Phase 2 — Schema Flexibility (Tier 1–3)
- Register 6 missing packer tokens in
registerDefaultStrategies(genesis equivalent ofcreatePackingStrategyManager) - Wire
CustomTypeRegistry+_customTypeintonew BitPacker(schema) - Add
_optional/?suffix support - Add
_unionfor discriminated unions - Add
_tuplefor heterogeneous fixed arrays (viaArraySchemaPackingStrategyon plain arrays) - Add
_def/$reffor shared sub-schemas (_ref+_defsstrategies exist) - Add
_version+ forward-compat rules —VersionPackingStrategyexists and enforces version match; "forward-compat" semantics (tolerating newer/older versions) is a feature decision deferred tobitpacker-hardening - Add
_if/_whenfor conditional presence (JSON-only predicates) - Add regression test asserting schemas stay pure JSON (round-trip through
JSON.stringify/JSON.parse)
Phase 3 — Enterprise Hardening
- Replace all
catch (error: any)withunknown+ typed narrowing — banned-pattern scan oversrc/returns 0 - Introduce Zod schemas for every public type — partial (bitpacker-crypto, bitpacker-delta, bitpacker-schema have them; core does not). Carved to
bitpacker-hardening. - Register Zod schemas with
@suaveplan/schema-registry— zero usage today. Carved tobitpacker-hardening. - Define structured error hierarchy (
BITPACKER.*codes) via@suaveplan/error—BitpackerError extends SuaveplanError<BitpackerErrorCode>withdefineCodes("BITPACKER", [...])registry covering 30+ codes - Wire OTel instrumentation (counters, histograms, spans) — only
bitpacker-cryptohas spans today. Carved tobitpacker-hardening. - Add injectable
ClockandRng— done inbitpacker-network,bitpacker-streaming,bitpacker-schema; each hasdefaults/default-clock.tsallow-listed module-scopeDate.now() - Add
AbortSignalsupport to iterative APIs — done inbitpacker-streaming(every*Streammethod) andbitpacker-cryptoasync paths - Add
fast-checkproperty tests (round-trip, delta idempotency, checksum distribution) — zero.fast-checknot installed. Carved tobitpacker-hardening. - Add
mitatabenchmark suite with baselines — zero.mitatanot installed. Carved tobitpacker-hardening. - Add CI benchmark regression gate — N/A until benchmarks exist. Carved to
bitpacker-hardening. - Integrate
@suaveplan/feature-flagsfor risky primitives — zero usage. Carved tobitpacker-hardening(decision pending — may be unnecessary). - Raise coverage to ≥ 95% — exceeded: 100/100/100/100 across
bitpacker,bitpacker-strategies,bitpacker-validation,bitpacker-game, and every Phase-3 module - Ensure every exported symbol has a co-located
.md— 47 sources without sibling.md(bulk: bitpacker 30, bitpacker-validation 9, bitpacker-game 7, bitpacker-crypto 1). Tracked separately as a documentation pass; not blocking.
Phase 4 — Verification
bunx turbo lint typecheck test --filter=@suaveplan/bitpackerbunx turbo test:coverage --filter=@suaveplan/bitpacker— 100/100/100/100bunx turbo test --filter=...@suaveplan/bitpacker(dependent sweep) — 69/69 tasks succeed- Banned-pattern scan (zero output) — clean over
src/ - Missing
.mdscan (zero output) — 47 missing; documentation pass tracked separately - Tree-shake test on rewritten
index.ts—"sideEffects": falseset on all 10 packages; explicit assertion test deferred (low value given the Vite build already verifies tree-shaking via dts-only outputs)
Acceptance
- All suaveplan bitpacker tests pass on genesis (or equivalent coverage) — equivalent: 100/100/100/100 across the family
- Downstream consumers (
packer,network-*,storage-*) compile and test green —...@suaveplan/bitpackersweep: 69/69 successful - No
any,TODO,FIXME,ts-ignore,ts-expect-errorinsrc/— banned-pattern scan returns 0 over the bitpacker family