Skip to content

fix!: update draft findings using saved IDs - #1156

Merged
mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-split-32-worker-draft-helpersfrom
mdangelo/codex/pr939-split-33-draft-identities
Oct 4, 2026
Merged

mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-split-32-worker-draft-helpersfrom
mdangelo/codex/pr939-split-33-draft-identities

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Assign missing IDs once per operation and reuse them during publication retries; preserve saved evidence while reconciling updates.
  • Keep independent deferred work when its referenced surface is unchanged. Automatic cleanup requires an actual transition from needs_follow_up to a resolved state.
  • Publish prepared documents and checkpoint acknowledgments through the workbench, and document the insert/update contract.
  • Retain each submitted checkpoint as immutable evidence independently of its reconciled presentation.
  • Recover stable-ID pre-index checkpoints, legacy staged-path markers and JSON payloads after interrupted history copying. Read newer finals first, and carry acknowledgments across later accepted drafts so old history cannot reopen removed findings.

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, surface id and deferred-work IDs on later updates. Missing IDs create new rows; a unique deferred candidateId can 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

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +358 to +360
for (const finding of input.findings)
finding.identity ??= { anchor: randomUUID() };
for (const surface of input.coverage.surfaces) surface.id ??= randomUUID();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-04T17:34:41.391182Z ddcd608 Draft marked ready
🔒 Security Review ⚠️ Failed 2026-10-04T17:34:47.259025Z ddcd608 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-32-worker-draft-helpers branch from 8f342f7 to da5f664 Compare October 1, 2026 07:25
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-33-draft-identities branch from b58c69f to 69f2dfd Compare October 1, 2026 07:25
@mldangelo-oai mldangelo-oai changed the title fix: update draft findings by their saved IDs fix!: update draft findings using saved IDs Oct 1, 2026

@faizan-oai faizan-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +267 to +272
row.surfaceIds.every((id) => {
const surface = surfaces.get(id);
return (
surface &&
surface.disposition !== "needs_follow_up" &&
!pendingSurfaces.has(id)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Comment on lines +454 to +460
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 [];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-32-worker-draft-helpers branch from da5f664 to 304afa5 Compare October 1, 2026 23:44
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-33-draft-identities branch from 97dd48c to 24f55e8 Compare October 1, 2026 23:44

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-32-worker-draft-helpers branch from 304afa5 to 78c764d Compare October 2, 2026 00:36
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-33-draft-identities branch from 24f55e8 to 40f4303 Compare October 2, 2026 00:36

@alandelong-oai alandelong-oai left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-33-draft-identities branch 2 times, most recently from 7ce462a to f5b5e81 Compare October 2, 2026 01:56
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-32-worker-draft-helpers branch from 071ccdf to 99ad9d7 Compare October 2, 2026 01:56

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-32-worker-draft-helpers branch from 99ad9d7 to 5560aef Compare October 2, 2026 02:47
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-33-draft-identities branch from f5b5e81 to 12ffb02 Compare October 2, 2026 02:47

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-32-worker-draft-helpers branch from 5560aef to 6852a44 Compare October 2, 2026 03:52
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-33-draft-identities branch from 12ffb02 to 6fa5255 Compare October 2, 2026 03:52

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@mldangelo-oai
mldangelo-oai marked this pull request as ready for review October 4, 2026 17:34
@mldangelo-oai
mldangelo-oai merged commit 612709d into mdangelo/codex/pr939-split-32-worker-draft-helpers Oct 4, 2026
1 check passed
@mldangelo-oai
mldangelo-oai deleted the mdangelo/codex/pr939-split-33-draft-identities branch October 4, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants