Skip to content

refactor: separate old worker draft handling - #1155

Merged
mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-split-31-saved-draftsfrom
mdangelo/codex/pr939-split-32-worker-draft-helpers
Oct 4, 2026
Merged

mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-split-31-saved-draftsfrom
mdangelo/codex/pr939-split-32-worker-draft-helpers

Conversation

@mldangelo-oai

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

Copy link
Copy Markdown
Collaborator

Part 32 of 46. Previous: #1154 · Next: #1156 · Stack index

Summary

Move Deep Scan worker and reducer draft handling into a separate module before changing ordinary scan draft updates.

Changes

  • Route worker writes, reducer checkpoints and result validation through the extracted helpers.
  • Update reconciliation of partial drafts, candidate evidence and coverage in the legacy worker path.
  • Keep fallback report and ledger identities, deferred review evidence and pre-index checkpoint history in the active legacy worker; point reconciliation tests at that worker module.

Testing

Eight production-worker identity/evidence cases, the complete legacy draft script and the reducer retry regression passed at their owning boundaries.

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

The legacy worker runner still uses these helpers at this stage, so this changes active reconciliation behavior as well as moving code. The later plugin switch and cleanup retire this protocol.

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 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 ✅ Completed 2026-10-04T17:37:17.666187Z 612709d Draft marked ready
🔒 Security Review ✅ Completed 2026-10-04T17:36:41.543183Z 612709d 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

🟡 Changes recommended

Pre-index checkpoint recovery regresses, and the extracted worker reconciliation lacks direct regression coverage.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Separates legacy Deep Scan worker draft handling from ordinary scan drafts.

Changes:

  • Extracts worker draft parsing, checkpointing, and reconciliation.
  • Routes worker, reducer, and validation paths through the extracted module.
  • Preserves candidate evidence and resolved coverage state.
File Description
artifact-worker-scan-draft.ts Adds legacy worker draft protocol implementation.
artifact-validation.ts Uses worker-specific draft helpers.
artifact-deep-reducer.ts Uses worker checkpoint and parsing helpers.
compact-artifact-tools.ts Routes worker draft writes to the new module.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +127 to +139
if (context.layout !== "worker") {
const marker = await artifactDestination(
context,
["checkpoints", "pending", name],
"scan checkpoint marker",
);
await replaceArtifactText(marker, "");
}
const destination = await artifactDestination(
context,
["checkpoints", name],
"scan checkpoint",
);
Comment on lines +187 to +194
if (input.complete === false) {
const final = sources.find((source) => source.complete !== false);
if (final) {
result = structuredClone(final);
sources.push(input as SemanticScan);
}
}
const resolvedSurfaces = resolvedCoverageSurfaceIds(result.coverage, sources);

@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: 8f342f7afe

ℹ️ 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 +326 to +330
Array.isArray(item.surfaceIds) &&
item.surfaceIds.length > 0 &&
item.surfaceIds.every(
(id) => typeof id === "string" && resolvedSurfaces.has(id),
)

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 Preserve deferred work on already-resolved surfaces

When an earlier checkpoint contains a generic deferred item whose surfaceIds reference a surface already marked reported or no_issue_found, and a later draft repeats that surface but omits the deferred item, this predicate treats the surface as resolved and silently discards the outstanding work. Deferred work is independent of surface disposition—a reported surface may still require additional review—so omission can incorrectly change coverage to complete and hide unfinished analysis. Only infer resolution from an actual transition out of needs_follow_up or another explicit resolution signal.

AGENTS.md reference: AGENTS.md:L42-L43

Useful? React with 👍 / 👎.

