Skip to content

conformance: cmd/specpin — the ruby/spec corpus pinned durably, its commit read back, nothing deleted (#857) - #963

Merged
tannevaled merged 1 commit into
mainfrom
corpus-pinned-durably
Nov 21, 2026
Merged

tannevaled merged 1 commit into
mainfrom
corpus-pinned-durably

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The corpus is pinned in a durable place, its commit is read back, and nothing is ever deleted

run.sh's corpus block had three defects (#857):

before now
where /tmp/rubyspec-corpus — purged by macOS, emptied at boot by most Linux os.UserCacheDir()/rbgo/rubyspec-corpus
which commit an existing cache reused unchecked; the log printed @ $SPEC_SHA, the constant moved to the commit, then read back from git; the log prints what git says
deletion rm -rf "$CACHE" whenever $CACHE/language was absent — CACHE=$HOME met that never; a non-empty directory that is not a checkout of its own is refused

cmd/specpin replaces the block; run.sh calls it and uses the directory it prints.

⛔ A fourth defect, found by the first end-to-end run

SPECDIR pointed at a scratch directory that happened to be a git repository of its own, and specpin went straight to fetch. It failed only because that repository had no origin. A checkout of its own is not a clone of ruby/spec: with a remote that served the commit, fetch and checkout --force would both have succeeded and discarded the repository's uncommitted work.

A checkout is now moved only when remote.origin.url is -url. It is read raw from the config, not through remote get-url, because get-url applies the host's insteadOf rewrites and would refuse a clone specpin made itself. A tree that is already at the commit and has ruby/spec's layout is still used as is, offline: the commit identifies the content.

specpin: …/_conform is at another commit and its origin is "", not https://github.com/ruby/spec; refusing to fetch into it or check it out

The test for that guard first passed with the guard deleted

Its fork was a path with nothing at it. The fetch therefore failed on its own, and the fetch's message contained the very path the assertion was looking for. The fork is now a bare clone that holds the commit:

guard TestACheckoutOfAnotherRemoteIsNeitherFetchedIntoNorMoved
neutralised (false && …) FAIL — "pin moved a checkout whose origin is not -url"
restored PASS, and the same clone with its origin put back is moved

Measured

  • mutsweep over the package: 11 refusals, 3 caught, 0 survived. It could not mutate 8 of them, because deleting the if leaves a variable unused. It does not see the origin guard at all (an if x, _ := …; cond form), which is why that guard was mutated by hand above.
  • Against the real ruby/spec: a clone into ~/Library/Caches/rbgo/rubyspec-corpus, printing corpus: … @ 87b1631992bd00cf0c4934474766d54dad088191.
  • go test ./scripts/conformance/rubyspec/... green; the root tests that read run.sh and the README (TestASpecCannotDictateItsOwnRecordedPassCount, TestShellCodeHasSeesCodeAndNotComments, TestReadmeConformance*) green.

Not in this PR

run.sh still defaults RBGO to /tmp/rbgo-rubyspec and builds only if [ ! -x "$RBGO" ]. A binary left there by an older checkout is therefore reused, so the sweep measures that older interpreter. That is a separate defect, filed separately.

Closes #857

🤖 Generated with Claude Code

…its commit back (#857)

run.sh's corpus block had three defects:

  1. CACHE defaulted to /tmp/rubyspec-corpus, which macOS purges and
     most Linux distributions empty at boot.
  2. An existing cache was reused WITHOUT checking its commit, and the
     log printed `corpus: $SPECDIR @ $SPEC_SHA` -- the constant. A cache
     from another SPEC_SHA reads as a sweep with files added or missing,
     which is what cmd/ratchet calls a regression.
  3. `rm -rf "$CACHE"` ran whenever "$CACHE/language" was absent --
     true of almost every directory. CACHE=$HOME met it.

cmd/specpin replaces the block. The default directory is
os.UserCacheDir()/rbgo/rubyspec-corpus; the commit is read back from git
after every path that can move it; a directory is never deleted -- one
that is neither empty nor a checkout of its own is refused.

AND A FOURTH, found by the first end-to-end run of the new wiring:
SPECDIR pointed at a scratch directory that happened to be a git
repository of its own, and specpin went straight to `fetch`. It failed
only because that repository had no origin. "A checkout of its own" is
not "a clone of ruby/spec": with a remote that served the commit, the
fetch and `checkout --force` would both have succeeded and discarded its
uncommitted work. A checkout is now MOVED only when remote.origin.url is
-url (read raw from the config, not through `remote get-url`, which
applies insteadOf rewrites). A tree already at the commit and shaped like
ruby/spec is still used as is, offline: the commit is the content.

The test for that guard first PASSED with the guard deleted: its fork
was a path with nothing at it, so the fetch failed on its own and quoted
the path the assertion looked for. The fork is now a bare clone that
holds the commit; with the guard neutralised the test is red ("pin moved
a checkout whose origin is not -url"), restored it is green.

mutsweep over the package: 11 refusals, 3 caught, 0 survived, 8 it
cannot mutate (deleting the `if` leaves a variable unused). It does not
see the origin guard at all (an `if x, _ := ...; cond` form), hence the
hand mutation above.

Measured: specpin against the real ruby/spec at the pinned SHA cloned
into ~/Library/Caches/rbgo/rubyspec-corpus and printed
`corpus: ... @ 87b1631992bd00cf0c4934474766d54dad088191`.

README and the conformance README name the new default, say that a
SPECDIR clone is checked out with --force, and no longer cite
/tmp/rubyspec-corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

conformance: the spec corpus cache defaults to /tmp, which a reboot empties

1 participant