Skip to content

[code-review] Scripts module cleanup: preserve port allocator identity during teardown - #8652

Merged
orbit-agent-01 merged 1 commit into
agent-mainfrom
orbit/ORB-23146-c85b1ee7
Nov 8, 2026
Merged

orbit-agent-01 merged 1 commit into
agent-mainfrom
orbit/ORB-23146-c85b1ee7

Conversation

@danieljhkim

Copy link
Copy Markdown
Member

Task

ORB-23146 — [code-review] Scripts module cleanup: preserve port allocator identity during teardown

Description

Whole-module review at pinned agent-main de6897dac213c8aae3fc75ed19b2fbdfce0947ec. This is the single low/medium cleanup task for the scripts module in this sweep. Module ID: file:scripts/test-ci-await-jobs.py,file:scripts/test-ci-download-verified.py,file:scripts/test-ci-fast-guards.py,file:scripts/test-ci-p90.py,file:scripts/test-ci-repack-nextest.py,file:scripts/test-ci-test-affected.py,file:scripts/test-codeql-extension-schema.py,file:scripts/test-codeql-path-barriers.py,file:scripts/test-codeql-production-paths.py,file:scripts/test-codeql-rust-local.py,file:scripts/test-compiler-cache-namespaces.sh,file:scripts/test-compiler-cache.sh,file:scripts/test-cpu-utilisation.py,file:scripts/test-cross-revision-check.sh,file:scripts/test-desktop-advisories.py,file:scripts/test-installer-security.sh,file:scripts/test-linux-gated-test-items.py,file:scripts/test-make-install.py,file:scripts/test-mcp-registry-publish-workflow.sh,file:scripts/test-openpty-portability.py,file:scripts/test-path-leases-listener-sudo.py,file:scripts/test-pr-state-workflows.py,file:scripts/test-qa-full-sweep.py,file:scripts/test-refresh-dashboard-vendor.py,file:scripts/test-release-breaking-changes.py,file:scripts/test-release-promotion.py,file:scripts/test-release-readiness-adapter.py,file:scripts/test-release-workflow.py,file:scripts/test-shell-waits-allowlist.json,file:scripts/test-smoke-claude-mcp.py,file:scripts/test-state-backup.py,file:scripts/test-unit-test-inventory.py,file:scripts/test-validate-agent-plugin.sh,file:scripts/test-validate-codex-plugin.sh,file:scripts/test-visual-fixture-server.py,file:scripts/test-website-workflow.py,file:scripts/test-windows-portability.py,file:scripts/unit-test-baseline.json,file:scripts/unit-test-inventory.py,file:scripts/update-auto-task-body-history.py,file:scripts/validate-agent-plugin.sh,file:scripts/validate-codex-plugin.sh.

  1. Port allocator cleanup signals a relinquished PID (low). At scripts/test-compiler-cache-namespaces.sh:141-151, release_port publishes the release marker and waits until kill -0 "$HOLD_PID" fails, then unconditionally sends SIGKILL to that same numeric PID at :150. Bash can already reap the background Python allocator while running foreground commands, so retaining $! and waiting later does not reserve the kernel PID. After the failed liveness probe, PID reuse can make the final signal reach an unrelated same-user process. The EXIT cleanup allocator branch at :237-239 also signals the raw retained allocator PID. This is rated low for the narrow fixture-only reuse window; no actual unrelated process termination is claimed.

Evidence: ORB-23106 artifacts allocator-reproduction.py and allocator-reproduction.json. The deterministic harness executes the exact pinned release_port with an intercepted process table: the liveness check observes ESRCH, the model admits numeric reuse, and the function then issues SIGNAL args=-KILL 424242 owner=foreign before wait. It reproduces the same identity bug on the introducing commit (then SIGTERM). A separate exact cleanup model confirms its raw allocator signal. All signals, waits and cleanup operations in the model are intercepted; no kernel PID churn, synthetic load or unrelated process signaling is used. This is source/control-flow reproduction, not a live namespace/compiler run.

Culprit: ORB-18359, landed commit ca85777611715db6f26ee62af52b8cf33ebb2084 (PR #6172), introduced the background allocator, both release_port callers, the unconditional post-exit signal, and the allocator cleanup branch. Confirmed by that commit's diff and the task record. ORB-18400 (4ea454cdbddd07689769dd9f4d7b2e6e49844c35) later changed TERM to KILL; it did not introduce the ownership defect. Classification: defect_in_new / no_test / low. At the introducing commit, scripts/test-compiler-cache.sh covers namespace readiness, disabled/refused namespaces, transport failures and bounded waits, but has no allocator exit/reuse ownership transition fixture.

Shared invariant and consumers: alloc_port (:108-139) creates the allocator and records HOLD_PID; release_port (:141-155) is called for client-side shared TCP (:596-597) and server-side shared TCP (:622-623); the EXIT cleanup (:235-254) consumes the same allocator ownership, alongside its participant-PID loop. Search/update these together. Existing ownership fixtures are driven by scripts/test-compiler-cache.sh and scripts/compiler_cache_process_regression.py; the latter currently covers embedded Python supervisor/watchdog ownership rather than the shell allocator. Preserve finite allocator termination and socket release, participant teardown and diagnostic behavior. Do not replace the stale signal with another check-then-signal numeric PID race. Any invariant shared with in-flight work needs integration-parent comparison, not just the task PR's own green base.

Duplicate checks: all-status code-review searches for release_port HOLD_PID reused and release_port allocator process identity, plus open review-work listing, found no matching open repair. ORB-21051 repairs a different ci-test-affected PGID owner; ORB-19844 and subsequent namespace owner repairs cover embedded supervisors, not the port allocator.

Acceptance Criteria

  • Allocator release and EXIT/error cleanup never signal a numeric PID after relinquishing its owned process identity; both shared-TCP allocation paths still release their sockets and terminate/reap the owned allocator within a finite bound.
  • A deterministic regression driven through the public compiler-cache script boundary reproduces the exited/reused allocator case without PID churn or real unrelated-process signaling, fails before repair and passes afterward, while retaining timeout and interruption coverage.
  • Update all named allocator ownership consumers and fixtures together; preserve participant teardown and failure diagnostics. If the repair shares ownership invariants with in-flight work, compare the integration branch per-commit suite against its parent in addition to checking the PR base.

Validation

  • Not reported

Branch Freshness

  • Base ref: origin/agent-main
  • Head ref: orbit/ORB-23146-c85b1ee7
  • Behind base: 0
  • Ahead of base: 1

…en… [ORB-23146]

[code-review] Scripts module cleanup: preserve port allocator identity during teardown

Fixes: ca85777 ("[code-review] Scripts module cleanup: vacuous guards, cache and test defects (#6172)")
Regression-From: ORB-18359
Regression: defect_in_new; escape=no_test; severity=low
@orbit-agent-01
orbit-agent-01 merged commit 736a096 into agent-main Nov 8, 2026
20 of 30 checks passed
@orbit-agent-01
orbit-agent-01 deleted the orbit/ORB-23146-c85b1ee7 branch November 8, 2026 11:38
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.

2 participants