Skip to content

perf(loop): cut the four fixed costs every run pays - #62

Merged
Ardnived merged 6 commits into
mainfrom
claude/perf-run-speed
Sep 7, 2026
Merged

Ardnived merged 6 commits into
mainfrom
claude/perf-run-speed

Conversation

@Ardnived

@Ardnived Ardnived commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Four of the six findings from a timing audit of sydevs-work-hourly and sydevs-survey-nightly — 16 run sessions, three transcripts read end to end. Every figure below is measured from a run log, not estimated.

The two findings left out are the CI watch and the webhook triggers. Both are bigger, and both change what a run decides, not what it spends. They follow in a second PR.

Why these ship together

Each is a fixed cost every run pays, none of them changes a rule about what work to pick, and each commit reverts on its own. Naming the failure each one prevents:

Commit Failure it prevents
10a3ac3 executable budget.mjs Both skills document ${CLAUDE_PLUGIN_ROOT}/lib/budget.mjs with no interpreter. At -rw-r--r-- that line returns Permission denied, and every run pays a turn retrying it with node. Mode only.
cfb6518 --fit On 2026-09-07 the 17:03 run spent thirteen budget re-checks between 17:38:45 and 17:49:38 shedding 1,557 characters, converged at 3,999/4,000, then broke the same body on a timestamp edit and spent four more. The 15:04 run gave 1m43s of a 12-minute session to five rewrites.
f78c348 the wait idiom The 17:03 run issued sleep 200; echo done in the foreground, the hook refused it, and it retried backgrounded — then left five overlapping waiters alive at once.
fe1f082 two-stage census Five list_issues calls at 8–29 KB each fire every run, including on repos no search named. Four runs that day (12:05–15:04) stopped at wipCapPerRepo with nothing to start, and each paid for all five.
3d0fce6 worktree on its final branch ExitWorktree refused with "15 commits on worktree-claude+feat-lecture-user-choices" — a branch git branch -vv did not list, because the run had renamed it to push. Proving the leftover directory safe to delete took seven more calls. The journal records this tool refusing twice.
515b9ee version bump The installed plugin caches by version. Four skills changed here.

No ceiling change

loop-config.json is untouched, so the hard split holds. FIT_RESERVE (200 characters of headroom) is a script constant with a --reserve override, not a writing.budgets key, for exactly that reason. Moving it into config is a value-only follow-up if you want it tunable.

What --fit will and will not cut

It drops the oldest 📄 Did lines, which is the cut order journal/SKILL.md already fixed, and takes the heading with them when the section empties — also already required. It never touches ⚠️ Failed, ⏭️ Ceiling, 🧭 Friction or the run table. It exits 1 only when dropping every 📄 Did line still leaves the body over, which is the one case a run must judge for itself.

--kind mode is unchanged, since both skills document it.

Verification

  • claude plugin validate ./workflow --strict — passed.
  • rule-delta.mjs --base origin/main workflow/skills — 57 → 58 directives, one added (Never pass discard_changes), none removed.
  • ste-lint.py on the three changed skills — 21 violations, all on pre-existing lines; no added line is flagged.
  • --fit exercised against synthetic journal bodies at 3.6 KB, 7.3 KB and 18.9 KB: fits to 3,636/4,000 in one call each, keeps every ⚠️/⏭️/🧭 line and all three table rows, and returns exit 1 with the shortfall when an oversized 🧭 Friction section makes the body unfittable.

What is not fixed here

.claude/worktrees/ is gitignored only in this repo, so the stop hook flags it as untracked at the end of every implementation run in the other four. That fix cannot live in this PR — one PR per repo. Four one-line PRs follow.

Ardnived and others added 6 commits September 7, 2026 12:02
`preflight/SKILL.md` and `journal/SKILL.md` both document the invocation as
`${CLAUDE_PLUGIN_ROOT}/lib/budget.mjs`, with no interpreter. The file shipped
`-rw-r--r--`, so that line fails with `Permission denied` and every run pays a
turn learning to retry it with `node`. The 2026-09-07 15:04 run lost four
checks to it at once, one per review reply.

