Repository navigation
refactor(tools): simplify the lockfile runner - #351
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
count-patchula | acc1f82 | Commit Preview URL Branch Preview URL |
Nov 22 2026, 07:47 PM |
This was referenced Nov 22, 2026
- tool() hides a credentialed run's output itself and reads refusals through Invocation::refused; held_tool and refusable_tool are gone, and credentials::Held carries a run's scopes and secrets. - One restore-on-drop guard (context::Replaced) for transient pins and sanitized settings files, keeping the pin rule: a file is forgotten only once written back. - Node manifest dependencies compare as JSON values, not canonical text. - validate_targets reads Cargo.lock through cargo::crates_io_entries. - Drop the GOFLAGS -modcacherw merge: eviction makes a partition writable before removing it. - Drop the tool usage mutex: the per-open flock on the usage lock and the exclusive store lock already serialise writers. - A cache partition is public only when the run reads at least one file that steers its ecosystem and every such file decided public-only; Terraform, APM, nix and actions.lock pass the run's verdict. - Drop Tool::versions: a run resolves and checks only its own tools' pins. gh-actions-lock installs as Install::Fixed, outside them. - mise.rs reads declarations with one grammar (request_list), which now takes a table whose version is an array. - Per tool@version install locks in tool() replace the nix-only one. - prewarm and tool() share hold_store; checkout_paths replaces two chunked checkout loops. - actions.lock output is masked with patchula_process::redact.
…sive - Install locks are flock files per tool@version under the tool store, taken in sorted order before the store lock, so runners of different installations and separate processes never install one version twice or clear each other's install, and install() only runs while they are held, even after a prune between checks. - prewarm holds the store exclusively across clearing, seeding, mise install and recording again. - Go runs with GOFLAGS=-modcacherw, cached or not, so its module cache stays removable by scratch cleanup and rm -rf. - Tests: two runners on one store install once; array `version` in request_list and merged(); a bad pin holds only its own ecosystem; gh-actions-lock is not pinnable; Go keeps its module cache writable.
… off the runtime prewarm takes every default's install lock before the exclusive store lock, in the order hold_installed uses, so it cannot run between another runner's first use and its install. prune rewrites the usage record under USAGE_LOCK on the blocking pool, like every other store lock.
sweepies
force-pushed
the
refactor/simplify-tools
branch
from
November 22, 2026 19:47
9e029c2 to
acc1f82
Compare
Merged
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.
Simplification pass over
crates/tools, items 1–12 of the tools review. Tests (patchula-toolsincludingtest:toolsreal-tool runs,patchula-process,patchula-update,patchula-lockfiles), clippy and the state/derive parity tests pass locally.Done
tool()(security: stronger).held_toolandrefusable_toolare gone.tool()itself withholds the output of any failed run that holds registry credentials, so a credentialed call can no longer skip hiding by callingtool()directly. The refusal check runs first throughInvocation::refused: Option<fn>, and Python wraps the refusal text in its lock-specific message.credentials::Held::of(entries)replaces the 9scopes+secretspairs. It sorts and dedups the scopes once, souse_cachesno longer sorts them again. Nix and actions.lock useHeld::masking(secrets): they have secrets to hide but no scopes.pin::Pinnedandcontext::Replacedare now one type,context::Replaced. It keepsPinned's rule: a file is forgotten only after it is written back, so a failure leaves the rest forDropto retry (the oldReplaced::restorelost the retry withmem::take).pin::applyreturns the guard.node::canonicalremoved.dependencies()returns the projectedserde_json::Value.Value's equality ignores key order with or withoutpreserve_order(IndexMap'sPartialEqalso ignores order).validate_targetsreads Cargo.lock throughcargo::crates_io_entriesinstead of parsing it by hand. Same rule: the same name, a crates.io source and the same release.GOFLAGS, socaches::acquireloses itscallenv parameter and the merge.go.rssetsGOFLAGS=-modcacherwdirectly, with caches on or off, because a read-only module cache (0555/0444) cannot be removed byTempDiror an operator'srm -rf(our own eviction already runsmake_writable). A test checks both cache settings.Runner.usagemutex removed.record_useandprunetake a flock onUSAGE_LOCKthrough a new open each time, and flock locks each open file, so threads in one process already exclude each other.seedruns only under the exclusive store lock.public_only(security: stronger). A partition ispubliconly when the run reads at least one file that steers its ecosystem and every such file decided public-only. Before, an ecosystem with no steering files (emptysteers), or a snapshot with none of them, was public by vacuous truth. Terraform, APM, nix and actions.lock now passcontext.publicinstead of a hard-codedfalse. For them the value is alwaysfalseby construction (emptysteers, or Actions' verdict, which is alwaysfalse), and none of their binaries keeps a cache.Tool.versionsremoved (approved edge change). A run resolves and checks only the pins of its own descriptor's tools. A bad pin for another ecosystem's tool no longer fails the job, and Gradle wrapper, mise, nix, dotnet and actions jobs read no pins. gh-actions-lock stays out of the pinnable set: its descriptor hastools: &[]and installs through the newInstall::Fixed(ACTIONS_LOCK_SPEC). Documented under "Which tool version" inguide/lockfiles.md.arguments()does not reject a table whoseversionis an array (bracketedskips theversionkey). Simply swapping inrequest_listwould therefore have skipped the specifier check for that form. Instead,request_listnow accepts an arrayversionas one request per version with shared options, andrequests()is gone. The specifier check covers every form it covered before thatarguments()admits. Side effect:merged()can now merge a task's tool into such a declaration instead of refusing it, writing one table per version.tool@versioninstall locks shared by every runner and process replace the nix-onlynix_installmutex; the race applied to every tool. Each lock is a flock file undermise_data/patchula-install-locks/, named by a hash of the spec, taken in sorted order throughspawn_blocking.hold_installedtakes the shared store lock and returns at once when every tool is installed; otherwise it drops it, takes the install locks, then the store exclusively for first use and shared formise install. Install locks are never taken while holding the store lock, andinstall()only runs with them held.concurrent_runners_install_a_tool_onceruns twoRunner::newon one store and checksmise installruns once.patchula_process::redactis now public, and actions.lock uses it instead of its own copy. The copy lacked longest-first ordering and the empty-secret filter. The mask text is now[redacted]everywhere. The larger executor option (status plus streams, removingRun::Shell) was skipped: it touchespatchula-processand is not small.first_use(clear unproven installs, then seed) is shared bytool()andprewarm.prewarmholds the exclusive store lock across first use,mise installand recording the use, as before.checkout_pathsreplaces the two chunked checkout loops.After review (Gemini 4 Neon, adversarial)
Fixed in 5142ce0:
prewarmhad lost its exclusive store hold duringmise install(regression): restored.prunebetween the check and the lock leftinstall()unguarded: now flock files under the store (item 10).-modcacherwleft Go module caches undeletable byTempDir/rm -rf: restored directly ingo.rs(item 5).versioninrequest_list/merged(), a bad pin failing only its own ecosystem (directly and through a Go job with a bad Node pin), and gh-actions-lock being unpinnable yet still prewarmed.Fixed in 9e029c2, after a focused re-check of the locking:
prewarmtook only the exclusive store lock, so it could run between another runner'sfirst_useand itsinstall; aprewarmkilled mid-install then left a half-written directory that the other runner installed over without clearing it, and recorded as proven.prewarmnow takes every default's install lock first, in the same INSTALL_LOCKS → STORE_LOCK → USAGE_LOCK order ashold_installed.prunewaited forUSAGE_LOCKand read and wrote the usage record on the async runtime; that block now runs on the blocking pool, like every other store lock.Dropped
None. Left alone as asked: the
CredentialChecktest inlockfiles/tests.rs, which another PR removes.Follow-ups
Run::Shelland the actions.lock shell wrapper.patchula-install-locks/are never pruned: one tiny file per tool version ever installed. A safe sweep needstry_lockremoval inpruneplus an inode-identity retry inlock_installs, like thesame()loop incaches.rs.