ytdb-slate
AGENTS.md5 starsChanged 57 days agoApache-2.0View on GitHub
This repo is a pi package. It provides the slate extension for thread-weaving orchestration in pi. The orchestrator dispatches bounded actions to persistent worker threads. Results return as compressed episodes. The shipped doctrine uses eleven risk-defined focus areas as workflow triggers. User-approved proofs select gates and routine implementation reviewers. A track with at least one proved area gets one general Reviewer I plus its required specialists. An implementer's approximate size above 100 counted lines also adds Reviewer I, except on…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
13 rules. About 0 are common, 8 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 36
Read the full diff before you commit: No tool does this for you.
- Distinctive: line 134
Run all five checks before you commit.
- Very specific: line 198
Use a temporary home outside the repository.
- Very specific: line 241
Run it with bash verification/run-resolver-checks.sh --repo .
- Distinctive: line 341
Run both package-content commands:
- Distinctive: line 394
Write for a reader whose first language is not English.
- Distinctive: line 395
Use plain words that appear in standard libraries and textbooks.
- Distinctive: line 401
Use one term for each concept.
- Distinctive: line 402
Do not explain an idea with a metaphor.
- Distinctive: line 403
Do not invent a term when the project already has one.
- Very specific: line 410
Before you edit README.md, read README-GUIDELINES.md.
- Very specific: line 414
Keep the pi-bundled SDK packages (@earendil-works/pi-ai, @earendil-works/pi-coding-agent, @earendil-works/pi-tui, typebox) in …
- Very specific: line 420
Keep "keywords": ["pi-package"] — it is what lists the package in the pi.dev gallery.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — ytdb-slate contributor guide
Overview
This repo is a pi package. It provides the slate extension for thread-weaving orchestration in pi. The orchestrator dispatches bounded actions to persistent worker threads. Results return as compressed episodes.
The shipped doctrine uses eleven risk-defined focus areas as workflow triggers. User-approved proofs select gates and routine implementation reviewers. A track with at least one proved area gets one general Reviewer I plus its required specialists. An implementer's approximate size above 100 counted lines also adds Reviewer I, except on documentation-only tracks. Before implementation, an orchestrator estimate above 100 counted lines requires a high-level design even for documentation-only tracks. Counted lines exclude lockfiles, migration files and generated output. With neither review trigger, a track gets no routine implementation reviewer. Draft pull request publishing is optional.
Dispatch uses logical-model routing and common recovery. router.models defines provider-free action choices, fixed effort, ratings, guidance, cautions, and exact physical permissions. router.compressor.models is an independent ordered list. Slate resolves one immutable trusted parent-session policy. Dispatch, compression, main recovery, handoff, doctrine, and effective output share it. Reference: docs/model-routing.md.
- Extension entry point:
extension/index.ts - Shipped doctrine docs:
docs/—track-workflow.md,review-rules.md,design-principles.md,pr-publishing.mdand (since routing shipped)model-routing.mdare cited by ABSOLUTE path resolved inside the installed package (extension/paths.ts) - Default branch:
main - Finding tags come from slate's own adversarial reviews. This file uses
AD6, and code comments useAD41,RG2and other tags. Each review round numbers its findings from 1, so one tag can name two different findings. TheAD6in § Packaging rules is not theAD6of the tier-1 CI review. Only the pull request or the track discussion that raised a finding explains the tag. Every citation in this file therefore states the finding in words, and the tag gives the origin only.
Dogfooding
This repo runs slate on itself:
.pi/settings.jsoncarries exactly ONE slate package entry, and that entry is the literal relative path../../main. pi resolves a project-scope local path against the.pidirectory, so the entry names the siblingmainworktree of this repository, and a session in this checkout loads the extension source of that worktree. The file holds nonpm:ytdb-slate@<version>entry any more, so a session here does NOT run the published release, and there is no dogfood pin to bump at release time. The measured file also listsnpm:pi-smart-fetchandnpm:pi-web-search, which are unrelated packages.T5of the load check asserts that exact shape.- The loaded source therefore depends on TWO worktrees. This checkout supplies
.pi/, and the siblingmainworktree supplies the extension. A plain clone, and a CI checkout, has no such sibling. NOTHING AUTOMATIC PROVES THAT ARRANGEMENT ANY MORE.T6,T7andT8of the load check did, and all three were deleted. Each one needed the sibling worktree to be present, so each one could run only on a developer machine, where every pi session already proves the same property by use. Two things establish the arrangement now. Every session in this checkout proves it by running, because a session with no slate extension has no/slatecommand and no dispatch tool. The manual isolated-load smoke test,pi --no-extensions -e ., proves it on demand.T5still protects the tracked settings entry itself, in CI and in a plain clone, becauseT5only reads a tracked file. - An edit under
main/extension/IS live in the next session of this checkout, because that directory is what the package entry resolves to. An edit underextension/of THIS checkout is NOT live, because nothing loads this directory. Put the edit in the sibling worktree and start a new session, or runpi --no-extensions -e .from the root of the worktree that holds the edit. - Two older instructions no longer apply. The first said to smoke-test with
pi --no-extensions -e .because a pinned npm copy would otherwise load beside your edit and mask a failure. No published copy loads here, so nothing masks it, and the flag now only keeps the session away from your other project packages. The second forbade a local path entry beside the npm pin. That prohibition is inverted now: the local entry is the only slate entry, and a registry entry for slate beside it would create exactly the duplicate load that broke pi startup before.T5fails on such an entry.T8used to fail when more than one copy loaded, andT8is gone.T5still catches the tracked registry-entry case. A duplicate that escapesT5surfaces as a dead session: pi reports a tool conflict and exits 1 before the first prompt. - Development follows the package's own
docs/track-workflow.md, withworkflow.draftPRsenabled in.pi/slate.json. - pi creates a
.pi/settings.json.lockdirectory in the checkout while it reads the project settings, and then deletes it. A session or a verification run that stops abruptly can leave one lock behind..gitignoretherefore covers.pi/*.lock. You can delete an old lock safely when no session runs. When a session runs, the lock belongs to that session.
Build & verification
- There is no build step, but there is a typecheck. pi loads raw TypeScript through jiti, and it uses
extension/index.tsas it is. No tool compiles the sources before pi runs them. jiti removes the types, and it does not check them. The typecheck is therefore the only check of the types, and it has no other purpose.npm run typecheckrunstsc --noEmit -p tsconfig.json, and it writes no output: no artifact, nodist/directory, and no input for a later step.
The typecheck reads extension/**/*.ts, test/**/*.ts, verification/probe.ts, verification/ci-canary.ts, verification/worker-reminder-canary.ts and verification/record-worker-canary.ts. Test imports also bring verification/logical-model-import-check.ts into the checked graph. It skips verification/*.mjs, because that code is JavaScript without type annotations. tsconfig.json sets strict, noUncheckedIndexedAccess, noUncheckedSideEffectImports and erasableSyntaxOnly. The last flag carries a second job beyond type safety: it keeps every source under extension/ executable by Node's native type stripping, which is how the node:test suite imports the shipped modules with no build step (§ Unit tests and the coverage gate). It also sets skipLibCheck: true, and that flag is necessary. Without it, tsc reports more errors, and all of them sit inside third-party .d.ts files under the pi SDK. This repo cannot correct those files.
exactOptionalPropertyTypes and noPropertyAccessFromIndexSignature stay off. This repo measured both flags, then deferred the first and rejected the second, and tsconfig.json records the reasons together with the two commands that re-derive the current diagnostics. It records no counts on purpose: the include list moves them, and a recorded count went stale twice, most recently when test/**/*.ts joined the include list. Nobody must repeat that decision without re-measuring. Every flag in the set passes on the current tree. Add a new flag together with its fix. A flag that fails makes the check unreliable, and people then ignore it.
A passing npm run typecheck does NOT make the TypeScript brands (SessionBaseline, OpenModel in extension/logical-model-runtime.ts) tamper-proof: TypeScript permits an assertion to a branded subtype, so someString as OpenModel — the exact shape that reintroduced a shipped defect while the full suite stayed green — still typechecks cleanly. The resolver checks' source scan is therefore load-bearing. It rejects direct and unknown or any two-step named as assertions in every scanned extension source except the exact producer extension/logical-model-runtime.ts. In the bounded consumer extension/threads.ts, it also rejects angle-bracket assertions to either brand and as never. The scan uses syntax only. It does not resolve renamed imports, local or transitive type aliases, type flow, or arbitrary loader forms. The typecheck and source scan cover different failures, and neither makes the brands tamper-proof.
- Automated verification exists. CI runs five Linux checks and two record-tool job matrices on every pull request, on every merge-queue candidate and on a push to
mainor a branch matchingrelease/[0-9]*. A manual dispatch runs the same checks and job matrices. It skips patch coverage loudly because that event carries no change boundary. Each check is the same command that you run locally (§ CI). The fifth check isnpm test. It runs thenode:testsuite undertest/and then the patch-coverage gate. That suite unit-tests the modules the tests import (§ Unit tests and the coverage gate). It is also the one check that no longer takes about a second. It dominates CI's wall clock. Additional nets run by hand and are named below. Writing also has a focused correctness suite.verification/writing-check-tests.mjstests the shipped, dependency-free JavaScript checker inextension/writing-check.mjs. It also tests the turn-outcome helpermeasureWritingTurninextension/writing.ts. It does not unit-test the modules thattest/leaves alone. Four tasks stay manual:- Read the full diff before you commit. No tool does this for you.
- Run the isolated-load smoke test when you must use an edit that you just made. The command is
pi --no-extensions -e .from the root of the worktree that holds the edit, because an ordinary session in this checkout loads the siblingmainworktree named by.pi/settings.jsonand not the directory you are standing in. The load check proves that the extension loads and registers its tools, but it does not prove that the tools work. Exercise tool execution, worker sessions, failover and handoff by hand here. Never run it while the ladder runs — § Verification ladder states what that costs. Open an INTERACTIVE session to reach the doctrine and the router. A headless
pi --no-extensions -e . -p "exit"run exercises extension registration andsession_startonly, and it never builds the doctrine. slate seeds orchestrator mode only whenctx.mode === "tui"(extension/mode.ts), andbefore_agent_startreturns at once while the mode is off. A headless run therefore reaches neitherbuildDoctrinenor thegetRouter()consultation inside it, and that consultation is the only one in the doctrine. Every smoke test during the work on the routing feature missed both. A release-time accident exposed this gap.An automatic interactive session needs a pty. This machine has no
script(1), and a small Pythonpty.forkharness works instead. Use\ras the submit key, and not\n.The session JSONL holds no doctrine text. Its entries are
session,message,custom,model_changeandthinking_level_change, and the system prompt is not one of them. To verify the CONTENT of the doctrine, ask the model to repeat it, and do not grep the transcript. This gap is a smoke-test gap, and it is not a coverage gap. Thedoctrine-*checks cover the rendering, and the router checks cover the resolution. Only a live session proves that the wiring runs.Run by hand every net that CI leaves out. The hand-run set is:
- the verification ladder (§ Verification ladder below).
- the package-content check and its
--self-test(§ Package-content check). - the writing checker's correctness suite.
- the writing checker's scaling gate (§ Writing-checker nets).
- the writing-reminder integration check (§ Writing-reminder integration check).
- the worker-reminder integration check (§ Worker-reminder integration check).
- the record-worker integration check (§ Record-worker integration check).
Each section states its own re-run trigger. CI excludes the ladder on purpose. The other hand-run nets are not wired into the workflow. The unit tests and the patch-coverage gate are NOT in this set any more: CI runs them (§ Unit tests and the coverage gate).
CI (.github/workflows/ci.yml)
CI is fast, and it references no secret. Every check uses fabricated inputs and a plain checkout. The checks reach the network for the dependency install only. The packaging guards reach no registry, and they pass when npm runs offline.
The checks do NOT prove that no credential reaches a child process. The load check scrubs the child environment by variable-name pattern, and not by a list of permitted variables, so a credential under a name the pattern list does not cover reaches the child. A gate measured AWS_ACCESS_KEY_ID doing exactly that. What holds instead is that a session has nothing to spend a credential on: every session runs with PI_OFFLINE=1, without models.json and without auth.json, and it contacts no provider. The permitted-variable list is the stronger design, and it is deferred.
The checks also touch real pi state, in one read path. The load check runs one pi --version probe with the ordinary environment, and pi creates and removes a settings.json.lock directory beside the REAL user settings file during that probe. Only the load check starts a pi session in CI, and both of its sessions point PI_CODING_AGENT_DIR at a throwaway empty directory. No session of the load check reads the real user agent directory any more. The mirror of that directory, and the fingerprint that watched it, belonged to T8 and were deleted with it.
The checks write in these places only:
- The load check, the resolver checks and the unit-test wrapper each make a scratch directory under
TMPDIR, outside the checkout. Each harness removes its own directory after a clean run. The load check and unit-test wrapper keep their directories when a check fails, and each prints the path. - Record-tool tests create disposable folders through Node's
mkdtempunderos.tmpdir(), outside the checkout. Test teardown removes them. - The packaging guards write nothing.
- pi creates a
.pi/settings.json.lockdirectory inside the checkout, and deletes it again, around each read of the project settings. - pi creates and removes a
settings.json.lockdirectory beside the real user settings file during the load check'spi --versionprobe. That directory is pi's own behaviour and not the harness's, and it moves the modification time of the real agent directory while every entry inside stays byte-identical.
CI is not hermetic beyond that, and it makes no such claim: the install fills the npm cache under HOME, like every other install.
The workflow uses a read-only token (permissions: contents: read). Four events start it: pull_request, merge_group, a push to main or release/[0-9]*, and workflow_dispatch. It never uses pull_request_target. The job stops after 15 minutes (timeout-minutes: 15), and the workflow pins each third-party action to a commit SHA. The job matrix pins Node 22.23.1 and Node 24.18.0: those are the exact versions on which native TypeScript execution, LCOV, stripTypeScriptTypes, physical-line DA emission, directive matching and the full suite were measured. A floating major would take experimental APIs beyond the evidence silently; an exact pin instead costs a manual re-measurement and workflow edit for every accepted Node patch. pi needs node 22.19.0 or later, and the two pins still exercise both current LTS lines.
The Linux jobs keep the five checks below and the stable names Node 22 and Node 24. The full suite runs only on Linux. The record-macos job runs the record-tool tests on macos-latest with Node 22.23.1 and 24.18.0. The record-windows job runs only Windows tests on windows-latest with the same pins. Both jobs use pinned actions, no secrets, the read-only token, and a 15-minute timeout. Record tests use disposable folders outside the checkout. WSL is tested through Linux CI and simulated drive checks.
node verification/record-test-roster.mjs audits record-tool test files in both new jobs. --run all runs the record-tool selection. --run windows runs only its Windows subset. The patterns are test/**/record-*.test.ts and test/**/record-windows-*.test.ts, with zero or more nested folders. Record imports and the record-tool-test: marker identify applicable tests. The canonical Windows marker is // record-tool-test: windows. Indented and block-comment markers with that value also identify Windows-only tests. Both filename patterns allow an empty suffix after their final hyphen. The audit refuses a record-tool file outside its applicable pattern or a pattern with no files. Each selected file must produce one successful Node test summary and run at least one non-skipped test. Unexpected skips, pending tests, cancelled tests and missing evidence fail the runner. Only record-native-windows-refusal uses the real platform on Windows in test/record-windows-refusal.test.ts may skip off Windows. That test must run on Windows. test/record-test-roster.test.ts tests roster and execution refusals. test/record-shared-rules.test.ts belongs to the record-tool selection.
The five checks follow. Each command reproduces its check on a laptop after npm ci --ignore-scripts; locally npm test derives a merge-base with main, while CI always passes the event's explicit base SHA:
| check | local command |
| typecheck | npm run typecheck |
| packaging guards | bash verification/run-packaging-checks.sh --repo . and bash verification/run-packaging-checks.sh --repo . --self-test |
| extension load check | bash verification/run-load-check.sh --repo . |
| pure-resolver checks | bash verification/run-resolver-checks.sh --repo . --strict |
| unit tests + patch coverage | npm test |
Keep --ignore-scripts on the install. The pinned pi SDK is a devDependency, and its dependency tree declares install scripts: @google/genai (preinstall), protobufjs (postinstall) and esbuild (postinstall). @earendil-works/pi-coding-agent holds a copy of all three packages in its shrinkwrapped tree, and the dependency tree also holds separate copies of @google/genai and protobufjs, so package-lock.json carries five entries with hasInstallScript. A plain npm ci runs all five scripts on every install. CI needs none of them, so the flag keeps third-party code out of the job. npm creates node_modules/.bin without those scripts, so the pi and tsc launchers appear in both installs.
How the harnesses find pi. Three of the five checks need a pi binary, and all three start with the same two steps:
PI_BIN, when you set it. The harness printsNOTElines for this case.PI_BINis an override for an expert user, and it is not a security boundary.node_modules/.bin/piin the checkout. The install above creates it, and a CI runner has no other pi.
The three harnesses then differ on purpose. The resolver checks and peer linker accept a pi from PATH as a last choice, and they apply no version guard. The resolver checks borrow only the jiti transpiler inside pi; an old jiti can only fail to transpile the sources, and then the run stops with no summary. The peer linker instead imports the SDK copies bundled with that pi, so choosing the checkout-local exact pin before PATH is load-bearing: CI has both paths available through npm, and must not silently take another global installation. A PI_BIN override remains explicit and prints a note.
The load check accepts no pi from PATH, and it also requires the same version from pi --version as the @earendil-works/pi-coding-agent pin. pi's rpc output shapes are the evidence for its checks, and a new shape can look like "no events" and pass in silence. The verification ladder keeps its own rule: it needs pi on PATH.
The three CI harnesses (the packaging guards, the load check and the resolver checks) share one exit-code contract:
| exit code | meaning |
| 0 | every check passed |
| 1 | a check failed |
| 2 | the harness refused to start: a bad invocation, a missing tool, or a failed precondition |
An exit code of 2 gives no verdict for any check, because the harness verified nothing. The build still fails. One case of exit 2 reports a real defect on purpose: the load check refuses to start when the checkout has no extension/index.ts. pi drops a nonexistent entry from pi.extensions in silence, so every check would otherwise pass on an empty session.
The typecheck stands outside this contract. tsc uses its own exit codes. With the pinned TypeScript, a type error gives exit 2. An unknown compiler option, or a missing tsconfig.json, gives exit 1. Read an exit code from tsc as a tsc code, and never as a refusal.
Read the exit code first when a check fails. An exit code of 2 points at the invocation, the environment or a precondition. All three harnesses print the same first words: verification: refused to start — <reason>. The reason names the missing tool, the bad path, the version mismatch or the absent file, and it gives a remedy where one exists. You can therefore grep a CI log for that phrase.
That phrase belongs to the three wrapper scripts. verification/packaging-checks.mjs and verification/resolver-checks.mjs print their own refusal in the form <module>.mjs: … when you run a driver directly. Use the wrapper scripts for that reason.
An exit code of 1 reports a real finding. The CHECK … FAIL — <detail> line explains the failure:
- typecheck —
tscprintsfile(line,col): error TS…. Correct the source. A new run costs about 2 seconds. - packaging guards — the detail names the manifest field or the shipped path that broke a rule. A failure under
--self-testmeans the opposite: a guard no longer detects its own violating mutation. Correct the guard, and keep the manifest. - load check — a failing run that started pi prints the raw rpc streams in its own output. It prints one section for each stream, stderr before stdout, and it cuts each stream at a limit. It also keeps the streams in the scratch directory (
artifacts: …), so the evidence survives a CI job that deletes that directory. The detail line summarises those streams, so read the streams first. A pi run must happen before the streams appear, and the identity of the failed check does not matter. A full run that fails the config-syntax check still prints the streams of the earlier pi runs, and only a run with--only T4prints none. - resolver checks — the detail line repeats the expectation that broke, and the harness prints the same sentence for a pass, for example
CHECK memoization FAIL — createWorkerExtensionResolver walks the registry exactly once across repeated calls. Anobserved:line under it gives the value that the check saw, for exampleobserved: {"walked":3}. The harness removes its fixtures on exit, but the pipeline is pure and deterministic. Read the body of that check inverification/resolver-checks.mjs, then run the harness again.
A NOT RUN from the ladder is neither a pass nor a fail. verification/README.md holds the table of the action for each one.
The unit tests dominate the enlarged CI set, and the load check is the slowest of the rest. One machine gave these times on 2026-09-04, and each one is a single measurement and not a speed promise:
| check | time |
| typecheck | 2.5 s |
| packaging guards, each pass | 0.4 s |
| extension load check | 2.6 s (it starts three real pi processes: two rpc sessions and one pi --version pin probe) |
| pure-resolver checks | 1.1 s |
| unit tests + patch coverage | ~35 s on Node 22.23.1; ~19 s on Node 24.18.0 |
Run all five checks before you commit.
Re-run obligations. The two sections below use the same form:
- Run the packaging guards again after a change to a packaging-relevant manifest field. Those fields are the
fileswhitelist,peerDependencies,dependencies,keywordsandscripts. Run them again also after you add, move or delete a file underextension/ordocs/. The pack layer asserts the real file list fromnpm pack, and not the manifest. The guard asserts thefileswhitelist by exact equality, so a deliberate change to the whitelist must updateFILES_EXACTinverification/packaging-checks.mjsin the same commit. Run--self-testtoo: it runs every guard against the real input with one violating mutation, and it requires a failure. - Run the load check again after a change to extension loading, to tool or command registration, or to
session_start. Run it again also after a change to the.pi/slate.jsonor the.pi/settings.jsonof this checkout. Run it again after a change to the shared package-resolution helpers, to theT5assertion, or to the redaction paths. The sibling-worktree triggers are gone withT6,T7andT8: a change to the sibling target, to its manifest, to a declared entry point, to the worktree layout, to a user-scope settings entry or to either automatically discovered extensions directory no longer moves any result here. That set of triggers is the setverification/README.mdcarries under its check table, and the two must agree. Those failure modes have no other signal (see § How extension-load failures surface). A check of its own reads the config file directly from disk, because slate drops an unparseable file in silence. The load check answers two conditions with exit 2 instead of a FAIL report:- A checkout without
extension/index.tsstops the run. pi drops a nonexistent entry frompi.extensionsin silence, and every check then passes on an empty session. A checkout withoutverification/ci-canary.tsstops the run for the same reason. - A mismatch between the pin and the installed pi stops the run. The message carries the remedy
run 'npm ci --ignore-scripts', which is the install that CI runs. The rpc output shapes hold for one pi version only.
- A checkout without
- The verification ladder stays outside CI on purpose (issue #24). It takes about 3 minutes, and most of that time is wall-clock wait in timing-sensitive rungs. It needs GNU coreutils, and it refuses to run as root. On a slow machine, or on a machine without the optional tools, it reports NOT RUN instead of PASS. A required check with that behaviour gives unreliable results, so the ladder stays a check for a person to read. Run it as § Verification ladder describes.
How extension-load failures surface (pi 1.0.0)
The lists below describe extension-load behavior in pinned pi 1.0.0. Check both the exit code and the diagnostic channels.
pi reports each failure below on stderr with Error: Failed to load extension "<path>": <detail>. Each failure exits 1.
- a syntax error;
- a broken import that the module uses;
- a throw at the top level or inside the factory function;
- a module without a default export;
-e <path>for a path that does not exist, with the detailExtension path does not exist;-e <dir>for a directory that resolves to no module at all, with the detailCannot find module '<dir>'. Such a directory has nopi.extensions, nomainand noindex.*.
A directory can load without a pi field or a package.json file. A bare index.ts is enough when the directory resolves. For each load failure above, both the exit code and the diagnostic string identify failure.
The following failures leave the exit code at 0. Their diagnostic channels differ.
- An entry in the
pi.extensionslist of a package points at a file that does not exist. pi drops the entry without a word, and it starts with no extension. A real install has this shape, so this case matters most. - A hook for
session_startthrows. RPC mode emits anextension_errorevent on stdout. Text mode printsExtension error (<path>): <msg>on stderr. Both modes exit 0 when the remaining invocation succeeds. Neither diagnostic matchesFailed to load extension. - A tool registration disappears. pi prints no diagnostic at all: it exits 0, its stderr holds 0 bytes, and the
/slatecommand still works.
verification/run-load-check.sh holds all of this knowledge, so you do not have to remember it. L1 reads the exit code. L2 reads both stderr markers. L3 reads the extension_error channel on stdout. L4 and L5 read the registered tool set through the positive control in verification/ci-canary.ts. L6 reads which copy of slate pi loaded. T1 through T5 add the trusted path and the tracked package entry. Take the current identifier set from bash verification/run-load-check.sh --repo . --list-checks and not from this file. A measured run of that command printed 13 identifiers, and a measured clean full run printed 14 result lines, because the roster audit reports one line of its own and is not selectable.
A pipeline hides the exit code of a process, and that trap probably produced the wrong claim. $? after a pipeline gives the status of the last command, and not the status of the piped process. A broken extension shows the difference. A direct run of pi exits 1. The same run as pi … 2>&1 | head -1 gives a $? of 0, while ${PIPESTATUS[0]} for that pipeline is still 1, and set -o pipefail makes the pipeline exit 1. Read a real exit code in one of three ways: use no pipe, read ${PIPESTATUS[0]}, or run set -o pipefail first. Every script in verification/ runs set -o pipefail.
Run the typecheck after ANY TypeScript change. That trigger is wide on purpose, and the deep nets below use a narrow trigger instead. The run takes about 2 seconds, and it checks every file that it covers in one pass. Spend no time on a decision about the type relevance of your edit.
The silent-failure nets are the ladder, pure-resolver checks, packaging guards, extension-load check, unit tests with the patch-coverage gate, and package-content check. They also include both writing-checker nets, the writing-reminder integration check, the worker-reminder integration check and the record-worker integration check. The sections below define their scope.
This inventory intentionally has no total. Earlier totals went stale twice. Add each new net to this inventory when you add it.
The typecheck is NOT one of these nets. It sees shapes, while each listed mechanism can fail with correct types. Run every net that covers a shared change. For example, extension/writing-check.mjs implicates its correctness suite, scaling gate and the resolver suite's writing-* families.
failover.ts, episodes.ts, worker.ts and the router use the model-spec helpers in extension/state.ts. failover.ts and handoff.ts drive extension/base-model.ts, and those two modules are the switch sites of the ladder. A change to either module therefore implicates BOTH nets.
Verification ladder (global model defaults across slate's model switches)
verification/run-ladder.sh is the deepest regression net in this repo. It is not the only net. § CI names the five checks that run on every pull request. The sections below add the package-content check, the writing checker's two nets and the writing-reminder integration check. The ladder is the only net that touches the global model-default machinery. It covers:
extension/model-default.tsand both switch sites (extension/failover.tsfailover,extension/handoff.tshandoff adoption): pi 1.0.0 production setters must write zero global-settings bytes. A test-onlypersist:truefixture keeps the compatibility restore, per-key rule, untrustworthy-read stand-downs, retry budget and reporting channels under test.extension/worker.ts's worker-session settings isolation, in rungWK1: a worker-side per-dispatch model AND effort switch — what every routed action performs — writes zero bytes to the global settings file and does not survive into a reopened session as a sticky default. A file-backed control uses explicit persistence to prove the read-only worker settings boundary has teeth. It is the only automated net for that guarantee, and the only rung that opens a worker session at all.
Everything runs against fake offline providers in a throwaway agent directory, so real pi settings are never touched (the run fails if the real file changes).
RUN THE LADDER ALONE. Any other pi process that shares the real agent directory can make its SAFE check lie. A process redirected to another directory through PI_CODING_AGENT_DIR cannot touch the watched file, but the harness refuses an inherited value because it must own that redirect. The final SAFE check compares the REAL ~/.pi/agent/settings.json before and after the run, and it compares size and mtime as well as the hash. It therefore reports SAFE FAIL — REAL SETTINGS FILE CHANGED when a pi you started yourself — the isolated-load smoke test of manual task 2, an interactive session, or a dogfooding session in another terminal — rewrites that file mid-run. Measured shape of the false alarm: an identical hash and size with only the mtime moved, under a summary that reads 26 pass, 1 fail. Read the hash first. Equal hashes mean a concurrent writer, not a leak, and the fix is to stop every other pi that shares the real agent directory and rerun the ladder, because a SAFE FAIL voids every rung above it and cannot be dispositioned by argument. Sequence the two nets; never overlap them.
Running the ladder beside an active pi session
The harness computes the watched settings file from node os.homedir() as <home>/.pi/agent/settings.json, unless SLATE_LADDER_REAL_AGENT_DIR names another agent directory (verification/run-ladder.sh:151-170). It refuses to start when PI_CODING_AGENT_DIR exists in the environment, including an empty value, because the harness must own that variable (verification/run-ladder.sh:115-131).
The harness creates a throwaway <lab>/agent directory and assigns it to AGENT (verification/run-ladder.sh:220-240). Every child pi launch sets PI_CODING_AGENT_DIR="$AGENT" (verification/run-ladder.sh:315-349). A child that ignores that redirect writes under the run process home directory when pi resolves its agent path through os.homedir(). An isolated home therefore keeps escape detection intact (verification/run-ladder.sh:152-168, 246-258, 347-351).
A run can therefore overlap another pi session using the real home directory when the run uses an isolated home. That session cannot change the watched file in the isolated home. The isolation is not an operating system sandbox. A process using a hard-coded path instead of the home directory could still escape detection (verification/run-ladder.sh:1420-1450).
Use a temporary home outside the repository. Create its agent directory and a settings file before the run. Keep PI_CODING_AGENT_DIR removed, and preserve a PATH containing every required tool. Prepend the repository's node_modules/.bin directory so the pinned pi resolves first:
tmp_home=$(mktemp -d /tmp/slate-ladder-home.XXXXXX)
mkdir -p "$tmp_home/.pi/agent"
printf '{}' > "$tmp_home/.pi/agent/settings.json"
env -u PI_CODING_AGENT_DIR -u SLATE_LADDER_REAL_AGENT_DIR HOME="$tmp_home" \
PATH="$PWD/node_modules/.bin:$PATH" bash verification/run-ladder.sh --repo . --strictThe harness takes pi from the search path. The search path can provide a different version than the version pinned in package.json. A wrong version can produce many rung failures that look like code regressions. On 2026-08-31, pi 0.84.4 from the search path made branch main report 10 pass, 15 fail and 2 not run. The pinned pi 0.83.0 from node_modules/.bin made the same branch report 26 pass, 0 fail and 0 not run. The same failing set appeared on a feature branch and produced a false regression report.
Record pi --version with the run. The ladder accepts pi from PATH as a last choice and has no version-drift guard (verification/README.md:681-686). Compare that version with the exact @earendil-works/pi-coding-agent devDependency pin (package.json:39-43). If the isolated run fails, run the same ladder on branch main with the same isolated-home setup, command shape and pi version. Treat a failure as a current-branch regression only after that comparison. The final safety verdict is based on the before-and-after watched-file fingerprint (verification/run-ladder.sh:1420-1450).
- Run it with
bash verification/run-ladder.sh --repo .(~3 min;--only <ids>for a subset). Not as root, and needs GNU coreutils. Exit 0 means nothing failed and the real settings file is unchanged — rungs can still report NOT RUN, so read the lines; automation should pass--strict, which makes any NOT RUN fatal. - Re-run it after any change to
extension/model-default.tsor to either switch site, and after any change to how a worker session is opened or switched —extension/worker.ts's settings manager, the model/thinkingLeveloptions it passes tocreateAgentSession, or the per-dispatch switch inthreads.ts'sapplyRoute(WK1). Both mechanisms fail silently when they regress — the switch still works, and the damage lands in the user's own pi configuration — so a passing smoke test proves nothing about either. Details, rung table and the timing-sensitive rungs:verification/README.md.
Pure-resolver checks
verification/run-resolver-checks.sh tests pure production pipelines with
fabricated in-memory inputs. It starts no Pi session and reads no real state.
The closed roster includes these current areas:
- worker-extension selection, load units, barriers, collisions, and doctrine rendering
- logical-model definitions, configuration resolution, runtime activation, exact reviewed imports, fixed effort, recovery planning, and effective output
- logical doctrine trust, sanitation, numbering, exact portable render sizes, runtime rejection boundaries, and whole-doctrine growth controls
- state snapshot sanitation, episode headers, base-model reduction, writing policy, writing reminders, worker reminders, and workflow contracts
The logical import check parses TypeScript and JavaScript module references.
It requires the exact reviewed active edge roster for recognized static imports,
exports, import-equals declarations, dynamic imports, and direct require calls.
It does not recognize arbitrary loader forms. Its brand-cast check rejects direct
and unknown or any two-step named as assertions in every scanned extension
source except extension/logical-model-runtime.ts. In extension/threads.ts, it
also rejects angle-bracket assertions to either protected brand and as never.
The syntax-only scan does not resolve renamed imports, local or transitive type
aliases, or type flow. A passing typecheck cannot replace this bounded source
scan, and the scan does not make the brands tamper-proof.
Run it with bash verification/run-resolver-checks.sh --repo . --strict. Exit 0
means every check passed. Exit 1 means a check failed or disappeared. Exit 2
means the wrapper refused to start. Re-run it after a change to any covered
production module, doctrine source, workflow contract, import edge, or published
budget figure. verification/README.md records the fixture basis and check
families.
Doctrine size uses portable characters. The check removes each installed
docs/ directory prefix and keeps each filename. Canonical measured baselines
must retain five-percent reserve. The separate runtime controls accept exactly
19,400 characters and 105 lines, reject 19,401 and 106, and use the measured
26,300 whole-doctrine ceiling. A valid logical policy with an enlarged supported
worker-tool roster supplies the over-cap counterfactual.
The suite loads the six active logical-model-* modules, mode.ts, paths.ts,
worker-extensions.ts, state.ts, base-model.ts, episodes.ts, writing and
reminder modules, worker.ts, and threads.ts. Re-run the ladder as well after
changes to shared model-switch, handoff, worker-session, or saved-default
behavior.
Writing-reminder integration check
bash verification/run-writing-reminder-check.sh --repo . starts three real pi
sessions against a deterministic in-process fake provider. The main scenario proves the finding trigger and four-turn cadence. The
trigger-off and findings-off scenarios prove that cadence remains active when
the trigger or findings section is disabled. Session JSONL must persist hidden
custom messages with display: false. Tool results must equal the exact
one-block content shape.
The harness requires node, mktemp, GNU timeout, mkdir, rm, date,
env, cat, tr and sed. GNU timeout supplies the required
--kill-after option. The selected pi CLI must match the exact devDependency
pin.
The harness resolves every scratch path physically and rejects a scratch root
inside the checkout. It creates a trusted project, agent directory, home and
temp directory under that root. The child starts through env -i. Only explicit
throwaway values, a minimal PATH, dead proxy settings and canary paths cross
the boundary.
PI_OFFLINE=1 keeps pi startup offline. The fake provider performs no network
operation. This is not a network sandbox because reviewed extension code can
still open raw sockets.
The canary uses a 1,000,000-token model window and reports 25,001 input tokens on its first provider call. The controller paces prompts from the RPC agent_settled event instead of using a fixed delay.
The three project configs set remindTurns: 4 and vary remindOnFinding and
findings. The main scenario proves the immediate finding reminder and the
later cadence reminder. The two switch scenarios prove that the four-turn
cadence still fires.
The pi phase is about one second on the reference machine. The wrapper's observed
wall clock is around two seconds. These figures describe one machine, not a speed
promise. GNU timeout sends TERM after 60 seconds and KILL five seconds later.
Exit 0 means every assertion passed. Exit 1 means a check failed. Exit 2 means the harness refused to start. A failed run keeps its scratch directory and inlines pi stderr and stdout. A clean run removes the directory.
This net is outside CI, the load check and the ladder. It proves the real
hook, steer, next-turn, provider and persistence paths. It proves display: false
structurally, not visual TUI invisibility. Check that presentation manually.
Re-run it after these changes:
- Requirement text, rendering, cadence or gates in
extension/writing-reminder.ts. - Reminder config in
extension/writing.ts. - Reminder hooks or reset ordering in
extension/mode.ts. - The handoff
forceNextassignment inextension/handoff.ts. - Custom-message type, options, steer delivery or next-turn delivery.
- The canary, harness, pi pin, RPC shape or JSONL shape.
A change to extension/handoff.ts still requires the full ladder. Run the
pure-resolver checks for reminder policy, config, mode, doctrine or ordering
changes.
Worker-reminder integration check
bash verification/run-worker-reminder-check.sh --repo . starts one real offline pi session against a deterministic in-process provider. The orchestrator calls the real thread tool. The worker issues two independent built-in reads in one turn. The continuation provider context must receive one exact hidden worker reminder. The worker transcript must persist both unchanged tool results and one custom message with display: false. The compressor request and durable episode must contain no reminder. The thread result must contain no reminder-miss warning.
The harness keeps workerExtensions empty and sets cacheKeyEnabled to false. It proves that the internal component loads across those two boundaries. Its fixed roster reports 18 result lines, including the roster audit. The roster has 17 expected checks plus the audit. The harness exits 0 when every assertion passes, 1 when a check fails and 2 when it refuses to start. A clean run removes its disposable scratch directory. A failed run keeps it and prints the path.
This net is outside CI, the load check and the ladder. It proves one clean worker path through the loader, tool-result hook, steer queue, provider context, JSON Lines persistence and episode filtering. It proves that successful delivery produces no false reminder-miss warning. A single clean run cannot prove that a real missing reminder produces the warning. The pure worker-reminder-detection and worker-reminder-wiring checks, plus test/single-action-threads.test.ts, prove the current rule. The rule reports a miss only when session-local handler evidence exists, the retained action slice has no exact reminder and no successful compaction invalidated that slice. Aborted compaction and a compaction event without a result do not suppress the warning. A real reminder loss during a successful compaction inside the same action is not reported. The project accepts this blind spot because the retained action slice no longer supports a conclusion about delivery. The integration run proves display: false structurally. It does not prove visual invisibility in the terminal user interface. Check that presentation manually. It does not prove concurrent worker-session isolation. The pure worker-reminder-state check covers two interleaved factory instances.
Re-run it after these changes:
- Reminder type, text, factory state, hook registration, message shape or detection in
extension/worker-reminder.ts. - Internal factory loading or loader-error reporting in
extension/worker.ts. - Action-slice detection, warning delivery or compression filtering in
extension/threads.ts. - Custom-message or steer semantics.
verification/run-worker-reminder-check.shorverification/worker-reminder-canary.ts.- The pi pin, RPC shape, provider-evidence shape or JSON Lines shape.
Record-worker integration check
node verification/run-record-worker-check.mjs . runs a real offline Pi parent session and its real thread tool. A deterministic in-process provider dispatches two assigned workers. The scenario checks active tool names, blocked built-in writes, independent record assignments, same-turn stale appends, one-link final records, durable outcome facts and visible internal-factory failure. It keeps workerExtensions empty and disables cache keys. It reads persisted worker and parent transcripts. A fixed roster checks every reported result.
This manual net creates its fixtures outside the checkout. It uses isolated project, agent and home directories. It starts the child with explicit environment values and PI_OFFLINE=1. The provider opens no network connection. The child has a 60-second termination bound. A clean run removes its scratch directory. A failed run retains its scratch directory and prints that path. Re-run this net after changes to record assignment, ownership, guard resolution, internal factory loading, activation, outcome facts, dispatch guidance, the canary, the driver or the Pi pin. Run the worker-reminder integration check and the full ladder after worker-loading changes too.
Package-content check (package-resolved runtime files)
Run both package-content commands:
node verification/package-content-check.mjs --repo .node verification/package-content-check.mjs --repo . --self-test
The normal check runs npm pack --dry-run --json --ignore-scripts. It derives every exported extension command and document path from extension/paths.ts. It recursively enumerates every Markdown file under docs/. It also recursively enumerates .mjs files under extension/ whose first line is exactly #!/usr/bin/env node.
That shebang is the runtime-command criterion. Helpers without it need no command export. Every document and command needs exactly one export. Every exported runtime path must appear in the publish set. The check also validates named path imports in extension/mode.ts.
The self-test uses temporary fixtures outside the checkout. It proves recursive nested-command discovery, helper exclusion, and the three required missing-roster findings. Isolated subprocesses prove help works without TypeScript and real analysis refuses missing TypeScript with exit 2. Exit 0 means all checks passed. Exit 1 means a real roster mismatch, missing packed runtime file, or escaped mutation. Exit 2 means a bad invocation, unavailable tool, parse failure, or failed precondition.
- Re-run both commands after adding, moving or deleting a Markdown file under
docs/. Run both after adding, moving or deleting a shebang-bearing.mjscommand anywhere underextension/. The same rule covers runtime path exports. Run both after apackage.jsonfiles-whitelist change. Run both after a path import change inextension/mode.ts, and before release. - The check covers package presence and roster completeness only. The resolver suite still covers doctrine content and rendering.
- It overlaps the CI packaging guards. The overlap is not yet consolidated. Both read the file list from
npm pack --dry-run. Both require doctrine documents to ship. The package-content check derives the complete Markdown roster and recursive shebang-command roster independently, then requires matching exports.pack-doctrine-docsscansextension/*.tsfor document joins instead. The package-content check is also the only net that requires each shipped runtime command by roster. Merging the nets is reasonable future work. Until then, run both and both self-tests.
Writing-checker nets (correctness suite + scaling gate)
extension/writing-check.mjs is the shipped writing checker and the only module with two nets of its own. It has them because it is called from a HOT path: extension/mode.ts's message_end hook runs it synchronously on the completed assistant message, so its wall clock is the TUI's. WRITING_TURN_MAX_BYTES (16 KiB of assistant text, in mode.ts) is what keeps a pathological input away from that hook — the command's own cap is 1 MiB, three orders of magnitude higher, and only the command can reach it.
node verification/writing-check-tests.mjs— CORRECTNESS: the rules, source offsets (BG2), the caps, report and file-input safety, command modes, the five hand-written scanners against the regexes they replaced, andextension/writing.ts's turn outcomes. Under 1 s, machine-independent. Exit 1 on any failure. It is fail-soft (one failure does not hide the rest) and ends with a roster audit against anEXPECTEDlist, so a deleted, duplicated or crashed test cannot exit 0. Any test added, renamed or removed must updateEXPECTED. Its test count and test numbers are the run's business and are deliberately NOT transcribed here or inverification/README.md: both were, and both went stale.node verification/writing-check-scaling.mjs— GROWTH: nothing in that module may grow faster than linearly. ~18 s, wall-clock. It is a separate file on purpose, so a timing assertion never makes the correctness suite read as machine-dependent.- Re-run BOTH after any change to
extension/writing-check.mjs, and the scaling gate in particular after adding or editing a REGEX, which is the change that reintroduces the class. Re-run the correctness suite and pure-resolver checks after a change toextension/writing.ts. Three reviews found six superlinear paths in the checker while every correctness net stayed green — the findings were right and the module was slow, which is precisely the failure a correctness suite cannot see. The gate'srosterrefuses an unclassified new regex literal by name, and itscanaryfails if the thresholds stop discriminating.
Unit tests and the coverage gate
npm test runs verification/run-tests.sh: it runs verification/link-peers.sh, then partitions the discovered node:test roster into a native TypeScript process and a separate mandatory real-Pi host process, then runs the patch-coverage gate in verification/coverage-gate.mjs. The host process contains only test/recovery-ownership-host.test.ts. It has an independent temporary directory and Jiti cache, and it writes separate host LCOV. It receives no patch-coverage credit. The native LCOV remains the only gate input. The runner requires a disjoint, exhaustive roster, and either process can fail the run. It needs node, git and a pi. The linker resolves PI_BIN, then the exact-pinned node_modules/.bin/pi, then PATH, and deliberately refuses to start without one.
CI runs this net on both exact-pinned Node legs. The checkout uses fetch-depth: 0, because the gate measures a COMMITTED <base>..HEAD diff. The base is event-specific and explicit. pull_request.base.sha against GitHub's synthetic PR merge commit measures that PR candidate. merge_group.base_sha against the queue's synthetic head measures the queued candidate. github.event.before against a push head measures that push to main or a release branch. A branch-creation push has no base and runs the tests without patch coverage with a visible warning.
A missing, all-zero, absent or HEAD-equal base exits 2. workflow_dispatch has no event change boundary. It runs the tests with --no-gate and emits a GitHub warning plus a job-summary section. It does not invent a diff or pass silently.
CI keeps a WARN green but makes it prominent. The small-denominator policy exists because a percentage verdict is not meaningful below 20 changed branches; turning WARN into FAIL would enforce the percentage the policy rejects. The test step therefore keeps exit 0, emits a GitHub warning annotation, and copies the OVERALL/WARN/VERDICT lines into the job summary with the instruction to record a manual disposition on the pull request. A green check is not that disposition.
- The harness adds no test-only dependency and no publish payload. It uses Node built-ins, shell,
git, the SDK bundled with pi, and the exact-pinnedtypescriptdevDependency. TypeScript has four direct uses:npm run typecheck, the coverage gate's executable-line classifier, package-content analysis, and the logical-model import-syntax check.test/,verification/andtsconfig.jsonstay outside thefileswhitelist (§ Packaging rules), so no part of this reaches a consumer install. - Native execution depends on an ERASABLE-SYNTAX invariant, and the compiler enforces it. There is still no build step: stable native type stripping lets Node execute the TypeScript tests and every extension module they import directly, but it handles erasable syntax only. Constructor parameter properties are not erasable and were the single construct that would have forced
--experimental-transform-types; this change replaced them inextension/state.tsandextension/threads.tswith explicit fields. KeeperasableSyntaxOnly: true:npm run typechecknow rejects a parameter property ANYWHERE underextension/, including in a module no test imports. Without that compiler guard, such a module passes both the typecheck and the tests, then throws when a real pi session loads it. (--experimental-test-coveragestays isolated in the wrapper, because Node's native LCOV API is separately still experimental.) - The two SDK import mechanisms have different jobs. The ordinary path is
link-peers.shabove: it resolves pi's own bundled copy of every declared SDK peer, replaces any installed package or stale link at the local target, symlinks the pi copies intonode_modules, and verifies every resulting target. That is zero stub code, it keeps coverage clean, and it tests against the SDK the installed pi runs. Treat the alternateverification/test-hooks.mjs,verification/test-resolve-hooks.mjsandverification/stubs/*.mjspath as INTENTIONALLY DORMANT scaffolding until a test invocation activates it with--import ./verification/test-hooks.mjs; the absence of that preload is not evidence that the scaffold is dead. A test that must CONTROL SDK behaviour, scripted failure injection for example, uses the preload somodule.register()maps peer imports to the mutable local stubs. - The floor is 85% LINE AND 85% BRANCH patch coverage, measured on the committed
<base>..HEADdiff rather than on the repository; both floors are independent. This is a FLOOR, not a target; the wrapper prints the configured floors and the gate prints the live numerators, denominators and percentages on every run. Branch coverage is the load-bearing metric for concurrency work, because the defects at issue are untaken paths — a waiter never woken, a join that throws, an abort arriving mid-flight — which line coverage does not distinguish. Coverage is not evidence by itself: a test that calls a function and asserts nothing can execute every measured path and still be worth nothing. A test earns its place only if it fails when the behaviour regresses. - Executable-line classification is SOURCE-authoritative; LCOV is coverage evidence only. Node emits a DA record for EVERY physical line of a loaded file, including blanks, comments, JSDoc, interfaces, type-only imports and overload signatures, while a coverage-disable region can remove DA from genuinely executable code. DA presence therefore does not prove executability, and DA absence does not disprove it: source decides whether an added line is COUNTED, and LCOV decides whether that counted line is COVERED. The gate erases types with
stripTypeScriptTypes, then classifies the stripped JavaScript with the exact-pinned TypeScript parser (ts.createSourceFile(..., ScriptKind.JS)) and a JSDoc-excluding leaf-token walk. The repo owns NO bespoke string/template/regex lexer; preserve that invariant, because the deleted lexer produced repeated defects in consecutive fixes. Type erasure remains REQUIRED rather than subsumed by the AST: the raw TypeScript AST was measured to over-include type-only lines and inflate the denominator. - Classifier uncertainty fails closed by forcing ZERO hits. A missing
typescriptdevDependency is a guarded infrastructure error and exits 2; non-erasable syntax rejected bystripTypeScriptTypesalso exits 2; a parser diagnostic or a classifier exception marks the file void, counts every added line, and assigns each one zero hits.erasableSyntaxOnlyis therefore a shared boundary for native test execution AND for gate classification, not merely a test-runner convenience. Do not replace the last rule with “assume executable and use DA”: covered comments commonly carry positive DA hits, so that intuitive fallback has already produced a false PASS. One known boundary remains: a.d.tsfile usingexport =hard-exits 2 instead of being classified as non-executable; no such file exists in this repo. The TypeScript parser roughly doubles gate runtime and raises peak memory, an accepted dev-tooling cost; re-measure it by running the same gate command with the same refs and fresh LCOV under/usr/bin/time -von the revisions being compared, not by recording a duration here. - Small branch denominators do not support a hard percentage verdict. With one branch uncovered, denominators 5 and 6 produce 80% and 83.3%, below the floor, while 7 produces 85.7%, above it. The gate therefore WARNS instead of enforcing the branch floor below 20 changed branches; at 20 or more it enforces 85%. A zero-branch diff is NEVER auto-passed: it also warns. The gate always prints both denominators. A WARN is not acceptance: inspect the changed paths and the denominator, record the manual disposition (including why a small or zero denominator is adequate), add tests for any unjustified uncovered or unmeasured path, and do not report PASS.
run-tests.shpreserves the distinction asRUN VERDICT: WARNeven though WARN exits 0. - Locally the base is a merge-base with your
mainREF, so a stale ref silently changes the numbers.run-tests.shprefersrefs/heads/main, thenorigin/main. A localmainleft behind while the remote moved therefore makes the diff include every commit that landed onmainsince, and the gate then measures other people's code against this suite: a real run in that state reported a 276-line denominator andVERDICT: FAILfor a change whose own denominator is 23. Nothing is wrong with the gate when that happens. Fetch and fast-forwardmain, or pass--base <sha>explicitly, which is what CI always does. - The gate sees committed changes only. Uncommitted in-scope files are invisible to its
<base>..HEADcoverage numbers;WORKTREE WARNINGmakes that omission visible but cannot measure the work. Commit the change, rerunnpm test, and disposition any remaining WARN by hand. At the LCOV boundary the gate fails closed per changed file: no usable line records make every added line uncovered and add a synthetic uncovered branch; if a recorded file has an added line missing or uncovered and no changed-line BRDA records, it adds the synthetic branch rather than letting the LCOV gap disappear. A nonempty diff that parses to zero files is an internal ERROR, never an empty PASS. - Treat BRDA as execution-dependent, not as a static branch inventory. Optional chaining,
&&short-circuits and destructuring defaults do not appear as uncovered branches until the alternate path actually executes, so weak tests can produce a SMALLER denominator and a better-looking percentage. Always regenerate LCOV from a real full run; never trust a static branch inventory. - Coverage-DIRECTIVE matching is a separate boundary: do not make that scanner cleverer than Node. Node v22.23.1 and v24.18.0 define byte-identical coverage directives with
kIgnoreRegexandkStatusRegexinlib/internal/test_runner/coverage.jslines 43 and 46, then applies them directly to each RAW source line at lines 113 and 122. Both regexes are unanchored, case-sensitive, exact-spacing, block-comment-shaped matches with NO lexical analysis. Consequently a matching substring inside a string or template literal IS honoured;// node:coverage ...syntax is NEVER honoured, whether line-leading or trailing; and changed case (DISABLE) or doubled spacing is inert. The gate copies those regexes VERBATIM and deliberately does not normalize, parse or broaden them. That rule governs directive recognition only; delegating executable-line classification to TypeScript's parser removes bespoke cleverness rather than violating it. Any directive-regex divergence is a defect in either direction: under-matching hides coverage, and over-matching rejects legitimate inert text. The gate adds one policy after the verbatim match: every matching substring on an added line fails unless text AFTER it on that SAME line carries an explicitreason,becauseorrationalelabel followed by:,=or-and a substantive value. This is self-referential: an exact block-shaped directive substring on a newly added fixture, comment or explanatory string is itself caught, even when it merely describes the pattern, so its line also needs the trailing reason annotation. The wrapper's central include/exclude policy remains the sanctioned exclusion mechanism, because it is auditable in one place; inline directives are the most gameable form. - The gate has its own regression net.
test/coverage-gate.test.tsexercises diff grammar, malformed and foreign LCOV, source classification, threshold boundaries, fail-closed behaviour, directive reasons and WARN propagation through the wrapper. Runnpm testafter ANY change toverification/coverage-gate.mjsorverification/run-tests.sh. This is load-bearing quality control for every other test: manual review found false-PASS defects in the gate that no other check would have caught, so a gate change without its fixture family can invalidate all downstream coverage claims while still printing success. - Waiter tests require an explicit timeout.
node:testhas no default timeout. Every test that awaits an operation which might never resolve must carry one, following the timeout option on the waiter test intest/thread-manager.test.ts; read that test for the maintained value instead of copying it here. Deadlocks and missed wakeups are exactly the defects that concurrency work targets; without the timeout they HANG the suite instead of failing it. - Run
npm testafter ANY change underextension/ortest/. Do not transcribe suite size or cost here:run-tests.shprints the discovered test-file count, and Node's summary prints the current test count and duration on every run.
Writing convention
The convention governs new or changed prose in the root README.md, PR descriptions and delivery commit bodies. It also governs issues, comments, release notes and agent messages to users. Use short, active language. Write sentences a reader understands on one reading. Keep exact technical terms. Do not use semicolons or contractions.
These ten requirements are project-authored:
- Write for a reader whose first language is not English.
- Use plain words that appear in standard libraries and textbooks. Treat any other term as new. A multi-word noun phrase, an abbreviation and a CamelCase name are terms.
- Avoid idioms.
- Replace bare-reference openers with the subject they reference.
- Explain each term, including project-specific, at first use.
- Define each abbreviation at first use.
- Express one idea in each sentence.
- Use one term for each concept.
- Do not explain an idea with a metaphor.
- Do not invent a term when the project already has one.
Research logs and worker-thread task text are excluded. A high-level design is always governed, even inside a research log. The project's own agent instruction file, AGENTS.md, is also excluded from these ten requirements and the style convention. Its rules need a dense, exact register. The requirements govern docs/, but every checker finding there remains advisory. verification/README.md remains a precision-first mechanism reference and is excluded.
The separate current-state documentation rule governs new or changed text in the root README.md, docs/, code comments and AGENTS.md itself. Describe only current state, not removed features or past behavior. Existing historical sentences are pre-existing debt and need no rewrite now. Pull request descriptions, delivery commit bodies, release notes and issues may describe removals as change records. Support for a deprecated key that still exists is current state and may be documented. See docs/writing-guidance.md § Current-state documentation rule.
The writing checker is diagnostic everywhere and authoritative nowhere. A match directs reviewer attention, and the reviewer decides whether the text has a defect. Changed convention-governed text should carry no fail-level findings. Findings in unchanged text are pre-existing debt, not an unrelated blocker. Every checker class is advisory in excluded files because mechanical findings can conflict with required precision. ASD-STE100 inspires only, Slate claims no conformance, and contributors must copy no standard material or examples.
Before you edit README.md, read README-GUIDELINES.md.
Packaging rules
- Keep the pi-bundled SDK packages (
@earendil-works/pi-ai,@earendil-works/pi-coding-agent,@earendil-works/pi-tui,typebox) inpeerDependencieswith the version"*". Never bundle them, and never add them todependencies. - The devDependency carve-out.
devDependenciesalso pins the same four packages to exact versions, so the typecheck, the load check and the unit tests use one known SDK. That practice is correct, and a bundle is a different matter: npm installsdevDependenciesfor no consumer, and it installsdependenciesonly.devDependenciespins the tooling in the same place and for the same reason:@types/nodeserves the typecheck, andtypescriptserves the typecheck, coverage classification, package-content analysis, and the logical-model import-syntax check.tsconfig.json,test/andverification/all sit outside thefileswhitelist, so no part of the checks or the tests reaches a consumer install. Re-check that boundary withnpm pack --dry-run --jsonafter a packaging change. - Commit
package-lock.json. This repo ignored the file while the four SDK packages existed as"*"peers only, because a lockfile then pinned an arbitrary resolution from npm. The exact pins indevDependenciesremoved that reason, and the lockfile now records the versions that this repo chose.npm ci --ignore-scripts, the install that CI runs, also needs the file. - Never add an install-time lifecycle script. npm runs
prepare,postinstall,installandpreinstallon every consumer install. Add none of them toscripts. - The
fileswhitelist inpackage.jsonmust includedocs/. The doctrine points at those files at package-resolved paths at run time. A publish without them ships a doctrine with a dangling citation in every rule, and an orchestrator that reads the workflow rules finds nothing. This is a rule and not a note, because adversarial review raised it as a finding (AD6in that round). Action-level routing needed no packaging change, becausedocs/ships as a whole and covereddocs/model-routing.mdon its first day. That fact makes the rule MORE important: one more doc now resolves at a package-resolved path at run time. - The guard asserts the
fileswhitelist by exact equality. A deliberate change to the whitelist must update the guard in the same commit (see § CI). - Keep
"keywords": ["pi-package"]— it is what lists the package in the pi.dev gallery.
verification/run-packaging-checks.sh enforces every rule above. It asserts the manifest, and it also asserts the real file list from npm pack --dry-run, because the manifest alone proves too little. npm expands a whitelisted directory recursively, and a files whitelist makes .npmignore and .gitignore inert. A stray file under extension/ or docs/ therefore ships behind a correct manifest.
The pack policy answers that risk. It permits a small set of file kinds, and it rejects junk and secrets. It also requires every doctrine doc that the extension references. verification/README.md gives the details.
The permitted kinds include extension/**/*.mjs, and that is deliberate. The shipped writing checker is dependency-free plain JavaScript. It runs as a command and inside a hot turn hook without a transpiler. The pack policy must permit this runtime command. verification/package-content-check.mjs enumerates runtime commands independently. It proves that each has one exported path and packed file.
Release & versioning
Before any release, read RELEASING.md in full. The Release workflow prepares one identity-bound branch. A user creates and merges its pull request. A merge into main starts publication. A merge into release/X.Y requires a publish dispatch on main with the exact version and request identity before publication starts.
The release-state branch keeps an additive durable lifecycle. It binds the original request, reviewed notes and path set, exact merge and its own parent, complete executable check roster, inspected archive, upload execution, registry bytes, clean install proof, promotion intent and observations, Git tag, and GitHub release. Version alone is never release identity. Each preparation dispatch adds a unique authorization generation to the request identity. A rerun of that workflow run keeps the generation. Preparation scans the additive release-state history at the commit bound to its lease and refuses any identity with a terminal record. A failed history read or parse refuses preparation. A still-prepared own identity can resume. Every later stage and operator action must carry the launch identity and reject a different current owner before an effect or state write. Compare-and-swap pushes fence the workflow's own writers.
One release permits one live package upload. The publisher binds the upload to one GitHub run and run-attempt pair and publishes under the internal slate-candidate npm distribution tag. Unknown upload blocks retry, abandonment, promotion, and final records. Retirement of an unknown upload requires a completed sealed run attempt, a completed non-success upload job, 60 minutes since job completion, and a fresh full npm package document from an empty cache with earlier versions and publication times. The version must be absent from both versions and time. A not-found response, read failure or malformed document refuses retirement without a state write. The terminal state keeps the archive and upload execution, marks the upload observed-absent, and frees the lane for a new identity. The gate records an observation, not proof that npm never accepted a request. A wrong verdict can leave only an unpromoted version under slate-candidate with the sealed archive. latest never moves without proof, and a later same-version upload fails and records unknown or mismatch. Recovery from upload-unknown requests failed jobs and their dependents from the original release run. The sealed upload authority rejects the upload rerun. Proof-gated dependents may later record registry and installation proof, promote, and create final records. Installation proof is read-only and may be retried under a later run attempt. Its success or failure result binds the producing execution to the exact request identity, version, release commit, parent, and verified registry record. Recovery from published state also requests failed jobs and their dependents. The recovery job itself grants no upload or promotion authority. Other stage artifacts bind the request identity, release commit, and owning stage execution. A late result cannot replace the outcome of a newer owner. A confirmed byte mismatch is terminal and records no uploader attribution that the evidence cannot prove.
After byte and exact-version install proofs, promotion uses OpenID Connect (OIDC) in the main-only npm-promote environment. Upload uses the main-only npm-release environment. Exactly upload, promote and recover-promote have id-token: write. No workflow job reads an npm token secret. npm trusted publisher A permits direct upload with dist-tag access off. Configuration B permits dist-tag access with direct publish off. Before every release, confirm exactly these two configurations, with both environment fields set. npm permits staged publishing in every configuration. The workflow never stages a version, and maintainers must never approve a staged ytdb-slate version. Upload still chooses its own version's tag. No credentialed job installs dependencies or executes package, test, lifecycle, or extension code.
Promotion uses Node built-in fetch for the GitHub ID token, npm exchange and latest PUT, only after the guard permits a write. Registry URLs are fixed to https://registry.npmjs.org. A different or invalid promotion registry origin saves refused with errorCode unknown before any read or credential request. The GitHub URL must use HTTPS. Requests reject redirects and time out after ten seconds each. Returned credentials are masked immediately and stay in memory. Results contain only existing closed codes. The tag PUT endpoint has no public API specification. Before merging a workflow interface, confirm no release is prepared or in progress and no Release run is active. Do not rerun a preparation or claim run whose stored executor lacks /-/npm/v1/oidc/token/exchange/. The stored executor uses OIDC only when it contains /-/npm/v1/oidc/token/exchange/. An executor without that path uses the stored-token route. A release with that stored-token executor can only close after unknown effects are resolved. Fresh preparation supplies OIDC control. Delete NPM_STAGE_ONLY_TOKEN and revoke its npm token after merge. After the first verified OIDC promotion, enable the npm package setting Require two-factor authentication and disallow tokens. Its effect on OIDC tag writes is undocumented. The first release after enabling it provides the first proof. If that setting blocks promotion, a maintainer turns it off and chooses recover.
Recovery selects bounded observation only when BOTH stored control modules export PROMOTION_OBSERVATION = "bounded-latest-v1". When both declarations are absent, recovery selects the supported legacy route. Partial or unsupported declarations fail visibly without a state change. Under OIDC bounded control, missing GitHub OIDC request variables save not-attempted with the existing cause missing-token. A failed or malformed guard read fails the job without a write or state change. It does not save not-attempted or latest-read-failed. The guard permits a write only at the saved earlier value. The release version verifies promotion without a write. Another version starts bounded observation without a write. Successful and failed authorized writes use the shared observer. After a failed write, observing the release version saves verified. Every other outcome saves refused with a fixed recognized npm error code or unknown, never free text. A completed observation supplies its actual after value. A failed observation still saves refused and omits after, never substituting the guard value. Its 60-second allowance includes reads, waits and npm retries, with five-second polling intervals and per-read timeouts within the remaining allowance. Reads run without npm tokens or GitHub OIDC request variables, with two distinct empty temporary npm configuration files and an isolated working directory without a project .npmrc file. No read starts with less than one second remaining. The observer then classifies the last valid read. A started read that fails, returns malformed data or times out cannot reuse an earlier successful read. Such failures change no state except after a failed write, which still saves refused. The release version gives verified. At the deadline the saved earlier value gives unchanged, and a third version gives superseded. unchanged does not prove npm never accepted the write. Every non-verified result emits a fixed GitHub error annotation while allowing recording. The recorder accepts a closed result shape and preserves expectedLatest and the release identity binding. Only verified permits final records. Recovery observes unknown outcomes and resolved refused, unchanged or not-attempted results through the same observer. A target observation records verified, including from a resolved result. An unchanged observation authorizes a new protected promoter with the same expectedLatest. That promoter checks the value again before writing. Stop every earlier promoter before recovery. Automatic inactivity proof is outside this route.
The legacy route retains stored policy and result vocabulary. A guard conflict records conflict without writing. Stored support for not-attempted determines whether missing-token and failed-first-read branches save that result, with fixed causes missing-token and latest-read-failed. Inspect both stored modules before using that result. Legacy recovery retries refused or supported not-attempted only when one read equals the saved expected value. Another value refuses the retry. An unknown outcome verifies the release version or saves superseded, including when the saved earlier value remains selected. Historical refused evidence without an error code and historical conflict evidence remain valid and permit close. Check the workflow at a rerun's commit for the required retry conditions. A rerun of the original promoter cannot retry. If a promotion result artifact exists but its recorder failed, rerun only that recorder first while the original intent owns state. Do not choose recover first. A failed promotion recorder can download the original fixed-name result artifact on a later run attempt when the original intent still owns state. Recorders commit only validated promotion content, not downloaded promotion directories. Neither route rolls back another observed selection. npm tag writes are unconditional, so independent writers inside the read-and-write window remain outside the guarantee. Nobody may change latest manually while release automation is active.
Ordinary abandonment covers only an unmerged request with no upload. A merged prepared request retires only after a successful GitHub read shows exactly one merged pull request into the request's bound target from this repository and its identity-bound branch. Failed or malformed reads and zero or multiple matches refuse the write. Prepared retirement uses current control code and keeps null claim fields. A claimed no-upload authorization also uses explicit retirement. Claim requires the durable owner to match the identified launch identity and refuses terminal or replaced owners. Do not retire while a preparation or claim run that started before pull request #439 merged is still active. Do not rerun a preparation or claim run that started before pull request #439 merged. GitHub permits reruns for 30 days. An observed-absent unknown upload may also retire under the evidence gate above. Preparation refuses a version listed in npm versions or time, and refuses package-not-found or failed registry reads. A corrected request may reuse the same unused version and may omit manifest files when the bound target branch already names that version. A proved release with a resolved but impossible promotion may close without promotion. A registry-verified published release with durable installation-failure evidence may also close without promotion. The attempt-keyed install-failure-<attempt> artifact feeds record-install-failure, which commits validated evidence under install-failures/. If that recorder fails, failed-job recovery must rerun the failed installation job and recorder together. A recorder-only rerun requests an artifact under a new attempt number that no installation job produced. This route requires resolved upload and promotion outcomes and no active publisher or promoter. Retirement, mismatch, and close preserve evidence, revoke the exact identity, create no success final records, and free the lane. A published close consumes the version and rejects late installation results.
Preparation on main binds each request to main or to an existing release/X.Y branch for the version line. A new version exceeds every npm version and publication-time entry. The durable request binds the target in its hash identity. A repeated attempt reuses its recorded base or refuses. A release-branch merge needs a publish dispatch on main with the exact version and request identity. That dispatch reads the stored control copy and checks the bound target, merged pull request and first-parent history before claim. Only the claiming workflow run can continue a claim or upload. Its later attempt reuses the recorded release commit, parent and pull request. On this path the release commit supplies check and package content only. The check roster runs in report mode, and stored control decides a coverage warning. Jobs that run the check roster or the package content of the release commit hold no persisted credential and save no dependency cache. On a main release, identify, claim and seal run control code from the main release commit. Claim and seal write release-state with a persisted checkout credential. For release-branch publication, identify, claim, the coverage decision, seal, upload, registry and installation proofs, recorders, promotion, and finalization use control code from release-state. Recover and close also use stored control code. Abandon and retire use current control code from the dispatch commit on main for operator checks. Some of their state transitions use stored control code. A main release keeps its push trigger and normal check-roster mode. The release request changes only package.json, package-lock.json, and its three files under release/requests/<version>/. A same-version correction can change a subset of the three request files, including request.json. The request records the fixed permitted set. A version-changing request must change both manifests and request.json. Those files remain outside the package files whitelist. CI runs on pushes to main and branches matching release/[0-9]*. A branch-creation push runs tests without patch coverage and reports the skip. One follow-up merge from main to release/0.12 supplies its CI trigger and check roster report mode before the first release from that branch. An administrator creates a release branch at the first verified tag of its line, updates the merge-queue ruleset and locks the previous branch. No ruleset restricts creation or deletion of matching release branches. The trusted group remains every collaborator with write access. The workflow moves no dogfood pin. Existing SDK pins change only during a targeted pi release.
verification/release-checks.sh is the executable release roster. Keep every listed command, order, strict flag, exit status, and verdict check. A refusal, failure, unsupported result, absent verdict, or NOT RUN stops before publication. A coverage WARN advances only when the changed paths are a subset of the reviewed permitted set, include request.json, and include both manifests for a version-changing request. The exact parent and identity enter evidence.
verification/release-job.mjs owns the upload, promotion, installed-command proof, and final-record execution boundaries. Behavioral tests invoke those production functions with closed fake interfaces. They also execute the real workflow run blocks for upload sealing, installation, installation-failure recording, published-state recovery, retirement, and close against isolated state and closed fake commands. The tests execute the real roster script against an isolated fake repository and command set. Keep all three forms of evidence when changing the workflow or release roster.
The fresh-install proof checks installation, extension loading, and /slate command registration. It does not prove interactive doctrine rendering, model routing, or tool registration. The first live release must prove trusted upload through configuration A and OIDC promotion through configuration B. It must also observe the package and organization token and two-factor authentication policy. Development work must not run the Release workflow live.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

