Skip to content

fix(sdk): preserve sealed artifacts after post-scan failure - #626

Merged
faizan-oai merged 17 commits into
mainfrom
mdangelo/codex/fix-postscan-restoration
Aug 27, 2026
Merged

fix(sdk): preserve sealed artifacts after post-scan failure#626
faizan-oai merged 17 commits into
mainfrom
mdangelo/codex/fix-postscan-restoration

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Preserve completed scan artifacts when optional follow-up instructions fail. Restore saved bytes through the SDK-owned writer, with writes bound to the original validated scan directory.

Changes

  • Retarget this PR to main and preserve its existing commit history with a normal integration commit. The resulting diff carries only the restoration change; it does not carry the closed fix(plugin): preserve committed diff scan integrity #623 or fix(scan): confine local diff inputs to the selected target #630 changes.
  • Adapt the Python helpers to the current plugins/codex-security source layout. The SDK bundle is generated from that source, not edited separately.
  • Read snapshots through checked file handles and keep restoration independent of a selected custom plugin. Preserve POSIX directory-descriptor and Windows ancestor-handle checks.
  • Compare unchanged artifacts in bounded chunks only during restoration. Ordinary writes still use private atomic replacement.
  • Advance the source plugin and SDK bundle markers to 0.1.79. Retain the existing real cached-plugin upgrade fixture, including stale MCP configuration, credential preservation, installed helper checks, and binary restoration.
  • Update the existing Python Windows-backend test mock for the writer's new optional identity argument.

Testing

  • Bun 1.3.14, seed 12345: 330 passed, 15 platform skips, no failures across post-scan, contract, API, runtime, and bundle-generation suites. The runtime suite was rerun successfully after its final formatting change.
  • Finalizer and Windows-helper Python suites: 163 passed, 2 native-Windows skips, and 56 subtests passed. Nine focused restoration helper probes also passed.
  • Node 22.15.1: bundle generation, generated-model check, MCP and SDK typechecks, SDK build, and plugin-source checks passed.
  • Formatting of changed TypeScript/JSON files, Ruff on changed Python files, and git diff --check passed.
  • Fresh npm package verification passed for all 282 package entries.
  • Full current-head hosted CI is pending this push. No local native Windows, live-model follow-up, real account refresh, or release/publish run is claimed.

Risk and rollout

No public CLI, configuration, or schema change. Keep the distinction between ordinary writes and unchanged-content restoration. Failure to prepare restoration skips optional follow-up; failure during actual restoration is reported rather than returning damaged artifacts as a successful result. This update does not reopen or approve either closed parent, and no other overlapping PR is changed.

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.

The existing qualification remains: historical commit contact metadata and account-gated links in automated comments are still present, so the second attestation stays unchecked. New changes use synthetic fixtures and a GitHub noreply commit identity. Other authors' comments are unchanged.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 24, 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-08-27T09:01:19.858632Z 97e8917 New commits
🔒 Security Review Completed 2026-08-24T04:43:35.729786Z 3e8985f PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 3e8985ff89

ℹ️ 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".

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

Critical review

Reviewed head 3e8985ff89d85e1550bd76dfa4b61825a676835c against its declared base, #623, and compared the overlapping #468 implementation.

Recommendation: use this as the single artifact-restoration implementation and retire/supersede #468. No new blocking defect found in this diff. Preserving a completed scan after optional follow-up failure is necessary. Restoring through a checked pathname alone is insufficient; the actual write must remain bound to the validated directory.

Correctness

The implementation reuses the existing cross-platform safe writer instead of adding another TypeScript pathname-check/write sequence. prepareScanArtifactRestorer captures canonical root identity before follow-up and uses the SDK-owned helper, independent of a selected custom plugin. Held parent descriptors on POSIX and the Windows ancestor-handle path enforce the write boundary. Setup failure skips optional work; restoration failure is not silently presented as a successfully recovered scan.

The differences from #468 matter: equality checking is restoration-only, uses bounded chunks and a size check, and does not change ordinary atomic/private replacement semantics. In a paired actual-helper fixture, an ordinary identical write on #468 retained mode 0644 and the original inode; this head replaced it with mode 0600. The plugin version bump and predecessor-cache test also cover the executable payload, not just source files.

