Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
# Tasks — qrcode-scan
> Every checkbox MUST reflect work actually done in this change. Do not retroactively tick boxes for work that was already in main when this change opened.
## 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 `MIGRATION.md` Section 4.5 for source requirements (skip enterprise — genesis-original)
- [ ] 1.2 Read `openspec/specs/qrcode/spec.md` (existing capability)
- [ ] 1.3 Read `openspec/AGENTS.md` Sections 13 and 14
- [ ] 1.4 Draft `proposal.md` from `openspec/templates/proposal.md`
- [ ] 1.5 Confirm no `## Source mapping` section (genesis-original)
- [ ] 1.6 Draft `specs/qrcode-scan/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/scan/scan.ts` — `scanFromImageData` decode entry point
- [ ] 2.2 Add `src/scan/scan-camera.ts` — `scanFromCameraStream` frame extraction wrapper
- [ ] 2.3 Add `src/scan/totp-extract.ts` — `extractTotpUri` otpauth parser
- [ ] 2.4 Add `src/scan/totp-types.ts` — `TotpConfig`, `TotpAlgorithm`, `OtpAuthUri`
- [ ] 2.5 Add `src/scan/scan-schemas.ts` — Zod schemas for boundary types
- [ ] 2.6 Add error codes `QRCODE.DECODE_FAILED`, `QRCODE.CAMERA_ACCESS_DENIED`, and `QRCODE.TOTP_PARSE_ERROR` to existing `src/error-codes.ts`
- [ ] 2.7 Add `src/scan/qr-scan-error.ts`, `camera-access-error.ts`, `totp-uri-parse-error.ts`
- [ ] 2.8 Add `src/scan/telemetry.ts` — OTel instruments for scan operations
- [ ] 2.9 Register `./scan/scan` subpath export in `package.json`
- [ ] 2.10 Update barrel `src/index.ts` if scan symbols are re-exported from root
- [ ] 2.11 Add `src/scan/clock.ts` — injectable `Clock` for deterministic frame-interval timing in tests
## 3. Tests
- [ ] 3.1 Unit tests at `src/scan/scan.test.ts` covering every scenario
- [ ] 3.2 Unit tests at `src/scan/scan-camera.test.ts` covering every scenario
- [ ] 3.3 Unit tests at `src/scan/totp-extract.test.ts` covering every scenario
- [ ] 3.4 Spec-conformance tests at `src/scan/scan.spec-conformance.test.ts` pinning type-level / observability / strict-mode scenarios
- [ ] 3.5 Integration / contract tests where the spec demands them
- [ ] 3.6 Every `it(...)` carries `{ timeout: 5000 }` (or 30000 for genuinely async)
## 4. Documentation
- [ ] 4.1 Sibling `.md` for every new implementation `.ts` (≥200 words, basic + advanced examples, full API reference)
- [ ] 4.2 Update `README.md` to list `./scan/scan` under `## Modules`
- [ ] 4.3 Update `CLAUDE.md` package listing if public surface changed
## 5. Pre-archive verification (the 5-gate triple)
- [ ] 5.1 `bun run check` — Biome 0 errors / 0 warnings / 0 info across the whole monorepo
- [ ] 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, no `error` findings
- [ ] 5.5 `bunx turbo build --filter=@suaveplan/qrcode` — green
## 6. Pre-archive 7-row checklist (AGENTS.md Section 13)
- [ ] 6.1 Generics threaded; `expectTypeOf` assertions on every literal-type claim
- [ ] 6.2 Zod schemas wired at every declared boundary
- [ ] 6.3 Every error code in `error-codes.ts` thrown by at least one production path
- [ ] 6.4 Strict-mode behaviors tested both on and off
- [ ] 6.5 OTel instruments emitted from production paths and asserted with a real in-memory `MeterProvider`
- [ ] 6.6 Lifecycle dedup tested where claimed (in-flight Promise, idempotent set/load)
- [ ] 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`
- [ ] 7.2 Move `openspec/changes/qrcode-scan/` → `openspec/archive/<yyyy-mm-dd>-qrcode-scan/`
- [ ] 7.3 Refresh `MANIFEST.md` if package set or deps changed