oficina / equipo Public

Merge branch 'push-error-detail' into main

Merge push-error-detail: keep git's answer on a failed push

A failed push logs and reports git's or the hub's answer, redacted
and capped at 500 bytes in log_tail, classified as refused or
non-fast-forward. No wire change. Hosted CI passed on 0c44021.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 5d8670cc1ff2ddb744dfe2e71e7aafd1d89d8661 parent 724659dparent 0c44021
9 files changed, +440 −17
  • .rastrillo/budgets.txt +1 −1
  • internal/equipo/work_views_test.go +20 −0
  • internal/runner/forge/branch.go +22 −9
  • internal/runner/forge/push_detail.go +156 −0
  • internal/runner/forge/push_detail_test.go +127 −0
  • internal/runner/thin/engineer.go +26 −3
  • internal/runner/thin/forge.go +9 −2
  • internal/runner/thin/pushdetail_test.go +75 −0
  • internal/runner/thin/relay.go +4 −2

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 794982e1..e574be79 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -34,7 +34,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full
perf GET /releases/* skip Verified runner release file downloads, not browser GET screens.
perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen.
time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s; niced serial reruns measured 5.773s and 5.750s. The added coordinator mount check has no repeated launches to remove; 15s leaves 38 percent headroom for namespace, process-exit and recovery assertions.
-size internal/runner/thin 18261 9927 Preview hosts add the preview host interface and the CARLOS devbox adapter (preview_devbox.go: explicit pairing, the fixed devbox commands, share in place, the learnt domain, unshare when the task ends, about 300 lines) and its tests (about 215); measured 18261 source and 9927 test lines. An unborn default in one request: merge inspection asks for main beside HEAD, names the unborn default main, and logs what an inspection failed on (about 11 lines); its test (TestHeadsReadsAnUnbornDefaultInOneCall, amadan-13's threatmin verbatim, about 74 lines): measured 17943/9712. Exploration tasks: the previews capability, the first hello without it, record_task's kind in the tool schema and house rule, and exploreRefused below protocol 10 (about 43 lines), with its unit test (about 37 lines); measured 17932 and 9638. Merge error detail: the merge step reports the hub's status, code and message in its log tail, merge and merge watch errors log their redacted words instead of their type, and ls-remote keeps git's stderr (logDetail, about 20 lines; the merge step and watch tests, about 110); measured 17889 source and 9601 test lines. Release previews merged with the first merge into an empty repository (previews move to protocol 9, empty-repository merge keeps 8): measured 17869 source and 9489 test lines. The first merge into an empty repository: merge inspection reads an unborn default (Heads, inspectMerge), a task branch at HEAD is never the default, the merge step says merge_unborn_default and kicks the index after a merge (about 36 lines); their test (TestUnbornDefaultForMerge, about 53 lines): measured 17201/8971. Release previews Astra round 2 adds the credential file checks (no link, exactly 0600, owned, never inside a mounted root, errors without content), the empty account listing and the cancelled reconcile (about 55 lines) and their tests (about 90); measured 17833 source and 9436 test lines. Release previews add the preview step (preview.go: the strict config from git objects, the export from git objects with its caps and digest, the fixed carlos commands each behind a publish check, the marker check that follows no redirect, the restart reconcile, about 560 lines) and its tests (preview_test.go, about 430 lines); measured 17777 source and 9347 test lines. Mac pending cleanup: the warm waits while an attempt's cleanup is pending (5 lines, test 4); measured 17165/8918. Mac simulators before T: quietSimulators shuts every simulator down (bounded) before a T cleanup and logs what is left (about 43 lines), and its test with a hung simctl (about 45 lines); measured 17160/8914. Mac user temp: the Mac host resolves the user's T and refuses an untrusted one (macUserTemp, why in words), gives every gate one turn across the worker and the probe command, and warms Xcode's plugin cache once per Xcode outside the sandbox (warm, warmNow; about 71 lines); its tests pin T on the srt gates, a refused T and the warm's once, retry and turn (about 46 lines); measured 17117/8869. Engineering in an empty repository: the step starts from no base and tells Engineering so, the push names an unborn default, Review reads an initial commit against the empty tree (changeDiff), checks list its files, and a repository whose only branches are task branches stays empty (onlyTaskBranches; about 60 lines); their tests (the task-branch, review diff and prompt tests in index_empty_test.go, about 92 lines): measured 17046/8823. Mac checks wait for the sandbox: macChecks.Run refuses unproven without the dispatch's consent, the consent context, the worker's refusal report and the link's protocol 7 gate (about 38 lines), and their tests (sandbox_consent_test.go, about 131 lines); measured 16986/8731. Mac Xcode scratch: the Mac host test pins the gate's environment (the runner user's HOME kept, no scratch home; 6 lines); measured 16948/8600. Empty repositories merged onto main: measured 16948/8594. Empty repositories: the index lists a reachable repository with no commits as empty, DefaultBranch tells that from no access (lsRemote), reads of it say so, and the handshake hello keeps empty entries back until a protocol 6 welcome (about 52 lines); their tests (index_empty_test.go, the handshake hello at protocols 5 and 6, startLinkWith; about 183 lines). Token row facts merged onto main: measured 16896/8411. Token row facts read the check's rate limit and record it as a turn's (TokenCheck, the Verify wiring, about 40 lines); measured 16614. The leftover helper's debug line adds 3 lines: measured 16572. The Mac host's hang fix and probe pacing add the process group and its kill (procgroup_unix.go, procgroup_other.go), the bounded wait for a command's output, and the untrusted report's rerun decision with its tool fingerprint (about 165 lines); measured 16569. Runner startup logs add the info lines a silent start is pinned to a phase by (startup phases, the Mac host's xcode-select and capability commands, slow-command warnings, the probes, and the link's connecting, hello and welcome lines: startPhase, openRunner, watchSlow and logged, about 155 lines); measured 16405. Merge authority thin v1 adds the review's measured change facts (facts.go: raw and numstat listings, modes, signing lines, the revert tree check, about 230 lines), the merge_request confirmation and the merge's provenance; measured 16196 with spend-1 merged. Spend 1 resumes a fix round in Engineering's kept session on its healthy connection (fixSession, fixPlan, fixPrompt, keptCommit, about 90 lines); measured 15873. Claude's sign-in by a link's review round 1 contains its setup-token in a recorded namespace (the contained terminal, its proven stop and the start's recovery before a home goes, about 130 lines); measured 15787. Claude's sign-in by a link adds the runner's own setup-token attempt, the code's sealed delivery with its crash boundaries and the shared token commit (signin.go, about 300 lines, less the removed terminal watcher); measured 15655. Claude setup tokens add sealed delivery, the token check, Check again and recovery (token.go, tokencheck.go, about 700 lines) beside the composer and Mac lines; measured 15239. Astra round 2 moves the attachment quota to admission: arriving files counted by declared size, admissions protecting a file until its message names it, room made from the oldest unprotected files, refusal as runner_storage_full, and a sweep that stops when protection cannot be read (about 150 lines); measured 12191. Mac runners slices A and B add protocol negotiation (link.go), the capability report, the start authorization, the pack relay (relay.go), the primary's publication, the worker executor (worker.go) and the test-build fake worker, about 2700 lines on the same step engine. Composer attachments add the chunked receipt with exactly-once writes, the read-only desk delivery and its checks (files.go, about 230 lines), image blocks and localImage inputs, the attachment read through read_file; measured 11736. Connections slice 1 Astra round 1 adds the Codex step path (codexstep.go: Engineering and Review on the pinned app-server in the implement and inspect containment, about 300 lines); measured 11345. Connections slice 1 (after Astra round 1) also keeps a durable ledger of each turn's write tools so a later attempt never repeats one (effects.go), the waiting state between attempts and usage rows per attempt, about 500 lines more; measured 10590 before gate 1d. Connections slice 1 adds the Codex coordinator beside the Claude one (codex.go: the pinned app-server over JSON-RPC in the converse containment, sharing the coordinator base, desk, tool socket and session table), the connection registry over the bindings with health and provider limits (conns.go), in-app sign-in attempts (connector.go) and turn failover and holding (failover.go), about 1500 lines; the pure parts (the choice function, limit parsing, the app-server client, the sign-in flows) live in internal/runner/connect. Measured 10097. Thin v1 UX1 adds step activity lines from the specialist's stream, the repository head and checks gate in the index and project-tagged notes (about 120 lines); measured 8615 with slice 4c's review fixes. Thin v1 slice 4c adds the merge step (mergestep.go, about 190 lines) and the rebase round beside the slice 4b ask fixes. Thin v1 slice 3 adds Engineering steps beside the coordinator: the durable step state and engine (step.go) and the executor that checks out the task tree, runs the CLI in the implement containment, commits and pushes (engineer.go), about 800 lines sharing the coordinator's launch, tool socket and account selection. Measured 5686 source lines. Splitting would export the launch internals; revisit at the slice 7 sweep. Slice 4 adds checks and review on a candidate (judge.go) and the merge watch (merge.go), about 800 lines, sharing the Engineer launch path; measured 6808, 7035 after review round 1 (branch head watch, deadlines, streamed outputs). Slice 4b keeps Engineering and Review sessions and answers the creator's questions from them (ask.go: kept-session and ask state, read-only git tools, the answer stream), about 700 lines on the same launch path. Mac P2 diagnostics hand the probes' host runner.log's WARN (macHost.warn, 8 lines) and pin it with a test (12 lines): measured 16854/8411. Mac probe deadlines bound the booted simctl list, move the worker's wait for the probes out of its lock (hold) and warn when a probe run reaches its limit (about 24 lines); their tests (mac_stall_test.go: a fake xcrun that never answers, probes stalled while an update applies, about 270 lines) beside the Mac host they drive: measured 16846/8399. Release slice 1 merged onto main: measured 16822/8130. Release slice 1 (hosted checks) adds the hub's hosted CI verdict for checks: the deferred one-read poll with its persisted deadline, the one-snapshot verdict, the failing units and the restart case (judge_hosted.go, about 200 lines) and the forge's CI reads (forge.go, about 40); measured 16821. Its tests (judge_hosted_test.go, about 270 lines) take the package's tests to 8113, beside the step engine they drive. The leftover helper's debug line adds 3 lines: measured 16572. The Mac host's hang fix and probe pacing add the process group and its kill (procgroup_unix.go, procgroup_other.go), the bounded wait for a command's output, and the untrusted report's rerun decision with its tool fingerprint (about 165 lines); measured 16569. Runner startup logs add the info lines a silent start is pinned to a phase by (startup phases, the Mac host's xcode-select and capability commands, slow-command warnings, the probes, and the link's connecting, hello and welcome lines: startPhase, openRunner, watchSlow and logged, about 155 lines); measured 16405. Merge authority thin v1 adds the review's measured change facts (facts.go: raw and numstat listings, modes, signing lines, the revert tree check, about 230 lines), the merge_request confirmation and the merge's provenance; measured 16196 with spend-1 merged. Spend 1 resumes a fix round in Engineering's kept session on its healthy connection (fixSession, fixPlan, fixPrompt, keptCommit, about 90 lines); measured 15873. Claude's sign-in by a link's review round 1 contains its setup-token in a recorded namespace (the contained terminal, its proven stop and the start's recovery before a home goes, about 130 lines); measured 15787. Claude's sign-in by a link adds the runner's own setup-token attempt, the code's sealed delivery with its crash boundaries and the shared token commit (signin.go, about 300 lines, less the removed terminal watcher); measured 15655. Claude setup tokens add sealed delivery, the token check, Check again and recovery (token.go, tokencheck.go, about 700 lines) beside the composer and Mac lines; measured 15239. Astra round 2 moves the attachment quota to admission: arriving files counted by declared size, admissions protecting a file until its message names it, room made from the oldest unprotected files, refusal as runner_storage_full, and a sweep that stops when protection cannot be read (about 150 lines); measured 12191. Mac runners slices A and B add protocol negotiation (link.go), the capability report, the start authorization, the pack relay (relay.go), the primary's publication, the worker executor (worker.go) and the test-build fake worker, about 2700 lines on the same step engine. Composer attachments add the chunked receipt with exactly-once writes, the read-only desk delivery and its checks (files.go, about 230 lines), image blocks and localImage inputs, the attachment read through read_file; measured 11736. Connections slice 1 Astra round 1 adds the Codex step path (codexstep.go: Engineering and Review on the pinned app-server in the implement and inspect containment, about 300 lines); measured 11345. Connections slice 1 (after Astra round 1) also keeps a durable ledger of each turn's write tools so a later attempt never repeats one (effects.go), the waiting state between attempts and usage rows per attempt, about 500 lines more; measured 10590 before gate 1d. Connections slice 1 adds the Codex coordinator beside the Claude one (codex.go: the pinned app-server over JSON-RPC in the converse containment, sharing the coordinator base, desk, tool socket and session table), the connection registry over the bindings with health and provider limits (conns.go), in-app sign-in attempts (connector.go) and turn failover and holding (failover.go), about 1500 lines; the pure parts (the choice function, limit parsing, the app-server client, the sign-in flows) live in internal/runner/connect. Measured 10097. Thin v1 UX1 adds step activity lines from the specialist's stream, the repository head and checks gate in the index and project-tagged notes (about 120 lines); measured 8615 with slice 4c's review fixes. Thin v1 slice 4c adds the merge step (mergestep.go, about 190 lines) and the rebase round beside the slice 4b ask fixes. Thin v1 slice 3 adds Engineering steps beside the coordinator: the durable step state and engine (step.go) and the executor that checks out the task tree, runs the CLI in the implement containment, commits and pushes (engineer.go), about 800 lines sharing the coordinator's launch, tool socket and account selection. Measured 5686 source lines. Splitting would export the launch internals; revisit at the slice 7 sweep. Slice 4 adds checks and review on a candidate (judge.go) and the merge watch (merge.go), about 800 lines, sharing the Engineer launch path; measured 6808, 7035 after review round 1 (branch head watch, deadlines, streamed outputs). Slice 4b keeps Engineering and Review sessions and answers the creator's questions from them (ask.go: kept-session and ask state, read-only git tools, the answer stream), about 700 lines on the same launch path. The paste box house rule merged onto the runner logs: measured 16573. The leftover helper's debug line adds 3 lines: measured 16572. The Mac host's hang fix and probe pacing add the process group and its kill (procgroup_unix.go, procgroup_other.go), the bounded wait for a command's output, and the untrusted report's rerun decision with its tool fingerprint (about 165 lines); measured 16569. Runner startup logs add the info lines a silent start is pinned to a phase by (startup phases, the Mac host's xcode-select and capability commands, slow-command warnings, the probes, and the link's connecting, hello and welcome lines: startPhase, openRunner, watchSlow and logged, about 155 lines); measured 16405. Merge authority thin v1 adds the review's measured change facts (facts.go: raw and numstat listings, modes, signing lines, the revert tree check, about 230 lines), the merge_request confirmation and the merge's provenance; measured 16196 with spend-1 merged. Spend 1 resumes a fix round in Engineering's kept session on its healthy connection (fixSession, fixPlan, fixPrompt, keptCommit, about 90 lines); measured 15873. Claude's sign-in by a link's review round 1 contains its setup-token in a recorded namespace (the contained terminal, its proven stop and the start's recovery before a home goes, about 130 lines); measured 15787. Claude's sign-in by a link adds the runner's own setup-token attempt, the code's sealed delivery with its crash boundaries and the shared token commit (signin.go, about 300 lines, less the removed terminal watcher); measured 15655. Claude setup tokens add sealed delivery, the token check, Check again and recovery (token.go, tokencheck.go, about 700 lines) beside the composer and Mac lines; measured 15239. Astra round 2 moves the attachment quota to admission: arriving files counted by declared size, admissions protecting a file until its message names it, room made from the oldest unprotected files, refusal as runner_storage_full, and a sweep that stops when protection cannot be read (about 150 lines); measured 12191. Mac runners slices A and B add protocol negotiation (link.go), the capability report, the start authorization, the pack relay (relay.go), the primary's publication, the worker executor (worker.go) and the test-build fake worker, about 2700 lines on the same step engine. Composer attachments add the chunked receipt with exactly-once writes, the read-only desk delivery and its checks (files.go, about 230 lines), image blocks and localImage inputs, the attachment read through read_file; measured 11736. Connections slice 1 Astra round 1 adds the Codex step path (codexstep.go: Engineering and Review on the pinned app-server in the implement and inspect containment, about 300 lines); measured 11345. Connections slice 1 (after Astra round 1) also keeps a durable ledger of each turn's write tools so a later attempt never repeats one (effects.go), the waiting state between attempts and usage rows per attempt, about 500 lines more; measured 10590 before gate 1d. Connections slice 1 adds the Codex coordinator beside the Claude one (codex.go: the pinned app-server over JSON-RPC in the converse containment, sharing the coordinator base, desk, tool socket and session table), the connection registry over the bindings with health and provider limits (conns.go), in-app sign-in attempts (connector.go) and turn failover and holding (failover.go), about 1500 lines; the pure parts (the choice function, limit parsing, the app-server client, the sign-in flows) live in internal/runner/connect. Measured 10097. Thin v1 UX1 adds step activity lines from the specialist's stream, the repository head and checks gate in the index and project-tagged notes (about 120 lines); measured 8615 with slice 4c's review fixes. Thin v1 slice 4c adds the merge step (mergestep.go, about 190 lines) and the rebase round beside the slice 4b ask fixes. Thin v1 slice 3 adds Engineering steps beside the coordinator: the durable step state and engine (step.go) and the executor that checks out the task tree, runs the CLI in the implement containment, commits and pushes (engineer.go), about 800 lines sharing the coordinator's launch, tool socket and account selection. Measured 5686 source lines. Splitting would export the launch internals; revisit at the slice 7 sweep. Slice 4 adds checks and review on a candidate (judge.go) and the merge watch (merge.go), about 800 lines, sharing the Engineer launch path; measured 6808, 7035 after review round 1 (branch head watch, deadlines, streamed outputs). Slice 4b keeps Engineering and Review sessions and answers the creator's questions from them (ask.go: kept-session and ask state, read-only git tools, the answer stream), about 700 lines on the same launch path.
+size internal/runner/thin 18293 10002 Push error detail merged onto preview hosts: measured 18293/10002. Push error detail: a failed push's report leads its log tail with git's answer and the refusal it shows (non-fast-forward, refused), the step and publication pushes log their redacted words and the refusal instead of the error's type, the default branch's failure says so, ls-remote keeps git's stderr and the push backoff is a variable (logPush, about 32 lines); its test (TestPushFailureKeepsTheHubAnswer, about 75 lines): measured 17975/9787. Preview hosts add the preview host interface and the CARLOS devbox adapter (preview_devbox.go: explicit pairing, the fixed devbox commands, share in place, the learnt domain, unshare when the task ends, about 300 lines) and its tests (about 215); measured 18261 source and 9927 test lines. An unborn default in one request: merge inspection asks for main beside HEAD, names the unborn default main, and logs what an inspection failed on (about 11 lines); its test (TestHeadsReadsAnUnbornDefaultInOneCall, amadan-13's threatmin verbatim, about 74 lines): measured 17943/9712. Exploration tasks: the previews capability, the first hello without it, record_task's kind in the tool schema and house rule, and exploreRefused below protocol 10 (about 43 lines), with its unit test (about 37 lines); measured 17932 and 9638. Merge error detail: the merge step reports the hub's status, code and message in its log tail, merge and merge watch errors log their redacted words instead of their type, and ls-remote keeps git's stderr (logDetail, about 20 lines; the merge step and watch tests, about 110); measured 17889 source and 9601 test lines. Release previews merged with the first merge into an empty repository (previews move to protocol 9, empty-repository merge keeps 8): measured 17869 source and 9489 test lines. The first merge into an empty repository: merge inspection reads an unborn default (Heads, inspectMerge), a task branch at HEAD is never the default, the merge step says merge_unborn_default and kicks the index after a merge (about 36 lines); their test (TestUnbornDefaultForMerge, about 53 lines): measured 17201/8971. Release previews Astra round 2 adds the credential file checks (no link, exactly 0600, owned, never inside a mounted root, errors without content), the empty account listing and the cancelled reconcile (about 55 lines) and their tests (about 90); measured 17833 source and 9436 test lines. Release previews add the preview step (preview.go: the strict config from git objects, the export from git objects with its caps and digest, the fixed carlos commands each behind a publish check, the marker check that follows no redirect, the restart reconcile, about 560 lines) and its tests (preview_test.go, about 430 lines); measured 17777 source and 9347 test lines. Mac pending cleanup: the warm waits while an attempt's cleanup is pending (5 lines, test 4); measured 17165/8918. Mac simulators before T: quietSimulators shuts every simulator down (bounded) before a T cleanup and logs what is left (about 43 lines), and its test with a hung simctl (about 45 lines); measured 17160/8914. Mac user temp: the Mac host resolves the user's T and refuses an untrusted one (macUserTemp, why in words), gives every gate one turn across the worker and the probe command, and warms Xcode's plugin cache once per Xcode outside the sandbox (warm, warmNow; about 71 lines); its tests pin T on the srt gates, a refused T and the warm's once, retry and turn (about 46 lines); measured 17117/8869. Engineering in an empty repository: the step starts from no base and tells Engineering so, the push names an unborn default, Review reads an initial commit against the empty tree (changeDiff), checks list its files, and a repository whose only branches are task branches stays empty (onlyTaskBranches; about 60 lines); their tests (the task-branch, review diff and prompt tests in index_empty_test.go, about 92 lines): measured 17046/8823. Mac checks wait for the sandbox: macChecks.Run refuses unproven without the dispatch's consent, the consent context, the worker's refusal report and the link's protocol 7 gate (about 38 lines), and their tests (sandbox_consent_test.go, about 131 lines); measured 16986/8731. Mac Xcode scratch: the Mac host test pins the gate's environment (the runner user's HOME kept, no scratch home; 6 lines); measured 16948/8600. Empty repositories merged onto main: measured 16948/8594. Empty repositories: the index lists a reachable repository with no commits as empty, DefaultBranch tells that from no access (lsRemote), reads of it say so, and the handshake hello keeps empty entries back until a protocol 6 welcome (about 52 lines); their tests (index_empty_test.go, the handshake hello at protocols 5 and 6, startLinkWith; about 183 lines). Token row facts merged onto main: measured 16896/8411. Token row facts read the check's rate limit and record it as a turn's (TokenCheck, the Verify wiring, about 40 lines); measured 16614. The leftover helper's debug line adds 3 lines: measured 16572. The Mac host's hang fix and probe pacing add the process group and its kill (procgroup_unix.go, procgroup_other.go), the bounded wait for a command's output, and the untrusted report's rerun decision with its tool fingerprint (about 165 lines); measured 16569. Runner startup logs add the info lines a silent start is pinned to a phase by (startup phases, the Mac host's xcode-select and capability commands, slow-command warnings, the probes, and the link's connecting, hello and welcome lines: startPhase, openRunner, watchSlow and logged, about 155 lines); measured 16405. Merge authority thin v1 adds the review's measured change facts (facts.go: raw and numstat listings, modes, signing lines, the revert tree check, about 230 lines), the merge_request confirmation and the merge's provenance; measured 16196 with spend-1 merged. Spend 1 resumes a fix round in Engineering's kept session on its healthy connection (fixSession, fixPlan, fixPrompt, keptCommit, about 90 lines); measured 15873. Claude's sign-in by a link's review round 1 contains its setup-token in a recorded namespace (the contained terminal, its proven stop and the start's recovery before a home goes, about 130 lines); measured 15787. Claude's sign-in by a link adds the runner's own setup-token attempt, the code's sealed delivery with its crash boundaries and the shared token commit (signin.go, about 300 lines, less the removed terminal watcher); measured 15655. Claude setup tokens add sealed delivery, the token check, Check again and recovery (token.go, tokencheck.go, about 700 lines) beside the composer and Mac lines; measured 15239. Astra round 2 moves the attachment quota to admission: arriving files counted by declared size, admissions protecting a file until its message names it, room made from the oldest unprotected files, refusal as runner_storage_full, and a sweep that stops when protection cannot be read (about 150 lines); measured 12191. Mac runners slices A and B add protocol negotiation (link.go), the capability report, the start authorization, the pack relay (relay.go), the primary's publication, the worker executor (worker.go) and the test-build fake worker, about 2700 lines on the same step engine. Composer attachments add the chunked receipt with exactly-once writes, the read-only desk delivery and its checks (files.go, about 230 lines), image blocks and localImage inputs, the attachment read through read_file; measured 11736. Connections slice 1 Astra round 1 adds the Codex step path (codexstep.go: Engineering and Review on the pinned app-server in the implement and inspect containment, about 300 lines); measured 11345. Connections slice 1 (after Astra round 1) also keeps a durable ledger of each turn's write tools so a later attempt never repeats one (effects.go), the waiting state between attempts and usage rows per attempt, about 500 lines more; measured 10590 before gate 1d. Connections slice 1 adds the Codex coordinator beside the Claude one (codex.go: the pinned app-server over JSON-RPC in the converse containment, sharing the coordinator base, desk, tool socket and session table), the connection registry over the bindings with health and provider limits (conns.go), in-app sign-in attempts (connector.go) and turn failover and holding (failover.go), about 1500 lines; the pure parts (the choice function, limit parsing, the app-server client, the sign-in flows) live in internal/runner/connect. Measured 10097. Thin v1 UX1 adds step activity lines from the specialist's stream, the repository head and checks gate in the index and project-tagged notes (about 120 lines); measured 8615 with slice 4c's review fixes. Thin v1 slice 4c adds the merge step (mergestep.go, about 190 lines) and the rebase round beside the slice 4b ask fixes. Thin v1 slice 3 adds Engineering steps beside the coordinator: the durable step state and engine (step.go) and the executor that checks out the task tree, runs the CLI in the implement containment, commits and pushes (engineer.go), about 800 lines sharing the coordinator's launch, tool socket and account selection. Measured 5686 source lines. Splitting would export the launch internals; revisit at the slice 7 sweep. Slice 4 adds checks and review on a candidate (judge.go) and the merge watch (merge.go), about 800 lines, sharing the Engineer launch path; measured 6808, 7035 after review round 1 (branch head watch, deadlines, streamed outputs). Slice 4b keeps Engineering and Review sessions and answers the creator's questions from them (ask.go: kept-session and ask state, read-only git tools, the answer stream), about 700 lines on the same launch path. Mac P2 diagnostics hand the probes' host runner.log's WARN (macHost.warn, 8 lines) and pin it with a test (12 lines): measured 16854/8411. Mac probe deadlines bound the booted simctl list, move the worker's wait for the probes out of its lock (hold) and warn when a probe run reaches its limit (about 24 lines); their tests (mac_stall_test.go: a fake xcrun that never answers, probes stalled while an update applies, about 270 lines) beside the Mac host they drive: measured 16846/8399. Release slice 1 merged onto main: measured 16822/8130. Release slice 1 (hosted checks) adds the hub's hosted CI verdict for checks: the deferred one-read poll with its persisted deadline, the one-snapshot verdict, the failing units and the restart case (judge_hosted.go, about 200 lines) and the forge's CI reads (forge.go, about 40); measured 16821. Its tests (judge_hosted_test.go, about 270 lines) take the package's tests to 8113, beside the step engine they drive. The leftover helper's debug line adds 3 lines: measured 16572. The Mac host's hang fix and probe pacing add the process group and its kill (procgroup_unix.go, procgroup_other.go), the bounded wait for a command's output, and the untrusted report's rerun decision with its tool fingerprint (about 165 lines); measured 16569. Runner startup logs add the info lines a silent start is pinned to a phase by (startup phases, the Mac host's xcode-select and capability commands, slow-command warnings, the probes, and the link's connecting, hello and welcome lines: startPhase, openRunner, watchSlow and logged, about 155 lines); measured 16405. Merge authority thin v1 adds the review's measured change facts (facts.go: raw and numstat listings, modes, signing lines, the revert tree check, about 230 lines), the merge_request confirmation and the merge's provenance; measured 16196 with spend-1 merged. Spend 1 resumes a fix round in Engineering's kept session on its healthy connection (fixSession, fixPlan, fixPrompt, keptCommit, about 90 lines); measured 15873. Claude's sign-in by a link's review round 1 contains its setup-token in a recorded namespace (the contained terminal, its proven stop and the start's recovery before a home goes, about 130 lines); measured 15787. Claude's sign-in by a link adds the runner's own setup-token attempt, the code's sealed delivery with its crash boundaries and the shared token commit (signin.go, about 300 lines, less the removed terminal watcher); measured 15655. Claude setup tokens add sealed delivery, the token check, Check again and recovery (token.go, tokencheck.go, about 700 lines) beside the composer and Mac lines; measured 15239. Astra round 2 moves the attachment quota to admission: arriving files counted by declared size, admissions protecting a file until its message names it, room made from the oldest unprotected files, refusal as runner_storage_full, and a sweep that stops when protection cannot be read (about 150 lines); measured 12191. Mac runners slices A and B add protocol negotiation (link.go), the capability report, the start authorization, the pack relay (relay.go), the primary's publication, the worker executor (worker.go) and the test-build fake worker, about 2700 lines on the same step engine. Composer attachments add the chunked receipt with exactly-once writes, the read-only desk delivery and its checks (files.go, about 230 lines), image blocks and localImage inputs, the attachment read through read_file; measured 11736. Connections slice 1 Astra round 1 adds the Codex step path (codexstep.go: Engineering and Review on the pinned app-server in the implement and inspect containment, about 300 lines); measured 11345. Connections slice 1 (after Astra round 1) also keeps a durable ledger of each turn's write tools so a later attempt never repeats one (effects.go), the waiting state between attempts and usage rows per attempt, about 500 lines more; measured 10590 before gate 1d. Connections slice 1 adds the Codex coordinator beside the Claude one (codex.go: the pinned app-server over JSON-RPC in the converse containment, sharing the coordinator base, desk, tool socket and session table), the connection registry over the bindings with health and provider limits (conns.go), in-app sign-in attempts (connector.go) and turn failover and holding (failover.go), about 1500 lines; the pure parts (the choice function, limit parsing, the app-server client, the sign-in flows) live in internal/runner/connect. Measured 10097. Thin v1 UX1 adds step activity lines from the specialist's stream, the repository head and checks gate in the index and project-tagged notes (about 120 lines); measured 8615 with slice 4c's review fixes. Thin v1 slice 4c adds the merge step (mergestep.go, about 190 lines) and the rebase round beside the slice 4b ask fixes. Thin v1 slice 3 adds Engineering steps beside the coordinator: the durable step state and engine (step.go) and the executor that checks out the task tree, runs the CLI in the implement containment, commits and pushes (engineer.go), about 800 lines sharing the coordinator's launch, tool socket and account selection. Measured 5686 source lines. Splitting would export the launch internals; revisit at the slice 7 sweep. Slice 4 adds checks and review on a candidate (judge.go) and the merge watch (merge.go), about 800 lines, sharing the Engineer launch path; measured 6808, 7035 after review round 1 (branch head watch, deadlines, streamed outputs). Slice 4b keeps Engineering and Review sessions and answers the creator's questions from them (ask.go: kept-session and ask state, read-only git tools, the answer stream), about 700 lines on the same launch path. The paste box house rule merged onto the runner logs: measured 16573. The leftover helper's debug line adds 3 lines: measured 16572. The Mac host's hang fix and probe pacing add the process group and its kill (procgroup_unix.go, procgroup_other.go), the bounded wait for a command's output, and the untrusted report's rerun decision with its tool fingerprint (about 165 lines); measured 16569. Runner startup logs add the info lines a silent start is pinned to a phase by (startup phases, the Mac host's xcode-select and capability commands, slow-command warnings, the probes, and the link's connecting, hello and welcome lines: startPhase, openRunner, watchSlow and logged, about 155 lines); measured 16405. Merge authority thin v1 adds the review's measured change facts (facts.go: raw and numstat listings, modes, signing lines, the revert tree check, about 230 lines), the merge_request confirmation and the merge's provenance; measured 16196 with spend-1 merged. Spend 1 resumes a fix round in Engineering's kept session on its healthy connection (fixSession, fixPlan, fixPrompt, keptCommit, about 90 lines); measured 15873. Claude's sign-in by a link's review round 1 contains its setup-token in a recorded namespace (the contained terminal, its proven stop and the start's recovery before a home goes, about 130 lines); measured 15787. Claude's sign-in by a link adds the runner's own setup-token attempt, the code's sealed delivery with its crash boundaries and the shared token commit (signin.go, about 300 lines, less the removed terminal watcher); measured 15655. Claude setup tokens add sealed delivery, the token check, Check again and recovery (token.go, tokencheck.go, about 700 lines) beside the composer and Mac lines; measured 15239. Astra round 2 moves the attachment quota to admission: arriving files counted by declared size, admissions protecting a file until its message names it, room made from the oldest unprotected files, refusal as runner_storage_full, and a sweep that stops when protection cannot be read (about 150 lines); measured 12191. Mac runners slices A and B add protocol negotiation (link.go), the capability report, the start authorization, the pack relay (relay.go), the primary's publication, the worker executor (worker.go) and the test-build fake worker, about 2700 lines on the same step engine. Composer attachments add the chunked receipt with exactly-once writes, the read-only desk delivery and its checks (files.go, about 230 lines), image blocks and localImage inputs, the attachment read through read_file; measured 11736. Connections slice 1 Astra round 1 adds the Codex step path (codexstep.go: Engineering and Review on the pinned app-server in the implement and inspect containment, about 300 lines); measured 11345. Connections slice 1 (after Astra round 1) also keeps a durable ledger of each turn's write tools so a later attempt never repeats one (effects.go), the waiting state between attempts and usage rows per attempt, about 500 lines more; measured 10590 before gate 1d. Connections slice 1 adds the Codex coordinator beside the Claude one (codex.go: the pinned app-server over JSON-RPC in the converse containment, sharing the coordinator base, desk, tool socket and session table), the connection registry over the bindings with health and provider limits (conns.go), in-app sign-in attempts (connector.go) and turn failover and holding (failover.go), about 1500 lines; the pure parts (the choice function, limit parsing, the app-server client, the sign-in flows) live in internal/runner/connect. Measured 10097. Thin v1 UX1 adds step activity lines from the specialist's stream, the repository head and checks gate in the index and project-tagged notes (about 120 lines); measured 8615 with slice 4c's review fixes. Thin v1 slice 4c adds the merge step (mergestep.go, about 190 lines) and the rebase round beside the slice 4b ask fixes. Thin v1 slice 3 adds Engineering steps beside the coordinator: the durable step state and engine (step.go) and the executor that checks out the task tree, runs the CLI in the implement containment, commits and pushes (engineer.go), about 800 lines sharing the coordinator's launch, tool socket and account selection. Measured 5686 source lines. Splitting would export the launch internals; revisit at the slice 7 sweep. Slice 4 adds checks and review on a candidate (judge.go) and the merge watch (merge.go), about 800 lines, sharing the Engineer launch path; measured 6808, 7035 after review round 1 (branch head watch, deadlines, streamed outputs). Slice 4b keeps Engineering and Review sessions and answers the creator's questions from them (ask.go: kept-session and ask state, read-only git tools, the answer stream), about 700 lines on the same launch path.
time internal/thintest 180s Mac runners slices A and B add role, scoping, migration, placement, withdrawal, transfer and publication contracts, and Astra round 1 eight transition contracts (about 15s; the package measured 126s locally under load). Housekeeping slice 1 adds six contract tests (combine, Undo round trips and the race, Pause, auto-disable, quiet hours, restart while claimed; about 6s); the package measured 67.7s beside other packages locally, so 75s. Thin v1 slice 4c adds the merge, adoption, cancel and retention contract tests (CI measured 35.7s). Thin v1 contract tests: a real instance and a scripted runner per test, fixtures replayed against every request, frame and event. Slice 3 adds the task, step-sync and grant contracts; CI measured 14.805s. 30s keeps room for the slice 4 review contracts. UX1 adds step activity, task source and duplicates, coordinator merging and project facts (four contracts, about 6s); the package measured 34s locally under load, so 40s. UX1's inner screens gallery (two owners, seven tasks, every page) adds about 3s; measured 40.9s locally under load, so 60s.
time internal/runner/mac 30s Mac runners (Darwin worker): real process groups killed after a grace and proven gone (SIGTERM, SIGKILL, the marker sweep), and the probes run end to end with fake srt and xcodebuild, P6 killing a waiting test two seconds after it starts. About 6s alone; loaded CI measured 12.5s.
time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s). Measured 17.8s locally under load. Slice 4b review adds a 16 MiB git output bound, an injected index-pack failure and stall (3s deadline) and held-answer tests; measured 30.3s locally under load. 45s keeps 33 percent headroom.
diff --git a/internal/equipo/work_views_test.go b/internal/equipo/work_views_test.go
index 1e72698f..3a6a3521 100644
--- a/internal/equipo/work_views_test.go
+++ b/internal/equipo/work_views_test.go
@@ -51,6 +51,26 @@ func TestStoppedMergeShowsTheHubAnswer(t *testing.T) {
t.Fatalf("no stopped merge in %+v", timelineOf(task, v))
}
+// A push the hub refused shows the person why: the stopped step's details
+// carry the refusal and git's answer from the runner's report, as written
+// (the runner redacts and bounds them).
+func TestStoppedPushShowsTheRefusal(t *testing.T) {
+ now := time.Now()
+ tail := "refusal: refused\npush: ! refs/heads/equipo/tk1-x [remote rejected] (pre-receive hook declined) remote: you cannot push to the default branch"
+ task := wire.Task{ID: "tk1", Creator: "a@example.com", Stage: wire.StageInProgress, Steps: []wire.Step{{Specialist: wire.SpecialistEngineering, State: wire.StepFailed, Reason: "push_failed", Attempt: 1, Terminated: true, LogTail: tail, FinishedAt: &now}}}
+ v := taskLineOf(task, "a@example.com")
+ v.richOf(task, "a@example.com", nil, now)
+ for _, it := range timelineOf(task, v) {
+ if it.Kind == "stopped" && it.Headline == "The push to Amadan failed." {
+ if html := string(pasteBox.Render(it.Markdown)); !strings.Contains(html, "refusal: refused") || !strings.Contains(html, "[remote rejected] (pre-receive hook declined) remote: you cannot push to the default branch") {
+ t.Fatalf("details %q", html)
+ }
+ return
+ }
+ }
+ t.Fatalf("no stopped push in %+v", timelineOf(task, v))
+}
+
// A timeline entry leads with one plain sentence: the specialist's own
// headline when it wrote one, else the first sentence that names no file;
// never a path, cut at a word.
diff --git a/internal/runner/forge/branch.go b/internal/runner/forge/branch.go
index 9f1189ab..a48c136b 100644
--- a/internal/runner/forge/branch.go
+++ b/internal/runner/forge/branch.go
@@ -1,13 +1,14 @@
package forge
import (
+ "bytes"
"context"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
- "io"
+ "fmt"
"os"
"os/exec"
"path/filepath"
@@ -113,9 +114,13 @@ func (b BranchPush) git(ctx context.Context, dir string, remote *workspace.Remot
for k, v := range env {
cmd.Env = append(cmd.Env, k+"="+v)
}
- cmd.Stderr = io.Discard
+ var stderr bytes.Buffer
+ cmd.Stderr = &capWriter{w: &stderr, n: 8 << 10}
out, err := cmd.Output()
- return strings.TrimSpace(string(out)), err
+ if err != nil {
+ return "", &gitAnswer{err: err, refusal: pushRefusalOf(string(out) + "\n" + stderr.String()), text: pushAnswer(string(out), stderr.String(), remote)}
+ }
+ return strings.TrimSpace(string(out)), nil
}
func (b BranchPush) save(r pushRecord) error {
@@ -176,7 +181,7 @@ func (b BranchPush) head(ctx context.Context, remote workspace.Remote) (string,
ref := "refs/heads/" + b.Branch
out, err := b.git(ctx, b.Root, &remote, "ls-remote", "--refs", "--", remote.URL, ref)
if err != nil {
- return "", ErrPushUncertain
+ return "", pushError("ls-remote", err, ErrPushUncertain)
}
fields := strings.Fields(out)
if len(fields) == 0 {
@@ -191,7 +196,10 @@ func (b BranchPush) head(ctx context.Context, remote workspace.Remote) (string,
// remote resolves the repository's remote and checks it is that one.
func (b BranchPush) remote(ctx context.Context) (workspace.Remote, error) {
remote, err := b.Remote(ctx)
- if err != nil || remote.URL == "" || !filepath.IsAbs(remote.URL) && (remote.URL != "https://"+b.Repo || remote.GitPassword == "") || filepath.IsAbs(remote.URL) && remote.GitPassword != "" {
+ if err != nil {
+ return workspace.Remote{}, fmt.Errorf("%w: resolving the remote: %v", ErrPushRefused, err)
+ }
+ if remote.URL == "" || !filepath.IsAbs(remote.URL) && (remote.URL != "https://"+b.Repo || remote.GitPassword == "") || filepath.IsAbs(remote.URL) && remote.GitPassword != "" {
return workspace.Remote{}, ErrPushRefused
}
return remote, nil
@@ -291,7 +299,7 @@ func PushBranch(ctx context.Context, b BranchPush) error {
return ErrPushConflict
}
if err := b.Confirm(ctx); err != nil {
- return ErrPushUncertain
+ return fmt.Errorf("%w: confirming the lease: %v", ErrPushUncertain, err)
}
rec.Phase = "push_started"
if err := b.save(rec); err != nil {
@@ -303,13 +311,18 @@ func PushBranch(ctx context.Context, b BranchPush) error {
_, perr := b.git(ctx, b.Root, &remote, "push", "--porcelain", "--no-verify", "--no-recurse-submodules", "--force-with-lease=refs/heads/"+b.Branch+":"+rec.Expected, "--", remote.URL, b.Commit+":refs/heads/"+b.Branch)
after, err := b.head(ctx, remote)
switch {
+ case err != nil && perr != nil:
+ // git's answer to the push says more than the read after it.
+ return pushError("push", perr, ErrPushUncertain)
case err != nil:
- return ErrPushUncertain
+ return err
case after == b.Commit:
rec.Phase = "published"
return b.save(rec)
case perr != nil && after != head:
- return ErrPushConflict
+ return pushError("push", perr, ErrPushConflict)
+ case perr != nil:
+ return pushError("push", perr, ErrPushUncertain)
}
- return ErrPushUncertain
+ return fmt.Errorf("%w: git push succeeded but the branch is not at the commit", ErrPushUncertain)
}
diff --git a/internal/runner/forge/push_detail.go b/internal/runner/forge/push_detail.go
new file mode 100644
index 00000000..2c37c2d8
--- /dev/null
+++ b/internal/runner/forge/push_detail.go
@@ -0,0 +1,156 @@
+package forge
+
+import (
+ "encoding/base64"
+ "errors"
+ "io"
+ "regexp"
+ "strings"
+
+ "amadan.net/oficina/equipo/internal/runner/workspace"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+// The refusals git's answer to a push can show.
+const (
+ // RefusalNonFastForward: the branch is not an ancestor of the commit
+ // ("[rejected] ... (non-fast-forward)", "fetch first", or the hub's
+ // own "[remote rejected] ... (non-fast-forward)").
+ RefusalNonFastForward = "non-fast-forward"
+ // RefusalRefused: the hub refused the update itself: a hook, a
+ // protected branch ("[remote rejected] ...", "pre-receive hook
+ // declined").
+ RefusalRefused = "refused"
+)
+
+// PushError is git's answer to a push, or to the read of the branch
+// around it, that failed: what git was doing (Op: "push" or
+// "ls-remote"), the refusal its answer shows (a push only; "" when it
+// shows none) and its words (the rejected ref lines and stderr),
+// redacted and bounded. It wraps the outcome (ErrPushUncertain,
+// ErrPushConflict), which still decides the step's reason.
+type PushError struct {
+ Op, Refusal, Answer string
+ Err error
+}
+
+func (e *PushError) Error() string {
+ s := e.Err.Error() + ": git " + e.Op
+ if e.Refusal != "" {
+ s += " (" + e.Refusal + ")"
+ }
+ return s + ": " + e.Answer
+}
+
+func (e *PushError) Unwrap() error { return e.Err }
+
+// PushRefusal is the refusal a failed push's answer shows, or "".
+func PushRefusal(err error) string {
+ var p *PushError
+ if errors.As(err, &p) {
+ return p.Refusal
+ }
+ return ""
+}
+
+// PushDetail is a failed push for the step report, a few lines: the
+// refusal and git's answer when git gave one, else the error's own
+// words; redacted and at most runnerproto.DetailLimit bytes either way.
+func PushDetail(err error) string {
+ var p *PushError
+ switch {
+ case err == nil:
+ return ""
+ case !errors.As(err, &p):
+ return "error: " + runnerproto.RedactDetail(err.Error(), runnerproto.DetailLimit-len("error: "))
+ }
+ out := ""
+ if p.Refusal != "" {
+ out = "refusal: " + p.Refusal + "\n"
+ }
+ out += p.Op + ": "
+ return out + runnerproto.RedactDetail(p.Answer, runnerproto.DetailLimit-len(out))
+}
+
+// gitAnswer is a git command that failed and what it said.
+type gitAnswer struct {
+ err error
+ refusal, text string
+}
+
+func (g *gitAnswer) Error() string { return g.text }
+func (g *gitAnswer) Unwrap() error { return g.err }
+
+// pushError is outcome with git's answer when err carries one.
+func pushError(op string, err, outcome error) error {
+ var g *gitAnswer
+ if !errors.As(err, &g) {
+ return outcome
+ }
+ p := &PushError{Op: op, Answer: g.text, Err: outcome}
+ if op == "push" {
+ p.Refusal = g.refusal
+ }
+ if p.Answer == "" {
+ p.Answer = runnerproto.RedactDetail(g.err.Error(), runnerproto.DetailLimit)
+ }
+ return p
+}
+
+var (
+ pushNonFastForward = regexp.MustCompile(`(?i)\[(?:remote )?rejected\][^\n]*\((?:non-fast-forward|fetch first)\)`)
+ pushRefused = regexp.MustCompile(`(?i)\[remote rejected\]|pre-receive hook declined|protected branch|\bis protected\b|\bGH006\b`)
+)
+
+// pushRefusalOf is the refusal git's output shows: a non-fast-forward
+// before anything else, then the hub's own refusal; "" for neither (a
+// stale lease, a transport failure).
+func pushRefusalOf(out string) string {
+ switch {
+ case pushNonFastForward.MatchString(out):
+ return RefusalNonFastForward
+ case pushRefused.MatchString(out):
+ return RefusalRefused
+ }
+ return ""
+}
+
+// pushAnswer is git's answer, safe to log and report: the rejected ref
+// lines of a porcelain push, then stderr without git's hints; the git
+// password gone (raw and as the Basic header git sends), then every
+// other credential shape, one line, bounded.
+func pushAnswer(stdout, stderr string, remote *workspace.Remote) string {
+ var lines []string
+ for _, l := range strings.Split(stdout, "\n") {
+ if strings.HasPrefix(l, "!") {
+ lines = append(lines, l)
+ }
+ }
+ for _, l := range strings.Split(stderr, "\n") {
+ if l = strings.TrimSpace(l); l != "" && !strings.HasPrefix(l, "hint:") {
+ lines = append(lines, l)
+ }
+ }
+ text := strings.Join(lines, "\n")
+ if remote != nil && len(remote.GitPassword) >= 8 {
+ text = strings.ReplaceAll(text, base64.StdEncoding.EncodeToString([]byte("x:"+remote.GitPassword)), "***")
+ text = strings.ReplaceAll(text, remote.GitPassword, "***")
+ }
+ return runnerproto.RedactDetail(text, runnerproto.DetailLimit)
+}
+
+// capWriter keeps the first n bytes written and drops the rest.
+type capWriter struct {
+ w io.Writer
+ n int
+}
+
+func (c *capWriter) Write(p []byte) (int, error) {
+ if k := min(len(p), c.n); k > 0 {
+ if _, err := c.w.Write(p[:k]); err != nil {
+ return 0, err
+ }
+ c.n -= k
+ }
+ return len(p), nil
+}
diff --git a/internal/runner/forge/push_detail_test.go b/internal/runner/forge/push_detail_test.go
new file mode 100644
index 00000000..d778362b
--- /dev/null
+++ b/internal/runner/forge/push_detail_test.go
@@ -0,0 +1,127 @@
+package forge
+
+import (
+ "context"
+ "encoding/base64"
+ "errors"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/runner/workspace"
+)
+
+// pushSecret is what a hub's hook may echo back: a header and a URL
+// that carry credentials.
+const pushSecret = "Authorization: Bearer s3cr3t-hub-token, see https://agent:s3cr3t-pw@amadan.net/x"
+
+// TestPushBranchKeepsGitsAnswer: a push the remote refuses comes back
+// with git's answer (the rejected ref line and the hub's own words) and
+// what kind of refusal it shows, redacted and bounded; the outcome is
+// as before, so the step's reason does not change.
+func TestPushBranchKeepsGitsAnswer(t *testing.T) {
+ ctx := context.Background()
+
+ // A hook (or a protected branch) refuses it.
+ r := newBranchRig(t)
+ hook := filepath.Join(r.remote, "hooks", "pre-receive")
+ if err := os.WriteFile(hook, []byte("#!/bin/sh\necho 'GL-HOOK-ERR: equipo/tk1-hook is protected. "+pushSecret+"' >&2\nexit 1\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ err := PushBranch(ctx, r.push("equipo/tk1-hook"))
+ var p *PushError
+ if !errors.Is(err, ErrPushUncertain) || !errors.As(err, &p) || p.Op != "push" || p.Refusal != RefusalRefused || PushRefusal(err) != RefusalRefused {
+ t.Fatalf("hook: %v", err)
+ }
+ for _, want := range []string{"[remote rejected] (pre-receive hook declined)", "GL-HOOK-ERR: equipo/tk1-hook is protected.", "Authorization: ***", "https://***@amadan.net/x"} {
+ if !strings.Contains(err.Error(), want) {
+ t.Fatalf("hook: %q lacks %q", err.Error(), want)
+ }
+ }
+ detail := PushDetail(err)
+ if !strings.HasPrefix(detail, "refusal: refused\npush: ") || !strings.Contains(detail, "GL-HOOK-ERR") || !strings.Contains(detail, "pre-receive hook declined") {
+ t.Fatalf("hook detail %q", detail)
+ }
+ if strings.Contains(err.Error()+detail, "s3cr3t") || len(detail) > 500 {
+ t.Fatalf("hook: not redacted or bounded: %q / %q", err.Error(), detail)
+ }
+ os.Remove(hook)
+
+ // The hub keeps its branches fast-forward: a new attempt's commit that
+ // does not descend from the last one is refused as such.
+ r = newBranchRig(t)
+ gitT(t, filepath.Dir(r.remote), nil, "--git-dir="+r.remote, "config", "receive.denyNonFastForwards", "true")
+ if err := PushBranch(ctx, r.push("equipo/tk1-nff")); err != nil {
+ t.Fatal(err)
+ }
+ b := r.push("equipo/tk1-nff")
+ b.Key, b.Commit = "tk1/s1/2", r.commit2
+ err = PushBranch(ctx, b)
+ if !errors.Is(err, ErrPushUncertain) || PushRefusal(err) != RefusalNonFastForward || !strings.Contains(err.Error(), "(non-fast-forward)") || r.head(t, b.Branch) != r.commit {
+ t.Fatalf("non-fast-forward: %v", err)
+ }
+ if detail := PushDetail(err); !strings.HasPrefix(detail, "refusal: non-fast-forward\npush: ") {
+ t.Fatalf("non-fast-forward detail %q", detail)
+ }
+
+ // The branch cannot be read: git's words, no refusal.
+ r = newBranchRig(t)
+ b = r.push("equipo/tk1-gone")
+ b.Remote = func(context.Context) (workspace.Remote, error) {
+ return workspace.Remote{URL: filepath.Join(r.root, "missing.git")}, nil
+ }
+ err = PushBranch(ctx, b)
+ if !errors.As(err, &p) || p.Op != "ls-remote" || p.Refusal != "" || !strings.Contains(err.Error(), "does not appear to be a git repository") {
+ t.Fatalf("unreadable: %v", err)
+ }
+ if detail := PushDetail(err); !strings.HasPrefix(detail, "ls-remote: ") {
+ t.Fatalf("unreadable detail %q", detail)
+ }
+
+ // No lease: the confirmation's words.
+ b = r.push("equipo/tk1-no-lease")
+ b.Key = "tk1/s2/1"
+ b.Confirm = func(context.Context) error { return errors.New("superseded") }
+ if err := PushBranch(ctx, b); !errors.Is(err, ErrPushUncertain) || PushDetail(err) != "error: forge: push outcome unknown: confirming the lease: superseded" {
+ t.Fatalf("no lease: %q", PushDetail(err))
+ }
+}
+
+// TestPushRefusalOf: git's rejected ref lines (porcelain or not) and the
+// hub's words decide the kind; anything else is not classified.
+func TestPushRefusalOf(t *testing.T) {
+ for in, want := range map[string]string{
+ "!\tHEAD:refs/heads/equipo/x\t[rejected] (non-fast-forward)": RefusalNonFastForward,
+ " ! [rejected] HEAD -> equipo/x (fetch first)": RefusalNonFastForward,
+ "!\tHEAD:refs/heads/equipo/x\t[remote rejected] (non-fast-forward)": RefusalNonFastForward,
+ "!\tHEAD:refs/heads/main\t[remote rejected] (pre-receive hook declined)": RefusalRefused,
+ " ! [remote rejected] HEAD -> main (protected branch hook declined)": RefusalRefused,
+ "remote: error: GH006: Protected branch update failed for refs/heads/main.": RefusalRefused,
+ "remote: You are not allowed to push to the default branch; it is protected.": RefusalRefused,
+ "!\tHEAD:refs/heads/equipo/x\t[rejected] (stale info)": "",
+ "fatal: unable to access 'https://amadan.net/x/': The requested URL returned 502": "",
+ } {
+ if got := pushRefusalOf(in); got != want {
+ t.Fatalf("pushRefusalOf(%q) = %q, want %q", in, got, want)
+ }
+ }
+}
+
+// TestPushAnswerRedacts: the git password is never in an answer, raw or
+// as the Basic header git would send, nor any other credential shape;
+// git's hints are dropped and the answer is bounded.
+func TestPushAnswerRedacts(t *testing.T) {
+ // Made at run time, so no scanner takes the fixture for a key.
+ password := strings.Join([]string{"pw", "0123456789"}, "-")
+ basic := base64.StdEncoding.EncodeToString([]byte("x:" + password))
+ remote := &workspace.Remote{URL: "https://amadan.net/oficina/sample", GitPassword: password}
+ stderr := "remote: denied for " + password + " (" + basic + ")\nhint: Updates were rejected\nerror: failed to push some refs to 'https://x:s3cr3t-pw@amadan.net/oficina/sample'\n" + strings.Repeat("word ", 400)
+ got := pushAnswer("To https://amadan.net/oficina/sample\n!\tHEAD:refs/heads/equipo/x\t[remote rejected] (denied)\nDone", stderr, remote)
+ if strings.Contains(got, password) || strings.Contains(got, basic) || strings.Contains(got, "s3cr3t") || strings.Contains(got, "hint:") || strings.Contains(got, "Done") || len(got) > 500 {
+ t.Fatalf("answer %q", got)
+ }
+ if !strings.HasPrefix(got, "! HEAD:refs/heads/equipo/x [remote rejected] (denied) remote: denied for *** (***)") {
+ t.Fatalf("answer %q", got)
+ }
+}
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go
index 45db398c..721733a2 100644
--- a/internal/runner/thin/engineer.go
+++ b/internal/runner/thin/engineer.go
@@ -36,6 +36,10 @@ const (
pushAttempts = 3
)
+// pushBackoff is the wait before the next try of an uncertain push,
+// times the tries so far (tests shorten it).
+var pushBackoff = 3 * time.Second
+
// The runner's commit identity: Equipo made the commit, the person
// decides whether it lands.
const (
@@ -374,7 +378,9 @@ func (e *Engineer) publish(ctx context.Context, r stepRow, rep wire.StepReport)
// and a task branch is never it.
def, err = "main", nil
}
- if err == nil {
+ if err != nil {
+ err = fmt.Errorf("reading the default branch: %w", err)
+ } else {
err = forge.PushBranch(ctx, forge.BranchPush{Root: filepath.Join(e.root(), "publish"), Git: e.O.Runner.GitPath, GitDir: tree.GitDir, Repo: r.Repo, Branch: r.Branch, Default: def, Base: r.Base, Commit: r.Candidate, Key: r.TaskID + "/" + r.key(), Person: r.Person, Owners: e.Owners,
Remote: func(ctx context.Context) (workspace.Remote, error) { return e.Forge.Remote(ctx, r.Repo) },
Confirm: e.confirmFor(r)})
@@ -384,7 +390,7 @@ func (e *Engineer) publish(ctx context.Context, r stepRow, rep wire.StepReport)
}
select {
case <-ctx.Done():
- case <-time.After(time.Duration(i+1) * 3 * time.Second):
+ case <-time.After(time.Duration(i+1) * pushBackoff):
}
}
switch {
@@ -395,8 +401,12 @@ func (e *Engineer) publish(ctx context.Context, r stepRow, rep wire.StepReport)
case errors.Is(err, forge.ErrPushConflict):
rep.State, rep.Reason = wire.StepFailed, "push_conflict"
default:
- e.log("step push", err)
+ e.logPush("step push", err)
rep.State, rep.Reason = wire.StepFailed, "push_failed"
+ // Why it was not pushed, for the person (the stopped step's log
+ // tail): git's answer and its refusal, or the error's words, before
+ // what Engineering's run said.
+ rep.LogTail = clip(strings.TrimSpace(forge.PushDetail(err)+"\n\n"+rep.LogTail), wire.MaxLogTail)
}
return rep
}
@@ -470,6 +480,19 @@ func (e *Engineer) logDetail(msg string, err error) {
}
}
+// logPush is logDetail for a failed push, with the refusal git's answer
+// shows (non-fast-forward, refused) when it shows one.
+func (e *Engineer) logPush(msg string, err error) {
+ if e.O.Logger == nil || err == nil {
+ return
+ }
+ args := []any{"err", runnerproto.RedactDetail(err.Error(), runnerproto.DetailLimit)}
+ if refusal := forge.PushRefusal(err); refusal != "" {
+ args = append(args, "refusal", refusal)
+ }
+ e.O.Logger.Warn(msg, args...)
+}
+
func firstNonEmpty(a, b string) string {
if a != "" {
return a
diff --git a/internal/runner/thin/forge.go b/internal/runner/thin/forge.go
index 73cdd1c8..e950d934 100644
--- a/internal/runner/thin/forge.go
+++ b/internal/runner/thin/forge.go
@@ -8,6 +8,7 @@ import (
"encoding/hex"
"encoding/json"
"errors"
+ "fmt"
"io"
"net/http"
"os"
@@ -533,6 +534,12 @@ func (c *Clones) lsRemote(ctx context.Context, remote workspace.Remote, args ...
for k, v := range env {
cmd.Env = append(cmd.Env, k+"="+v)
}
- cmd.Stderr = io.Discard
- return cmd.Output()
+ // git's own words on a failure (logged redacted, never reported raw).
+ var stderr bytes.Buffer
+ cmd.Stderr = &limitWriter{w: &stderr, n: 2 << 10}
+ out, err := cmd.Output()
+ if err != nil {
+ return nil, fmt.Errorf("ls-remote: %w: %s", err, strings.TrimSpace(stderr.String()))
+ }
+ return out, nil
}
diff --git a/internal/runner/thin/pushdetail_test.go b/internal/runner/thin/pushdetail_test.go
new file mode 100644
index 00000000..570f7558
--- /dev/null
+++ b/internal/runner/thin/pushdetail_test.go
@@ -0,0 +1,75 @@
+package thin
+
+import (
+ "context"
+ "log/slog"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// TestPushFailureKeepsTheHubAnswer: when the hub refuses a step's push
+// (a hook, a protected branch), the runner's log line has git's answer
+// and the refusal, and the step report's log tail (what the task page
+// shows for a stopped step) leads with them, before Engineering's own
+// tail; redacted and bounded in both. The reason is as before.
+func TestPushFailureKeepsTheHubAnswer(t *testing.T) {
+ old := pushBackoff
+ pushBackoff = time.Millisecond
+ t.Cleanup(func() { pushBackoff = old })
+ e, f, r, _ := hubRig(t)
+ logs := &lockedBuffer{}
+ e.O.Logger = slog.New(slog.NewTextHandler(logs, nil))
+ secret := "Authorization: Bearer s3cr3t-hub-token, see https://agent:s3cr3t-pw@amadan.net/x"
+ hook := "#!/bin/sh\necho 'GL-HOOK-ERR: you cannot push to the default branch. " + secret + "' >&2\nexit 1\n"
+ if err := os.WriteFile(filepath.Join(f.dir, "hooks", "pre-receive"), []byte(hook), 0700); err != nil {
+ t.Fatal(err)
+ }
+ // The step's private repository holds a commit on main.
+ r.Specialist, r.StepID, r.Branch = wire.SpecialistEngineering, "s2", "equipo/tk1-another-fix"
+ base := gitOut(t, f.dir, "rev-parse", "main")
+ gitDir := e.tree(r, base).GitDir
+ gitOut(t, filepath.Dir(f.dir), "clone", "-q", "--bare", f.dir, gitDir)
+ tree := gitOut(t, filepath.Dir(f.dir), "--git-dir="+gitDir, "rev-parse", base+"^{tree}")
+ r.Base, r.Candidate = base, gitOut(t, filepath.Dir(f.dir), "--git-dir="+gitDir, "commit-tree", tree, "-p", base, "-m", "another fix")
+
+ rep := e.publish(context.Background(), r, wire.StepReport{LogTail: "Engineering's own tail"})
+ line := string(logs.Bytes())
+ if rep.State != wire.StepFailed || rep.Reason != "push_failed" || rep.Pushed {
+ t.Fatalf("report %+v", rep)
+ }
+ detail, rest, _ := strings.Cut(rep.LogTail, "\n\n")
+ if !strings.HasPrefix(detail, "refusal: refused\npush: ") || !strings.Contains(detail, "[remote rejected] (pre-receive hook declined)") || !strings.Contains(detail, "GL-HOOK-ERR: you cannot push to the default branch.") || rest != "Engineering's own tail" {
+ t.Fatalf("log tail %q", rep.LogTail)
+ }
+ if !strings.Contains(line, `msg="step push"`) || !strings.Contains(line, "refusal=refused") || !strings.Contains(line, "GL-HOOK-ERR: you cannot push to the default branch.") || !strings.Contains(line, "Authorization: ***") {
+ t.Fatalf("log %q", line)
+ }
+ if strings.Contains(rep.LogTail+line, "s3cr3t") || len(detail) > 500 || len(line) > 800 {
+ t.Fatalf("not redacted or bounded: %q / %q", rep.LogTail, line)
+ }
+
+ // The default branch cannot be read: the push is never tried, and the
+ // report and the log say why.
+ before := logs.Len()
+ f.dir = filepath.Join(t.TempDir(), "missing.git")
+ rep = e.publish(context.Background(), r, wire.StepReport{})
+ line = string(logs.Bytes()[before:])
+ if rep.Reason != "push_failed" || !strings.HasPrefix(rep.LogTail, "error: reading the default branch: ls-remote: exit status 128: ") || !strings.Contains(rep.LogTail, "does not appear to be a git repository") || strings.Contains(line, "refusal=") || !strings.Contains(line, "does not appear to be a git repository") {
+ t.Fatalf("unreadable default: %+v %q", rep, line)
+ }
+
+ // The remote cannot be resolved, in words that carry credentials.
+ before = logs.Len()
+ e.Clones.Forge = brokenRemote{f}
+ rep = e.publish(context.Background(), r, wire.StepReport{})
+ line = string(logs.Bytes()[before:])
+ want := "reading the default branch: dial https://***@amadan.net/x: Authorization: *** refused"
+ if rep.Reason != "push_failed" || rep.LogTail != "error: "+want || !strings.Contains(line, want) || strings.Contains(rep.LogTail+line, "s3cr3t") {
+ t.Fatalf("unresolved remote: %+v %q", rep, line)
+ }
+}
diff --git a/internal/runner/thin/relay.go b/internal/runner/thin/relay.go
index b3aa726c..b8f5b746 100644
--- a/internal/runner/thin/relay.go
+++ b/internal/runner/thin/relay.go
@@ -465,7 +465,7 @@ func (e *Engineer) publishWorker(ctx context.Context, p pubRow) (wire.PublishedR
def, err := e.Clones.DefaultBranch(ctx, p.Repo)
if err != nil {
// The hub is unreachable: a failed push, which Retry publishes again.
- e.log("publication default branch", err)
+ e.logDetail("publication default branch", err)
return fail("push_failed")
}
// forge reports any failed confirmation as uncertain: remember why.
@@ -495,7 +495,9 @@ func (e *Engineer) publishWorker(ctx context.Context, p pubRow) (wire.PublishedR
case errors.Is(err, forge.ErrPushConflict):
return fail("push_conflict")
default:
- e.log("publication push", err)
+ // The published report has no log tail (a wire change): the log
+ // line keeps git's answer.
+ e.logPush("publication push", err)
return fail("push_failed")
}
}