fix: bind saved assessment readback to the requested ID

Merged
SI
2d ago
+208-1

Requesting saved assessment A could display private snapshot B when readback returned a different ID. Capture the submitted ID before asynchronous work and reject mismatched readback before publishing its snapshot, text or saved ID. Preserve the entered ID for explicit retry/recovery. UUID case differences and trimmed whitespace remain supported.

This extracts only the existing-hook safety fix and direct tests from #2405; that draft and its new recovery interface remain unchanged. Four files: hook, new identity regressions, one mounted mismatch regression, and three fixture-input corrections required by the existing capture tests. No recovery UI/parser, API/schema/store or dependency changes.

Validation: the new identity tests on untouched main 630d3aca reproduce two failures publishing the wrong snapshot; with the fix, all 48 focused tests/6 files pass, including scope, delayed token/read, unavailable responses and save retry contracts. Changed-file ESLint, Prettier and diff checks pass. Full local type checking has the exact same unrelated dependency/image diagnostics as an untouched same-base checkout using the same dependency installation; no global clean-type/build claim.

Frozen head 17adec821c42f6262f5786349bb69945bbb96720; tree e56f5381c164692889b152b42e225fbf7869a05e. Independent exact-head review and CI pending. No merge or native/account acceptance claimed; existing runtime holds remain in place. Related to #2231, without closing it or #2207.


Summary by cubic

Fixes a race where requesting saved assessment A could display private snapshot B when readback returned a different ID. The submitted ID is now captured before async work, and mismatched readback is rejected before publishing its snapshot, text, or saved ID.

  • Preserves the entered ID so users can retry or recover.
  • UUID case differences and trimmed whitespace remain supported.
  • Adds regression tests for identity binding, delayed readback, and unavailable responses.

Summary by CodeRabbit

  • Bug Fixes
    • Improved saved assessment loading by ensuring results match the selected company, including when company IDs differ only in letter casing. This helps prevent displaying an assessment for a different company when an operation is underway.