Skip to content

fix(proxy): put the mitmproxy cache warm on the shared retry window - #912

Closed
tend-agent wants to merge 1 commit into
fix/issue-909from
fix/issue-911
Closed

tend-agent wants to merge 1 commit into
fix/issue-909from
fix/issue-911

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

lib/retry.sh covers three pre-agent third-party reaches. There is a fourth: proxy/setup-sandbox.sh warms the uvx cache before backgrounding the proxy, and on a cache miss that resolves and downloads mitmproxy from PyPI. The script runs under set -euo pipefail, and its step — Set up credential-isolation sandbox — sits three steps ahead of Run Claude, so a PyPI blip there loses the whole run having done none of the work the trigger asked for.

The miss is scheduled rather than rare: the actions/cache key is version-scoped (tend-mitmproxy-${{ runner.os }}-${{ inputs.mitmproxy_version }}), so every mitmproxy_version bump misses on each workflow's first run — which is exactly when a lost run is most expensive, since it reddens the weekly bump PR that carries the security-relevant pin.

Solution

Source the shared lib from setup-sandbox.sh and wrap the warm in retry_install. The source sits up top, next to the env checks, so a wrong path fails before the user creation and the workspace chown rather than mid-setup.

Stacked on #910 — the lib it sources lands there.

The two questions #911 left open

Is 60s enough for a cold mitmproxy resolve? Yes, with room to spare. The ~20s resolve figure in claude/action.yaml was undated and is now wrong. Measured on a GitHub-hosted runner (this triage job), 2026-08-09, with uv 0.12.3 and the pinned mitmproxy==12.2.3:

elapsed
cold UV_CACHE_DIR (43 packages, ~100MB downloaded) 2.28 / 2.26 / 2.27 / 2.24 s
warmed cache 0.516 / 0.514 / 0.515 s

So no third TIMEOUT parameter is needed — the case #909 raised and #910 declined stays declined. This PR also corrects the stale figure in the action comment, keeping the cache's real justification (not re-pulling ~100MB from PyPI on every run) rather than the seconds.

Does the backgrounded mitmdump need its own retry? No — retrying the warm already covers it. The launch shares UV_CACHE_DIR, and a cache warmed by this line serves the same --from invocation with no network at all:

$ UV_CACHE_DIR=$D uvx --from 'mitmproxy==12.2.3' mitmdump --version   # warm
$ UV_CACHE_DIR=$D uvx --offline --from 'mitmproxy==12.2.3' mitmdump --version
Mitmproxy: 12.2.3

Once the warm succeeds, PyPI is off the launch path, so the nohup-plus-readiness-wait shape never has to be retried. That's recorded in the comment at the warm.

Testing

Two tests in generator/tests/test_shared_steps.py, both failing before the change:

  • test_setup_sandbox_resolves_the_shared_retry_window runs the script's own . "${ACTION_PATH}/…" line (matched by content, not position) with ACTION_PATH set the way the action sets it, and asserts retry_install becomes a defined function. A path that doesn't resolve wouldn't degrade to an unretried warm — under set -euo pipefail it loses every run, not just the ones that hit a blip.
  • test_setup_sandbox_warms_the_mitmproxy_cache_through_the_window asserts the warm is an argument to retry_install rather than a bare command.

The second is a call-site assertion rather than the behavioural suite the three installers get. setup-sandbox.sh creates the sandbox user, chowns the workspace and installs a CA before reaching the warm, so faking a path to that line would assert more about the fakes than about the script; what the window itself does is already covered by the installer suites. Flagging the asymmetry rather than hiding it.

pre-commit run (shellcheck, ruff, actionlint) and the full 393-test generator suite pass.


Closes #911 — automated triage

max-sixty pushed a commit that referenced this pull request Aug 11, 2026
…will convert (#914)

## Problem

Filing an issue in this repo is not a note to a maintainer —
`tend-triage` fires on `issues`. Twice in 66 minutes this morning a run
filed an issue describing a fix it had already fully scoped, and triage
then re-derived that fix from the issue body and opened the PR:

| Issue filed | Triage boots | Turns / cost | PR opened |
|---|---|---|---|
| [#909](#909) 07:18:53Z |
[31300864191](https://github.com/max-sixty/tend/actions/runs/31300864191)
07:18:56Z | 64 / $4.08 |
[#910](#910) `fix/issue-909`
07:25:17Z |
| [#911](#911) 07:39:37Z |
[31301666194](https://github.com/max-sixty/tend/actions/runs/31301666194)
07:39:40Z | 58 / $4.20 |
[#912](#912) `fix/issue-911`
07:49:37Z |

Three seconds from issue to triage boot in both cases. Neither issue was
under-specified: #909 named `codex/action.yaml:120-124` and proposed
extracting to `shared/steps/install-codex-cli.sh` sourcing
`lib/retry.sh`; #911 named `proxy/setup-sandbox.sh:319` and proposed the
same treatment. Both PRs implemented exactly the proposal. Triage's own
session log confirms the conversion — run 31300864191's artifact is
`claude-session-logs-n909`, and it ran `gh pr create --head
fix/issue-909`, classifying the reporter as "the bot's own review of
#908".

So the issue bought nothing and cost $8.28 of agent time plus two
threads. The filing run could have opened both PRs itself.

<details><summary>Wider context — the cascade this sat inside</summary>

A single transient CDN 403 lost one matrix leg of `review-reviewers` run
[31297986524](https://github.com/max-sixty/tend/actions/runs/31297986524)
at 06:03Z (`curl: (22) ... 403`, three attempts inside 15.7 s, the other
four legs installing the same version from the same runner at the same
moment succeeded). Between 06:29Z and 07:56Z that produced #906, #907,
#908, #909, #910, #911 and #912 — five stacked PRs and two issues, none
merged, across ~14 agent runs and roughly $30 at list prices.

The engineering is sound and correctly atomic; this PR does not argue
with any of it. Only the two issue hops are pure overhead, and they are
the part with a mechanical fix.

</details>

## Solution

A short section in `running-in-ci` — the skill every workflow loads —
stating that an issue in this repo is picked up by triage, so a fix you
can already scope should be opened as a PR in the same run. The escape
hatches stay: too large or ambiguous to fix, needs a maintainer
decision, or verification is out of reach from CI.

This generalizes a rule that already exists but only in two skills:
`review-runs` ("Issue (fallback): Only for problems too large or
ambiguous to fix directly") and `review-reviewers` carry it, so the runs
that have it don't do this. The runs that did — a `tend-review` session
and a `tend-mention` session — load neither.

## Gate assessment

- **Evidence level**: High — 2 occurrences this window, and the
self-amplifying-output family has been recorded in prior windows
(2026-08-04: review→fix ping-pong over five rounds; two bot PRs seven
minutes apart on one root cause).
- **Structural**: yes for the costly half. The bot's choice to file
rather than fix is stochastic, but once an issue exists the triage
conversion has no decision point — it fires on the `issues` event every
time.
- **Change type**: targeted fix (one short section), normal evidence
bar.
- **Both gates**: pass.

Found by `/tend-ci-runner:review-runs` on run
[31302531474](https://github.com/max-sixty/tend/actions/runs/31302531474).

---------

Co-authored-by: tend-agent <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner

Closing with #906 — the reason is there.

This was written by Claude Code on behalf of max-sixty

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