stock-bot/docs/development/backlog/tasks/RP15.md

13 lines
2.2 KiB
Markdown

# RP15 — Preserve research CLI recovery receipts after journal failure
Parent E12. Priority P1 / High recovery defect. Complexity S. Dependency A03. Owner continuation authorizes this correction.
Verified baseline: `scripts/examples/research-cycle.ts` preserves an accepted resource in `ResearchCycleStopped.event` when journal persistence fails, but its executable catch prints only the message. A no-network subprocess probe runs the actual CLI, accepts one hypothesis, fails the second journal write, and exits with only an intent in the journal and no accepted IDs in output. Evidence: `/tmp/stock-bot-cycle-journal-probe/`. A subsequent `journal.close()` failure can also mask the primary error.
Scope: emit structured recovery evidence from the existing stopped event at the CLI boundary. Preserve exact accepted resource/revision IDs, operation, input, key and resource identity. Keep exit status nonzero and stop subsequent admissions. Cleanup failures must not suppress the primary recovery evidence. Do not label unacknowledged work accepted. Keep successful output compatible and fresh/exclusive journal creation unchanged. No automatic replay, silent fallback journal, client framework, credential output or backend/financial changes.
Ownership: agent owns `scripts/examples/research-cycle.ts`, `scripts/test/research-cycle.test.ts` and one small subprocess preload fixture if needed. Root owns docs/manifest, combined gates and commits. Parallel with RP16, which owns the client and its tests. Independent review required.
Acceptance/tests: run the actual executable with deterministic no-network fetch and journal faults after server acceptance; assert exact recovery event in stderr, empty success output, exit 1, original intent retained and no later mutation. Cover write/sync failure and a simultaneous close failure; ordinary pre-admission errors must not invent receipts or reveal the credential. Existing callable receipt/cancellation and successful workflow tests remain green.
Gates: research-cycle/client tooling suites, subprocess recovery regressions, authored types, scoped lint/formatting, root repository check. No browser suite required for a CLI-only change. Existing untrusted-candidate isolation and research authorization stay unchanged.