Plan: the public surface, inventoried - one page naming every item an operator, a sibling extension or the phone relies on, kept true by a test

Closes: #280 (its inventory; the freeze becomes its own issue, filed as this lands, with the handoff below). Branch: docs/public-surface. Status: Done (2026-11-02) — public-surface.adoc lists the surface with tiers, and a validate test holds it to the code; the freeze is #701

Erratum (2026-11-02): the Package exports rows name each package’s stable candidates and call the rest internal without a count, since nothing would keep a count true as exports change.

TL;DR

#280 asks for the 1.0 public surface, frozen and documented. The operator parked the freeze until a 1.0 date and un-parked the inventory. The inventory was taken on 2026-11-02 across every package:

  • Operator-facing: 7 per-user config files under the agent dir, each with validated keys (gadhs-pi-modes.json alone has 61 keys); 10 slash commands; 29 tools (16 new, 7 replacing pi’s, the bash two packages may own); about 40 environment variables; 14 bus channels; two versioned wires (the SSH helper’s PROTOCOL_VERSION, the local hub socket’s HUB_PROTOCOL), and the phone’s wire owned by @gadhs/pivot-wire 0.10.0.

  • Code-facing: 10 packages exporting about 250 identifiers. Apart from each package’s default export, the loader contract, only a few dozen are imported by another package; the rest are used nowhere outside their own, or only in tests.

  • Gaps: one config key documented nowhere (mode.planAuthoring); 14 top-level keys missing from modes.adoc’s `ModesConfig summary table; 15 environment variables and 6 bus channels with no doc mention; and nothing anywhere, no snapshot, no schema, no test, that would catch a change to any of it.

The design: one page, public-surface.adoc, with a table per kind. Each row names the item, the file that defines it, the page that documents it, and a tier. A test derives each kind’s names from the code and fails when the page lists something the code lacks or the code has something the page lacks. The gaps close where their canonical doc is. No key, export or event changes; no schema; no contract test per item. Those are the freeze.

Tiers, the operator’s decision (2026-11-02): stable is what crosses the install boundary and is a 1.0 candidate: config files and keys, commands, tools, environment variables an operator sets, the bus events a sibling extension consumes, and the versioned wires. internal is the rest: package exports beyond the default export and the helpers a sibling imports, debug-log event names, session entry kinds, review-log event names. upstream is owned elsewhere and pinned: pivot-wire, pi’s own settings.json keys. Nobody installs a package alone; @gadhs/pi pins every sibling exactly, so an export’s only consumer is a sibling in the same release, and a promise on 250 names would protect no one.

Design

The page

docs/modules/ROOT/pages/public-surface.adoc, under Project in nav.adoc after packages.adoc. One section per kind, in this order, each a table with the columns Item, Defined in, Documented in, Tier:

  1. Configuration files under the agent dir: the file, its loader (config.ts, workflow-config.ts, pi-agents/index.ts, pi-ssh/config.ts, pi-remote/config.ts, pi-vertex/config.ts, helper-retention.ts), and its keys. The modes overlay’s 61 keys are not repeated: the row links `modes.adoc’s two tables, which this plan completes. The other files' keys are listed in full, since no table holds them today.

  2. Slash commands: 10 rows.

  3. Tools: 29 rows. The seven pi tools pi-ssh re-registers say so; the bash pi-workflow registers only when pi-ssh has not is one row with both owners.

  4. Environment variables: every process.env read outside tests, with one line each on what it does. Operator-set ones are stable (PI_OFFLINE, PI_BRUSH, PI_WINDOWS_SHELL, GADHS_PI_*, GADHS_PIVOT_RELAY, VERTEX_CONFIG, the Google ones, OTEL_*, GITLAB_TOKEN); the ones pi sets for a child (PI_SESSION_ID and the session markers) and the ones read as facts (TERM, VTE_VERSION, WSLENV, MSYS) are internal.

  5. Bus channels: 14 rows, with the emitting and listening packages and the payload type’s name. The gadhs: ones a sibling may consume are stable; gadhs:bash-owner, gadhs:bash-shell and gadhs:hub-wanted are internal (between our own packages); the permissions:* three are upstream.

  6. Wires: PROTOCOL_VERSION (pi-ssh), HUB_PROTOCOL (pi-remote), and @gadhs/pivot-wire at its pin, each with the file that declares it and the page that describes it.

  7. Package exports: one row per package: its subpath map, its default export, and the named exports a sibling imports (stable candidates, named), with the count of the rest (internal). The full list is the code’s index.ts, linked, not copied.

  8. Records: session entry kinds (gadhs-recap, gadhs-adjudication and the rest), the review-log event names task.mjs verdicts reads, and the diagnostics-stream event names, each as a list, all internal. They are named so a reader of a session file or a log knows what wrote a line, not as a promise.

The page opens with the tier definitions above and one sentence on what the page is not: a freeze. It closes with the gaps it found and where each was closed.

The test

tools/lib/test/public-surface.test.mjs, with its reader in tools/lib/public-surface.mjs, part of task validate. For each kind it reads two sets and asserts they are equal, naming every difference:

Kind From the code From the page

Commands

