Files
suaveplan/openspec/changes/barcode-batch-generator/tasks.md
2026-05-27 23:29:53 +01:00

6.2 KiB
Raw Blame History

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 status reports nothing) and no in-flight worktrees with uncommitted work (git worktree list then git status in 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.md matches find packages -maxdepth 3 -name package.json count. 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.ts end-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.md Sections 13, 13a, 14, 14a
  • 1.4 Draft proposal.md from openspec/templates/proposal.md
  • 1.5 Fill in ## Source mapping table — every requirement cites a line range OR appears in the "no source line" table with justification
  • 1.6 Draft specs/barcode/spec.md from openspec/templates/spec-delta.md
  • 1.7 Every requirement in the spec delta carries a **Verified by:** line naming concrete it(...) titles

2. Implementation

  • 2.1 Add src/core/batch/batch-generator.ts exporting BatchBarcodeRequest, BatchBarcodeResult, BatchBarcodeOptions, BatchBarcodeSummary, generateBatch, BatchBarcodeGenerator
  • 2.2 Add src/core/batch/batch-generator.types.ts with the shared interface declarations and Zod schemas (BatchBarcodeRequestSchema, BatchBarcodeOptionsSchema)
  • 2.3 Wire BARCODE.BATCH_ABORTED into src/errors/barcode-error.ts::BARCODE_CODES; throw BarcodeError (never plain Error) from the abort path and from per-item failures
  • 2.4 Concurrency limiter — clamp to [1, 64]; sequential default (concurrency 1); honour AbortSignal between 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 Clock via constructor dependency on BatchBarcodeGenerator; generateBatch free function uses the default real clock
  • 2.7 Add ./batch subpath to package.json exports
  • 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, onItem callback, abort, deterministic results across symbologies)
  • 3.2 src/core/batch/batch-generator.spec-conformance.test.ts — injectable Clock deterministic durationMs, Zod BatchBarcodeRequest rejection with structured ZodError, BARCODE.BATCH_ABORTED code emission, OTel counters/histogram asserted via in-memory MeterProvider
  • 3.3 Property test (fast-check): for any Array<{ symbology, value }> of length ≤ 100 where every item is a valid encoding, generateBatch SHALL return succeeded === input.length and failed === 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 .md under ## Modules
  • 4.3 Update CLAUDE.md barcode listing 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, no error findings
  • 5.5 bunx turbo build --filter=@suaveplan/barcode — green

6. Pre-archive 7-row checklist (AGENTS.md Section 13)

  • 6.1 Generics threaded; expectTypeOf assertions on BatchBarcodeResult discriminated-union narrowing
  • 6.2 Zod schemas wired at the generateBatch and BatchBarcodeGenerator.generate boundary
  • 6.3 Every error code in error-codes.ts thrown by at least one production path (BARCODE.BATCH_ABORTED covered by abort scenario)
  • 6.4 Strict-mode behaviors tested both on and off (concurrency 1 vs > 1; continueOnError semantics 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.generate is 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.md if package set or deps changed (no change expected — purely additive feature)

Audit Note (2026-05-02)

Status: DEFERRED.

State at audit:

  • @suaveplan/barcode package itself is shipped and green, but the batch-generator feature has not been authored. No src/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_ABORTED is not yet wired into src/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).