Skip to content

fix(sdk): keep restored scan artifacts within their output directory - #468

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

fix(sdk): keep restored scan artifacts within their output directory#468
mldangelo-oai wants to merge 5 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 artifact restoration within the selected scan output directory.

Changes

  • Reuse the completed-contract directory checks when restoring preserved artifacts.
  • Bind restoration to the approved canonical output root and reject linked artifact-parent directories.
  • Preserve missing-artifact restoration, cancellation behavior, and the existing synthetic post-scan coverage.
  • Preserve the additive main merge and the existing artifact-restoration implementation.
  • Retry transient Windows credential-lock owner reads through the existing acquisition loop. Bound continuous read failures, retain cancellation, and recheck the lock before each retry.
  • Release the parallel API-key test barrier if either scan fails.

Testing

Current head e8fc8455:

  • Focused lock, parallel-scan, and artifact-restoration tests: 18 passed, 0 failed.
  • pnpm run test --randomize --seed 12345: 1,311 passed, 11 skipped, 0 failed.
  • pnpm run test: 1,311 passed, 11 skipped, 0 failed.
  • pnpm run types, pnpm run format, pnpm run build, and git diff --check: passed.
  • Packed and checked the installed npm artifact, including the CLI/SDK, 106 bundled plugin files, and a nested worker without a global Codex installation: passed.
  • The existing artifact-restoration change is unchanged from the previously reviewed public head 3368d07e.
  • Three independent native reviews of the new CI-fix delta and a fresh verifier: no findings or blockers. The earlier whole-PR review remains recorded separately.

Risk and rollout

Normal completed-artifact restoration remains unchanged. Public contract readers keep their existing path canonicalization, including supported output directories beneath directory links. Restoration uses the same non-symlink artifact-parent requirement as completed-contract reads and stops if the approved canonical output root has changed. The Windows retry does not reclaim an unreadable lock or hide persistent errors. No public SDK export, dependency, or runtime setting is added.

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.

Newly authored material was reviewed for public disclosure. Existing automated review comments contain access-restricted report references; maintainer cleanup remains outstanding.

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

}
const path = join(scanDir, ...parts);
const metadata = await lstat(path);
return { path: join(scanDir, ...parts), parents };

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 Bind restoration writes to the validated parent

If a background command started during the post-scan phase replaces a validated parent directory with a symlink after this check returns, the subsequent writeFile(temporary, ...) and rename(temporary, path) follow that replacement and can overwrite a matching file outside the scan directory. The helper returns only a pathname, so none of the captured parent identities are bound to or revalidated around the actual restoration write; keep the write and rename tied to the checked directory identity so a concurrent swap fails safely.

AGENTS.md reference: sdk/typescript/AGENTS.md:L19-L20

Useful? React with 👍 / 👎.

Comment on lines +1110 to +1114
const deadline =
platform === "win32"
? (readRetry.deadline ??=
Date.now() + INCOMPLETE_CREDENTIAL_LOCK_MILLISECONDS)
: undefined;

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 Reset retry state when the Windows lock changes

On Windows, if one lock remains unreadable for most of this deadline and is then released and quickly replaced before the waiter observes an absent directory, readRetry.deadline is carried over to the new lock because the lstat identity is not tracked. A transient EPERM or EBUSY on the replacement can therefore exceed the old lock's deadline immediately and fail an otherwise healthy scan; associate the retry state with the lock's device/inode and start a fresh deadline when that identity changes.

AGENTS.md reference: sdk/typescript/AGENTS.md:L24-L24

Useful? React with 👍 / 👎.

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.

1 participant