Simplification

Do not ship both proposals or keep two subtly different restoration paths. This version is the more complete replacement. The one naming/ownership cleanup I would consider is moving the platform-neutral stream_matches_payload routine out of the Windows-named module if a natural existing shared helper fits; do not create a new abstraction layer solely for that name. Preserve the distinction between normal writes and no-op restoration writes.

Verification

Ran focused post-scan/restoration and predecessor-bundle tests: 11 passed, 0 failed; also executed the paired ordinary-write fixture against both heads. Linux, Bun 1.3.14 / Node 22.13.1, cached dependencies. Source review covered the held Windows-handle path, but I did not run native Windows tests or a live model follow-up. This review does not substitute for reviewing the much larger #623 base.

@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 this PR's artifact-preservation delta against #623. The focused artifact, contract, runtime, and cache checks pass (64 passed, one platform skip), as do typecheck and current-head CI. No blocking findings in this delta; this is not a review of #623.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 429ecd18a8

ℹ️ 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".

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

Re-reviewed 429ecd18a88866f8d16b736187066b19776789c9 against f5ca13647d427b1e4230674978c59dba2d79cf76. The update synchronizes bundle/cache versions; restoration implementation is unchanged. Focused checks pass (66 tests, one platform skip), as does typecheck. No new blocking code finding in this delta; this does not review or approve #623.

Holding approval for the current Windows CI failures:

  • Node 22, shard 3: parallel credential imports encounter a PowerShell Get-ChildItem / FileNotFoundException for an .auth-*.tmp file.
  • Node 24, shard 2: the API-login cancellation test's ready file never appears before its deadline.

Those credential functions and test bodies are unchanged here, so these logs do not demonstrate a new restoration regression. Please get the full Windows checks passing; the local macOS passes do not establish Windows success.

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

The CI-only hold is cleared: node-ci attempt 2 passes all 25 jobs, including Windows.

Head 429ecd18a88866f8d16b736187066b19776789c9 and declared base f5ca13647d427b1e4230674978c59dba2d79cf76 are unchanged from the code review. The earlier 66 passing focused tests (one platform skip) and typecheck apply to this exact delta; no new discussion concern appeared. No blocking findings in #626's own changes. This approval does not review or approve parent #623.

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

Re-reviewed 97e8917991acd6f11d9ee607439bd1b94573f0e2 against declared base e78c7e4ccb415cad8241aeb3db3cb9b74e516148 (#623). No blocking findings in this delta: restoration behavior is preserved, and the restack's bundle/cache updates and consolidated tests remain consistent.

Full current-head CI passes all 27 jobs, including Windows. Checked source/diff equivalence and hosted results for the changed tests; no local Bun suite was run this pass.

This approval does not review or approve parent #623.

Retain the existing branch history while carrying only the artifact-restoration
change onto the current plugin source layout. Closed parent changes are not
included in the main-based diff.
@faizan-oai
faizan-oai changed the base branch from mdangelo/codex/fix-git-object-validation-clean to main August 27, 2026 20:40
@github-actions github-actions Bot added the bug Something isn't working label Aug 27, 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 2a098d3b5f4cb1eb6d50bf6a021526b0bac4713a against current main 9bd256af7667bda1a293e77fff90475f9fec1f3f. No blocking findings in the main-based restoration change. The published diff matches the reviewed source: SDK-owned restoration, the current generated-bundle layout, and compatible Windows test mocks. It excludes the closed #623/#630 implementations.

Full current-head CI passes all 28 jobs, including Windows. Local verification includes 330 Bun passes (15 platform skips), 163 Python passes (2 native-Windows skips), types/build/formatting, and the package check; the final test-only mock adaptation was separately tested. No local native Windows or live-model run is claimed. Head, base, and discussions were rechecked before this exact-head approval.

@faizan-oai
faizan-oai merged commit 562db12 into main Aug 27, 2026
37 checks passed
@faizan-oai
faizan-oai deleted the mdangelo/codex/fix-postscan-restoration branch August 27, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants