6.4 KiB
6.4 KiB
Tasks — QR code 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/qrcode/src/batch/batch-generator.tsend-to-end - 1.2 Read
openspec/specs/qrcode/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/qrcode/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.tsexportingBatchQrCodeRequest,BatchQrCodeResult,BatchQrCodeOptions,BatchQrCodeSummary,generateBatch,generateBatchAsync,BatchQrCodeGenerator - 2.2 Add
src/core/batch/batch-generator.types.tswith shared interface declarations and Zod schemas (BatchQrCodeRequestSchema,BatchQrCodeOptionsSchema) - 2.3 Wire
QRCODE.BATCH_ABORTEDintosrc/errors/qrcode-error.ts::QRCODE_CODES; throwQRCodeError(never plainError) from the abort path and from per-item failures - 2.4 Concurrency limiter — clamp to
[1, 64]; sequential default forgenerateBatch;generateBatchAsynchonoursconcurrencystrictly; both honourAbortSignalbetween items - 2.5 OTel instrumentation:
qrcode.batch.items_total(counter),qrcode.batch.items_failed(counter),qrcode.batch.duration_ms(histogram) - 2.6 Inject
Clockvia constructor dependency onBatchQrCodeGenerator; free functions use 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, completion-order async iterable, failure isolation, concurrency clamp,onItem, abort, version-1-through-10 coverage) - 3.2
src/core/batch/batch-generator.spec-conformance.test.ts— injectableClock, ZodBatchQrCodeRequestrejection with structuredZodError,QRCODE.BATCH_ABORTEDcode emission, OTel counters/histogram asserted via in-memoryMeterProvider - 3.3 Property test (fast-check): for any
Array<{ value }>of length ≤ 50 where every value fits 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, async iterable, 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.mdqrcodelisting 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/qrcode— green - 5.3
bunx turbo test:coverage --filter=@suaveplan/qrcode— 100/100/100/100 - 5.4
bun scripts/openspec-conformance.ts @suaveplan/qrcode— exit 0, noerrorfindings - 5.5
bunx turbo build --filter=@suaveplan/qrcode— green
6. Pre-archive 7-row checklist (AGENTS.md Section 13)
- 6.1 Generics threaded;
expectTypeOfassertions onBatchQrCodeResultdiscriminated-union narrowing - 6.2 Zod schemas wired at every public boundary (
generateBatch,generateBatchAsync,BatchQrCodeGenerator.generate,.stream) - 6.3 Every error code in
error-codes.tsthrown by at least one production path (QRCODE.BATCH_ABORTEDcovered by abort scenario) - 6.4 Strict-mode behaviors tested both on and off (concurrency 1 vs > 1; 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 (
BatchQrCodeGenerator.generateand.streamare 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/qrcode/spec.md(creates the canonical capability spec from scratch since none exists) - 7.2 Move
openspec/changes/qrcode-batch-generator/→openspec/archive/<yyyy-mm-dd>-qrcode-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/qrcodepackage itself is shipped and green, but the batch-generator feature has not been authored. Nosrc/core/batch/directory exists. The currentsrc/core/only containsencoder/,mask/,matrix/,reed-solomon/,renderer/,tables/, plus the top-levelqrcode.tsorchestrator.- Section 1 (spec authoring) is checked, so the proposal + spec delta exist; Sections 2–7 (implementation, tests, docs, verification, archive) are entirely unchecked.
QRCODE.BATCH_ABORTEDis not yet wired intosrc/errors/qrcode-error.ts::QRCODE_CODES.
Resuming work: execute Sections 2–7 in order. Reference upstream ../suaveplan/packages/universal/qrcode/src/batch/batch-generator.ts (read in Section 1.1). Note this proposal additionally requires generateBatchAsync (completion-order async iterable) which the barcode equivalent does not.