Repository navigation
fix: a glob that matches nothing, and a worktree guard that would have deleted live work - #716
Merged
Merged
Conversation
…ty.yaml Nine tracked files told the reader that `er-entity gen` and `er-entity verify` work from `entities/*.yaml`. That glob expands to zero files: every declaration is `entities/<name>/entity.yaml`, 49 of them. Anyone who trusted the literal got an empty expansion and no error, in CLAUDE.md, CONTRIBUTING.md, the Makefile comment, rust.yml's `entities` job comment, the design doc's layer diagram and its CLI block, the eslint ignore comment, and the generated crate's manifest header. It was shorthand everywhere rather than a typo in one place, which is why it survived: no single site looked wrong, and nothing executes a comment. The decision to rewrite all nine rather than leave them is deliberate — a path in prose that resolves to nothing is the same defect as a stale count, and this repo does not keep those. Each file was rewritten with its match count asserted before and after (9 replaced, 0 remaining) rather than by a blind pass over the tree. Verified beyond the grep, because this touches four languages' worth of comment syntax: `make -n entities-check` still prints its recipe, rust.yml still loads as YAML with 16 jobs, `er-entities/Cargo.toml` still parses as TOML, `frontend/eslint.config.mjs` passes `node --check`, the mermaid fences are still balanced with the label intact, and `skills-check all` is green (CLAUDE.md is a splice target, so an edit outside its generated block has to stay outside it). One instance is deliberately left: `rust-conventions/evals.md` is fixed on the branch for #703 and touching it here would conflict. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…k claim was wrong Two claims in the worktree procedure did not survive being measured against a clone with 19 worktrees open. **`lsof -a -p <pid> -d cwd` does not find a live session.** It is proof of attachment when it hits and proves nothing when it misses, because the dominant pattern here is a session whose cwd is the PRIMARY checkout driving its worktree with `git -C <path>` — no descriptor in that directory, nothing for `lsof` to see. Measured: 15 of 19 worktrees had a commit land in the previous 22 minutes while only 7 were any process's cwd. One committed 12 seconds before the audit evaluated it as unattached, and another moved its HEAD between two commands of the same run. A session following the old procedure literally would have deleted work in progress. What catches those is local git activity — the per-worktree `index` and `logs/HEAD` mtime — plus HEAD resampled at the end of the audit. **"Each worktree carries its own rust/target, at tens of gigabytes" is false** as a general claim, and it was the stated reason the prune is non-negotiable. A worktree only grows a target once something in it compiles; a skills or docs session that never runs `make check` stays near a gigabyte. Measured: 83GB across all 19, concentrated in a single 24GB outlier, most carrying no target at all — while the primary checkout's own target was 132GB, larger than every worktree combined. The worktree count is a poor proxy for the disk problem. `scripts/worktree-audit.sh` turns the four guards into one read-only command. It prints KEEP with reasons or REMOVABLE with the removal line, and never removes anything: a wrong removal costs another session's unpushed work, which is not a cost a script should be allowed to pay alone. Three things learned building it, each now a comment at the site: - A plain `git status` REFRESHES THE INDEX, so the dirty check overwrote the mtime the activity check then read, stamping every worktree "active 0m ago". `git --no-optional-locks status` is the fix. The audit was perturbing exactly what it measured. - The age of the commit HEAD points at is not liveness. A worktree cut from a week-old commit is brand new; one cut from a commit that landed a minute ago may be abandoned. - `/usr/bin/env bash` on this machine is 3.2.57, where `mapfile`, `EPOCHSECONDS` and `declare -A` are runtime failures that `bash -n` does not catch. No other script here uses them either. Verified by discrimination, not just by it running: a synthetic worktree at the merged #692 squash commit — clean, backdated activity — is reported REMOVABLE with its removal command, while all 19 live worktrees report KEEP with specific reasons. Deriving the primary checkout from `--git-common-dir` rather than the script's own location was needed for that: run from inside a worktree, the earlier version excluded itself and offered the primary checkout for removal. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The two items I'd left as "worth a decision, not a drive-by". Both turned out to
be worse than the summary implied, and the second one inverts the premise.
1.
entities/*.yamlmatches zero files (1247499c)Nine tracked files told the reader that
er-entity gen/verifywork fromentities/*.yaml. The layout isentities/<name>/entity.yaml, 49 of them, sothat glob expands to nothing and does it silently: CLAUDE.md, CONTRIBUTING.md
(×2), the Makefile comment,
rust.yml'sentitiesjob comment, the designdoc's layer diagram and CLI block, the eslint ignore comment, and the generated
crate's manifest header.
It survived because it was shorthand everywhere rather than a typo somewhere —
no single site looked wrong, and nothing executes a comment. Rewritten with each
file's match count asserted before and after (9 replaced, 0 remaining) rather
than a blind pass.
This is the commit that costs the full gates, which is the thing worth
deciding and the reason it was not a drive-by. Verified locally across all four
comment syntaxes first:
make -n entities-checkstill prints its recipe,rust.ymlstill loads as YAML with 16 jobs, the manifest still parses as TOML,eslint.config.mjspassesnode --check, the mermaid fences stay balanced, andskills-check allis green (CLAUDE.md is a splice target, so the edit had tostay outside its generated block).
One instance is deliberately left alone:
rust-conventions/evals.mdis fixed on#703 and touching it here would conflict.
2. The worktree guard would have deleted work in progress (
0c00f67c)I reported the prune as blocked by my own caution. It was worse than that — the
documented guard is wrong, and following it literally destroys unpushed work.
lsof -a -p <pid> -d cwddoes not find a live session. It is proof ofattachment when it hits and proves nothing when it misses, because the dominant
pattern here is a session whose cwd is the primary checkout driving its
worktree via
git -C. No descriptor in that directory, nothing to see.Measured with 19 worktrees open: 15 had a commit land in the previous 22
minutes; only 7 were any process's cwd. One committed 12 seconds before the
audit evaluated it as unattached; another moved HEAD between two commands of the
same run.
And the stated justification for pruning was false. "Each worktree carries
its own
rust/target, at tens of gigabytes" is only true after a worktreecompiles; a skills session that never runs
make checkstays near a gigabyte.Measured: 83GB across all 19, concentrated in one 24GB outlier, most with no
targetat all — while the primary checkout's owntargetis 132GB, largerthan every worktree combined. The worktree count is a poor proxy for the disk
problem, and the prune ritual targets the smaller half.
scripts/worktree-audit.shmakes the four real guards one read-only command. Itprints KEEP with reasons or REMOVABLE with the removal line, and never removes
anything — a wrong removal costs another session's unpushed work, which is not a
cost a script should pay alone.
Three bugs found while building it, each now a comment at the site:
git statusrefreshes the index, so the dirty check overwrote themtime the activity check then read, stamping every worktree "active 0m ago".
The audit was perturbing exactly what it measured.
git --no-optional-locks statusfixes it.a week-old commit is brand new; one cut from a commit that landed a minute ago
may be abandoned.
/usr/bin/env bashhere is 3.2.57, wheremapfile,EPOCHSECONDSanddeclare -Aare runtime failuresbash -ndoes not catch. I had used allthree; no other script here does.
Verified by discrimination rather than by it merely running: a synthetic
worktree at the merged #692 squash commit — clean, activity backdated — reports
REMOVABLE with its removal command, while all 19 live worktrees report KEEP with
specific reasons. Deriving the primary checkout from
--git-common-dirwasneeded for that: run from inside a worktree, the first version excluded itself
and offered the primary checkout up for removal.
Outcome on the original ask
Nothing was pruned, and that is the correct result — the audit says so with
a reason per worktree, rather than me declining. The actionable disk finding is
the primary checkout's 132GB
target, which I did not touch: 13 sessions havethat directory as cwd and cleaning it makes every one of their next builds cold.
That is your call, not a drive-by either.
🤖 Generated with Claude Code