Repository navigation
fix!: update draft findings using saved IDs - #1156
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b58c69fdb6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const finding of input.findings) | ||
| finding.identity ??= { anchor: randomUUID() }; | ||
| for (const surface of input.coverage.surfaces) surface.id ??= randomUUID(); |
There was a problem hiding this comment.
Expose generated IDs before requiring them on updates
When an MCP client follows the documented partial-checkpoint-to-final-draft flow and omits these optional fields, every tool call assigns new UUIDs. The record result returns only counts/status, while canonical draft files are unavailable through the supplemental artifact reader, so the client cannot discover the generated IDs to reuse. Re-submitting the same finding or surface therefore creates a new row while preservation retains the old one, duplicating findings and coverage in the final report; return the assigned IDs or provide draft readback/stable reconciliation before requiring their reuse.
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It substantially rewrites concurrent draft persistence and recovery behavior, warranting final human review despite extensive coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Updates scan-draft reconciliation to use persisted IDs, preventing reordered rows from modifying the wrong finding.
Changes:
- Assigns and preserves stable finding, surface, and deferred-work IDs.
- Reworks publication and recovery around committed snapshots and pending checkpoints.
- Updates documentation and regression/integration coverage.
| File | Description |
|---|---|
sdk/typescript/src/scan-semantics.ts |
Handles generated and explicit identity collisions. |
plugins/codex-security/references/scan-contract.md |
Documents stable-ID update semantics. |
plugins/codex-security/references/final-report.md |
Adds ID-preservation guidance. |
plugins/codex-security/mcp-app/tests/test_legacy_scan_checkpoint_publication.mjs |
Removes superseded legacy publication coverage. |
plugins/codex-security/mcp-app/tests/test_deep_scan_store_integration.mjs |
Passes draft payloads through stdin. |
plugins/codex-security/mcp-app/tests/test_compact_artifact_server.mjs |
Reuses persisted IDs in fixture updates. |
plugins/codex-security/mcp-app/tests/test_artifact_scan_draft.mjs |
Replaces legacy cases with ID-based reconciliation coverage. |
plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.mjs |
Adds concurrent recovery and ID-stability tests. |
plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts |
Validates accepted aggregate drafts. |
plugins/codex-security/mcp-app/src/artifact-scan-draft.ts |
Implements snapshot-based publication and ID reconciliation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8f342f7 to
da5f664
Compare
b58c69f to
69f2dfd
Compare
faizan-oai
left a comment
There was a problem hiding this comment.
Reviewed the saved-ID reconciliation and documented input contract at 97dd48c. The integrated compact artifact server checks and recovery suites pass; current-head CI passed. No new issue found in this increment.
alandelong-oai
left a comment
There was a problem hiding this comment.
Reviewed this draft reconciliation rewrite with three independent passes and root verification. Two P2 data-loss regressions remain, detailed inline. Both reproduce against the actual base and head modules. The existing generated-ID concern is a usability risk, but I have not established that persisted IDs are inaccessible in the supported caller workflow.
Validation: 39 MCP tests pass across five files, all 9 compact diff SDK tests pass, and the bundled plugin build succeeds. Disposable probes show that the base preserves independent deferred work and pre-index checkpoint findings while this head drops them. No repository files were changed.
| row.surfaceIds.every((id) => { | ||
| const surface = surfaces.get(id); | ||
| return ( | ||
| surface && | ||
| surface.disposition !== "needs_follow_up" && | ||
| !pendingSurfaces.has(id) |
There was a problem hiding this comment.
[P2] Preserve deferred work when its surface disposition has not changed
A prior draft can legitimately contain a no_issue_found surface plus an independent deferred review referencing that surface. If a later draft repeats the same surface and omits the deferred row, this condition treats the unchanged disposition as a resolution and discards the work. I reproduced the previous implementation retaining partial coverage and this implementation returning complete coverage with no deferred rows. Require an actual resolution of the saved work; merely resubmitting an already reviewed surface is not evidence that the independent review finished.
| for (const part of ["checkpoints", "pending"]) { | ||
| directory = join(directory, part); | ||
| let metadata; | ||
| try { | ||
| metadata = await fs.lstat(directory); | ||
| } catch (error) { | ||
| if ((error as NodeJS.ErrnoException).code === "ENOENT") return []; |
There was a problem hiding this comment.
[P2] Do not silently discard checkpoint-only resume evidence
For a pre-index scan whose accepted findings exist only in checkpoints/<digest>.json, the missing checkpoints/pending directory now returns an empty set. The next draft succeeds and publishes zero findings. An exact base/head probe with an explicit stable finding identity produces one saved finding on the base and none on this head; the old regression test for this state is also deleted. Recover these checkpoints, or reject this unsupported resume with the documented original-version/new-scan error instead of accepting a draft that silently drops its evidence.
da5f664 to
304afa5
Compare
97dd48c to
24f55e8
Compare
alandelong-oai
left a comment
There was a problem hiding this comment.
Three independent re-review passes and root verification are complete. The two original deferred-review and pre-index checkpoint reproductions are fixed. Three distinct P2 issues remain at this head, with inline details: legacy staged-pointer continuation fails, legacy history acknowledgements can be dropped and revive superseded findings, and the original submitted checkpoint is no longer retained before reconciliation.
The acknowledgement issue is fixed later by #1163; the other two still reproduce at the integrated tip. Base/head comparison ruled out a new rendering-loss claim: the late deferred row was already omitted from the rendered draft before this PR, but this PR additionally removes it from immutable checkpoint history. Probes use real workbench publication and synthetic artifacts. Approval remains withheld.
| name, | ||
| ])); | ||
| if (contents === undefined) continue; | ||
| const saved = parseJsonObject(contents, "pending scan checkpoint"); |
There was a problem hiding this comment.
[P2] Continue reading legacy staged-path pending markers
When the immutable checkpoint copy is absent, older writers leave a pending marker containing drafts/<uuid>.checkpoint.json, with the actual checkpoint intact at that path. This reader now parses the path itself as JSON. An ordinary continuation of such a saved scan fails with pending scan checkpoint: stored JSON is malformed before publication, even for valid stable finding identities. Both this head and the stack tip reproduce it; the previous reader followed the staged path and verified its hash. Retain that format alongside the new pending JSON payload.
| } catch (error) { | ||
| if ((error as NodeJS.ErrnoException).code === "ENOENT") { | ||
| if (part === "checkpoints") return []; | ||
| // Older writers saved stable checkpoints before the pending index existed. |
There was a problem hiding this comment.
[P2] Keep acknowledgements when falling back to immutable history
This new fallback rereads all immutable checkpoints whenever no pending directory exists. The Python writer retains prior acknowledgement IDs only while a matching pending marker exists. For a pre-index Deep scan, the first final write imports checkpoint A, the next final aggregate supersedes A and drops its acknowledgement, and the third final write imports A again. Real workbench publication at this head produces finding counts 1, 0, 1 across those writes. Retain the legacy acknowledgements or establish the pending index before switching to the new lifecycle. The later #1163 writer does the latter, but this head does not.
| preserved.checkpointIds, | ||
| ); | ||
| return { | ||
| scanId: reconciled.scanId, |
There was a problem hiding this comment.
[P2] Preserve the submitted checkpoint separately from reconciliation
Passing reconciled in place of parsed means immutable history no longer retains the original input when reconciliation omits evidence. With an accepted final draft followed by a late partial checkpoint containing a new deferred review on the same surface, the existing reconciliation drops that row from presentation. Before this PR, the raw row remains in a separate immutable checkpoint; at this head and the tip no immutable or pending checkpoint contains it. Base/head probes confirm two saved checkpoints with the original review before the change versus only the reconciled final afterward. Keep the submitted checkpoint as the recovery receipt while publishing reconciled documents; the rendering behavior is pre-existing, but losing the original evidence is new.
304afa5 to
78c764d
Compare
24f55e8 to
40f4303
Compare
There was a problem hiding this comment.
Re-reviewed the real PR diff at 40f4303f7a9499488c892cd937e6fd958aa6fb90. Three independent high-reasoning passes covered the complete changed patch and tests; root source checks and focused reproductions informed this decision.
The checkpoint ordering correction is present. Existing findings remain: older staged-path pending markers are rejected as malformed JSON, and saving only the reconciled payload discards original submitted checkpoint evidence. The latter finding is limited to immutable history; the presentation loss predates this PR. The own-head legacy acknowledgement issue is fixed later in #1163.
Validation across touched paths at branch tip 06e75cfe: 1,356 SDK tests, 867 Python tests plus 100 subtests, and 108 MCP tests passed; builds, types, portable checks and installed-package checks passed. These are integration checks at the branch tip, not a claim that every intermediate PR or its CI is clean. Latest workflow runs for this unchanged head were verified successful at 2026-10-02 01:26 UTC. Earlier failed or canceled job records are superseded; this CI status correction does not alter the review decision.
7ce462a to
f5b5e81
Compare
071ccdf to
99ad9d7
Compare
alandelong-oai
left a comment
There was a problem hiding this comment.
Retained the three independent passes for the identical patch and reconciled inherited touched-file changes at f5b5e81a7f5a.
Actual own-head workbench probes accept legacy staged-path markers, retain the submitted late-review input in immutable history, and preserve checkpoint acknowledgements across four writes without reviving a rejected finding. The separately observed old presentation behavior is pre-existing. The prior holds are cleared.
Current tip 355ec321 passed 75 report-projection tests, portable source checks, SDK build:ci and plugin build. The immediately preceding tip fec36f1d passed 1,360 SDK tests, 873 Python tests plus 100 subtests, 109 MCP tests, builds/types and the clean 600-entry installed-package check. Only report_projection.py and its test changed between those tips; SDK/MCP runtime files are byte-identical. Both descend from main 008a8b4d. These are integration checks, separate from own-head probes. No native Windows local run.
No serious outstanding finding introduced by this PR. Code review approval does not establish CI or merge readiness.
99ad9d7 to
5560aef
Compare
f5b5e81 to
12ffb02
Compare
alandelong-oai
left a comment
There was a problem hiding this comment.
Retained the three independent passes for the verified identical patch and reconciled inherited touched-file changes at 12ffb023873f.
No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch and inherited changes in touched files.
Integrated tip 6ef8cbb8, based on 008a8b4d, passed 1,388 SDK tests, 879 Python tests plus 100 subtests, 109 MCP tests, portable checks, builds and the clean 600-entry installed-package check. These are branch-tip integration checks, separate from own-head probes; no local Windows execution was performed.
No serious outstanding finding introduced by this PR. Code approval is separate from CI and merge readiness.
5560aef to
6852a44
Compare
12ffb02 to
6fa5255
Compare
alandelong-oai
left a comment
There was a problem hiding this comment.
Retained three prior independent passes for the verified identical patch and reconciled inherited touched-file changes at 6fa52554554d.
No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch and inherited changes in touched files.
Branch tip 3e0083d9, based on 008a8b4d, passed 1,392 SDK tests, 881 Python tests plus 100 subtests, 109 MCP tests, builds, portable source checks and the 600-entry installed-package check. These are tip checks, separate from own-head probes. No local Windows run was performed. The tip excludes the dependency update merged separately in #1184; combined validation remains outstanding.
No serious outstanding finding introduced by this PR. Code approval is separate from CI and merge readiness.
Consolidate approved Deep Scan changes into the parent topic branch.
612709d
into
mdangelo/codex/pr939-split-32-worker-draft-helpers
Part 33 of 46. Previous: #1155 · Next: #1157 · Stack index
Summary
Use saved finding identities and coverage row IDs for draft updates, so reordering rows or editing their text cannot select a different saved row.
Changes
needs_follow_upto a resolved state.Testing
The complete MCP draft module passed 41 cases; composition and pending-draft Python suites passed 107 cases. The pre-index acknowledgment regression passed at part 33.
Checks against the complete stack passed: SDK and MCP typechecks, formatting, Ruff, the SDK build, portable plugin compatibility and its tests, focused recovery/accounting tests, and local-artifact package smoke using exact cached dependencies. The package check was not a clean registry install. See this PR’s Checks tab for CI results for its current commit.
Risk and rollout
Draft clients must reuse finding
identity, surfaceidand deferred-work IDs on later updates. Missing IDs create new rows; a unique deferredcandidateIdcan reuse its saved row. Saved drafts without stable IDs require their original version or a new scan. Stable-ID pre-index checkpoints remain recoverable; a valid committed snapshot and pending index prevent acknowledged history from reopening removed findings.Public disclosure review