fix(execution): swarm-review follow-ups — security hardening, Windows shims, correctness nits, test gaps (#88) - #91
Merged
Conversation
6 tasks
Rebase the contributor follow-ups onto current main and preserve the original security, correctness, and test-gap repairs. Use one shell-free invocation descriptor across Claude, Codex, and OpenCode. Native Windows executables run directly; package-manager shims require a sibling PowerShell script and pass hostile arguments literally through PowerShell -File. Bound OpenCode startup, SSE, teardown, and subprocess termination; validate routing inputs and adapter construction; forward supported turn caps; document the repository trust boundary. Verification: pnpm run check; pnpm run test:surface; pnpm audit --audit-level=moderate; pnpm run lint:links:internal.
pacphi
force-pushed
the
fix/swarm-followups
branch
from
July 30, 2026 21:16
8f1413f to
5acd4fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The #88 swarm-review follow-ups, all verified against the code before acceptance. Grouped by theme; each item names its evidence.
Security hardening
:0and reports its port on stdout — there is no freed port for a squatter to win (the rogue would then have intercepted the per-run credential and the worker prompt).reservePortstays as the fallback for stdout-less (injected) children, and a child that dies before reporting — or during the health check — fails honestly with its exit code instead of polling into the timeout./abort+/instance/disposego through a 10 s (injectableteardownTimeoutMs) deadline — a wedged server cannot hang the runner's cancel/cleanup path.ak run --help: workers run with the user's own CLI trust posture; a hostile repo'sopencode.jsonpermissions /.claude/settings.json/AGENTS.mdare inside that boundary (a repo that pre-allows permissions generates nopermission.updatedevent, so the abort boundary does not trip by design — the abort covers requests, it is not a sandbox). Runakonly in repos you trust with full user privileges.Windows shim path
resolveShimis exported (with a{windows, env}test seam) and applied at both spawn sites (subprocess claude/codex; the opencode serve child), andcodexis added toCMD_SHIMS. Readiness and launch now resolve the same binary — fixing launch-ENOENT on Windows where.cmdshims are required. Includes a simulated-PATH PATHEXT-order test.Correctness nits
worker.maxTurnsreaches the claude CLI as--max-turns(codex exec + opencode serve have no equivalent — documented, not faked).$&$`$'in a prompt/model id are data, never replacement syntax.--timeoutabove Node's2^31-1ms timer ceiling is rejected with a clear error (would otherwise clamp to ~1 ms for every worker).dualRoutingis schema-checked at load: malformed entries fail with the entry named, not apadEndcrash at print time.EXECUTION_ADAPTERSkeys are enforced at import — a routable host with no adapter (or an adapter for an unroutable host) throws at import instead ofcli_unavailableon every worker at runtime.Test gaps filled
SSE foreign-session isolation; plan-validation guards (duplicate/unknown/self deps, bad
maxConcurrent, dependency cycle); readiness-false short-circuit; TERM-then-KILL signal order; construction invariant via fresh-process import.Verification
pnpm run checkexit 0 (1083 kit + cjs),pnpm run test:surfaceexit 0 (25).Closes #88. Touches
run.mjs(timeout ceiling, policy validation) — merges cleanly with #90 (escalation) or rebases trivially on it.