6.2 KiB
6.2 KiB
Tasks — Barcode batch generator
Every checkbox MUST reflect work actually done in this change. Do not retroactively tick boxes.
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Spec authoring
- 1.1 Read
../suaveplan/packages/universal/barcode/src/batch/batch-generator.tsend-to-end - 1.2 Read
openspec/specs/barcode/spec.md(does not exist yet — capability spec authored fresh in this change) - 1.3 Read
openspec/AGENTS.mdSections 13, 13a, 14, 14a - 1.4 Draft
proposal.mdfromopenspec/templates/proposal.md - 1.5 Fill in
## Source mappingtable — every requirement cites a line range OR appears in the "no source line" table with justification - 1.6 Draft
specs/barcode/spec.mdfromopenspec/templates/spec-delta.md - 1.7 Every requirement in the spec delta carries a
**Verified by:**line naming concreteit(...)titles
2. Implementation
- 2.1 Add
src/core/batch/batch-generator.tsexportingBatchBarcodeRequest,BatchBarcodeResult,BatchBarcodeOptions,BatchBarcodeSummary,generateBatch,BatchBarcodeGenerator - 2.2 Add
src/core/batch/batch-generator.types.tswith the shared interface declarations and Zod schemas (BatchBarcodeRequestSchema,BatchBarcodeOptionsSchema) - 2.3 Wire
BARCODE.BATCH_ABORTEDintosrc/errors/barcode-error.ts::BARCODE_CODES; throwBarcodeError(never plainError) from the abort path and from per-item failures - 2.4 Concurrency limiter — clamp to
[1, 64]; sequential default (concurrency 1); honourAbortSignalbetween items - 2.5 OTel instrumentation:
barcode.batch.items_total(counter),barcode.batch.items_failed(counter),barcode.batch.duration_ms(histogram); use the package's existing OTel meter - 2.6 Inject
Clockvia constructor dependency onBatchBarcodeGenerator;generateBatchfree function uses the default real clock - 2.7 Add
./batchsubpath topackage.jsonexports - 2.8 Re-export new symbols from
src/index.ts
3. Tests
- 3.1
src/core/batch/batch-generator.test.ts— all scenarios from spec delta (in-order results, failure isolation, concurrency clamp,onItemcallback, abort, deterministic results across symbologies) - 3.2
src/core/batch/batch-generator.spec-conformance.test.ts— injectableClockdeterministicdurationMs, ZodBatchBarcodeRequestrejection with structuredZodError,BARCODE.BATCH_ABORTEDcode emission, OTel counters/histogram asserted via in-memoryMeterProvider - 3.3 Property test (fast-check): for any
Array<{ symbology, value }>of length ≤ 100 where every item is a valid encoding,generateBatchSHALL returnsucceeded === input.lengthandfailed === 0 - 3.4 Every
it(...)carries{ timeout: 5000 }(or 30000 for genuinely async)
4. Documentation
- 4.1
src/core/batch/batch-generator.md— sibling doc, ≥200 words, basic + advanced examples (sequential, concurrent, abort, custom clock), full API reference for every public export, implementation notes covering concurrency clamping and per-item isolation - 4.2 README links the new co-located
.mdunder## Modules - 4.3 Update
CLAUDE.mdbarcodelisting to mention "batch generation with per-item failure isolation"
5. Pre-archive verification (the 5-gate triple)
- 5.1
bun run check— Biome 0 errors / 0 warnings / 0 info - 5.2
bunx turbo lint typecheck test --filter=@suaveplan/barcode— green - 5.3
bunx turbo test:coverage --filter=@suaveplan/barcode— 100/100/100/100 - 5.4
bun scripts/openspec-conformance.ts @suaveplan/barcode— exit 0, noerrorfindings - 5.5
bunx turbo build --filter=@suaveplan/barcode— green
6. Pre-archive 7-row checklist (AGENTS.md Section 13)
- 6.1 Generics threaded;
expectTypeOfassertions onBatchBarcodeResultdiscriminated-union narrowing - 6.2 Zod schemas wired at the
generateBatchandBatchBarcodeGenerator.generateboundary - 6.3 Every error code in
error-codes.tsthrown by at least one production path (BARCODE.BATCH_ABORTEDcovered by abort scenario) - 6.4 Strict-mode behaviors tested both on and off (concurrency 1 vs > 1;
continueOnErrorsemantics implicit — failure isolation always on) - 6.5 OTel instruments emitted from production paths and asserted with a real in-memory
MeterProvider - 6.6 Lifecycle dedup tested where claimed (
BatchBarcodeGenerator.generateis stateless across calls — verified by parallel-call test) - 6.7 No retroactive tick — every box above reflects work done in this change
7. Archive
- 7.1 Fold spec delta into
openspec/specs/barcode/spec.md(creates the canonical capability spec from scratch since none exists) - 7.2 Move
openspec/changes/barcode-batch-generator/→openspec/archive/<yyyy-mm-dd>-barcode-batch-generator/ - 7.3 Refresh
MANIFEST.mdif package set or deps changed (no change expected — purely additive feature)
Audit Note (2026-05-02)
Status: DEFERRED.
State at audit:
@suaveplan/barcodepackage itself is shipped and green, but the batch-generator feature has not been authored. Nosrc/core/batch/directory exists.find packages/barcode/barcode/src -name 'batch*'returns no hits.- Section 1 (spec authoring) is checked, so the proposal + spec delta exist; Sections 2–7 (implementation, tests, docs, verification, archive) are entirely unchecked.
BARCODE.BATCH_ABORTEDis not yet wired intosrc/errors/barcode-error.ts::BARCODE_CODES.
Resuming work: execute Sections 2–7 in order. Reference upstream ../suaveplan/packages/universal/barcode/src/batch/batch-generator.ts (read in Section 1.1).