Mode only. No content change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`check()` answers over or under and nothing else, so a run that went over
regenerated the whole body, re-checked, and repeated. On 2026-09-07 the 17:03
run did that thirteen times between 17:38:45 and 17:49:38 to shed 1,557
characters. It converged at 3,999 of 4,000, then wrote a fresher `Last:`
timestamp into the same body and spent four more re-checks. The 15:04 run,
twelve minutes long in total, spent 1 minute 43 on five rewrites of the same
shape.

Every one of those rewrites applied a rule already written down and already
fixed: drop the oldest `Did` lines first, never cut a failure. So `--fit`
applies it once. The section is the only thing it touches — a failure, a
ceiling, a friction line and the run table all survive, and the heading goes
when the section empties, which the skill already required.

`--fit` writes the fitted body to stdout and its verdict to stderr, so a
redirect never swallows the report. It exits 1 only when dropping every `Did`
line still leaves the body over, which is the one case a run must judge.
`--kind` mode is unchanged, since both skills document it.

`FIT_RESERVE` is 200, and it is a script constant rather than a
`loop-config.json` value so this ships without a ceiling change beside it. A
body fitted to the last character breaks on the next edit, and the next edit
is a timestamp the journal step always writes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… blocked

A run learns this by failing. On 2026-09-07 the 17:03 run issued
`sleep 200; echo done` in the foreground, the bash hook refused it, and the run
retried it backgrounded. That is one blocked call per run that waits.

The same run then left five overlapping waiters alive at once — three
background sleeps and two `until` loops — and each one notified separately.
So the rule names the count as well as the form.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Fields are readable but not searchable, so the census fetches a whole repo's
issues to see `Stage` at all. That call is unavoidable. Making it five times a
run is not.

The searches above it already name every repo holding a candidate. A repo none
of them named has no issue to attach a field to, so its response — 8 to 29 KB,
measured on 2026-09-07 — is read, carried through the rest of the run's
context, and used for nothing. Four consecutive runs that day, 12:05 to 15:04,
stopped at `wipCapPerRepo` with no work to start, and each paid for all five.

Nothing downstream loses data. `list_issues` only attaches fields to issues the
searches already returned, and the WIP gate counts PRs from the PR search.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…refuses

`EnterWorktree` names its own branch `worktree-<name>`. A cloud session can
only push to `claude/*`, so the run renames it, and `ExitWorktree` then holds
bookkeeping for a branch that no longer exists.

On 2026-09-07 the 17:03 run hit exactly that: `ExitWorktree` refused with "15
commits on `worktree-claude+feat-lecture-user-choices`", a name `git branch -vv`
did not list. The run kept the worktree rather than force a destructive
removal with no human present, the stop hook then flagged the leftover
directory as untracked, and proving it safe to delete took seven more calls.
The journal records the same tool refusing twice.

So step 6 creates the worktree with `git worktree add -b claude/<type>-<slug>`
and enters it by path, which the tool supports and which never renames
anything. Step 12 removes it with `git worktree remove`, since `ExitWorktree`
does not remove a worktree entered by path. `discard_changes` stays forbidden:
the refusal it silences is the one guard against dropping unpushed work.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The installed plugin caches by `version`, so an unchanged string keeps the old
skills however far `main` has moved. Four skills changed here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Ardnived
Ardnived force-pushed the claude/perf-run-speed branch from 515b9ee to c3e3772 Compare September 7, 2026 19:02
@Ardnived
Ardnived merged commit f1b6e39 into main Sep 7, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in SYDevelopers Technical Roadmap Sep 7, 2026
@Ardnived
Ardnived deleted the claude/perf-run-speed branch September 7, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant