[P1] Go harness: ssh argv word-splitting and phase-timeout mis-attribution #253

Closed
opened 2026-07-03 02:30:51 -07:00 by nelsong6 · 2 comments
nelsong6 commented 2026-07-03 02:30:51 -07:00 (Migrated from github.com)

Priority: P1. From the 2026-07-02 audit.

Part A — ssh argv word-splitting (finding confirmed against code; real-world impact needs one check)

Remote commands sent via Conn.RunCommand lose argument word boundaries: the SDK appends each word to the ssh argv with no quoting, ssh joins them with spaces, and the remote shell re-splits. So:

  • pushBranch (internal/pod/llmwork.go:104-140) sends a multi-word commit message and a multi-word user.name config value → git receives the trailing words as pathspecs / positional args and fails.
  • syncHostCheckout (internal/pod/helpers.go:58 → SDK SyncCheckout) sends -c http.<url>.extraheader=AUTHORIZATION: basic <b64> whose value contains spaces → remote git parses basic as a subcommand and fails.

Code analysis says this fails deterministically. However, PRs are currently merging (e.g. #244, #245), which contradicts "100% of runs fail." Before rewriting anything, confirm the laptop's sshd DefaultShell: the two space-containing RunCommand calls that do work (conn.go:106, cleanup.go:39) survive only because PowerShell -Command re-joins trailing tokens. If DefaultShell is PowerShell, the real behaviour differs from the POSIX-shell analysis and the exact failure mode must be re-derived.

Fix direction (once confirmed): move remote git into host-face subcommands (push-branch, sync-checkout) invoked via RunSelf with single-word flag values, exactly like run-phase already does. This also removes a GitHub-token-in-process-listing exposure (the token is currently in a remote command line). Report the extraheader-space bug upstream to glimmung/harness remotehost.SyncCheckout.

Guardrail: a unit test walking every RunCommand call site asserting no argv word contains whitespace (documented exemption for the powershell -NoProfile -Command pattern).

Part B — phase-timeout mis-attribution (confirmed)

A phase timeout returns a harness-layer error (exit 1) though runphase.go:196-197's own doc says it must become a clean phase_timeout verdict, and no code path ever writes a phase_timeout artifact despite it being in every phase's AllowedAbortReasons. So a routine slow agent burns the run as an unattributed harness failure — defeating the documented reason for the Go migration. Restore the synthetic-abort-on-timeout: on DeadlineExceeded, write the phase's abort artifact (abort_reason=phase_timeout) and route through ctx.Abort for clean teardown; keep LayerModel only for genuine agent failures. Add round-trip tests for both.

**Priority: P1.** From the 2026-07-02 audit. ## Part A — ssh argv word-splitting (finding confirmed against code; real-world impact needs one check) Remote commands sent via `Conn.RunCommand` lose argument word boundaries: the SDK appends each word to the ssh argv with no quoting, ssh joins them with spaces, and the remote shell re-splits. So: - `pushBranch` (`internal/pod/llmwork.go:104-140`) sends a multi-word commit message and a multi-word `user.name` config value → `git` receives the trailing words as pathspecs / positional args and fails. - `syncHostCheckout` (`internal/pod/helpers.go:58` → SDK `SyncCheckout`) sends `-c http.<url>.extraheader=AUTHORIZATION: basic <b64>` whose value contains spaces → remote git parses `basic` as a subcommand and fails. Code analysis says this fails deterministically. **However, PRs are currently merging** (e.g. #244, #245), which contradicts "100% of runs fail." Before rewriting anything, **confirm the laptop's `sshd` `DefaultShell`**: the two space-containing `RunCommand` calls that *do* work (`conn.go:106`, `cleanup.go:39`) survive only because PowerShell `-Command` re-joins trailing tokens. If DefaultShell is PowerShell, the real behaviour differs from the POSIX-shell analysis and the exact failure mode must be re-derived. Fix direction (once confirmed): move remote git into host-face subcommands (`push-branch`, `sync-checkout`) invoked via `RunSelf` with single-word flag values, exactly like `run-phase` already does. This also removes a GitHub-token-in-process-listing exposure (the token is currently in a remote command line). Report the `extraheader`-space bug upstream to `glimmung/harness` `remotehost.SyncCheckout`. **Guardrail:** a unit test walking every `RunCommand` call site asserting no argv word contains whitespace (documented exemption for the `powershell -NoProfile -Command` pattern). ## Part B — phase-timeout mis-attribution (confirmed) A phase timeout returns a harness-layer error (exit 1) though `runphase.go:196-197`'s own doc says it must become a clean `phase_timeout` verdict, and no code path ever writes a `phase_timeout` artifact despite it being in every phase's `AllowedAbortReasons`. So a routine slow agent burns the run as an unattributed *harness* failure — defeating the documented reason for the Go migration. Restore the synthetic-abort-on-timeout: on `DeadlineExceeded`, write the phase's abort artifact (`abort_reason=phase_timeout`) and route through `ctx.Abort` for clean teardown; keep `LayerModel` only for genuine agent failures. Add round-trip tests for both.
nelsong6 commented 2026-07-03 09:34:24 -07:00 (Migrated from github.com)

Uncapped audit pass — additional confirmed Go-harness items beyond the ssh word-splitting (#132):

  • LayeredError flattened to bare exit 1 so every laptop failure is billed suspected_cause=host (#133, HIGH) — encode the layer in the exit code.
  • Phase timeout returns HarnessError instead of a clean phase_timeout abort verdict, so a slow agent burns the run and recycle never sees a verdict (#134, HIGH).
  • runDeterministicUnitTests discards runCmd's start error, so dotnet-not-on-PATH becomes unit_tests_failed blaming the implementation (#135).
  • GitHub token embedded in the push URL leaks into persisted error blocks and the process table (#139, HIGH) — use extraheader + redact.
  • Transient RunSelf/GitHub-API errors mapped to definitive bridge_not_ready/implementation_branch_missing aborts (#137); swallowed mkdir/decodeB64 errors (#136, #140).
  • Doc drift: glimmung-workflow.md describes a retired pack-evidence flow + a stale SDK-gap list (#138).
**Uncapped audit pass — additional confirmed Go-harness items beyond the ssh word-splitting (#132):** - LayeredError flattened to bare `exit 1` so every laptop failure is billed `suspected_cause=host` (#133, HIGH) — encode the layer in the exit code. - Phase timeout returns `HarnessError` instead of a clean `phase_timeout` abort verdict, so a slow agent burns the run and recycle never sees a verdict (#134, HIGH). - `runDeterministicUnitTests` discards `runCmd`'s start error, so dotnet-not-on-PATH becomes `unit_tests_failed` blaming the implementation (#135). - GitHub token embedded in the push URL leaks into persisted error blocks and the process table (#139, HIGH) — use extraheader + redact. - Transient `RunSelf`/GitHub-API errors mapped to definitive `bridge_not_ready`/`implementation_branch_missing` aborts (#137); swallowed mkdir/decodeB64 errors (#136, #140). - Doc drift: `glimmung-workflow.md` describes a retired pack-evidence flow + a stale SDK-gap list (#138).
nelsong6 commented 2026-07-05 15:45:10 -07:00 (Migrated from github.com)

Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.

Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens#253
No description provided.