3.2 KiB
Task 5 report
Status: complete
Implemented deterministic page assembly with printed-number/pagination and continuation evidence, mobile session hints that cannot override conflicting printed numbers, multi-document/open-page review handling, and exact page coverage checks. Kept segmentPages() as the legacy compatibility adapter. Added the manual assembly revision route with stale-revision, posted-candidate, and coverage validation; successful revisions update only unposted notes, increment the batch-level assembly_revision, record dn_review_events, and do not invoke vision. The staged-ingestion schema and DnBatchRecord now include the optional batch revision field; note-level revision remains candidate provenance.
Next 16 docs read before route edits:
node_modules/next/dist/docs/01-app/01-getting-started/15-route-handlers.mdnode_modules/next/dist/docs/01-app/03-api-reference/03-file-conventions/dynamic-routes.md
Tests:
npx vitest run src/lib/dn-pipeline/assemble.test.ts 'src/app/api/dn-batches/[id]/assembly/route.test.ts'— 14 passed.python3 scripts/pb-add-dn-staged-ingestion.py --dry-run— completed; dry-run only, no schema applied.npx vitest run src/lib/dn-pipeline src/app/api/dn-batches— 260 passed.npm run typecheck— passed.git diff --check— passed.
Fix round 3 evidence
Task 5 implementation/fix commit: 62720699573f4bdb8ff2c57b63beaab68da5e929.
Manual assembly now rejects any existing dismissed candidate (status=dismissed or stage=dismissed) before candidate, batch, or review-event writes, preserving dismissal intent and preventing stale-row deletion. The obsolete dangling SHA claim was removed from this report. This report is intentionally a separate documentation-only commit.
Commands and results:
npx vitest run 'src/app/api/dn-batches/[id]/assembly/route.test.ts'— 13 passed.npx vitest run src/lib/dn-pipeline src/app/api/dn-batches— 265 passed.python3 scripts/pb-add-dn-staged-ingestion.py --dry-run— completed; no schema changes written.npm run typecheck— passed.git diff --check— passed.
Concerns: no production schema was applied. The route defensively sorts notes by note_index; posted detection covers legacy status, staged stage=posted, and non-empty posted_at.
Fix round 2 evidence
Task 5 implementation/fix commit: dd0560c2d66f013e173e432d27bfffd34a6146f3.
This round removes surplus unposted candidates during merges, captures the full before-state for the audit event, and serializes revisions through the existing unique dn_pipeline_locks batch lease. Live leases return 409; expired leases are reclaimed; leases release in finally on success, stale revision, and failure. Added coverage for merge deletion, live/reclaimed leases, release behavior, malformed payloads, staged posted candidates, and pagination conflicts. No production schema was applied.
Commands and results:
npx vitest run 'src/app/api/dn-batches/[id]/assembly/route.test.ts'— 11 passed after test-first failures.npm run typecheck— passed.npx vitest run src/lib/dn-pipeline src/app/api/dn-batches— 263 passed.python3 scripts/pb-add-dn-staged-ingestion.py --dry-run— completed; no schema changes written.git diff --check— passed.