the first argument of every pi.registerCommand("name", …​) under packages/*/, tests excluded

the Item column of the Slash commands table

Tools

every name: "…​" in a registerTool call, plus the seven pi tool names pi-ssh’s switched* re-register

the Tools table

Environment variables

every process.env.X, process.env["X"] and env.X read under packages// outside tests, by a regex over the sources; a read through a template, process.env[\`GADHS_PI_SSH_${name}\]` (pi-ssh/helper.mjs), is one item, the prefix with , and the page’s row for it names the four names the file lists

the Environment variables table

Bus channels

every string constant whose value starts with gadhs:, gadhs-hub: or gadhs-msg:, and the three permissions: literals

the Bus channels table

Wires

PROTOCOL_VERSION, HUB_PROTOCOL, and pivot-wire’s pinned version in pi-remote/package.json

the Wires table’s version cells

Config files

every join(agentDir, "<name>.json") or equivalent path constant

the Configuration files table

Overlay keys

OVERLAY_KEYS, exported from config.ts (the one code change): the nested blocks' tuples it already holds (JUDGE_KEYS, TITLE_KEYS, SHORTCUT_KEYS, UNATTENDED_KEYS, COMPACTION_KEYS, MONITOR_KEYS) and, for the top level and the mode descriptor, lists written beside their validators, which check keys one by one today

`modes.adoc’s two summary tables, read by the same parser

Package exports

each package.json’s `exports map

the Package exports table’s subpath cells

The page is read by a small AsciiDoc table parser: a section’s table is the rows between \|=== markers under its heading, and the items of a row are every backticked word of its first cell (modes.adoc’s `ModeDescriptor table opens with a cell holding both id and label). Records are not checked: debug-log names change with every feature and a test on them would be noise; the page says so.

A disagreement fails validate with the kind and the names on each side, so an item added without its row, or a row left after its item went, is caught at push. The test is the inventory’s teeth; it binds nothing.

The gaps, closed where they live

  • modes.adoc’s `ModesConfig table gains the 14 missing top-level rows (stickyModel, recap, worktreeAgents, imageModel, workingLine, registryFacts, registryTimeoutMs, contextBudgetKiB, shortcuts, unattended, compaction, title, requestWarnMb, imageBudgetMb), one line each, linking the section that explains the key. The ModeDescriptor table gains planAuthoring, with what it does read from config.ts and its one consumer.

  • The 15 environment variables and 6 bus channels with no page get their line on the new page; the four GADHS_PI_SSH_* helper tunables (IDLE_MS, RESUME_BYTES, FINISHED_KEEP_MS, DAEMON_START_MS, helper.mjs lines 46-53) also get one sentence in `ssh.adoc’s helper section, where a reader tuning the helper looks.

  • subagentPolicy.profiles is named in modes.adoc where enforce is.

Found by the inventory and left as issues, not scope: exports used by nothing (a trim is the freeze’s), and plan pages that name keys the code never grew (kernel-sandbox.adoc’s `sandbox, coming-back.adoc’s `alt+d): plans are history.

Scope

In

  1. tools/lib/public-surface.mjs: the code readers (one function per kind) and the page reader. Tests (contract): each reader against a fixture tree with a known answer; the page reader against a fixture page; a seeded disagreement is reported with the kind and both names (regression: the test cannot pass vacuously, asserted by a fixture where the page lists one item too many and one too few).

  2. tools/lib/test/public-surface.test.mjs: the real comparison, in validate. Test (contract): it passes on the tree as committed.

  3. packages/pi-modes/config.ts: OVERLAY_KEYS, one exported record of the key names per block, so the test and the later schema read one list. Test (regression): for every listed key, a value of the wrong type makes validateModesConfig throw naming that key, which proves the validator knows it; and each nested block’s list equals the tuple its validator refuses unknown keys against. The top level and the mode descriptor accept an unknown key silently today (recapp: false does nothing): a finding for the freeze, filed as an issue, since refusing them is a behaviour change.

  4. docs/modules/ROOT/pages/public-surface.adoc and its nav.adoc entry.

  5. modes.adoc: the 14 summary rows, planAuthoring, subagentPolicy.profiles. ssh.adoc: the helper’s four variables. packages.adoc: one sentence pointing at the new page.

  6. CHANGELOG under Unreleased.

  7. Delivery: one MR, Closes #280. As it lands, a new issue, "chore: freeze the 1.0 public surface", carries what the freeze still needs: the overlay schema validated at load (refusing the unknown top-level keys accepted silently today), a contract test per stable item, the export trim, and the page as its starting list. It is labelled deferred until the operator sets a 1.0 date, as #280’s note was.

Out

  • Any change to a key, export, event, command or tool: the inventory records; the freeze decides.

  • A JSON Schema for the overlay, contract tests per bus event, an export trim, API-extractor or d.ts snapshots: the freeze.

  • Checking the records (debug-log and review-log names): listed, not tested, for the reason above.

  • pivot-wire’s own surface: owned by its repository; the page names the pin and links its docs.

Risks

Risk Response

The code readers are regexes, and miss a registration written another way (fail-open: an item the page lacks goes uncaught)

Each reader’s fixture holds every form found in the tree today (a name: literal, a constant, pi-ssh’s switched* factory list); a new form is a one-line reader change, and the fixture pins it.

The page reader breaks on an AsciiDoc table edit (fail-closed: validate goes red)

The parser reads only the first backticked word of a row between |=== markers; the test’s failure names the row it could not read.

The test adds friction: every new tool or env var now needs a row (fail-closed)

That is the point; the row is one line, and the failure says which. The records, which change most, are not checked.

The tier column reads as a promise before 1.0 (silent: a reader relies on "stable")

The page’s first paragraph says the tiers are the freeze’s candidates, not its promise, and that pre-1.0 breaking changes stay allowed and changelogged, as the standards say.

OVERLAY_KEYS drifts from the validator (silent)

Built from the same tuples the validator reads, and the regression test feeds every listed key through validateModesConfig.

Acceptance

  • task validate passes on the branch, and fails with the kind and the names when a tool, command, env var, channel, config file, overlay key or export subpath is added or removed without its row (shown by the fixture cases, and once by hand on the real tree before the MR).

  • public-surface.adoc lists every item the inventory found, with a tier; the gaps named above are closed in their canonical pages.

  • #280 carries the note that hands the freeze its starting point.

Edit this page · latest