Comment on lines +990 to +994
function findingCandidateId(finding: JsonObject): string | undefined {
return [
isObject(finding.provenance) ? finding.provenance.candidateId : undefined,
isObject(finding.extensions) ? finding.extensions.candidateId : undefined,
].find((id): id is string => typeof id === "string" && id.trim().length > 0);

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 Retain legacy report IDs when matching worker candidates

On retries or resumptions of older Deep workers, a finding may lack candidateId and carry only extensions.reportId or extensions.ledgerRowId; the compatibility projection in scripts/finalize_scan_contract.py:2524-2529 still treats both as fallback candidate identities. Restricting this helper to candidateId prevents sameSavedFinding and deferred reconciliation from associating such a finding with its saved candidate, so a refinement can duplicate the prior finding or leave an already-reported candidate deferred instead of transferring its evidence. Preserve the previous fallback order for these legacy identifiers.

AGENTS.md reference: AGENTS.md:L42-L43

Useful? React with 👍 / 👎.

Comment on lines +1 to +4
import {
recordCodexSecurityWorkerScanDraft,
type ScanDraftInput,
} from "../artifact-worker-scan-draft.js";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exercise the split worker implementation in reconciliation tests

These imports move the production worker tool to artifact-worker-scan-draft.ts, but tests/test_artifact_scan_draft.mjs:23-40 still bundles artifact-scan-draft.ts and invokes its old duplicate recordCodexSecurityWorkerScanDraft. The compact-server test only checks validation and a first empty write, so the extensive retry, archived-checkpoint, and evidence-reconciliation cases now exercise an implementation that production workers no longer call. Point those worker cases at the split module so behavioral changes here are actually covered.

Useful? React with 👍 / 👎.

@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-31-saved-drafts branch from 6bd22a2 to 76aa937 Compare October 1, 2026 07:25
@mldangelo-oai mldangelo-oai changed the title refactor: keep the old worker draft protocol separate refactor: separate old worker draft handling 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 legacy worker-draft extraction at da5f664 against its base and the subsequent retirement path. Current-head CI passed. No additional issue found in this increment; the draft recovery issues are tracked on #1154.

@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 the worker draft split at da5f6642f517be8f6bbd461975d669b62b3a2a1e with three independent passes and root verification. Approval is withheld for two reproduced P2 regressions:

All four existing MCP test files pass. I also redirected the existing worker regression cases to the split module in a disposable harness. They pass after adjusting the one old expectation that discarded late incomplete evidence; the checked-in suite still exercises the old implementation, as noted in the existing coverage comments. No repository files were changed.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-31-saved-drafts branch from 76aa937 to c469e17 Compare October 1, 2026 23:44
@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

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

Reconciled the unchanged patch and prior three-pass review against this exact restacked head.

The touched files and patch are unchanged, so the prior worker identity/deferred-coverage findings remain at this own head. The old worker implementation is removed later by #1169; that removal is not an own-head fix for this PR.

Approval remains withheld. This review distinguishes the PR's own head from fixes verified later in the stack; it does not duplicate existing inline findings.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-31-saved-drafts branch from c469e17 to 976f84b Compare October 2, 2026 00:36
@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

@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 78c764dc6ce25dcf11041aa9603a6dcf63610130. The patch is unchanged from the prior three-pass review. I reconciled the inherited changes in touched files and retained the prior verified findings and tests.

The touched files and patch are unchanged, so the prior worker identity/deferred-coverage findings remain at this own head. The old worker implementation is removed later by #1169; that removal is not an own-head fix for this PR.

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-31-saved-drafts branch from 976f84b to 6d44799 Compare October 2, 2026 01:37
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-32-worker-draft-helpers branch 2 times, most recently from 071ccdf to 99ad9d7 Compare October 2, 2026 01:56
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-31-saved-drafts branch from 6d44799 to 6490f01 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 99ad9d77fab5.

The legacy worker now recognizes reportId and ledgerRowId, and resolves deferred coverage only after an actual transition from needs_follow_up. The own-head worker identity and reducer tests pass, including eight identity/recovery cases. Both prior holds are fixed before the later worker removal.

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-31-saved-drafts branch from 6490f01 to fbdec7f Compare October 2, 2026 02:47
@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

@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 5560aef89306.

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-31-saved-drafts branch from fbdec7f to c612e66 Compare October 2, 2026 03:52
@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

@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 6852a44ba247.

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 585cf4b into mdangelo/codex/pr939-split-31-saved-drafts Oct 4, 2026
1 check passed
@mldangelo-oai
mldangelo-oai deleted the mdangelo/codex/pr939-split-32-worker-draft-helpers 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