# Tasks — Enterprise hardening (extensibility cluster) for `@suaveplan/packer` ## 1. Spec authoring - [x] 1.1 Read `../suaveplan/enterprise/packer.md` end-to-end - [x] 1.2 Read `openspec/specs/packer/spec.md` - [x] 1.3 Read `openspec/AGENTS.md` Sections 13 and 14 - [x] 1.4 Draft `proposal.md` from `openspec/templates/proposal.md` - [x] 1.5 Fill in `## Source mapping` table — every requirement cites a line range - [x] 1.6 Draft `specs/packer/spec.md` from `openspec/templates/spec-delta.md` - [x] 1.7 Every requirement in the spec delta carries a `**Verified by:**` line naming concrete `it(...)` titles ## 2. Implementation — error codes (E-1 / E-2 / E-3) - [x] 2.1 Add `FORMAT_VERSION_UNSUPPORTED` and `PLUGIN_FAILED` codes to `src/error-codes.ts` with metadata. - [x] 2.2 Add catalog keys `packer.error.FORMAT_VERSION_UNSUPPORTED.v2-not-implemented`, `packer.error.PLUGIN_FAILED.` to `src/i18n/messages.ts`. ## 3. Implementation — schema registry (E-1) - [x] 3.1 Add `@suaveplan/schema-registry` to `packer/package.json` deps (`workspace:^`). - [x] 3.2 New `src/schemas/registration.ts` — `registerPackerSchemas(registry)` + `getPackerSchemaRegistry()`, registering every Zod schema in `packer.schemas.ts` plus a `packer-chunk-format` subject with V1 evolution metadata. - [x] 3.3 Sibling `registration.md` + `registration.types.ts` + `index.ts` barrel. - [x] 3.4 Subpath export `./schemas` in `package.json`. ## 4. Implementation — feature flags (E-2) - [x] 4.1 Add `@suaveplan/feature-flags` to `packer/package.json` deps (`workspace:^`). - [x] 4.2 New `src/flags/flags.ts` — `PackerFeatureFlags` interface, `defaultPackerFlags()` no-op, `resolvePackerFlags(opts)` factory, `PACKER_FLAG_KEYS` constants. - [x] 4.3 Sibling `flags.md` + `flags.types.ts` + `index.ts` barrel. - [x] 4.4 `Packer.pack` reads `packer.format.v2` from the resolved provider; when truthy, throws `PackerError(PACKER.FORMAT_VERSION_UNSUPPORTED)`. - [x] 4.5 `PackerOptions.flags?: PackerFlagsOptions` threaded through `AbstractPacker.resolvedOptions`. - [x] 4.6 Subpath export `./flags` in `package.json`. ## 5. Implementation — plugin interface (E-3) - [x] 5.1 New `src/plugins/plugins.ts` — `PackerPlugin` contract, `PluginPipeline.runHook(name, ctx)`, error mapping to `PACKER.PLUGIN_FAILED`. - [x] 5.2 Sibling `plugins.md` + `plugins.types.ts` + `index.ts` barrel. - [x] 5.3 `PackerOptions.plugins?: ReadonlyArray` threaded through `AbstractPacker`. - [x] 5.4 `Packer.pack` invokes `onPackStart` → per-entry `onEntry` → `onPackEnd` in declaration order around the pipeline. - [x] 5.5 `Unpacker.unpack` invokes `onUnpackStart` → `onEntryDecoded` → `onUnpackEnd`. - [x] 5.6 Subpath export `./plugins` in `package.json`. ## 6. Tests — schema registry, flags, plugins - [x] 6.1 `src/schemas/registration.test.ts` + `.spec-conformance.test.ts` — every schema registered, V1 evolution metadata, BACKWARD compatibility, singleton invariant. - [x] 6.2 `src/flags/flags.test.ts` + `.spec-conformance.test.ts` — default provider returns V1 for every key, V2 throws `PACKER.FORMAT_VERSION_UNSUPPORTED`, custom evaluator wiring, integration with `Packer.pack` write path. - [x] 6.3 `src/plugins/plugins.test.ts` + `.spec-conformance.test.ts` — declaration-order hook fire, error → `PACKER.PLUGIN_FAILED`, noop-logger + double-integrity example plugins exercised against real `Packer` + `Unpacker`. ## 7. Tests — fast-check property (E-4) - [x] 7.1 `src/__property__/round-trip.property.test.ts` — pack→unpack identity over arbitrary `Uint8Array` inputs; streaming↔batch equivalence via chunked pack. - [x] 7.2 `src/__property__/determinism.property.test.ts` — same inputs + seeded Rng + fixed Clock ⇒ byte-identical bundles. ## 8. Benchmarks (E-5) - [x] 8.1 `src/__benchmarks__/packer.bench.ts` — mitata suite (whole-file pack/unpack, chunked single + 1000 chunks, integrity verify, plugin overhead). - [x] 8.2 `bun run benchmark` script in `package.json`. - [x] 8.3 `README.md` Benchmarks section with baseline numbers and hardware/runtime context line. ## 9. Documentation - [x] 9.1 Sibling `.md` for every new `.ts` (≥200 words, basic + advanced examples). - [x] 9.2 Update `README.md` Modules list with `flags/`, `plugins/`, `schemas/registration`. ## 10. Pre-archive verification (the 5-gate triple) - [x] 10.1 `bun run check` — Biome 0/0/0. - [x] 10.2 `bunx turbo lint typecheck test --filter=@suaveplan/packer` — green. - [x] 10.3 `bunx turbo test:coverage --filter=@suaveplan/packer` — 100/100/100/100. - [x] 10.4 `bun scripts/openspec-conformance.ts @suaveplan/packer` — exit 0. - [x] 10.5 `bunx turbo build --filter=@suaveplan/packer` — green. ## 11. Consumer sweep - [x] 11.1 `bunx turbo lint typecheck test --filter=@suaveplan/drive-plugin-chunks --filter=@suaveplan/drive-webrtc` — green. ## 12. Pre-archive 9-row checklist - [x] 12.1 Generics threaded; `expectTypeOf` assertions on every literal-type claim. - [x] 12.2 Zod schemas wired at every declared boundary. - [x] 12.3 Every error code in `error-codes.ts` thrown by at least one production path. - [x] 12.4 OTel instruments emitted from production paths. - [x] 12.5 No `export *` in feature barrels. - [x] 12.6 No direct `vitest` / `bun:test` imports. - [x] 12.7 No retroactive tick — every box above reflects work done in this change. - [x] 12.8 Sibling `.md` for every new `.ts`. - [x] 12.9 Items E-1, E-2, E-3, E-4, E-5 each have ≥1 production code path and ≥1 test pinning every named scenario. ## 13. Archive - [x] 13.1 Fold `specs/packer/spec.md` into `openspec/specs/packer/spec.md`. - [x] 13.2 Move `openspec/changes/enterprise-packer-extensibility/` → `openspec/archive/-enterprise-packer-extensibility/`. - [x] 13.3 Refresh `MANIFEST.md`.