Skip to content

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

Open
mldangelo-oai wants to merge 4 commits into
mdangelo/codex/fix-git-object-validation-cleanfrom
mdangelo/codex/fix-postscan-restoration
Open

fix(sdk): preserve sealed artifacts after post-scan failure#626
mldangelo-oai wants to merge 4 commits into
mdangelo/codex/fix-git-object-validation-cleanfrom
mdangelo/codex/fix-postscan-restoration

Conversation

@mldangelo-oai

Copy link
Copy Markdown
Collaborator

Summary

Preserve completed scan artifacts when optional post-scan instructions fail by restoring the sealed bytes with SDK-owned, identity-bound logic and bounded comparisons.

Changes

  • Snapshot completed artifacts before the post-scan turn and restore them if that turn fails.
  • Capture the bundled SDK finalizer independently of the selected or custom scan plugin.
  • Bind restoration to the validated scan root and artifact parent on Unix and Windows.
  • Compare same-size files in 64 KiB chunks only during identity-bound restoration, while ordinary writes retain atomic private replacement.
  • Advance the bundled plugin identity from 0.1.23 to 0.1.24 and cover a real predecessor-cache upgrade with safety-key retention.
  • Add custom-plugin, private-replacement, constrained-memory, path-replacement, binary-artifact, and installed-cache regressions.

Testing

  • Focused SDK suites: 321 passed, 13 platform skips, 0 failed.
  • Interaction suites: 110 passed, 0 failed.
  • Full TypeScript suite with seed 468: 1,776 passed, 28 platform skips, 0 failed.
  • After the final test-only cache assertion: runtime slice 128 passed, 11 platform skips, 0 failed; targeted regressions 4 passed, 0 failed.
  • pnpm run types, pnpm run format, and pnpm run build.
  • Package pack, archive check, and installed-package smoke: 265 entries and 113 bundled plugin files validated.
  • Three independent native code-review passes and a separate verifier completed with no findings.

Risk and rollout

Internal artifact-restoration behavior only; no CLI, configuration, or schema changes. The Windows implementation changed but was not executed locally and remains gated on hosted Windows CI.

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 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-24T23:11:21.290404Z 429ecd1 Manual request
🔒 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.

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.

3 participants