Skip to content

refactor(plugin): let callers wait on the same scan - #1124

Merged
mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-stack-18-native-preparationfrom
mdangelo/codex/pr939-stack-19-native-lifetime
Oct 4, 2026
Merged

mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-stack-18-native-preparationfrom
mdangelo/codex/pr939-stack-19-native-lifetime

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Part 19 of 46. Previous: #1123 · Next: #1139 · Stack index

Summary

Add a scan manager that lets multiple plugin tool calls wait on one SDK operation. Canceling a waiting request detaches that caller while the accepted scan continues.

Changes

  • Explicit scan cancellation and manager shutdown abort the operation and wait for SDK client cleanup.
  • Keep each scan registered until cleanup finishes, reject new work after shutdown, and avoid starting a scan if explicit cancellation occurs during preparation.
  • Verify that an already-aborted waiter detaches while durably accepted scan work continues.

Testing

At the rebuilt #1141 integration, all 19 native preparation, permission, executable, and lifetime tests passed. SDK and MCP types, Ruff check/format, SDK CI build, source compatibility, and all nine compatibility tests passed.

Risk and rollout

This adds the manager and its lifecycle coverage. The plugin server starts using it in part 40. Request cancellation and explicit scan cancellation deliberately have different lifetimes.

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 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-10-04T17:50:45.749493Z 43cf620 New commits
🔒 Security Review ✅ Completed 2026-10-04T17:52:12.308812Z 43cf620 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.

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

Reviewed commit: 421f474bbc

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

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

An aborted in-flight preparation can still invoke the scan client after cancellation or shutdown.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Introduces shared native scan operations so multiple requests can safely await one scan.

Changes:

  • Adds scan sharing, cancellation, shutdown, and cleanup handling.
  • Adds lifetime and concurrency tests.
