Skip to content

fix(sdk): bind post-scan artifact restoration - #468

Closed
mldangelo-oai wants to merge 9 commits into
mainfrom
mdangelo/codex/confine-postscan-artifact-restoration-20260815
Closed

fix(sdk): bind post-scan artifact restoration#468
mldangelo-oai wants to merge 9 commits into
mainfrom
mdangelo/codex/confine-postscan-artifact-restoration-20260815

Conversation

@mldangelo-oai

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

Copy link
Copy Markdown
Collaborator

Summary

Keep completed scan artifacts inside the validated output tree when a post-scan
follow-up fails.

Changes

  • Snapshot sealed artifacts through checked file handles and capture the
    canonical scan-root identity before starting the follow-up.
  • Restore through descriptor-relative POSIX operations and held Windows handles,
    preventing replacement roots or linked/swapped parents from redirecting writes.
  • Skip unchanged artifacts while recovering missing, damaged, unreadable,
    nested, and binary artifacts.
  • Treat restoration setup failures as warnings and return the completed scan
    without starting the follow-up.
  • Merge current main, including its credential-lock and Windows ACL updates.
    Keep this PR's restoration guards unchanged and simplify test callbacks and
    metadata assertions.
  • Refresh the bundled plugin to 0.1.90 so previous caches load the restoration helpers and current main together.

Testing

Local first-pass verification:

  • Initial API, post-scan, contract, and credential tests: 195 passed, two skipped.
  • Final restoration, contract, concurrency, and runtime tests: 191 passed,
    11 skipped, no failures.
  • Types, formatting, and build passed.
  • Ruff and Python 3.10 syntax checks passed for both changed Python modules.

After merging main 01bd062, 204 restoration/contract/concurrency/runtime tests
passed with 12 platform skips. Types/models, formatting, Ruff, build, static
package checks and full installed smoke passed again. Real upgrades from the
original PR's 0.1.22, previous push's 0.1.59 and main's 0.1.60 each matched all
118 installed plugin files while preserving credentials.

The old Windows failure occurred in concurrent credential-lock setup; its
implementation has since changed on main. Native Windows and the full suite
were not rerun. CI is not awaited before advancing to the next PR.

  • Final main refresh (fd98a90): package 0.1.21 includes the MCP launcher-permission fix; feature source and bundled payload are unchanged. Types/model generation, formatting, build, 28 focused package/report/launcher tests, static artifact verification and full installed-package smoke passed, including MCP initialization. CI was not awaited.

Risk and rollout

No documented SDK, CLI, flag, environment, dependency, or state-format changes.
Failed follow-ups can atomically replace damaged sealed artifacts, then the
completed contract is revalidated. Unchanged artifacts retain their file
identity and timestamps.

If the root or an artifact parent changes identity, restoration fails closed.
If setup is unavailable, the follow-up is skipped and the completed scan is
returned with a warning. This remains a draft PR; no release is published.

Public disclosure review

The current update and public PR surface have been reviewed. Existing automated
comments contain access-restricted report links, so the second attestation
remains unchecked.

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

@github-actions github-actions Bot added the bug Something isn't working label Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 6e0e19c3b8

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 6e0e19c3b8

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, 4ca4c82b4f14ede84e666742c52639391a127384.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 4ca4c82b4f

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4ca4c82b4f

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review commit 3368d07e98709dc1096f3d31f5f41b025b4727cb.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 3368d07e98

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 3368d07e98

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head e8fc845591364b41ac8da88462098e90852df680. This additive follow-up fixes transient Windows credential-lock reads and test cleanup. The artifact-restoration implementation is unchanged.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: e8fc845591

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: e8fc845591

ℹ️ 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 thread sdk/typescript/src/contract.ts Outdated
Comment thread sdk/typescript/src/runtime.ts Outdated
@mldangelo-oai mldangelo-oai changed the title fix(sdk): keep restored scan artifacts within their output directory fix(sdk): bind post-scan artifact restoration Aug 22, 2026
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review exact head 1664172 against current main.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex security review

Please review exact head 1664172 against current main.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 22, 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-22T06:32:35.278945Z 1664172 Manual request
ℹ️ 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. Hooray!

Reviewed commit: 1664172ca7

ℹ️ 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 1664172ca719ae1f4dc07ed23e6e228aab900324 and compared the overlapping newer #626 implementation.

Recommendation: supersede this PR with #626 rather than merging both. The underlying restoration fix is necessary, but this older version changes an unrelated write contract and ties recovery to the selected plugin's helper API.

[P2] Restrict unchanged-content short-circuiting to restoration

The new comparison in write_scan_local_bytes returns early for all identical writes, including ordinary callers that previously received a new private file. I executed the actual helper against an existing 0644 artifact with identical contents: this head left both its mode and inode unchanged. The corresponding #626 helper replaced it and produced mode 0600. Gate the optimization on restoration identity being supplied, as #626 does. Content equality is not equivalent to preserving the original writer's metadata/replacement contract.

Custom-plugin and bundle compatibility

prepareScanArtifactRestorer invokes options.pluginRoot and assumes that plugin contains the newly introduced scan_root_identity API. An otherwise compatible existing custom plugin will fail restoration setup and therefore skip requested post-scan instructions. Recovery is an SDK guarantee, so use the SDK-owned helper independently of the selected scan plugin. This PR also changes bundled Python code without advancing the bundled version markers; the version-keyed install/cache path needs an upgrade plan. #626 addresses both points and avoids the unbounded whole-file equality read in this version.

Existing feedback and verification

The earlier checked-path/rename race is addressed in the current implementation by held descriptors/handles; the unrelated credential-lock edit was removed. I am not re-reporting those old comments as current defects.

Ran the checked-in post-scan suite: 13 passed, 0 failed, plus the paired ordinary-write reproduction above. Linux with Bun 1.3.14 / Node 22.13.1 and cached dependencies; no native Windows or live model run. Keep the regression fixtures, but consolidate the production fix into #626.

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.

2 participants