feat(wait): a run's end, for the background beside a detached run
A run launched detached, as the prepush skill says, tells the session nothing when it ends: a round finished unread for hours. `crafter-review wait --artifact <artifact> --hash <hash>`, the two values of the run line, follows the hash's run lock. A full run holds it until it ends; taking it, the run now clears the last run's identity there, and it names itself with its run number once it has one. When a run the wait has seen hold or take the lock lets it go, the wait reads the identity - under its own instant shared hold, so never a rewrite in flight - prints the summary of the final dump of the run the identity names and exits with the code its verdict maps to, as run's does: 2 when there is no final dump or no run number, 3 with the message of a preflight check that stopped the run after it took the lock, which the run adds to the identity. A wait that sees no run within --appear (120 s by default) exits 3. Every probe of the lock, a test or dry run's too, takes it shared for an instant, and the run lock is tried for 200 ms before another driver counts as its holder. A wait only reads: one that is stopped is started again and the run goes on. freeze prints the wait line before the run line, and the skill and the process start the wait in the background, then launch the run detached. Released as 1.2.0.
This commit is contained in:
parent
ad33242609
commit
4318c7d8f2
15 changed files with 607 additions and 33 deletions
|
|
@ -70,7 +70,7 @@ One directory per test under `tests/`, each an ordinary `main()` linking the lib
|
|||
- the foundations: Crypto, Text, Platform and Process;
|
||||
- Goldens: the pure pipeline against the recorded answers in `tests/Goldens/fixture`;
|
||||
- Runs: full runs end to end on a claude stand-in;
|
||||
- Commands: init, doc, stop, seats, browser;
|
||||
- Commands: init, doc, stop, wait, seats, browser, --version;
|
||||
- LensTools: every allowlisted program on PATH, strict inside the Flatpak build.
|
||||
|
||||
Conventions:
|
||||
|
|
@ -137,7 +137,7 @@ Conventions:
|
|||
- `progress.json` is written atomically, through a temporary file and a rename.
|
||||
- The `seats` API report says the ledger counts what "the review drivers" spent: every driver writes it.
|
||||
- In the Flatpak, a pass's `SHELL` is `/bin/bash` (Platform).
|
||||
- **Commands beyond the gates**: `init`, `doc`, `browser install`, `stop`, and `--version`, which prints the home and the charters' sha256s (Commands).
|
||||
- **Commands beyond the gates**: `init`, `doc`, `browser install`, `stop`, `wait`, and `--version`, which prints the home and the charters' sha256s (Commands).
|
||||
- **Order, not value:** `estimate.cacheWrite`'s last digit depends on the order the passes ran, because it is a float sum.
|
||||
- **A mode is an artifact kind plus the lenses it runs and its effort** (2026-11-01: `modes.<name>` in the config, `Config::ModeOf`, `ModeNames`, `LensesOff(config, mode)`). The three kinds (`Plan::Kinds`: reply, series, commits) are modes of their own name; a mode of another name states its `kind`. The kind decides the partition and hash, the common text and run layer, the schemas, the disposition and reuse-key rules and what the CLI requires (`Run::Arguments::kind`, `Plan::IsKernelKind`); the mode decides which of the kind's lenses run (`Plan::KindLenses`, in the kind's gate order, `Plan::Gates`) and the effort (`modes.<name>.effort`, else the kind's default). Every lens is off until a mode lists it (2026-10-31, Jorijn: "all lenses off by default and opt in only"): `Config::Defaults()` runs no lens, while the template lists every lens of each kind at the kind's effort, to trim (Jorijn, 2026-11-01, on the populated template as the example: "looks good"; `init` says to trim); `lenses.<name>.run` is retired with a warning that says so; a lens of another kind, a name that is no lens, a lens listed twice and an unknown effort are config problems; `--mode` names any configured mode, the dump records `mode` and `kind`, and a reuse key carries no mode name, so a clean read bought in one mode counts in another of the same kind. The run lock, the run numbers and the dump names are the kind's (`<kind>-<h8>-run-N.json`): one full run per hash across the modes of a kind, their rounds counting on together; the dump's `mode` says which ran (Config, CommitsMode, KernelModes).
|
||||
- **The commit-truth lens** (`repo-facts.md`, 2026-10-31): Gate 4, after the proofs, so the messages and documents are read once the code they describe has settled. Its block kinds are text, doc and slot: the message units keyed on their text, the base and the code up to their commit (`MessageDeps`); a documentation unit on its file, its normalised text, the base and the code of the whole range (`DocKeyParts`); a diffstat on its text alone; `whole:order` and `whole:absent` in slot passes of its own (a lens with no whole pass asks the slots named in its row; never stored). A documentation file's diff header and a part the commit writes nothing in are mechanical n/a. Budgets 60/40 for a text or doc block, 50/35 for a slot; one read. The owner's gate is 5. The other lenses' prompts, keys and plans are untouched (CommitsMode, CodeKeys, Runs, the Goldens' series and gates).
|
||||
|
|
@ -165,6 +165,10 @@ Conventions:
|
|||
- A stop is handled exactly like SIGTERM, and it stays in force across gates.
|
||||
- Claiming a scratch dir drops a stale `stop`.
|
||||
- A process-group SIGTERM to the `setsid` launch reaches the driver; `flatpak kill` is the hard stop.
|
||||
- **Wait.** `wait --artifact <artifact> --hash <hash>` reads the hash's run lock and the run's dump, never writes them: stopping it leaves the run alone (Commands, Runs). It is started before the run, so the run takes the lock after it began.
|
||||
- The run it waits for is one a poll sees holding the lock, or one that names itself there - or clears the last run's identity from it - after the wait began: a run can take and leave the lock between two polls. A full run takes the lock before anything slow, clears the last run's identity from it (`RunLock`) and names itself there once it has its run number (`RunLock::WriteInfo`). One killed between taking the lock and clearing it (two consecutive calls) leaves the last run's identity, which a wait that saw it hold the lock reads as that run's; one that takes and leaves the lock unnamed where no run was named before is not seen. A run a preflight check stops before it takes the lock never shows - the check that refuses a second full run of a live hash among them, whose wait follows the live run. A test or dry run takes no lock and is not waited for.
|
||||
- The run has ended once nobody holds the lock. `wait` reads the identity only then, under its probe's own hold, so it never reads a holder's rewrite in flight (`RunLock::AddInfo`) or a new holder's first instant, before it clears the last run's identity; should another run have taken the lock between two polls, the identity is that newer run's. `wait` then prints `State::Summary` of the dump of the run the identity names and exits with the code its verdict maps to, as `run`'s does: 3 with the message of a preflight check that stopped the run after it took the lock (`Main` adds it to the lock's identity, `RunLock::AddInfo`), 2 when the dump is missing or IN PROGRESS (killed before its end, or stopped before Gate 0 has set up its seats - a stop then ends the driver at once, as SIGTERM does) or when the run ended before it named itself, and 3 when it sees no run within `--appear`, naming the run the lock names, with its dump, its preflight message or its log.
|
||||
- Every probe of the run lock is `State::ProbeRunLock` - `LockHolder`, a test or dry run's, is built on it: it opens the lock file (one it cannot open counts as none), takes the lock shared for an instant (`/proc/locks` hides another pid namespace's locks), reads a failure to take it as a holder, and reads the identity under that hold when nobody holds the lock. Probers never see each other, and `RunLock` tries for 200 ms before it counts a holder.
|
||||
- **gpg.** Only `xdg-run/gnupg/S.keyboxd` is exposed, so `%G?` verifies against the public keys and the agent stays out of reach.
|
||||
|
||||
**Process lifetime.**
|
||||
|
|
|
|||
Loading…
Reference in a new issue