File Description
native-scan.ts Implements shared native scan hosting.
test_native_scan.mjs Tests joining, cancellation, cleanup, and shutdown.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +73 to +77
try {
return await client.run(input.scan.targetPath, {
...options,
signal: controller.signal,
});
@mldangelo-oai mldangelo-oai changed the title refactor: share native scans across waiting requests refactor: let plugin tool calls wait on the same scan Sep 30, 2026

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

Reviewed 421f474bbc006a05600df1bd494192bfd69f6924 against mdangelo/codex/pr939-stack-18-native-preparation at 5bfc9854b68ee044dd8e94bab05dfb9c6f1dc3d8, scoped to this PR's diff and touched files.

Reviewed shared-operation ownership, waiter detachment, cancellation, shutdown, and cleanup. No additional distinct finding beyond the existing preparation/shutdown-race comment. All five added lifetime cases passed against an isolated extraction of the exact implementation, with preparation/error dependencies stubbed.

Review included simplification/deletion opportunities. Full repository and platform test suites were not run.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-19-native-lifetime branch from 421f474 to ce162f8 Compare September 30, 2026 16:55
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-18-native-preparation branch 2 times, most recently from e53883b to c9c9ae4 Compare September 30, 2026 17:19
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-19-native-lifetime branch 2 times, most recently from c503aba to 983f2b1 Compare September 30, 2026 18:17
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-18-native-preparation branch from c9c9ae4 to 06527bb Compare September 30, 2026 18:17

@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: 983f2b1c46

ℹ️ 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 on lines +66 to +68
if (!active) {
const controller = new AbortController();
const promise = Promise.resolve()

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 Reject pre-aborted waiters before starting a scan

When waiterSignal is already aborted and no operation is active, this branch registers and schedules the scan before waitForScan calls throwIfAborted(). The caller therefore gets a synchronous exception despite the Promise-returning API, while the queued preparation and scan continue in the background with no waiter. Check the waiter signal before creating the active operation; an already-active operation can remain untouched when rejecting that waiter.

Useful? React with 👍 / 👎.

@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 shared scan lifetime, detaching waiters, explicit cancellation, and cleanup during preparation/shutdown. No issue found in this focused layer. The integrated native lifecycle/stop suites passed locally with synthetic, isolated credentials.

@mldangelo-oai mldangelo-oai changed the title refactor: let plugin tool calls wait on the same scan refactor(plugin): let callers wait on the same scan Oct 1, 2026

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

Three independent passes and root verification found no actionable regression. The 15 focused native lifecycle tests passed; later activation checks also passed. I traced the pre-aborted waiter concern through the #1163 caller: workbench registration accepts the durable scan before the host waits, and waiter detachment is intentionally separate from canceling that accepted scan. Cancellation or shutdown during preparation is checked before client.run and still closes the prepared client. No repository files were changed.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-18-native-preparation branch from 06527bb to fdef28b Compare October 1, 2026 23:44
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-19-native-lifetime branch from 983f2b1 to 177fcc1 Compare October 1, 2026 23:44

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

Three independent re-review passes and root reconciliation are complete for this restacked head.

No serious outstanding finding was identified in this change. The scoped prior review and current diff remain consistent.

Approval is for this change. Integrated-tip validation passed 1,357 SDK tests (31 skipped), 105 MCP tests (2 skipped), portable checks, types/builds and installed-package smoke. Other stack findings and known CI fixture failures still prevent the stack from being mergeable.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-19-native-lifetime branch from 177fcc1 to 9bc4841 Compare October 2, 2026 00:36

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

Re-reviewed the real PR diff at 9bc48415f9faad45ee0117ec2a382069aeb0ebf3. The patch is unchanged from the prior three-pass review. I reconciled the inherited changes in touched files and retained the prior verified findings and tests.

No serious outstanding finding identified in this patch; prior conclusions remain consistent with the unchanged change or the current re-review.

Validation across touched paths at branch tip 06e75cfe: 1,356 SDK tests, 867 Python tests plus 100 subtests, and 108 MCP tests passed; builds, types, portable checks and installed-package checks passed. These are integration checks at the branch tip, not a claim that every intermediate PR or its CI is clean.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-18-native-preparation branch from 32f2372 to 742cdd7 Compare October 2, 2026 01:37
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-19-native-lifetime branch 2 times, most recently from 5fe3f32 to d4eb058 Compare October 2, 2026 01:56

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

Retained the three independent passes for the identical patch and reconciled inherited touched-file changes at d4eb058380be.

No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch, touched-file changes, and current integration checks.

Current tip 355ec321 passed 75 report-projection tests, portable source checks, SDK build:ci and plugin build. The immediately preceding tip fec36f1d passed 1,360 SDK tests, 873 Python tests plus 100 subtests, 109 MCP tests, builds/types and the clean 600-entry installed-package check. Only report_projection.py and its test changed between those tips; SDK/MCP runtime files are byte-identical. Both descend from main 008a8b4d. These are integration checks, separate from own-head probes. No native Windows local run.

No serious outstanding finding introduced by this PR. Code review approval does not establish CI or merge readiness.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-19-native-lifetime branch from d4eb058 to b68f49a Compare October 2, 2026 02:47
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

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

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

Retained the three independent passes for the verified identical patch and reconciled inherited touched-file changes at b68f49ae8507.

No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch and inherited changes in touched files.

Integrated tip 6ef8cbb8, based on 008a8b4d, passed 1,388 SDK tests, 879 Python tests plus 100 subtests, 109 MCP tests, portable checks, builds and the clean 600-entry installed-package check. These are branch-tip integration checks, separate from own-head probes; no local Windows execution was performed.

No serious outstanding finding introduced by this PR. Code approval is separate from CI and merge readiness.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-19-native-lifetime branch from b68f49a to e20ef28 Compare October 2, 2026 03:52

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

Retained three prior independent passes for the verified identical patch and reconciled inherited touched-file changes at e20ef28e8b24.

No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch and inherited changes in touched files.

Branch tip 3e0083d9, based on 008a8b4d, passed 1,392 SDK tests, 881 Python tests plus 100 subtests, 109 MCP tests, builds, portable source checks and the 600-entry installed-package check. These are tip checks, separate from own-head probes. No local Windows run was performed. The tip excludes the dependency update merged separately in #1184; combined validation remains outstanding.

No serious outstanding finding introduced by this PR. Code approval is separate from CI and merge readiness.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-18-native-preparation branch from 0e27989 to bd8e9b8 Compare October 4, 2026 12:33
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-18-native-preparation branch from bd8e9b8 to 42c3a60 Compare October 4, 2026 13:19
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-stack-19-native-lifetime branch from e20ef28 to 8828b65 Compare October 4, 2026 13:19

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

Reviewed exact head 8828b651cdb9daec9853852ad2c7d4cb1c2b16f2 against base 42c3a6004be5cbdb91ae0fbe18c9533aba7d1f14. Three historical independent reviews retained after actual three-dot, ordered contribution, touched own/base modes and bytes, instructions and inherited-context reconciliation; root synthesis completed.

The own NativeScanHost contribution is unchanged: accepted scans are shared, a waiter can detach without cancelling the scan, cancellation and shutdown drain the operation, and cleanup preserves its outcome. Both inherited touched paths were reconciled on base and head against the separately reviewed preceding contribution; no residual own change remains. Three historical independent review summaries are retained. Their individual timestamp/effort fields are absent; HIGH is recorded workflow provenance, not newly populated metadata. This approval covers this PR's own contribution; it inherits the separate #1123 source hold and does not establish stack readiness.

Hosted CI is recorded separately in the final review evidence; it is not inferred from these local or retained checks. Source approval, hosted CI and whole-stack/current-main integration remain separate. No product model, local Windows run, clean install, fresh native compilation or deployment validation was performed.

Hosted CI observation 2026-10-04T13:37:39.993325+00:00 to 2026-10-04T13:38:02.237036+00:00: this exact head was pending. No failed jobs were reported for this head in that observation. Later source/metadata readbacks are not CI refreshes.

Consolidate approved Deep Scan changes into the parent topic branch.
@mldangelo-oai
mldangelo-oai merged commit 8e9a059 into mdangelo/codex/pr939-stack-18-native-preparation Oct 4, 2026
1 check passed
@mldangelo-oai
mldangelo-oai deleted the mdangelo/codex/pr939-stack-19-native-lifetime branch October 4, 2026 17:48
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.

5 participants