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

3.5 KiB

RP30 — Verify saved research revisions before clearing drafts

Parent E12. Priority P1 / High draft-custody defect. Complexity M. Dependencies R04, RP24. Owner continuation authorizes implementation and commits. All seven conditional tasks remain deferred.

Verified baseline: ResearchEntry.save awaits researchApi.reviseHypothesis or reviseArtifact but ignores the returned record, immediately clears editing and reloads. The transport checks only a broad envelope/record ID. A stale, foreign or altered successful acknowledgement therefore discards the draft. The existing finding-create dialog already verifies its source/reference acknowledgement; the revision form already preserves uncertain drafts and prevents automatic replay for transport failures/conflicts.

Scope: verify the revision acknowledgement in the existing form before clearing its draft. Match entry/project/parent identity, immutable owner and artifact kind/hypothesis linkage; require a distinct revision ID and expected next ordinal, normalized submitted title/body/proposition/criteria/content origin and unvalidated state. Artifact revisions must preserve the original source and exact evidence reference identities, including legacy null/omitted strategy-version compatibility. Reuse shared request schemas and existing reference conversion/canonical comparison. Do not recalculate or compare financial values in the browser. A mismatch uses ResearchApiError with uncertain status and the current blocked-draft/discard-and-review controls; no automatic retry or false success refresh.

Affected files: apps/stock/web-app/src/features/research/components/ResearchEntry.tsx, existing research workspace/finding UI tests, test/e2e/workbench.test.ts, and walkthrough usage. No backend/API/schema, engine, evidence resolution, permission, archive/project/create workflows, generic client framework or real research execution changes. Preserve valid normalized submissions, declared human/AI/unknown origins and historical evidence.

Acceptance/tests:

  • Reproduce stale/foreign/altered successful acknowledgements losing the draft before the fix. Hypothesis, note and finding forms retain text and selected origin/criteria, disable resubmission and preserve one POST on verification failure. Loading, missing history and ordinary 4xx/conflict controls retain existing behavior.
  • Reject wrong entry/project/owner/parent/kind/linkage, old or unexpected revision identity/ordinal, changed submitted fields/state, missing/extra/substituted evidence identities and changed aggregate source. Check normalized title/proposition, body/criteria preservation, valid new IDs/ordinals, canonical and legacy null/omitted strategy versions and null/omitted source successes.
  • Actual production-built Chromium commits an ordinary hypothesis and evidence-backed finding revision, corrupts only their acknowledgement, verifies preserved blocked drafts and one POST each, deliberately discards/reloads and reopens the original committed revision with exact content/evidence. No duplicate revisions or new runs/dispatches; original Rust result remains unchanged.
  • Run relevant workspace/finding/source UI suites, complete built browser workbench, application/authored types, contracts, strict scoped lint/formatting, secret audit and diff checks. No native rebuild or performance work.

Definition of done: red regressions, smallest form correction using existing schemas/uncertain-state handling, root review, passing gates, task/evidence updates and commits. No new architecture decision or real study activation is needed.