Skip to content

test(switch): drop duplicate configure_mock_glab_env helper - #3707

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-30737194867-switch-dedup
Aug 2, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-30737194867-switch-dedup

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Nightly sweep finding (survey of tests/integration_tests/switch.rs): the configure_mock_glab_env helper was a functional duplicate of configure_mock_cli_env — identical WORKTRUNK_TEST_MOCK_CONFIG_DIR env setup and the same case-insensitive PATH-prepend logic, differing only in comments. It existed solely for the GitLab MR tests.

This PR removes the duplicate and points its 16 call sites at configure_mock_cli_env, so the mock-PATH setup has a single home. Net −24 lines with no behavior change.

Verified with the full GitLab/gitea/azure/MR switch suites (cargo test --test integration -- switch::…_mr switch::test_switch_pr_gitea switch::test_switch_pr_azure) — all green — and a clean --no-run compile (no unused-function warning).

No new regression test: this is a pure test-helper consolidation covered by the existing tests that call it.

`configure_mock_glab_env` was byte-for-byte identical to
`configure_mock_cli_env` (same WORKTRUNK_TEST_MOCK_CONFIG_DIR env and
case-insensitive PATH-prepend logic) — the only difference was the
comments. Removed the duplicate and pointed its 16 call sites at
`configure_mock_cli_env`, so the mock-PATH setup lives in one place.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Aug 2, 2026
@max-sixty
max-sixty merged commit cbc7522 into main Aug 2, 2026
37 of 47 checks passed
@max-sixty
max-sixty deleted the nightly/clean-30737194867-switch-dedup branch August 2, 2026 16:30
max-sixty pushed a commit that referenced this pull request Aug 3, 2026
…ion (#3722)

Daily review of the 2026-08-02T08:51Z → 2026-08-03T08:51Z tend window. 8
runs failed, all with the same root cause, and one of them left a PR
permanently un-reviewed. This adds the recovery step that was missing.

## What happened

Every failure in the window was `claude -p exited non-zero (exit=1)` at
the harness step, across three workflows — `tend-notifications` ×5,
`tend-review` ×2, `tend-nightly` ×1. The session logs give one cause for
all eight:

```
{"model":"<synthetic>","stop":"stop_sequence",
 "content":["You've hit your session limit · resets 8:30am (UTC)"]}
```

Two 5-hour subscription windows were exhausted (resets at 03:10Z and
08:30Z). That is quota, not a bug — no fix PR is warranted for the
exhaustion itself.

The consequence is the problem. The harness recorded all eight in the
`tend-outage` issue
[#3715](#3715), one row
each with the run link and the triggering `#N`, and then nothing re-ran
them. `tend-review` fires only on `pull_request_target`, so a review
that dies at turn 1 never retries.
[#3712](#3712) recovered by
luck — a later push re-triggered it.
[#3721](#3721) did not: at
analysis time it was the only non-bot open PR in the repo with zero
`worktrunk-bot` reviews, its head unchanged since 06:06Z, and nothing
was going to re-trigger it. I re-ran
[30789110268](https://github.com/max-sixty/worktrunk/actions/runs/30789110268)
manually (attempt 2) to unblock it.

## Why codify it

This isn't a one-off. "Bot temporarily unavailable" issues recur about
weekly — [#3715](#3715),
[#3632](#3632),
[#3586](#3586),
[#3260](#3260),
[#3153](#3153), and ~15
more back to April. The failure is structural: a rate-limited run always
dies at turn 1, always leaves its trigger unserviced, and there is no
decision point where the bot could have done better. It's also invisible
— the PR just sits there looking reviewed-by-nobody, and the last two
review windows both recorded "0 failed runs", so the log gave no warning
either.

## The change

One section in `running-tend`, placed next to the existing CI-fix
classification guidance:

- Drain the open `tend-outage` issue during the daily `review-runs`
sweep and extract the stranded run IDs and triggers.
- Re-run only event-triggered runs — `tend-nightly` and
`tend-notifications` recover on their next cron tick.
- Check the PR still lacks the work before re-running, so a trigger that
already recovered via a later push doesn't burn quota twice.
- Diagnose the cause from the session log rather than the issue body,
which says only "The bot failed to process a request".

Both recipes were run against this window's data before being written
down: the outage-issue drain returns all 8 run IDs plus `#3712` /
`#3721`, and the session-log `jq` returns the session-limit line from
the downloaded artifact.

<details><summary>Window detail</summary>

**Spend**: $49.74 API-list across 52 token-bearing runs (7.7K in /
304.6K out / 2.5M cache-create / 31.2M cache-read). Per workflow:
`tend-review` $35.16 (29 runs, 15 distinct PRs), `tend-weekly` $4.64
(1), `tend-notifications` $4.34 (10), `tend-mention` $5.60 (11). Down
from $86.04 the prior window, partly because eight runs died at turn 1
for $0. No waste outlier — the review spend tracks real PR throughput.

**Outcomes**: 3 bot PRs merged
([#3706](#3706),
[#3707](#3707),
[#3708](#3708)), 0 closed
without merge, 0 maintainer corrective comments. `tend-nightly`
[30793479820](https://github.com/max-sixty/worktrunk/actions/runs/30793479820)
died at turn 1, so this window's nightly sweep produced nothing — it
recovers on tomorrow's cron. No job ran long (max 4 min among failures;
nothing near the 360-min cap).

**Notifications cadence checked, not a problem**: `*/15` gives ~36
runs/day, but only 10 reached the harness — the workflow's pre-Claude
notification gate exits the rest before any token spend. ~6 substantive
runs/day at ~$0.87. Not the quota driver.

</details>

---------

Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants