Plan: freeze the 1.0 public surface
Closes: #701. Relates to: #280, #836, #380. Branches: feat/overlay-unknown-keys, test/surface-contracts, chore/surface-freeze. Status: Done (2026-12-04) — 1.0 public surface frozen (#701)
Context
#701 is the freeze half of #280. What the tree says, by reading:
-
docs/modules/ROOT/pages/public-surface.adoclists every item with a tier (stable, internal, upstream).tools/lib/test/public-surface.test.mjsfailsvalidatewhen the page and the code name different items (tools/lib/public-surface.mjs). It compares names. No shape is held. -
packages/pi-modes/config.ts: six nested blocks (judge,title,shortcuts,unattended,compaction,monitor) refuse an unknown key by name. Five places with a fixed key set do not:-
validateTopLevelandvalidateModecheck each known key and ignore any other, so"recapp": falseloads and does nothing.TOP_LEVEL_KEYSandMODE_KEYSalready list every key; they are pinned toModesConfigandModeDescriptorat compile time, and to the two summary tables ofmodes.adocby the public-surface test (OVERLAY_KEYS). -
guidance(one key,global) is read field by field invalidateTopLevel. -
subagentPolicy(enforce,profiles) and eachsubagentPolicy.profiles[<agent>](tools) are read field by field invalidateSubagentPolicy. A profile written{ "tool": ["read"] }loads as a profile with notools, which the delegation gate reads as every tool (the comment onprofilesinModesConfig).
-
-
Three maps are keyed by names the operator chooses, so no key list exists for them:
permission(surface, then pattern),modelRoles(role), andsubagentPolicy.profiles(agent). -
loadModesConfigvalidates the shippedmodes.json, merges the overlay over it, and validates the result.mergeModesConfigspreads the overlay’s keys over the baseline’s at the top level and in each mode, andmergeSubagentPolicycarries each overlay profile whole, so those keys are in the merged object.mergeSubagentPolicyrebuilds thesubagentPolicyblock itself fromenforceandprofiles, so any other key the overlay puts there is gone before the merged validation. The shippedmodes.jsonopens with a"//"comment key. -
loadModesConfigruns in the extension factory (packages/pi-modes/index.ts:74). A throw there is caught by pi’s loader (node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js:566-568) and reported asFailed to load extension: <message>; the session continues without pi-modes. The permission system then skips its unregisteredgadhs-mode-judgelink and the ask reaches the terminal (node_modules/@gotgenes/pi-permission-system/src/authority/authorizer-chain-audit.ts:1-12). This is what any invalid overlay does today. -
Tools and commands are registered through
pi.registerToolandpi.registerCommand. pi-modes' test harness records both (fakePiinpackages/pi-modes/test/harness.ts); pi-remote registers its command and its fivemsg_*tools increateRemote(packages/pi-remote/index.ts:881-893). -
Bus events: some payloads are asserted whole today (
gadhs:mode,gadhs:title,gadhs:pending,gadhs-msg:received,gadhs-msg:read), others in part (gadhs:statusbytoMatchObject,gadhs-hub:factsfield by field). No test is named for the item it pins, so nothing can check that each stable item has one. -
Wires:
PROTOCOL_VERSION(pi to its SSH helper) andHUB_PROTOCOL(a session to its box’s hub). Each end refuses another version by name (packages/pi-ssh/connection.tshelloProblem,packages/pi-remote/hub.tsattachProblem), and tests cover it. -
Package exports: the page’s hand-written list of names a sibling imports has drifted from the code in both directions. The sibling packages are bundled inside
@gadhs/pi, pinned exactly, and keep their own 0.x versions. -
The standards pages are byte-copied from the template and not edited here (ADR-002).
standards:git-workflow.adocalready carries SemVer and "API contract stability"; the project’s mapping lives indocs/modules/ROOT/pages/project-conventions.adoc.
Decisions taken with the operator (2026-12-04)
-
No JSON Schema file. The defect is the silently ignored key; the validator fixes it with the tuples it has. A schema would be a second description of the config to keep in step, and its editor benefit needs a hosted URL. Recorded on #701 at the close.
-
Every named export of a sibling package is internal. The 1.0 promise covers the distribution: config files and keys, commands, tools, environment variables, bus events, wires,
bus-rules.json, and each package’s default export. No export is removed. -
The page’s per-name list of sibling imports is dropped. Nothing reads it once every name is internal, and
tscalready fails a broken sibling import.
Design
D1. Every block with a fixed key set refuses an unknown key
In packages/pi-modes/config.ts:
/** A key beginning `//` is a comment: the shipped modes.json opens with one. */
const COMMENT_KEY_PREFIX = "//";
/** The keys of `obj` that are neither a comment nor in `known`. */
function unknownKeys(obj: Record<string, unknown>, known: readonly string[]): string[] {
return Object.keys(obj).filter((k) => !k.startsWith(COMMENT_KEY_PREFIX) && !known.includes(k));
}
-
validateTopLevelbegins by throwing${source}: unknown top-level key(s): <keys> (known: <TOP_LEVEL_KEYS>)whenunknownKeys(cfg, TOP_LEVEL_KEYS)is not empty. -
validateModebegins by throwing${source}: mode "<id>" has unknown key(s): <keys> (known: <MODE_KEYS>)likewise. -
Membership is
Array.prototype.includeson the tuple, soconstructororprotoas a key is unknown like any other (T2). -
Both run on the baseline pass and on the merged pass, so an overlay’s key is reported with the source
<overlay> (merged over <baseline>)(T1). -
A
//-prefixed key is a comment at these two levels only. The nested blocks keep their own checks and take no comment key, as today (T3). -
The three unchecked nested blocks get the check the six have, with the same message form,
${source}: <label> has unknown key(s): <keys> (known: <tuple>), through one helperrefuseUnknownKeys(obj, known, source, label):-
guidance, label"guidance", against a newGUIDANCE_KEYS = ["global"], invalidateTopLevel; -
subagentPolicy, label"subagentPolicy", against a newSUBAGENT_POLICY_KEYS = ["enforce", "profiles"], invalidateSubagentPolicy(which gains thesourceparameter); -
each profile, label
subagentPolicy.profiles["<agent>"], against a newSUBAGENT_PROFILE_KEYS = ["tools"], in the same function. A misspelttoolsis then a refusal, not a profile holding every tool (T1).
-
-
Each new tuple is pinned to its type at compile time as
JUDGE_KEYSis, and joinsOVERLAY_KEYSasguidance,subagentPolicyandsubagentProfile. The six existing checks are left as written. -
The overlay’s own
subagentPolicykeys are checked before the merge, by a newvalidateOverlaySubagentPolicy(raw, overlayPath)called inloadModesConfigbesidevalidateOverlayPermissions, which is the existing pre-merge check of the same kind. It appliesrefuseUnknownKeyswithSUBAGENT_POLICY_KEYSwhen the block is a plain object and leaves any other type to the merged validation.mergeSubagentPolicyis not changed. -
The doc comment on
OVERLAY_KEYSdrops "accepted silently today". -
No alias, warning period or migration: before 1.0 the refusal is the change.
-
A fixture or test config in the tree that carries a stray key is corrected (the key removed, or spelt
//…when it is a comment).unknownKeysis not widened for it.
D2. Tools and commands: one recorded registration per package
A new test/surface-contract.test.ts in each package that registers a stable tool or command: pi-modes (17 tools, 7 commands), pi-remote (5 tools, 1 command), pi-ssh (1 command), pi-guidance (1 command). Each:
-
Loads the package’s real entry against a recording
pi:gadhsPiModes(pi)withfakePi(), isolated aswiring.test.ts’s `load()is (a scratchPI_CODING_AGENT_DIR, noGADHS_PI_MODES_CONFIG);createRemote(pi, { wire })aspackages/pi-remote/test/extension.test.tsbuilds it; the default exports ofpi-sshandpi-guidance. Registration happens in the factory, so no session is started. -
Builds
{ "commands": { "/<name>": <description> }, "tools": { "<name>": <parameters> } }, names sorted.-
A tool’s value is
JSON.parse(JSON.stringify(def.parameters))with everydescriptionkey whose value is a string removed, recursively. That strips schema prose and keeps a parameter that is itself nameddescription(its value is an object). -
A command’s value is its registered description. A command takes one free-text argument, and each stable command that takes one states its usage there (
/mode [id|next|models];/huband/gadhs-inittake none), so the description is the only declared form of its parameters. -
pi-sshandpi-guidancerecordcommandsonly: the toolspi-sshre-registers are pi’s own (tier upstream).
-
-
Compares with
await expect(text).toMatchFileSnapshot("./fixtures/surface.json"), aspackages/pi-modes/test/gate-characterisation.test.ts:102does. The records hold no path, so the tests run on every platform.
A change to a stable tool’s parameters or a command’s usage then fails until the record is regenerated (vitest -u), and the regenerated record is a diff in the MR. With CI set, vitest runs snapshots in none mode: a mismatch or a missing record fails. Locally a missing record would be written, which D4 covers.
D3. Bus events and wires: one contract: test each
Convention: a test whose title begins contract: <item> ` (the item, then a space), where the item is the channel name or the wire’s constant. It asserts the whole payload the real emitter produces with `toEqual on a literal, so an added, removed or retyped field fails. Two kinds of value are not written as literals: a clock value is expect.any(Number), and a value that follows the shipped modes.json is not hard-coded, so a rule edit does not fail the contract: gadhs:status’s `modeId and modeLabel are read from the loaded config, ruleCount is expect.any(Number), and text is renderStatus (packages/pi-modes/status.ts) of the event’s own fields. Where the suite below already asserts that, the test is retitled; where it asserts part, a test is added. No assertion is loosened.
| Item | Suite | What the contract test asserts |
|---|---|---|
|
|
A fresh session’s event, whole: |
|
same |
|
|
|
|
|
|
Retitled; extended with a step carrying |
|
|
|
|
|
The payload is |
|
|
|
|
|
Retitled. |
|
|
Retitled, or a focused test beside it. |
|
|
The bump rule’s two halves: |
|
|
An attach on another number is refused with |
The bump rule in words goes on the page (D5): a change to a frame that a peer on the previous number does not read bumps the constant; the page’s row and the constant’s comment record it.
D4. validate requires a contract for every stable item
tools/lib/public-surface.mjs gains three readers, in the file’s existing style:
-
stableOf(rows, map): the backticked items of the first cell of each row whose last cell beginsstable. For the Wires table,mapkeeps the name before ` = `. -
recordedSurface(root): the union of everypackages/*/test/fixtures/surface.json, as{ tools, commands }sets. A record that does not parse is an error naming the file. -
contractTitlesIn(root): the item of every title that opens anit(ordescribe(call withcontract: ` in `packages//test/.test.ts. It reads each file throughwithoutComments, takes either quote or a backtick, and allows whitespace and a line break between the(and the title, since Biome wraps a long call (gate-characterisation.test.ts:96).
tools/lib/test/public-surface.test.mjs gains, each through difference so both sides are named:
-
the page’s stable tools are exactly the recorded tools; likewise commands;
-
every stable bus channel and stable wire constant on the page is among the contract titles.
Reading the records from disk is what fails a missing record on a developer’s machine.
D5. Named exports are internal; the page states the promise; the conventions state the rule
-
public-surface.adoc:-
Intro: the page is the freeze. Stable is bound by SemVer from
@gadhs/pi1.0.0; internal changes in any release; upstream is owned elsewhere. It points at the rule in project conventions and at how each kind is held (names, D2 records, D3 tests). -
Configuration files: "accept one silently today" becomes: every block with a fixed key set refuses an unknown key by name, and the three maps keyed by the operator’s own names (
permission,modelRoles,subagentPolicy.profiles) take any key (this sentence moves with D1, in the first unit). -
Wires: the bump rule.
-
Package exports: an extension package’s tier becomes
stable: the default export(for@gadhs/pi-modes, alsobus-rules.json) andinternal: every named export. The two libraries,@gadhs/pi-bashand@gadhs/pi-workspace, have no extension to load: their tier isinternal: every export. The per-name lists and the "stable candidates" paragraph go. One paragraph says siblings import named exports within one release, held by exact pins andtsc.
-
-
Entry files: every
.tsfile anexportsmap targets (25 files: each package’sindex.ts;pi-modes’ `ask-broker,config,diagnostics,drop,hub-facts,hub-publish,msg-wake,pending-event,status,title;pi-ssh/extension.ts;pi-workflow/git-guard.ts;pi-workspace’s `contract,process-start,windows-kill) gets one sentence in its header comment:Named exports here are internal to the @gadhs/pi distribution: no semver promise (public-surface.adoc).The public-surface test asserts each target carriesinternal to the @gadhs/pi distribution, so a new subpath states its tier. -
project-conventions.adoc, a new section== Stability from 1.0before== Project Overrides: from@gadhs/pi1.0.0, SemVer binds the stable tier of the public-surface page. A breaking change to a stable item (removing or renaming it, changing the type of a parameter or payload field, a config loader refusing what it accepted, a wire’s peers refusing each other) needs a major version of@gadhs/piand an entry under=== BreakinginCHANGELOG.adocthat says what to change. An addition is a minor. Internal and upstream items change in any release. The sibling packages keep their 0.x versions. This is the project’s form of the standard’s "API contract stability"; the synced standards pages are not edited.
Units
| Unit | Branch, MR | Changes |
|---|---|---|
U1 |
|
D1 in |
U2 |
|
D2 (four tests, four records), D3 (the suites in the table), D4 ( |
U3 |
|
D5: the page, the 25 entry-file sentences and their check, |
Units land in order, each through the merge train, squash off.
Tests
Regression (the case that would have caught it):
-
T1,
config.test.ts: throughloadModesConfigwith an overlay file,"recapp": falseat the top level is refused namingrecappand the overlay’s path;"modle"in an existing mode and in a new, complete mode is refused naming the mode and the key;"guidance": { "globl": "x" }and"subagentPolicy": { "enforec": false }are refused naming the block and the key; a profile{ "tool": ["read"] }is refused naming the agent andtool. Before D1 all six load, the last as a profile with every tool. -
T1b,
config.test.ts: the existing test "each nested block’s list is the one its validator refuses unknown keys against" gainsguidance,subagentPolicyandsubagentProfile, so each new tuple inOVERLAY_KEYSis the list its check reports. -
T3,
config.test.ts: the shippedmodes.jsonloads with its"//"key; an overlay with"// note"at the top level and in a mode loads;"//"insidetitleis still refused by `title’s own check. -
T6,
tools/lib/test/public-surface.test.mjs, on its temporary tree: a stable tool with no record, a recorded tool the page does not call stable, and a stable channel with nocontract:title are each named bydifference; an internal row is not required.
Property (fast-check):
-
T2,
config.test.ts: for any string that is not in the tuple and does not begin//, the shipped config with that key added at the top level, and separately in its first mode, is refused with a message that starts${SRC}: ` and contains the key. `constructorandprotoare among the fixed examples.
Contract (wire and surface):
-
T4: the four
surface-contract.test.tsrecords (D2). -
T5: the
contract:tests of D3’s eleven items (gadhs-hub:factshas one per emitter), the two wires among them. -
T7,
tools/lib/test/public-surface.test.mjs: the page against the records and the titles (D4); everyexportstarget carries the internal sentence (D5).
No concurrency test: no unit changes ordering, locking or a shared resource.
Risks
-
An operator’s overlay carries a stale or misspelt key in a checked block after the upgrade: fail-closed.
loadModesConfigthrows, pi reportsFailed to load extensionwith the file and the key, pi-modes does not load, and asks reach the terminal. Mitigation: the CHANGELOG entry says what happens and the fix; the message lists the known keys; it is the path a nested block’s unknown key takes today. -
A comment key spelt without
//("_comment"): fail-closed, as above. Mitigation:modes.adocstates the comment form; T3 pins it. -
A record regenerated without thought hides a breaking change: silent. Mitigation: the record is a committed file, so the change is a diff the commit review and the MR reader see beside the rule in project conventions. It is not blocked mechanically.
-
A later
contract:title on a test that asserts little: silent. Mitigation: D4 checks presence only; this plan writes the tests of all eleven items to D3’s rule, and review holds later ones to it. -
A record missing on a developer’s machine is written, not failed, by vitest: silent locally. Mitigation: T7 reads the records from disk and fails on a missing one; CI runs snapshots in
nonemode. -
A tool’s parameter schema differs by platform, so a record fails on the Windows or macOS nightly: fail-closed (a red job naming the tool). Mitigation: records hold no path; the fix is in the schema’s source, not a skip.
-
Someone outside the distribution imports a sibling’s named export and a later release changes it without a major: silent for them. Mitigation: none is known (the siblings ship inside
@gadhs/pi);bus-rules.json, which pivot-msg pins, stays stable; the entry files and the page say so; #836 tracks standalone publishing.
Out of scope
-
A JSON Schema for the overlay, hosted or not (decision 1).
-
Removing exports or subpaths (decision 2).
-
Key checks for the other config files: each loader’s own validation stands, and the page lists their keys unchecked.
-
A misspelt role name in
modelRoles(commitReviwer) is still ignored. Refusing it needs the role grammar (mode:<id>,helper:<name>) in the validator; it gets its ownfix:issue when U1 starts. -
A
release prepareguard that a=== Breakingsection needs a major version. -
What a session does when pi-modes fails to load.
Delivery
-
Canonical doc pages:
modes.adoc(U1),public-surface.adoc(U2, U3),project-conventions.adoc(U3). -
CHANGELOG.adoc== Unreleased: U1 under Changed (an unknown key at the top level, in a mode, inguidance, insubagentPolicyor in one of its profiles is refused at load by name; remove or correct the key), U2 under Added, U3 under Changed. -
Each unit:
node tools/task.mjs checkbefore the push, then the merge train. The release that carries U1 is the operator’s to name; 1.0.0 also waits on #380. -
The close: U3’s MR closes #701. One note on the issue with the merge SHA and the two deviations from its text: no schema file (decision 1), and the policy line in project conventions with the synced standards pages unedited.
-
Status moves to
In progresswhen U1 starts and toDone (date)with U3.