ADR-004: Package boundaries — policy, workflow, and content are separate packages

Status

Accepted

Date

2026-08-31

Deciders

@bitskrieg (Chris Apsey)

Tags

architecture, packaging, distribution

Relates

ADR-002 (downstream-in-spirit), ADR-003 (config lives in @gadhs/pi)

NOTE
2026-12-04 amendment (#836): the packages remain as boundaries in the workspace, and only @gadhs/pi is published (the ten sibling packages are private: true and move in lockstep with @gadhs/pi).

Context

@gadhs/pi-modes began as the workflow-modes framework and accreted most of the agency behavior layer: the permission policy and judge, the git workflow guards and the cold-reader commit review, the agency guidance payload and its language profiles, generic tools, governed memory, and the judge evaluation harness. Each arrival was individually reasonable — "a small addition to the package that already loads at session start" — and the sum is a package whose name says modes and whose diffs range from security-critical enforcement to prose wording.

Two costs became visible in practice:

  • Review posture mismatch. A guidance wording tweak (a one-sentence change to an agency rule) version-bumps and re-reviews the same package that carries the judge and the authorizer. Content diffs want prose review; enforcement diffs want security review. One package means one posture.

  • A concern defined by mode-independence living inside the modes package. The workflow guards deliberately apply in every mode — the per-mode opt-out was removed as a design decision — yet they ship inside the package whose organizing concept is per-mode variation.

A third force arrived with subagent definitions (#33): pi packages cannot ship agent definitions at all (the pi manifest is exactly extensions|skills|prompts|themes, and @gotgenes/pi-subagents discovers agents only from two on-disk directories), so agency-standard helpers need a seeding extension — content delivery, with no natural home in pi-modes.

Decision

Split by concern, using three criteria: change cadence, review posture, and actual coupling to modes. Consumers are unaffected — pi install npm:@gadhs/pi remains the whole story; only the meta package’s loader list changes.

Package Carries Rationale

@gadhs/pi-modes

mode-policy, authorize, judge, denial-tracking, config, modes.json, bootstrap, subagent-gate, plan-mode, status, trace, and the small stable tools (ask, count, yield, checkrun) plus governed memory

The permission lifecycle is one concern: rules, staging, judge, and the config that feeds them change together and get security review together. The small tools and memory stay because splitting them is churn without a differing change cadence — four GADHS packages plus provider and meta is the ceiling of this decision.

@gadhs/pi-workflow (new)

git-guard (commit format, trailer mutation, --no-verify, main-branch, stage/commit separation, glab preflight, the J1–J8 reflection pause), reflection-review (cold reader), authoring-guard

Delivery-workflow enforcement, mode-independent by design. Its diffs are always enforcement diffs. The SCRATCH_ROOTS mirror test becomes a cross-package dev-dependency, which is correct: it exists to bind the two packages' views of scratch space.

@gadhs/pi-guidance (new)

guidance/global.md, the four language profiles, payload composition (guidanceSections; until #729 composeSystemPrompt/stripGadhsBlocks, which composed one forced prompt - amended 2026-11-09), the /gadhs-init skeleton

Agency standards prose. Changes are wording, reviewed as prose, and should reach consumers without version-bumping the judge.

@gadhs/pi-agents (new, #33)

Explore/Verify/Research definitions plus the managed-file seeding extension

Content delivery around an upstream gap (#35). If upstream grows registerAgentType(), only this package changes.

Additionally, the judge evaluation harness (eval/) is confirmed dev-only: the root-only files glob never shipped it, and the pack test now pins that as a decision rather than an accident of glob shape.

Consequences

  • The meta package gains loader shims for the three new packages and remains logic-free.

  • pi-modes exports its trace/status helpers for the sibling packages; if a third consumer appears, promoting them to an internal shared package is a new decision, not this one.

  • @gadhs/pi-workflow declares @gadhs/pi-modes as a dependency only if a runtime import proves necessary during extraction; the mirror-constant pattern (assert-equal in tests, no runtime coupling) is preferred and is the current state.

  • Versioning: the new packages start at 0.1.0 and ship together with the 0.2.0 distribution release.

  • The cold-reader review of any enforcement change now sees a diff whose blast radius is legible from the package name alone.

  • A package’s per-user tuning file is <agentDir>/gadhs-pi-<name>.json. The convention is load-bearing: /gadhs-reset (pi-modes, #104) finds every package’s tuning by that name, since pi-modes may not import the packages to ask them. pi-vertex’s vertex-models.json predates the convention and is enumerated as the one exception.

Amendment (2026-09-15): a seventh package, @gadhs/pi-remote

pivot (gadhs/standard/package/pi-pivot), the agency’s phone client, needs a box side that runs inside pi: it must mirror the session the developer is in and answer the dialogs pi-modes owns, and pi has no hook for one extension to reach another’s dialog from outside the process. By the criteria above it is its own package, not a pi-modes module: its change cadence follows pivot’s wire, not the permission lifecycle; its review posture is "network, keys and a phone", which a pi-modes diff never carries; and its only coupling to modes is the ask-broker contract (@gadhs/pi-modes/ask-broker, #140), a published seam. Ownership is by runtime: everything in pi’s process is this repository’s; the relay, the PWA, the crypto and the wire protocol are pivot’s and arrive as @gadhs/pivot-wire. The meta package gains one dependency and one loader (60-remote.ts, after modes); the tuning file is <agentDir>/gadhs-pi-remote.json by the convention above, and its state lives in <agentDir>/gadhs-pi-remote/. The ceiling this decision set (“four GADHS packages plus provider and meta”) moves to seven for this one reason; another would need its own decision.

Amendment (2026-09-26): a library, @gadhs/pi-bash

This decision kept pi-modes and pi-workflow apart and preferred copies held equal by test to runtime coupling. For constants that holds. For the bash parser it failed. pi-workflow’s bash-structure.ts (#14) came first, for the commit guard, and pi-modes copied it as bash-line.ts when the compound-line fix (#205) needed a parser. The wrapper tables drifted:

  • first inside pi-workflow, two tables pinned equal (#62);

  • then between the packages, on the day pi-modes grew its own (#208). pi-workflow’s commit guard did not unwrap setsid, so setsid git commit passed it unseen.

The parser, its two views and one wrapper table become a library package, a species beside the extension packages (#206). A library ships no extension and needs no loader. The enforcement packages take it as a regular dependency and import it by name, and it reaches consumers through them, so the meta package is unchanged. By the criteria above:

  • its change cadence is the parser’s;

  • its review posture is enforcement;

  • it is coupled to neither mode nor workflow.

The mirror-constant preference stands for constants. A shared library is now the answer for shared logic. Like any package, a new one is its own decision.

Rejected

  • Splitting tools and memory out too — no differing change cadence today; speculative boundaries are over-engineering.

  • Renaming pi-modes (to pi-policy or similar) — accurate but churn; the meta package hides names from consumers, and pre-1.0 renames of published packages cost more confusion than the name earns.

  • Content inside the meta package — the meta’s value is that it is a pure manifest; the moment it carries logic or content its tests stop being purely structural.

Edit this page · latest