refactor: reduce pid-tracker API surface and harden api-proxy startup retry handling#2895
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR tightens the security-critical pid-tracker module by reducing its exported API to only production-facing entrypoints, and updates tests to validate behavior strictly through that public surface.
Changes:
- Removed exports for internal
/procparsing and lookup helpers, and removed the unused async PID tracking entrypoint. - Updated the module’s usage example to the sync-only API.
- Refactored
pid-trackerunit tests to be black-box tests againsttrackPidForPortSync/isPidTrackingAvailable.
Show a summary per file
| File | Description |
|---|---|
| src/pid-tracker.ts | Removes internal/helper exports and the unused async entrypoint; updates module example to the sync API. |
| src/pid-tracker.test.ts | Reworks tests to validate outcomes via the public API only, instead of importing internal helpers. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| } | ||
|
|
||
| /** | ||
| * Synchronous version of trackPidForPort for use in contexts where async is not available |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
|
@copilot merge main |
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 87.88% | 87.91% | 📈 +0.03% |
| Statements | 87.83% | 87.84% | 📈 +0.01% |
| Functions | 83.11% | 83.08% | 📉 -0.03% |
| Branches | 79.88% | 79.91% | 📈 +0.03% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/pid-tracker.ts |
97.6% → 96.1% (-1.51%) | 96.6% → 93.9% (-2.72%) |
src/container-lifecycle.ts |
87.1% → 88.2% (+1.14%) | 87.5% → 88.6% (+1.11%) |
Coverage comparison generated by scripts/ci/compare-coverage.ts
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The OIDC refactoring PRs (#2811, #2772, #2887) added new JS modules (github-oidc.js, aws-oidc-token-provider.js, gcp-oidc-token-provider.js, oidc-refresh-utils.js) but did not update the Dockerfile COPY command. This caused the api-proxy container to crash immediately on startup with exit code 1 (Cannot find module './github-oidc'), breaking all integration tests since commit 7c25298. Fixes the api-proxy container startup crash that has been failing all integration test runs on main since 2026-05-11T15:45Z. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…remove-dead-exports-pid-tracker
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 87.88% | 87.92% | 📈 +0.04% |
| Statements | 87.83% | 87.84% | 📈 +0.01% |
| Functions | 83.11% | 83.08% | 📉 -0.03% |
| Branches | 79.88% | 79.93% | 📈 +0.05% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/pid-tracker.ts |
97.6% → 96.1% (-1.51%) | 96.6% → 93.9% (-2.72%) |
src/container-lifecycle.ts |
87.1% → 88.3% (+1.23%) | 87.5% → 88.6% (+1.19%) |
Coverage comparison generated by scripts/ci/compare-coverage.ts
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Add back tests for malformed /proc/net/tcp rows and non-symlink file descriptors that were removed when the async trackPidForPort was dropped. These paths are still exercised in production via trackPidForPortSync and need coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 87.88% | 87.94% | 📈 +0.06% |
| Statements | 87.83% | 87.89% | 📈 +0.06% |
| Functions | 83.11% | 83.08% | 📉 -0.03% |
| Branches | 79.88% | 79.97% | 📈 +0.09% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/pid-tracker.ts |
97.6% → 97.4% (-0.21%) | 96.6% → 96.3% (-0.28%) |
src/container-lifecycle.ts |
87.1% → 88.3% (+1.23%) | 87.5% → 88.6% (+1.19%) |
Coverage comparison generated by scripts/ci/compare-coverage.ts
Smoke Test Results✅ Playwright: GitHub page loads, title contains "GitHub" Status: PASS
|
🔬 Smoke Test Results
Overall: PARTIAL — File I/O test passed; MCP auth not available in this sandbox environment. cc
|
|
Smoke Test: Copilot BYOK — by
Running in BYOK offline mode ( Overall: PASS
|
Smoke Test
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Chroot Version Comparison Results
Overall: ❌ Not all versions match — Python and Node.js differ between host and chroot environments.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results — FAIL
|
Bug Fix
What was the bug?
src/pid-tracker.tsexposed internal helper functions and an unused async entrypoint, creating unnecessary API surface in a security-critical module.container awf-api-proxy exited (1), which was not treated as a retryable transient startup failure.How did you fix it?
trackPidForPortSyncisPidTrackingAvailablePidTrackResulttype re-export/proclookup functions.trackPidForPortexport/path.pid-trackertests to validate behavior via the public API only.trackPidForPortSyncto describe it as the public PID lookup entrypoint.maininto this branch and resolved conflicts while preserving this PR’s intendedpid-trackerAPI-surface changes.src/container-lifecycle.tsto retry when API proxy startup failures are reported as either:is unhealthyexited (1)src/docker-manager-lifecycle.test.tsto cover theexited (1)retry path and adjusted expected startup error messaging.Testing
npm run lintnpm run buildnpm testpid-trackertest validation after feedback updates.npm test -- src/docker-manager-lifecycle.test.ts) for retry behavior updates.