Skip to content

ST4 worker: follow-ups deferred during review #173

Closed

Description

@pdettori

Follow-ups from the ST4 worker (#87, PR #172) that were seen, judged, and deliberately
not fixed
. None affects the acceptance battery or runtime correctness on the paths the
harness exercises today.

Filed as its own issue rather than a note in the repo, because an in-repo list went stale
within one commit: it was generated from an implementation ledger that recorded findings
as they were raised and never reconciled against the code after the final review wave,
so it advertised three blockers that were already fixed. Everything below was audited
against feat/st4-go-worker at review time.

Item numbers are stable and never reused. Resolved items move to Resolved at the
bottom keeping their original number, because commit messages and a test comment
(packages/knative-server/test/worker-deployment.test.ts) cite them as "#173 item N".
Last reconciled against main at dd77aca, 2026-09-08 — each open item below was
re-verified in the tree, not just re-read. Four items remain open: 2, 4, 9, 10.
None is a correctness defect: 2 needs a both-ends wire decision, 4 is a pure refactor, and
9 and 10 are small. Note item 4 is now more worth doing than when filed — PRs #229 and #230
both touched accept's signature, which is the plumbing item 4 is about.

Worth doing, in rough priority order

  • 2. gRPC MaxCallRecvMsgSize is unconfigured, so a base64 write payload above the
    4 MiB default is rejected.
    kills the whole stream rather than one exec, triggering a reconnect. Needs a decision
    on both ends plus a documented max write size — relay-side coordination, which is why it is
    not in the PR.

    Severity corrected 2026-09-08, and it is LOWER than written — but the real defect is
    something this item never mentioned.
    Traced rather than re-read; see
    the analysis comment below.

    • The stream is not killed. Two receivers could reject the oversized Exec: the relay's
      SandboxExec server (harness→relay, an ExecRequest) and the worker's Attach client
      (relay→worker, a ServerFrame). ExecRequest is {sandbox_id, exec} and relay.ts
      forwards {exec: {…}} with no sandbox_id, so the frame the worker receives is
      strictly smaller than the request that carried it in. Both limits are 4 MiB, so the
      relay's ingress always trips first and the Attach stream never sees the payload. Blast
      radius is one exec, rejected with RESOURCE_EXHAUSTED.
    • The real defect is a read/write asymmetry. Read is cat → raw stdout, capped by
      DEFAULT_OUTPUT_CAP at 8 MiB. Write is content → base64 (×4/3) → stdin, capped at 4 MiB
      ⇒ ~3 MiB of file. The relay path can therefore read a file it cannot write back,
      and createPodEditOps composes read with write, so Pi's Edit on a 4 MiB file succeeds at
      reading and then fails. KubectlTransport has no such ceiling, so the identical write
      succeeds on the pod path — the backend-dependent divergence persistentExecInPod is an uncapped third SandboxTransport, and it serves the file-reading tools #180/KubectlTransport has no default deadline while GrpcRelayTransport always applies 120s, and the battery cannot see it #182/Output-cap enforcement is not equivalent across transports: kubectl kills only the local client #185 were closed on.
    • "Needs a both-ends decision" was illusory, and is what kept this item untouched for a
      month. Derive the limit instead: DEFAULT_OUTPUT_CAP × 4/3 plus command and framing
      headroom, pinned by a coupling test the way output-cap-coupling.test.ts pins the caps.
      Write capacity ≥ read capacity by construction, no committee required.
  • 4. Unify the session's state plumbing. abortReq/finish close over inflight/mu
    while recvLoop/accept take the map and a *sync.Mutex as positional parameters —
    seven parameters, two of them raw synchronization primitives. For a file whose central
    safety property is "every access is under mu", one convention would make that locally
    checkable instead of requiring a whole-file audit. A small struct with methods collapses
    both signatures. Wanted specifically because this is the reference implementation
    other language ports get written against.
    Still open at loop.go:248 (recvLoop) and loop.go:278 (accept). Pure refactor —
    best folded into whichever change next touches that file.

Smaller

  • 9. settle() is a fixed sleep in an otherwise poll-based test file. Justified: there
    is no exported observable for "the inflight slot has been released". An exported test
    hook would let it become a condition wait.

  • 10. The images install findutils, which none of the harness's operations use.
    Still present in remote-worker/Dockerfile and remote-worker/Dockerfile.runtime.

Resolved

  • 1. A dropped refusal left an exec unanswered. Done in PR fix(worker): reserve outbound capacity for terminal frames (#173 item 1) #230 (b0da405, refined in
    26c689b). The receive goroutine sent through a non-blocking trySend so it could never
    stall and miss an Abort, but every frame it sends is terminal and refusals are uncached,
    so a drop lost the caller's only answer — and it correlated with the overload that caused it.
    KubectlTransport has no default deadline while GrpcRelayTransport always applies 120s, and the battery cannot see it #182 had since made that stall up to 30 minutes (DEFAULT_EXEC_TIMEOUT_S), retiring the
    deferral's own "survivable because the harness timeout is dual-ended".
    The remedy named in this item is unsafe as written. "A priority channel, or a dedicated
    terminal-frame forwarder" both let a terminal frame overtake queued chunks for the same
    req_id, and spec §8 requires Chunk* then End. Two reachable cases: a cache-hit replay
    overtaking the original's still-queued chunks, and a colliding refusal overtaking an earlier
    exec's frames under the same id — the harness settles on whichever lands first and discards
    the real output behind it. Safe priority needs per-req_id pending tracking.
    Shipped instead: reserved capacity in the single channel. outbound stays one FIFO (so it
    cannot reorder, by construction) and gains TerminalReserve (QueueCap/4 = 16) slots that a
    chunkSlots semaphore keeps chunk producers out of; the sender releases a slot when it
    takes a non-reserved frame, so the accounting measures channel residency rather than
    tracking Send latency. Exhaustion is then a genuinely different condition — nothing draining
    at all — so accept returns ErrEgressWedged, recvLoop propagates it, and Serve returns
    it for main.go to re-dial, with dedup answering redeliveries (§5, §6.2). A dropped cache-hit
    replay escalates too: the harness redelivers precisely because it never got the first answer.
    Guarded by TestBusyRefusalSurvivesAChunkBacklog (defect + FIFO),
    TestExhaustedReserveEndsTheSession, and a compile-time assertion that the reserve cannot
    silently become 0. No wire or proto change — §8 is enforced here, not amended.
    Also fixed a teardown wedge that predates this item: a Send that blocks (rather than
    fails) parked the sender, so a producer waiting for room waited forever and wg.Wait() never
    reached zero, after which Serve could never return — the one thing that makes main.go
    re-dial. enqueue now gives up on connCtx. TestSendFailureDoesNotWedgeTeardown missed it
    because a failing Send lets the sender keep draining. Pinned by
    TestBlockedSendDoesNotWedgeProducers.

  • 3. SANDBOX_TOKEN was a literal env value in worker-deployment.yaml, filled by
    sed in deploy-incluster.sh, so it landed in the Deployment spec, oc describe, and
    any GitOps mirror. Done in PR fix: open-issue triage, first session (#190, #191, #192, #182, #173 item 3) #226 (e33bf3e and follow-ups): the token now arrives
    via secretKeyRef on the worker Deployment, the OCP overlay, and both deploy scripts,
    and both relay and worker are restarted after a token rotation, since env from a
    secretKeyRef is resolved only at pod start. worker-example.yaml keeps its literal
    dev-token on purpose. Guarded by
    packages/knative-server/test/worker-deployment.test.ts, which fails if the literal
    returns or if the secretKeyRef stops matching the Secret name/key the deploy script
    creates.

  • 5. Most tests never joined the Serve goroutine. Done in PR fix(worker): #173 items 5, 6, 8 — build constraint, joined Serve goroutines, activity-based drain grace #229 (e8aae74).
    loop_test.go gained a serve() helper that starts Serve and registers the cleanup
    which closes the stream and waits for the return; contract_test.go's
    attachCancellable now joins as well as cancels, and the SH_LIVE_RELAY gate joins too.
    fakeStream.close() became idempotent, since the cleanup always closes as well.
    Measured rather than assumed: injecting this item's exact deadline — deleting the
    cancelConn() before close(queue), so the heartbeat producer never returns — left
    14 of loop_test.go's 15 tests passing; with the join it fails 17. A second fault
    that cancellation cannot mask (close(outbound) removed) confirmed the contract-test
    join: all 11 catch it, where before they passed. No production code changed.
    This item's premise was wrong on one point: it said "Two of them observe teardown".
    Only one did. TestSendFailureDoesNotWedgeTeardown looks like the second, but a failing
    Send makes the sender call cancelConn() itself, ending the heartbeat producer as a
    side effect, so it passed even with the deadlock injected. Its comment now says what it
    really covers.

  • 6. Drain-watchdog grace was wall-clock, not activity-based. Done in PR fix(worker): #173 items 5, 6, 8 — build constraint, joined Serve goroutines, activity-based drain grace #229
    (c5f17c9, refined in afc83eb). drainGrace is now a quiet period: any read returning
    bytes defers the force-close, tracked by one atomic counter that drain bumps before
    delivery. The watchdog moved out of Run into a package-level watchDrain, so both
    behaviours are unit-testable at millisecond timings.
    Two deliberate departures from this item as written. It was not as narrow as "the run
    is already out of budget" implies — a python3 writer that os.setsid()s out of the
    process group and ticks every 400 ms delivered 7 of 10 ticks, truncated at exactly
    3.01 s = 1 s timeout + 2 s grace. And "resetting the timer on read activity" is unbounded
    as stated, so a holder trickling forever would pin a pool slot and up to BufferCap —
    a slower form of the wedge the watchdog exists to prevent. Added drainCeiling = 30 s
    (15× the grace), verified by neutering it and watching only the ceiling test fail.
    Note the real teardown bound: progress is sampled at timer expiry, not observed per
    read, so the close lands between 1× and 2× drainGrace after the last byte — up to
    ~4 s. Pinned by TestWatchDrainClosesAtTwiceGraceAfterTheLastRead. No wire or spec
    change; the watchdog appears in no spec.

  • 7. The memory coupling is documented but unenforced. BufferCap × 2 streams ×
    MaxConcurrent must fit the pod limit; both sides carried the arithmetic in a comment,
    but nothing stopped a future WORKER_MAX_CONCURRENT entry in the Deployment from
    invalidating the 256Mi limit silently. Done before this issue's first triage pass
    (65160bf, strengthened by a1ba25b, both 2026-08-28): the same
    worker-deployment.test.ts reads BufferCap from runner.go, DefaultConcurrency from
    loop.go, and the manifest's WORKER_MAX_CONCURRENT override if one exists, then
    asserts the pod memory limit covers 2 × concurrency × BufferCap. It throws loudly
    rather than skipping if a constant is reformatted out of reach.

  • 8. No //go:build unix constraint. Done in PR fix(worker): #173 items 5, 6, 8 — build constraint, joined Serve goroutines, activity-based drain grace #229 (7aa1bad). Both
    syscall.Setpgid and syscall.Kill now sit behind //go:build unix.
    This needed one step past the remedy this item prescribed. "Just the tag" would have
    turned two errors about a struct literal into build constraints exclude all Go files in …/internal/exec — better located, but still not the "clear unsupported platform message"
    the item asks for. So the !unix side is a refusal rather than a second implementation:
    Run returns "remote-worker is unix-only: <GOOS> has no equivalent of the process-group
    isolation (Setpgid/Kill) that abort and timeout depend on" before spawning anything, on the
    grounds that a runner which cannot reliably kill what it spawned has no correct behaviour
    to offer. Still no platform-specific logic — a tag and a refusal.
    Guarded by TestModuleCrossCompilesForNonUnix, which cross-compiles the module for
    GOOS=windows (~1.1 s) rather than asserting on the constraint's text.

Platform note, not a follow-up

TestRunReturnsWhenPipeHolderEscapesGroup needs setsid to detach a pipe holder from the
process group, so it skips on macOS and runs on Linux CI. It is the test that hangs
rather than fails if the drain watchdog regresses, so its coverage is real — just not on a
developer's Mac.

Its sibling from item 6, TestSlowDrainKeepsTrailingOutput, needs the same detachment but
gets it from python3 -c 'import os; os.setsid()', which works on macOS too — so that one
runs everywhere. Prefer that form for any future test needing a process outside the group;
setsid(1) simply does not exist on macOS, and a test that silently skips looks exactly
like a test that passes.

Assisted-By: Claude Code

Activity

  1. pdettori commented on Sep 6, 2026

    @pdettori
    MemberAuthor

    Item 3 (SANDBOX_TOKEN is a literal env value) is done in #226, merged as 1b5d4ef. Leaving this issue open for the rest.

    It took four commits rather than the one secretKeyRef this item describes, because the leak had more surfaces than the item names.

    499269d — the worker template. SANDBOX_TOKEN now arrives via secretKeyRef; deploy-incluster.sh creates the Secret with create --dry-run=client | apply so a re-run rotates instead of failing. The same script's

    oc set env deploy/sandbox-relay SH_RELAY_TOKEN=$TOKEN
    

    was putting the identical token into the relay's spec, so fixing only the worker would have left the leak open one Deployment over. It now points the relay at the same Secret.

    One Secret, one key, read by both sides. Fail-closed auth requires the relay's SH_RELAY_TOKEN and the worker's SANDBOX_TOKEN to be equal, and a shared key makes that structural rather than something a test compares — which is why the key is named SH_RELAY_TOKEN even on the worker side.

    7cf5058 — the OCP overlay. relay-deployment.yaml's dev-token is a deliberate public value for Kind, but the same file is a shared resource of overlays/ocp, so it was a live credential on any OCP-deployed relay. Patched in the overlay, not the base: the base is applied bare by demo-remote-worker.sh, relay-leaf-smoke.sh and README-worker.md Step 1, and since relay auth is fail-closed, a base referencing a Secret would turn "Secret not created yet" into "every Attach rejected" on all of those paths. value: null is load-bearing — without it kustomize emits both value and valueFrom, which the API server rejects. Verified against real kubectl kustomize output both ways.

    f4e0f77 — the blocker review caught. The patch made sh-relay-token a hard requirement of the overlay, but setup-ocp.sh — which renders and applies that overlay — never created it. On a fresh OCP install the relay pod would have sat in CreateContainerConfigError, and silently, since setup-ocp.sh doesn't rollout status the relay. It now creates the Secret with a generated token (defaulting to dev-token would satisfy the manifest while keeping exactly what this item is about), and never overwrites an existing one, so a re-run can't rotate a token out from under an attached worker.

    334be0e — a rotation defect found while verifying that. Env from a secretKeyRef is resolved only at pod start, and oc set env --from=secret/... is a no-op on a re-run, so rewriting the Secret left both pods serving the old token. Nastier than a plain break: both stay stale together and keep matching, so it's invisible until one pod restarts alone and fail-closed rejects everything. Both Deployments now get an explicit rollout restart. The old set env SH_RELAY_TOKEN=<literal> had masked this by changing the spec every time.

    cd4df9f adds caveats to the three documented set env SH_RELAY_TOKEN= commands (README-worker.md Step 1 and its troubleshooting row, remote-sandbox-demo.md step 1b) — set env replaces the whole env entry rather than merging, so on an overlay deployment those commands would swap the secretKeyRef back for a literal, in the live spec where no manifest test can see it.

    Deliberately unchanged: deploy/knative/worker-example.yaml keeps its dev-token. It's the third-party copy-and-edit surface paired with the Kind base's public dev value, and relay-deployment.test.ts pins that pair.

    Residual, honestly: the token is still on deploy-incluster.sh's argv for the life of the oc create secret call — visible to ps on the machine running the deploy. That's the standard --from-literal tradeoff and is noted in the script; it no longer persists in cluster state, which was the point. And the oc calls themselves are unverified — there's no cluster-free harness for remote-worker/ scripts and no OCP cluster was available. shellcheck plus the manifest↔script coupling tests are the coverage.


    Bookkeeping on the rest of this list. Item 7 (memory coupling documented but unenforced) also looks already done — packages/knative-server/test/worker-deployment.test.ts carries a test that derives BufferCap and DefaultConcurrency from the Go source and asserts the pod limit covers 2 × concurrency × BufferCap, citing "#173 item 7", and it reads a WORKER_MAX_CONCURRENT override if one ever appears. Worth ticking off if that matches your reading.

    Still open: 1 (dropped busy: queue full refusal — the real bug), 2 (MaxCallRecvMsgSize, needs a both-ends decision), 4 (session state plumbing), 5 (tests never join Serve), 6 (drain-watchdog grace is wall-clock), 8 (//go:build unix).

  2. pdettori commented on Sep 6, 2026

    @pdettori
    MemberAuthor

    Reconciled the body against main at 1b5d4ef. Items 3 and 7 moved to a new
    Resolved section at the bottom with what closed each; the remaining eight items are now
    the whole list, and each carries a pointer to where it was re-verified in the tree.

    Item numbers are kept stable rather than renumbered, because worker-deployment.test.ts
    and several commit messages cite them as "#173 item N".

    One correction worth recording: item 2 (MaxCallRecvMsgSize) was expected to be
    already done and is not — no message-size option is set anywhere in remote-worker/
    or packages/sandbox-relay/. It stays open, and still needs a both-ends decision plus a
    documented max write size.

    Assisted-By: Claude (Anthropic AI) [email protected]

  3. pdettori commented on Sep 7, 2026

    @pdettori
    MemberAuthor

    Items 5, 6 and 8 addressed — PR #229 (open, not yet merged)

    One commit per item, each independently revertable. This issue stays open: items 1, 2, 4, 9 and 10 remain. Item 1 is still the top correctness item on the list.

    I'll move these three into Resolved in the body — keeping their numbers, per the convention above — once #229 merges, so the body never claims something the tree does not yet do.

    5 — most tests never joined the Serve goroutine

    loop_test.go gets a serve() helper that starts Serve and registers the cleanup that closes the stream and waits for the return; contract_test.go's attachCancellable now joins as well as cancels. fakeStream.close() became idempotent, since the cleanup always closes too.

    Measured, not assumed. Injecting the exact deadlock this item describes — deleting the cancelConn() that precedes close(queue) in Serve, so the heartbeat producer never returns and wg.Wait() never reaches zero — left 14 of loop_test.go's 15 tests passing. With the join registered, the same fault fails 17. A second fault that cancellation cannot mask (close(outbound) removed) confirmed the contract-test join: all 11 catch it, where before they passed.

    One correction to this item's premise. It says "Two of them observe teardown". Only one does. TestSendFailureDoesNotWedgeTeardown looks like the second, but a failing Send makes the sender call cancelConn() itself, ending the heartbeat producer as a side effect — so it passes even with the missing-cancelConn deadlock injected. Its real coverage is the sender's drain-after-failure behaviour, and its comment now says so.

    No production code changed for this item — loop.go is byte-identical to main.

    6 — drain-watchdog grace was wall-clock, not activity-based

    drainGrace is now a quiet period: any read that returns bytes restarts it, tracked by a single atomic counter that drain bumps before delivery, so the record is of when the pipe produced bytes rather than when a slow sink finished accepting them.

    Two departures from the item as written, both deliberate:

    1. It is not as narrow as "the run is already out of budget" suggests. A python3 writer that os.setsid()s out of the process group (so the SIGKILL at timeout misses it) and emits a tick every 400 ms delivered 7 of 10 ticks, truncated at exactly 3.01 s = 1 s timeout + 2 s grace. Three ticks of legitimate output, silently gone.

    2. "Resetting the timer on read activity" is unbounded, so it needs a cap. A holder trickling one byte per second would reset the grace forever, pinning a pool slot and up to BufferCap — a slower form of the wedge the watchdog exists to prevent. Added drainCeiling = 30 s: 15× the grace, far longer than any legitimate trailing flush, negligible beside the harness's 30-minute exec ceiling.

    The watchdog moved out of Run into a package-level watchDrain so both behaviours are testable without a child process — the ceiling especially, which end-to-end would mean waiting 30 real seconds and is driven at 50 ms/500 ms instead. Verified by neutering the ceiling and watching only the ceiling test fail.

    No wire or spec change — the watchdog appears in no spec, so no §8 amendment.

    8 — no //go:build unix constraint

    Both calls now sit behind //go:build unix.

    This needed one step past the item's own remedy. The item says "no second implementation is needed — just the tag". A bare tag turns

    internal/exec/runner.go:128:41: unknown field Setpgid in struct literal of type "syscall".SysProcAttr
    internal/exec/runner.go:139:15: undefined: syscall.Kill
    

    into build constraints exclude all Go files in …/internal/exec — better located, but still not the "clear unsupported-platform message" the item asks for. So the !unix side is a refusal rather than a second implementation: Run returns

    remote-worker is unix-only: windows has no equivalent of the process-group isolation
    (Setpgid/Kill) that abort and timeout depend on
    

    before spawning anything, on the grounds that a runner which cannot reliably kill what it spawned has no correct behaviour to offer. Still no platform-specific logic — just a tag and a refusal.

    Guarded by TestModuleCrossCompilesForNonUnix, which cross-compiles the module for GOOS=windows (~1.1 s) rather than asserting on the constraint's text.

    Verification

    Each fix was watched failing before it was written. Both injected faults were removed before commit; git diff against main for loop.go is empty.

    go test -race ./... · go vet ./... · gofmt -l . · make test (whole repo) · make typecheck (0 errors) · make lint (9/9 hooks) — all green. worker-deployment.test.ts, which parses BufferCap out of runner.go for item 7's guard, is 7/7.

    New coverage: 1 cross-compile test, 1 end-to-end trailing-output test, 5 watchDrain unit tests. internal/exec goes from 6.7 s to 15.0 s, 4.4 s of which is the end-to-end test waiting out a real writer by design. The session suite is unchanged at ~9.8 s.

    Note for whoever takes item 9

    Item 9 wants an exported test hook so settle() can become a condition wait. #229 does not add one, and settle() is untouched — but the serve() helper is now the single place every test in loop_test.go starts a session, so a hook would have one obvious place to be threaded through.

    Assisted-By: Claude (Anthropic AI) <[email protected]>

  4. 1 remaining item

  5. added 2 commits that reference this issue on Sep 7, 2026
  6. pdettori commented on Sep 7, 2026

    @pdettori
    MemberAuthor

    Reopened — closed at 14:46 as "completed" shortly after #229 merged, but #229 only covered items 5, 6 and 8 and said so explicitly. Five items were never done: 1, 2, 4, 9, 10.

    The body is now reconciled against main at f9c59d1: 5, 6 and 8 moved to Resolved keeping their numbers (per the convention at the top), each carrying what closed it and where it departed from the item as written. The two open sections list exactly the five that remain.

    Flagging item 1 in particular, so a future close does not take it silently: it is the top correctness item on this list, and its severity has risen since it was filed. The code comment deferring it (loop.go:145-159) justifies the loss as "survivable only because the harness timeout is dual-ended" — written when the relay ceiling was 120 s. #182 replaced that with a shared DEFAULT_EXEC_TIMEOUT_S = 30 * 60, so a dropped busy: queue full refusal now strands its caller for up to 30 minutes, under exactly the overload that produces the drop. The deferral was correct when written; the value it depended on changed underneath it.

    Items 9 and 10 are the genuinely small ones. 2 needs a decision on both ends of the wire, and 4 is a pure refactor best folded into whichever change next touches loop.go — plausibly item 1's.

  7. pdettori commented on Sep 7, 2026

    @pdettori
    MemberAuthor

    Item 1 addressed — PR #230 (open, not yet merged)

    Items 2, 4, 9 and 10 remain, so this issue stays open. As with 5/6/8, item 1 moves to Resolved in the body only once #230 merges.

    The remedy this item names is unsafe as written. It proposes "a priority channel, or a dedicated terminal-frame forwarder with its own bounded queue". Either lets a terminal frame overtake queued chunks for the same req_id, and spec §8 requires Chunk* then End. Two reachable cases: a cache-hit replay overtaking the original's still-queued chunks, and a colliding refusal overtaking an earlier exec's frames under the same id. The harness settles the exec on whichever arrives first, then discards the real output behind it. Making a priority lane safe needs per-req_id pending tracking.

    What shipped instead: reserved capacity in the single channel. outbound stays one FIFO — so it cannot reorder, by construction — and gains TerminalReserve (QueueCap/4 = 16) slots that a chunkSlots semaphore keeps chunk producers out of. The sender releases a slot when it takes a non-reserved frame rather than after Send, so the accounting measures channel residency instead of tracking Send's latency.

    Exhaustion is now a distinct condition. The reserve is a probability argument, not a proof — nothing bounds how many refusals arrive between drains. But with chunk producers fenced off, a failed terminal enqueue no longer means "busy", it means nothing is draining at all. So accept returns ErrEgressWedged, recvLoop propagates it, and Serve returns it for main.go to re-dial with the dedup cache covering the rest — seconds rather than the 30 minutes this item was about. A dropped cache-hit replay escalates too: it reads as harmless, but the harness redelivers precisely because it never got the first answer.

    A teardown wedge that predates this item, and was uncovered. A Send that blocks rather than fails parks the sender, so a producer waiting for room waits forever and wg.Wait() never reaches zero — after which Serve can never return, which is the only thing that makes main.go re-dial. TestSendFailureDoesNotWedgeTeardown misses it because a failing Send lets the sender keep draining. enqueue now gives up on connCtx. Honest limit: Serve still cannot return while Send blocks forever, since teardown ends at wgSender.Wait(); gRPC's keepalive bounds that in production, and the new test says so.

    Item 4 stays open. accept gains an error return, which is not the plumbing refactor item 4 describes — kept separate deliberately, per this issue's own note that item 4 belongs with whichever change next touches the file, as a pure refactor with tests green either side.

    No wire or proto change: §8 is enforced here, not amended, so nothing is owed in the spec or ADR-0024.

  8. added a commit that references this issue on Sep 7, 2026
  9. added 2 commits that reference this issue on Sep 8, 2026
  10. pdettori commented on Sep 8, 2026

    @pdettori
    MemberAuthor

    Item 2 re-scoped — the severity claim was wrong, and correcting it unblocks the item

    Item 2 has sat untouched for a month behind "needs a decision on both ends plus a documented max write size — relay-side coordination." I traced it instead of re-reading it, and both halves of that framing turn out to be off.

    The stream is not killed

    The item says an oversized base64 write "kills the whole stream rather than one exec, triggering a reconnect."

    Two receivers could reject the oversized Exec:

    Hop Message Receiver Limit
    harness → relay ExecRequest {sandbox_id, exec} relay's SandboxExec server (grpc-js) 4 MiB
    relay → worker ServerFrame {exec} worker's Attach client (grpc-go) 4 MiB

    relay.ts forwards {exec: {reqId, command, stdin, timeoutS, streaming}} — no sandbox_id. So the frame the worker receives is strictly smaller than the request that carried it in. With both limits at 4 MiB, the relay's ingress always trips first, on the larger message. The Attach stream never sees the payload, so it cannot be killed by it.

    Blast radius is one exec, rejected with RESOURCE_EXHAUSTED. No reconnect.

    Verified rather than assumed: grpc-js 1.14.4 DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH = 4 * 1024 * 1024, DEFAULT_MAX_SEND_MESSAGE_LENGTH = -1; grpc-go defaultClientMaxReceiveMessageSize and defaultServerMaxReceiveMessageSize both 4 MiB, send MaxInt32. One caveat on my own evidence: the Go constants came from [email protected] in the local module cache, while this repo pins v1.83.2, which was not cached.

    The real defect is a read/write asymmetry the item never mentions

    Mechanism Ceiling
    read cat → raw stdout DEFAULT_OUTPUT_CAP = 8 MiB
    write content → base64 (×4/3) → stdin 4 MiB gRPC ⇒ ~3 MiB of file

    The relay path can read a file it cannot write back. Files between ~3 and 8 MiB read fine and fail to write — and createPodEditOps composes read with write, so Pi's Edit on a 4 MiB file succeeds at reading and then fails at writing.

    KubectlTransport pipes base64 through kubectl exec stdin with no 4 MiB ceiling, so the identical write succeeds on the pod path. That is the backend-dependent divergence #180, #182 and #185 were each closed on.

    Why the blocker was illusory

    The number stops being a judgement call once the asymmetry is the framing. Derive it: DEFAULT_OUTPUT_CAP × 4/3 (≈10.7 MiB) plus headroom for the command string and framing. Then write capacity ≥ read capacity by construction, and the relationship gets pinned by a coupling test exactly as output-cap-coupling.test.ts already pins the caps across the language boundary. No cross-team decision needed.

    Considered dismissing it

    Writes above ~3 MiB are rare, which is the honest argument for closing this as won't-fix. What defeats it is precedent: this repo has repeatedly treated backend-dependent behaviour as a bug worth fixing, and read-then-fail-to-write is reachable through ordinary Edit use rather than requiring an adversarial payload.

    The generalizable point, which is the third time this pattern has appeared across these issues: an item's stated severity is not evidence. Here the true severity was lower than claimed, and the true reason to fix it was absent from the item entirely. Both only showed up by following the message through both hops.

    Assisted-By: Claude (Anthropic AI) <[email protected]>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions