Skip to content

fix(changed): guard the index, which is the tree the sandbox comes from - #13

Merged
Disble merged 1 commit into
mainfrom
fix/gate-guard-reads-the-index
Aug 30, 2026
Merged

Disble merged 1 commit into
mainfrom
fix/gate-guard-reads-the-index

Conversation

@Disble

@Disble Disble commented Aug 30, 2026

Copy link
Copy Markdown
Owner

CI refuted the guard in fifty-one seconds, on the very first run of the gate it
was written to protect:

checking the checkout: ditto: a range scope measures committed bytes,
and this checkout has uncommitted work:
    M devbox.lock

The Devbox install step modifies a tracked lockfile that has nothing to do with
any change, and the gate refused to run at all.

The condition was wrong, not merely strict

The sandbox is git checkout-index --all, so it holds the index. A range
scope names bytes of HEAD. Those agree exactly while the index agrees with
HEAD — which is narrower than a clean worktree.

A worktree modification is never written into the sandbox, so it cannot move a
verdict; refusing it only stops runs that would have been correct. A staged
change is written into it, and running then would mean scoping against one tree
while mutating another — the defect measured at seven of eight verdicts moving,
and silent.

So the check is git diff --cached --name-only, and the method is named for
what it actually asks.

Tests

The public test keeps the refusal. The allow case is pinned in internal/staged
rather than at the top, because allowing it there would run a real release to
prove that a guard did not fire — the first version of this change did exactly
that and took 50 seconds to say so.

Readme, changelog and backlog entry 21 all corrected: they described the wrong
condition too.

CI refuted the guard in fifty-one seconds, on the first run of the gate it was
written to protect. RunChanged demanded a clean worktree; the Devbox install
step modifies devbox.lock, a tracked file with nothing to do with any change,
and the gate refused to run at all.

The condition was wrong, not merely strict. The sandbox is
`git checkout-index --all`, so it holds the INDEX, and a range scope names bytes
of HEAD: the two agree exactly while the index agrees with HEAD. A worktree
modification is never written into the sandbox and therefore cannot move a
verdict. A STAGED one is, and would mean scoping against one tree while
mutating another -- the defect measured at seven of eight verdicts moving.

So the check is `git diff --cached --name-only`, and it is named for what it
actually asks. The public test keeps the refusal; the allow case is pinned in
internal/staged rather than at the top, because allowing it there would run a
real release to prove a guard did not fire.
@Disble Disble added the bug Something isn't working label Aug 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

@Disble
Disble merged commit 4f7235a into main Aug 30, 2026
8 checks passed
@Disble
Disble deleted the fix/gate-guard-reads-the-index branch August 30, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant