Skip to content

fix(runner): show git's reason on a failed clone or push; no false folder_not_granted after a grant - #13

Merged
zeekay merged 3 commits into
mainfrom
job/runner-grants
Nov 27, 2026
Merged

zeekay merged 3 commits into
mainfrom
job/runner-grants

Conversation

@jamessburnss1313-dev

Copy link
Copy Markdown
Contributor

Two fixes from a customer's day with a linked machine (Carbon District problem log, 25 Nov 2026, items 3.7 and 3.8). Two commits, each with a test that fails before it.

1. A failed clone or push hid git's reason (9e9bf98)

Seen: session error workspace setup failed: git clone failed. The real cause, found only with git trace2 on the machine, was Permission denied (publickey).
Root cause: run_git keeps stderr and the clone adds context, but runner/mod.rs formatted the anyhow error with {e}, which prints only the outermost context.
Fix: {e:#} at the workspace-setup and push sites.
Tests: a_failed_clone_reports_gits_reason, a_refused_push_reports_gits_reason (a pre-receive hook refuses; the report now carries its words).
Secrets: the chain adds git's stderr, io errors and key-file paths, never key contents. The reviewer traced the three clone URLs the cloud hands out (coding_lifecycle.go:57, forge.go:353, the grant's SSH remote); none carries userinfo.

2. folder_not_granted for up to 30 s after hanzo link grant (dbadf42)

Seen: the cloud accepted a run 20 s after the grant (routed: true); the runner refused it. The same call two minutes later ran.
Root cause: the runner's granted-folder list is refreshed only by the 30 s beat; execute_folder_run refused from that snapshot.
Fix: a claimed run whose dir is outside the current grants triggers one refresh through the existing sync helper; the unchanged real-path containment check then decides. No timers, no retries, no IPC.
Tests: a_folder_granted_since_the_last_beat_runs, a_folder_still_not_granted_after_the_refresh_is_refused.

Testing

  • cargo test --locked: 381 passed, 0 failed (+ filesize, signals).
  • cargo clippy --locked --all-targets -- -D warnings: clean.
  • cargo fmt --check not run (no rustfmt for the pinned toolchain on the author's machine; main is not rustfmt-clean and CI does not check it).

Not tested

  • A real linked machine end to end.

Follow-ups, not in this PR

  • Customers get this only after hanzo-gen is bumped in hanzoai/cli (Cargo.toml:59, Cargo.lock:972, pinned at 8807647).
  • Pre-existing, found in review: an instantly-empty claim reply makes the claim loop spin with no wait (runner/mod.rs ~426).

Built by one agent, reviewed by a second (which asked for the push test). Nothing merged; production is Zach's call.
Risk: low. How to revert: git revert either commit.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T22:47:48.225898Z
We couldn’t complete this review. Comment @codex review to try again.
dbadf42 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

zeekay commented Nov 27, 2026

Copy link
Copy Markdown
Member

Useful customer fix; current-head CI/CD run 45716235067 reports success, but branch base 8807647 predates current main and automated review failed. Please rebase/requalify; specifically test redaction of tokens, credential-bearing URLs and remote stderr before exposing git error chains to users, and verify grant/revoke authorization is unchanged.

jamessburnss1313-dev and others added 3 commits November 26, 2026 19:24
The error was formatted with {e}, which prints only the outermost anyhow
context, so a failed clone read "git clone failed" and lost git's stderr
(for example Permission denied (publickey)). Print the whole chain with {e:#}
at the workspace setup and finalize (push) sites.

Testing: a_failed_clone_reports_gits_reason and a_refused_push_reports_gits_reason
each fail without the change (git's words missing) and pass with it.
Risk: reports are longer; git's stderr now reaches them. A clone URL carrying a
token in userinfo could be echoed by git; the runner builds no such URL itself.
How to revert: git revert this commit.
… heard

Grants reach the runner only on the 30 s beat, and hanzo link grant signals
nothing, so a folder granted seconds earlier was refused as folder_not_granted
after cloud had already routed the run. When a claimed run's dir is not inside
the current grants, sync once (the helper the 403 path uses), then decide.
The real-path containment check is unchanged.

Testing: a_folder_granted_since_the_last_beat_runs fails without the change
(folder_not_granted) and passes with it; a_folder_still_not_granted_after_the_refresh_is_refused
passes before and after.
Risk: one extra target sync per run naming a folder not yet in the grants; that
beat carries no rate metrics (fresh Sampler).
How to revert: git revert this commit.
@zeekay

zeekay commented Nov 27, 2026

Copy link
Copy Markdown
Member

Rebased onto main (744c720) and added credential/token redaction (redact_git_detail) at 05c1e993:

  • Scrubs URL userinfo (https://***@host), Bearer/Basic tokens, and PAT prefixes (ghp_, ghs_, github_pat_, glpat-, sk-, hk-) before surfacing git clone/push error chains.
  • Verified grant/revoke containment (the_runner_checks_a_claimed_runs_folder_against_the_beat, a_folder_granted_since_the_last_beat_runs, a_folder_still_not_granted_after_the_refresh_is_refused, mid-run revoke termination).
  • cargo test --locked: 388 lib + integration tests passed (filesize clean).
  • cargo clippy --all-targets -- -D warnings: 0 warnings.

@zeekay
zeekay merged commit afe1483 into main Nov 27, 2026
1 check passed
@zeekay
zeekay deleted the job/runner-grants branch November 27, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants