Skip to content

fix(history): preserve native turn failures observed before cancellation - #735

Merged
mldangelo-oai merged 34 commits into
openai:mainfrom
Hughhhhcoder:codex/codex-security-scan-cancel
Nov 4, 2026
Merged

mldangelo-oai merged 34 commits into
openai:mainfrom
Hughhhhcoder:codex/codex-security-scan-cancel

Conversation

@Hughhhhcoder

@Hughhhhcoder Hughhhhcoder commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#2307 landed the registered-scan cancellation and measured-cost changes. This PR keeps one case that remained on main. A native SDK scan can report turn.failed while the caller signal is live, then receive a caller abort as the SDK closes the failed event stream. History now records the failure and its native diagnostic. If the caller aborts before the SDK observes the failure event, history records cancellation.

Scope

The SDK records the order when it receives the native terminal event. Hosted executor receipts continue to follow #2307. An explicit hosted cancellation records a canceled scan even if the executor reports failure. A caller deadline after registration records a failed scan. The existing workbench command persists measured cost. The hosted result retains available executor identity, status and usage.

The branch includes the shared one-line component test correction for #2317. An expressly aborted component scan reports a canceled lifecycle event while the component receipt records failure and retains its scan ID.

Verification

  • Tested both event orders through the public SDK entry point with a synthetic native stream. Main lost the failure-first diagnostic. The revised code saves it and passes the abort-first control.
  • Both component observer cases, all 84 hosted scan cases (including cancellation and deadlines), all 21 mock and time-budget cases, and all eight workbench cancellation tests passed. The SDK type check passed.

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.

@github-actions github-actions Bot added the bug Something isn't working label Aug 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 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-11-04T21:57:26.749269Z 0df84d8 New commits
🔒 Security Review ✅ Completed 2026-09-04T11:13:49.197272Z 48e5e5b New commits
ℹ️ 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.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 53a8c9f052

ℹ️ 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/api.ts Resolved
@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 67afadc3ba

ℹ️ 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/api.ts Resolved
@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 3394120d06

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

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

canceled is inferred from the signal's current state, not from the exception that ended the scan. If a real scan failure occurs and abort/close races before this bookkeeping block, the failure is recorded as canceled and its message/cost are dropped. Use cancel-scan only for a cancellation-derived failure, and add a fail-then-abort race test.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

Addressed in commit 13ca814c. Cancellation is now selected only for a cancellation-derived failure: direct interruption/AbortError failures (including wrapped causes) still use cancel-scan, while an ordinary failure that races with caller cancellation remains on fail-scan and keeps its message. The existing cancellation tests plus the new race regression pass (3 targeted tests); TypeScript, Prettier, model-generation, and diff checks pass.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 13ca814c11

ℹ️ 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/api.ts Resolved
…scan-cancel

# Conflicts:
#	sdk/typescript/src/api.ts
@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

Merged latest origin/main in commit 6eb5e4db to clear the branch conflict. The cancellation-race fix and regression test are unchanged. Re-validated the focused API tests (3 passed), TypeScript lint, Prettier check, generated-model check, and plugin build.

@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: 6eb5e4dbc8

ℹ️ 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/api.ts Resolved
@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

Addressed the client-close race review in commit ad93cd53. A CodexSecurity is closed. sentinel is now recognized as cancellation only when it is the observed failure, so close-triggered scans use cancel-scan while earlier ordinary/internal failures still use `fail-scan. Added a deterministic regression test for closing while feedback is in flight.

Validation: 5 focused API tests passed, TypeScript lint, Prettier, generated-model check, and plugin build passed.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

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

ℹ️ 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/api.ts Resolved
@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 647d72662f

ℹ️ 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/api.ts Resolved
@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 3854a75fc9

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

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Thanks for the careful cancellation updates. I checked the current red CI run and found a specific leftover expectation: sdk/typescript/scripts/fixtures/package-behavior.mjs:186 still asserts savedScan(1).progress.status === "failed" after an explicit caller abort. The new code correctly records "canceled", so the installed-package smoke test fails on every Node/platform lane and also breaks container validation (for example, this run). Please update that fixture's cancellation expectation and check the nearby client.close() expectation against the intended new behavior. The underlying review issue remains resolved from my side.

Copy link
Copy Markdown
Contributor Author

Thanks for catching this. I updated both the caller-abort and client.close() expectations in package-behavior.mjs to canceled; the close path follows the same terminal cancellation behavior.

Validation on this head:

  • The focused cancellation tests passed (7 tests).
  • pnpm run types, pnpm run format, and pnpm pack passed.
  • The installed-package smoke passed both corrected history assertions, then hit a later local failure at the scoped npm exec --offline --no -- @openai/codex-security --version check (sh: @openai/codex-security: No such file or directory).
  • The broader SDK test run is not claimed green: this environment produced unrelated timeouts and missing-shell failures, so I stopped it after confirming those failures.

Pushed normally as 6b58a82. The new node-ci and title-validation runs currently show action_required with no jobs started, so there is no CI result yet.

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Thanks for updating the installed-package cancellation fixtures and carrying this through the latest main merge, @Hughhhhcoder. I checked head 7d58f84: both caller-abort and client-close smoke expectations now say canceled, and Source CI passed. The remaining PR CI failure is three Windows test shards in run 41862975982: cli-verify-fix.test.ts repeated-signal batch saw an extra occ_1 (shard 12); the OpenRouter deep-preflight case failed in shard 13; and a Windows sandbox ACL setup exceeded 30 seconds in shard 2. These are outside the test files changed by this PR, but I have not established whether they are flakes or integration effects. Could you rerun or check those shards before merge? My earlier cancellation-classification concerns remain resolved.

mldangelo-oai and others added 5 commits November 4, 2026 20:14
@mldangelo-oai mldangelo-oai changed the title fix(history): preserve canceled scan state fix(history): preserve native turn failures observed before cancellation Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks for tracking down this race, @Hughhhhcoder. The tests for both event orders make the intent clear: a failure the SDK has already seen should survive cleanup, and an earlier caller cancellation should still be recorded as such. I appreciate you narrowing the patch after the broader cancellation fix landed.

@mldangelo-oai
mldangelo-oai merged commit 8a44cb0 into openai:main Nov 4, 2026
60 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 4, 2026
3 tasks done
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