From 7b7eb2631a3da970141c36c1bf3802c1a13f58f3 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 17:26:56 -0700 Subject: [PATCH 01/12] docs: ADR-016 + ADR-017 full drafts, reviewer checklist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the ADR-016/017 stubs merged in #775 with the full drafts, and adds the incident-derived reviewer checklist assembled during milestone #11. ADR-016 (pod model and visibility) — kind x visibility tier x joinPolicy over the existing flags, no schema change. 7-state reachable enumeration, migration for the unrepresentable state, and an Enforcement gaps section verified against origin/main: 4 of 5 read surfaces consult the visibility tier; GET /api/agents/runtime/pods does not, and still returns latestSummary for non-member pods. ADR-017 (attention routing) — judge divergence + static irreversibility feeds, escalation envelope with required typed evidence, needs-you card with four lifecycle-visible faces, in-pod first. Budget sized against EEMUA/ISA-18.2 rates (source-verified, with the transfer caveat stated). docs/development/review-checklist.md — 13 reviewer rules, each carrying the incident that earned it. Both ADRs are Proposed, not Accepted; ratification is Sam's. Co-Authored-By: Claude Fable 5 --- docs/adr/ADR-016-pod-model-and-visibility.md | 139 ++++++++---- docs/adr/ADR-017-attention-routing.md | 211 ++++++++++--------- docs/development/review-checklist.md | 46 ++++ 3 files changed, 251 insertions(+), 145 deletions(-) create mode 100644 docs/development/review-checklist.md diff --git a/docs/adr/ADR-016-pod-model-and-visibility.md b/docs/adr/ADR-016-pod-model-and-visibility.md index fc4b2da8d9..01788a47ec 100644 --- a/docs/adr/ADR-016-pod-model-and-visibility.md +++ b/docs/adr/ADR-016-pod-model-and-visibility.md @@ -1,62 +1,115 @@ # ADR-016 — Pod model and visibility -**Status:** Proposed (stub — decision not yet made) +**Status:** Proposed — full draft for ratification (replaces the stub merged in #775) +**Shipped as of 2026-08-01 (`d07ab712`):** #780 landed the `communityListed` writer + `podListing.ts`; #781 landed the DM exclusion on the agent runtime discovery route. **One invariant below is NOT yet enforced in code** — see §Enforcement gaps. **Date opened:** 2026-07-28 +**Date drafted:** 2026-07-28 +**Author:** pod-architect (Sam ratifies) +**Informed by:** #770 (label incoherence), #772 / PR #779 (missing listing writer + join-gate/discovery contradiction), idea-register P1/P5 -## Why this is open +## Decision, in one paragraph -The pod-creation flow asks the user to choose "Team Pod" or "Private Pod". That -choice sets one field, `joinPolicy`, and nothing else. `type` is hardcoded to -`'team'` regardless. Two pods created either way behave identically for every -human-facing purpose today, because the join path additionally requires -`communityListed`, and **no HTTP route can set `communityListed` at all** — -only a seed script or a hand-written database edit. +A pod's audience is described by two orthogonal axes — **kind** (dm / room, derived from `type`) and **visibility** (an ordered tier: `private` → `showcase` → `community`, derived from `publicRead` + `communityListed`) — plus one constrained setting, **joinPolicy**. Storage does not change: the tiers are a *vocabulary and a set of invariants* over the existing boolean flags, enforced at every writer, never a schema migration. UI and API surfaces speak in tiers; only writers that can prove the invariants may touch the underlying flags. -So the most prominent decision in the creation flow is, in practice, inert. +## The axes -Worse, "Private" means three different things depending on where you are: +### Kind — derived, not chosen -| Surface | "Private" means | -|---|---| -| Creation card | an invite-only room | -| Sidebar filter | a 1:1 DM | -| Pod inspector | an agent-room | +`kind = 'dm'` if `type ∈ {agent-room, agent-dm}` (the ADR-001 §3.10 strictly-1:1 set), else `kind = 'room'`. (`agent-admin` is a room: N:1 by design.) -And the "Team" filter matches `type === 'team'`, which **excludes every user's -auto-created "My Workspace"** (created as `type: 'chat'`) while including any -pod created via the "Private Pod" card. +- DMs are terminally private: never listable, never publicRead, membership fixed at 2. Every visibility writer refuses them (already true in PR #779's endpoints). +- The behaviorally identical room types (`team`, `chat`, `study`, `games` — no backend branch keys on them) become **presentation labels**. We do not collapse the `type` column now: additive-not-destructive, and identity continuity says a stored discriminator outlives its UI. Answering the stub: yes to *conceptual* collapse, no to a column migration nothing needs yet. -## The shape of the decision +### Visibility — an ordered tier, each step strictly adds audience -Three axes appear to be genuinely independent, and the current model conflates -them into one creation-time fork: +| Tier | Flags | Who can read | Who can find | +|---|---|---|---| +| `private` | `publicRead:false, communityListed:false` | members (+ admin ops per canViewPod) | members | +| `showcase` | `publicRead:true, communityListed:false` | **anyone, incl. anonymous** | nobody new — reachable by link only | +| `community` | `publicRead:true, communityListed:true` | anyone | any authenticated user, via Discover | -1. **Kind** — is this a DM (strictly 1:1, per ADR-001 §3.10) or a room? -2. **Who can find it** — unlisted, or discoverable in Community -3. **Who can join** — invite-only, or open to anyone who finds it +`{publicRead:false, communityListed:true}` is **not a state**. It is the joinable-but-invisible bug (#772). The lattice is linear on purpose: monotone audience growth means "which tier is this pod in" is always answerable and each promotion is a strictly bigger disclosure, which is what the audit log records. -A fourth, **who can read it** (`publicRead`), currently varies independently of -all three, which produces states that contradict each other: a pod can be -listed-but-unreadable, or readable-but-unfindable. +### Join — one setting, gated by the tier -## Open questions +`joinPolicy ∈ {open, invite-only}`, meaningful combination rule (PR #779's `isDirectlyJoinable`): -- Do we collapse `type` to `kind`, given that `chat` / `study` / `games` / - `team` are behaviorally identical (no backend branch keys on them)? -- Should visibility be chosen at creation at all, or set afterwards once the - pod has content worth showing? -- What happens to existing pods on migration — is there a state that has no - faithful representation in the new model? -- Does `parentPod` belong in this ADR or its own? (see the register, P2) +> **self-joinable ⟺ tier = community ∧ joinPolicy = 'open'.** You can only self-join what you could have found. -## Scope note — deliberately excluded +- Invite redemption is the separate, always-available rail into any room at any tier. +- `joinPolicy:'open'` below `community` tier is a *dormant declaration*, not an incoherence: "open once listed." Preset UI must present it that way. +- Invite-only pods at `community` tier are excluded from Discover (ruling 51621) until a request-access primitive (register H5) gives a non-joinable row a real action. `COMMUNITY_LISTING_QUERY` deliberately owns only listed-ness, so that flip is one query line later. -The consumer-versus-developer question (who this product is for) affects how -much explanation the creation flow needs, but is **not** decided here. Current -working position: developer-first, with the consumer path gated behind a -sandbox layer. If that reverses, revisit the labels but not the model. +## Invariants (every writer enforces; no reader compensates) -## Not yet decided +1. **listed ⇒ readable** — `communityListed` requires `publicRead` (writer 409s; unpublish cascades unlist). +2. **self-joinable ⇒ listed** — join gate is the discovery predicate plus joinPolicy. +3. **dm ⇒ private, forever** — visibility writers refuse dm kinds; membership fixed at 2 (DM_POD_TYPES_GUARD). +4. **Promotion is deliberate and audited** — each tier step is its own admin action (`showcase.publish`, `community.list`) with its own AuditLog row; no writer flips two flags on a caller's behalf (the 409-not-auto-publish decision). +5. **One predicate module** — `backend/services/podListing.ts` is the sole owner of the flag logic; a grep for `communityListed` outside it and its writers finding raw boolean logic is a regression. -This stub exists to hold the shape of the problem so it is not re-derived from -scratch. It should not be cited as a decision. +## Reachable-state enumeration + +Rooms: 3 tiers × 2 join policies = **6 states**, all meaningful: + +| # | Tier | joinPolicy | Reading | In Discover | Self-join | Name in UI | +|---|---|---|---|---|---|---| +| 1 | private | invite-only | members | no | no | Invite-only | +| 2 | private | open | members | no | no (dormant) | Invite-only (open once listed) | +| 3 | showcase | invite-only | world | no | no | Showcase | +| 4 | showcase | open | world | no | no (dormant) | Showcase (open once listed) | +| 5 | community | invite-only | world | **no** (until H5) | no | Listed, invite-only | +| 6 | community | open | world | yes | **yes** | Open via Community | + +DMs: exactly **1 state** (private, 2 members, invite/creation rail only). Total reachable: 7. + +Unreachable by construction after PR #779: `{publicRead:false, communityListed:true}` (writer refuses, cascade removes), and any dm kind outside state row "DM". + +## Migration — pods with no faithful representation + +One idempotent script (pattern: `scripts/migrate-agent-dm-multimember.ts`), each mutation logged to AuditLog with `action: 'adr016.migrate'`: + +1. **`{publicRead:false, communityListed:true}` rows** → `communityListed := false` (tier `private`). Faithful because the state never rendered anywhere: invisible to both discovery scopes, and its only behavior — joinable by raw id — was the #772 bug, already dead via the narrowed gate. **Members who entered through the bug keep their membership**: revoking reads is a moderation decision about people, not a data migration, and the model must not silently eject anyone. +2. **dm kinds with `publicRead` or `communityListed` set** → assert none exist; if found, clear flags + flag for operator review (that would be a live privacy incident, not a cleanup). +3. **`joinPolicy` absent/null** → normalize to `invite-only` (the conservative default; matches the narrowing principle). +4. Emit a tier-distribution report (counts per state row above) so the first real numbers inform the #770 modal defaults. + +No schema change. No state is deleted, only re-expressed; the audit rows make every step reversible by hand. + +## Enforcement gaps — where the model is not yet the code (verified against `origin/main` @ `d3e00046`, 2026-08-01) + +The invariants above are enforced at the **writers** and at the **human** read surfaces. They are not yet enforced at one agent read surface: + +| Surface | Invariant 1 (listed ⇒ readable) | Invariant 3 (dm ⇒ private) | Content (`latestSummary`) | +|---|---|---|---| +| `getAllPods` / `joinPod` (human) | ✅ `podListing` predicates | ✅ | n/a | +| `POST /admin/pods/:id/{showcase,listing}` | ✅ 409 + cascade | ✅ refuses dm kinds | n/a | +| **`GET /api/agents/runtime/pods`** | ❌ **no `publicRead`/`communityListed`/membership filter** — `Pod.find({ type: { $nin: nonDiscoverableTypes } })` | ✅ (#781) | ❌ **returned for every pod listed** | + +Consequence, reproduced live 2026-08-01 before #781 and unchanged by it for non-DM types: any agent runtime token enumerates private unlisted `chat`/`team` pods and receives their generated conversation summaries. **This is the single highest-priority conformance gap in the model** and the reason ADR-016 is worth ratifying as more than description: the visibility tier is only real where every reader consults it. Fix: the route composes `communityDiscoverQuery` for discovery breadth plus the caller's `AgentInstallation` pods for membership, and omits `latestSummary` for non-member pods (existence and content are separable disclosures; leaking the latter is strictly worse). + +**Rule this generalizes into (ADR-016's operative clause):** *terminal privacy and visibility tiers must be enforced at every read surface, not only at the writers that set them.* A tier enforced at 4 of 5 readers is not a tier. + +## Writers, current and planned + +| Writer | Sets | Guard | Status | +|---|---|---|---| +| `POST /api/admin/pods/:id/showcase` | tier ↔ private/showcase | admin; refuses dm kinds; unlist cascade | live (PR #766-era + #779 cascade) | +| `POST /api/admin/pods/:id/listing` | tier ↔ showcase/community | admin; 409 below showcase; refuses dm kinds | PR #779 | +| Creation flow presets (#770 deliverable 2) | joinPolicy at creation; tier stays `private` | presets can only express the 7 reachable states | parked until this ADR ratifies | +| Owner "request listing" | asks an admin for tier promotion | H5 request-access shape | phase 2, explicitly out of scope here | + +Answering the stub's second question: **visibility is not chosen at creation.** Every pod is born `private`; promotion is a later, deliberate act on a pod that has content worth disclosing. This matches the curation model, keeps the creation modal to one honest choice (join policy), and makes "I accidentally created a public pod" structurally impossible. + +## Out of scope + +- `parentPod` / pods-as-graph — parked (register P2) pending competitor-source evidence; separate ADR if activated. +- Renaming the storage columns; retiring `type` values. +- The consumer-vs-developer positioning question (unchanged from stub). +- Request-access (H5) mechanics — only its *slot* in the model is reserved (state row 5's Discover exclusion). + +## Consequences + +- #770's modal can now be designed against a ratified vocabulary: one kind, one join choice at creation, tier promotions elsewhere. +- Every future read surface composes `canViewPod` (read) with `podListing` (find/join); a new endpoint that open-codes a flag is reviewable as a defect by rule 5. +- The showcase F3 warning inherits a sharper statement: promotion to `showcase` is the world-readable event; `community` adds findability and (if open) joinability, never readability. diff --git a/docs/adr/ADR-017-attention-routing.md b/docs/adr/ADR-017-attention-routing.md index 90892b5f82..6a65860780 100644 --- a/docs/adr/ADR-017-attention-routing.md +++ b/docs/adr/ADR-017-attention-routing.md @@ -1,135 +1,142 @@ # ADR-017 — Attention routing -**Status:** Proposed (stub — decision not yet made) +**Status:** Proposed — full draft for ratification (supersedes the 2026-07-28 stub) **Date opened:** 2026-07-28 +**Date drafted:** 2026-07-29 +**Author:** pod-architect (Sam ratifies; delivery-channel choice is explicitly his) +**Informed by:** idea-register H1–H6, judge spec + needs-you-card design round (sprint pod, 2026-07-28/29), ADR-016 draft -## Why this is open +## Decision, in one paragraph -Keeping a human in the loop is a stated product value, but the usual -implementation — an approval gate on each consequential action — assumes a -human is sitting and watching. They are not. A gate nobody attends either -blocks work or gets clicked through without reading, and both outcomes are -worse than no gate. +Attention routing is three separable layers: **two detection feeds** (a cheap judge that flags divergence from the intent an agent accepted, and a static irreversibility classifier that needs no model at all), a **routing layer** that spends a visible escalation budget and learns from dismissal, and a **rendering layer** built around one invariant unit — the needs-you card — with digest, in-pod, and push as renderings of that card, shipped in that order. v1 is **observe-only**: it flags, it never suspends. Holds arrive in stages tied to what can honestly hold, never as a promise the mechanism can't keep. -The reframing this ADR exists to settle: +## Layer 1 — detection feeds -> The primitive is not *"stop and ask before every action."* -> It is *"decide what deserves a human at all."* +### The judge (divergence feed) -Call it **attention routing** — the system spends a scarce resource (human -attention) rather than assuming it is free. +Compares one action against the **accepted intent**. Deliberately *not* a correctness model — correctness needs ground truth, policy needs authoring, anomaly detection needs baseline volume; divergence needs only two things CAP already records. -Under that frame, the familiar options stop being alternatives and become -states of one mechanism: +**Accepted intent, precedence (latest-wins):** +1. a claimed task's description (`commonly_claim_task` — explicit acceptance) +2. the `chat.mention` payload the agent replied to (the reply is the acceptance) +3. the pod goal (fallback for unprompted work, e.g. heartbeat) -- **notify** — the default. Something happened you may want to know about. -- **approve** — escalated. Something is about to happen that should not - proceed unattended. -- **interrupt** — human-initiated. Stop or redirect a turn in flight. +**Re-bindable intent:** any later in-thread message from the intent's issuer addressed to the agent supersedes the accepted intent for subsequent actions. Latest human word wins — ordering, not semantics. Rendering consequence (ux-lead): the card must quote the *superseding* message, or every flag on a renegotiated task reads as a false positive and trains dismissal. -## What we already have +**Contract:** per-action, stateless, small-model. Input: intent text, one action record, one line of pod context — no transcript crawl. Output: -Worth naming, because it is more than it sounds: agents and humans share the -same rooms by construction, agent-to-agent DMs are readable by humans who share -a pod with either participant (ADR-001 §3.7), and an a2a DM announces itself -with a system message. Agent work is **observable** today. What is missing is -everything that acts on that observability. +``` +{ diverged: bool, + class: scope-expansion | target-change | irreversible-outside-intent | abandonment | other, + evidence: { intent_quote, action_quote }, + why: one sentence } +``` -## The open design problem: not being noise +**Classes, not scores.** Scalars are miscalibrated and thresholds rot; classes map to human sentences ("did more than asked" / "changed target" / …) that are the card headline, and they are the unit the routing layer budgets and mutes. `other` (+ free-text why) is the taxonomy's escape valve: whether four classes are exhaustive is empirical, and observe-only v1 is the instrument that answers it before anything gates on the answer. -A notifier that fires often gets muted, and a muted notifier is worse than -none, because it looks like coverage. Starting positions, none decided: +### Static irreversibility (H4 feed) -- **A judge model compares an action to the intent the agent accepted.** It - does not need to evaluate whether the work is *good* — only whether it - diverged. That is a much cheaper question, and a small model can answer it. -- **An escalation budget**, N per agent per day. Scarcity forces ranking. An - unbudgeted judge has no reason to be selective. -- **Learn from silence.** Approved or ignored three times for a class of - action, stop escalating that class. Anti-spam that needs no configuration. -- **Escalate on irreversibility, not importance.** Outward-facing, spending, - destructive. Importance is subjective; irreversibility is a property of the - action and can be determined statically. +A property of the tool call, determined without any model: outward-facing, spending, destructive. Evaluated at the kernel tool layer. Its evidence is computed from the action record itself (branch names, recipient count, dollar amount) — the floor is never "trust me," even where the judge is absent or wrong. -## The reframe: human attention is the resource, and the agent spends it +## Layer 2 — the escalation event envelope -A later and better framing than the one above; read the rest of this ADR -through it. +Both feeds emit into one envelope; **evidence is required**, typed per feed: -If agents are cheap and human attention is scarce, then human attention is the -only real constraint in the system — and the agent is the thing spending it. -That inverts the mechanism. +``` +{ escalationId, // stable id — every render, decision, and audit row references it + action, // what happened / is pending + feed: judge | static, + class, // divergence class, or the irreversibility category + evidence, // tagged union, discriminated by `feed` — see below + acceptedIntent, // the quoted intent text the judge compared against (null for static-feed unprompted) + state: flagged | held, // hold status of the UNDERLYING action — see staging; v1 emits only `flagged` + lifecycle: pending | resolved | expired, // status of the ESCALATION itself + actions: [ { id, label, kind: safe | risky | ack } ], // stable IDs; cards render by kind, never by position + decision, // set on resolution: { deciderId, actionId, decidedAt, messageRef } + basis: { ref, intentRef, computedAt }, // the state snapshot + intent version the escalation was computed against + refs } // podId, messageId/runId, agent +``` -The draft above assumes a judge model watches agent output from the outside and -decides what escalates. But **the agent already knows what it is uncertain -about.** A judge has to infer that after the fact, expensively, and less well -than the agent could simply report it. +**Staleness is a first-class field (sprint-review + ux-lead inputs, 2026-07-29).** An escalation is computed against a state that can change before a human sees it — the observed failure mode is not volume but *a correct verdict delivered seconds after the decision it addressed* (delivery delayed by an outage; the referenced PR already closed). A divergence-only judge cannot catch this, so the envelope carries it structurally: `basis.ref` names the state the computation saw (message id, run id, PR head), `basis.intentRef` names which intent version the judge compared against, `basis.computedAt` stamps it. The card renders the flag's age. Two-tier staleness rule: -**Give the agent a budget instead.** N human-interrupts per day; it chooses -what to spend them on. Scarcity becomes real from the agent's side, so -conserving is in its own interest rather than a rule imposed from outside. +**One rule for all staleness — expiry is re-evaluation, never demotion** (sprint-review composition fixes, 2026-07-29, second instance closing the tier the first left open). Whether the basis drifted (referenced entity closed/deleted/superseded) or the intent re-bound after `computedAt`: the stale card **auto-expires** — a card must never present a decision computed against superseded inputs — and the judge immediately re-runs the same action against the *current* state and intent, for `flagged` and `held` alike. Two outcomes only: still-divergent → a **fresh escalation at full attention** with a new `basis`; moot (target gone, concern resolved by events) → the escalation resolves as re-evaluated-clean in the digest trail. Never a silent attention downgrade. -This **deletes the judge from v1.** The judge becomes a fallback for agents -that misreport their own uncertainty — a v2 concern, not the foundation. +Why no tier may demote instead of re-evaluate: neither trigger is outside the monitored agent's reach — re-binding intent is ordinary agent behavior, and so is closing a PR or deleting a branch. Any demotion tier is therefore a self-suppression path: the party the escalation is about downgrades its attention as a side effect of working normally — the budget-unmutes-danger failure arriving through the staleness door. Re-evaluation removes the free downgrade while preserving both invariants exactly: a stale-but-confident escalation never interrupts, and **attention level is a function of the verdict against current state, never of who caused the drift.** -### The prior art is a permission model, not an alarm system +**Evidence is a tagged union discriminated by `feed`** — no separate type field, because the mapping is 1:1 and a redundant discriminator would drift. Judge feed: `{ intent_quote, action_quote }`, rendered as two attributed lines (intent vs action). Static feed: blast-radius facts, rendered as concrete nouns (names, counts, amounts). The card switches layout on `feed` and never guesses; if a future feed breaks the 1:1 mapping, add the explicit tag then, not before. -Claude Code and Codex already ship this under a different name. The user -pre-declares a boundary (`allow` / `deny`, path-scoped, plus a `defaultMode`) -and the system interrupts only on a **boundary crossing**. Commonly's own -public-agent policy is exactly that shape. +### Decision authorization — enforced, not implied -The delta for us is narrow, and worth stating precisely: +"Anyone in the pod can decide" is a product promise the backend must enforce; card copy never carries authorization. -| Claude Code / Codex | Commonly | -|---|---| -| synchronous — a human is present | asynchronous — nobody is | -| one agent, one session | many agents, concurrent | -| the prompt blocks until answered | must queue, rank, and route | +- **Deciders are human members of the pod the escalation posted to.** Enforced server-side at the decision endpoint (membership check in the `canViewPod` family — but deciding requires *membership*, not viewability: ADR-001 §3.7 read-only observers of a2a DMs can see an escalation and cannot decide it). +- **No agent may decide in v1** — least of all the escalated agent. Escalation exists to spend *human* attention; agent-deciders re-enter only as a deliberate future decision, never as a convenience. +- **First decision wins.** The endpoint is idempotent-by-refusal: a second attempt on a `resolved` escalation returns the recorded decision, it does not re-decide. +- **Every decision is a pod message** — attributed, CAP-visible, referenced from `decision.messageRef`. This is the same fact that makes in-pod the primary channel and feeds H3 attribution for free. +- **Expiry fails closed.** A `held` escalation that expires stays parked — the action is NOT auto-approved on timeout — and the digest re-surfaces it. `expired` is a lifecycle state, not a decision. -**Theirs prompts; ours has to queue.** That is the whole problem, and it is -much smaller than inventing a judge. Two modes fall out directly, both already -proven in those CLIs: a full-autonomy mode, and an -attention-on-boundary-crossing mode where the permitted set is declared up -front. +**Routing composes three inputs:** the two feeds plus the budget (H2, e.g. N escalations/day, surfaced on the card — visibility is what makes the interruption credible). -### Why this makes AX load-bearing +**The hold is not the interrupt (ux-lead amendment, load-bearing).** A hold is *safety*: the action parks regardless of any budget, and the card renders in-pod unconditionally. An interrupt is *attention*: the push/ping/badge that demands a human now — and only interrupts are budgeted. When the budget is spent, a static-feed hold still holds — parked action, in-pod card, digest entry — but its interrupt is suppressed. Safety never gets muted; the attention budget never gets breached. Without this split the two constraints collide: either budget exhaustion silently unmutes danger, or danger blows the budget. -If an agent must spend a scarce resource well, it needs an interface for doing -so: +**Rarity by construction for the static feed.** The override statistic (49–96% including maximum severity) is what happens to an unmutable alert class that fires too often. Defense: the irreversibility taxonomy stays closed — outward-facing / spending / destructive, nothing else; widening it is an ADR-level change, not a tool-author choice. Every new kernel tool must carry an **explicit** irreversibility declaration (absence is a lintable defect), and the declared default is `none` — no category inherits members silently. Rare because narrow, trusted because rare. -- **remaining budget as readable state** — you cannot ration what you cannot see -- **machine-readable affordances** — *what am I already permitted to do without - asking?* Today an agent discovers its limits by hitting 403s -- **a structured request format** — so a human resolves it in seconds rather - than minutes +**Budget ceiling — external constraint (source-verified by sprint-review, 2026-07-29).** EEMUA 191's operator-load scale: **<1 alarm/10 min acceptable** · 1/5 min manageable · 1/2 min over-demanding · >1/min very likely unacceptable. ANSI/ISA-18.2 defines alarm **flood as >10 alarms in 10 minutes** — the draft's earlier ~100 burst figure was wrong by 10×; the true ceiling is tighter, which constrains in the design's favor — and recommends a system spend <1% of time in flood. Clinical override magnitude is well-attested (~46–96% across reviews; exact endpoints unconfirmed at the primary source), with *untiered* systems accepting top-severity alerts at only ~10%. **Transfer caveat, stated rather than assumed:** this is process-control and clinical literature; its application to agent escalations is an untested analogy — v1's observe-only event log is the instrument that tests it. -Agent experience stops being courtesy toward agents and becomes the agent's -interface to the only scarce thing in the system. +Two design consequences: +1. The default budget is per **receiving human across all their agents** (the budget-owner recommendation below), sized against the *acceptable* band — a handful of interrupts per day by default, nowhere near the flood line. +2. **Classes carry differentiated interaction consequences, not severity scores.** Labels alone do not survive volume — untiered top-severity alerts are overridden ~90% — but **differentiated friction does**: tiering by interaction consequence (hard stop / forced-reason interrupt / passive display) took most-severe compliance from **34% to 100%** in the one direct comparison (Paterno 2009, JAMIA; cite as directional — small n, single specialty, pre-modern-EHR). This ADR's design is already that shape: action `kind`s (safe/risky/ack), the unmutable static feed, hold vs flag — friction differentiated by consequence class, never by a severity label. The rule is stated precisely so a future simplification cannot collapse the kinds into one uniform card *in conformance with this ADR*: **uniformity of friction is the failure mode, not tier count.** **Learn-from-silence (H3) operates on divergence classes only.** Explicit dismissal ("Expected — don't flag this again") is the same teaching signal as silence, just faster. The static feed is **never mutable** — silence may mean absent, not consenting, and nothing irreversible should inherit consent from absence. UI corollary: the class-mute button MUST NOT render on static-feed cards; they may offer at most a this-time acknowledgment. -### Two known weaknesses +## Layer 3 — rendering: the needs-you card -- **Do not surface this framing to users.** "Human as a resource agents - consume" is a good internal design frame and bad product copy. Nobody wants - to be told they are a rate limit. -- **Model calibration is the weak joint.** Budgeted self-reporting assumes an - agent knows when it does not know, and models are poorly calibrated. - Over-spending is self-correcting because the budget bites. **Under**-asking - is not — it produces silence, which is the failure mode that looks like - success. Measurement belongs in the first version, not after it appears to - be working. +The invariant unit (ux-lead's sketches, sources attached in-pod). Anatomy: state chip first (the state is the promise), quoted intent (the judge's comparison object shown to the human — "why am I seeing this" needs no explanation), typed evidence, budget line, actions. `state` describes the underlying action and gives the two primary faces; `lifecycle` adds two more — four lifecycle-visible faces total, all designed from day one so the product never claims a hold it didn't have and an implementer never improvises a face this section omits: -## Open questions - -- Who runs the judge — the kernel, or the wrapper? Kernel-side means it works - for every driver; wrapper-side means it can see the turn before it lands. -- What does an escalation *look like* in the product? A DM, a badge, a - system message in the pod, a push? -- Does the budget belong to the agent, the human, or the pod? -- Is "learn from silence" safe? Silence may mean absent, not consenting. -- Does an approval need to suspend the turn (hard, needs resumable turns) or - can it be advisory-after-the-fact for a first version? - -## Not yet decided - -This stub holds the framing so it is not lost. No mechanism here is committed. +- **`flagged`** (v1): past tense — "Force-deleted…, flagged, ran 24 min ago." Actions: open the run · tell the agent · class-mute (judge-feed only). +- **`holding`** (v1.5+): "Nova is holding…" with a real safe-primary / risky-secondary decision. Risky action never appears on a lock screen. +- **`resolved`**: buttons replaced by the decision attribution ("Approved by Sam · 11:41", linking `decision.messageRef`) — the card becomes the permanent record its pod message already is. +- **`expired`**: "Timed out — still parked; re-surfaced in your digest" — the fails-closed promise stated on the card itself. + +(The `resolved`/`expired` frames are committed to the sketch bundle in the post-ratification re-cut.) + +**Channel order: in-pod → digest → push.** (Joint recommendation after two design rounds; an earlier digest-first position from both seats was reversed once the flagged-state card proved in-pod works observe-only — sketch 5.) +- **In-pod first, and primary.** The escalation renders as a message from the agent in the pod stream — which needs zero new delivery infrastructure and works in flagged-only v1 (sketch 5 is the v1 face). Primary for a structural reason: the *decision* is a pod message too — CAP-visible, attributed — so H3's approve/ignore data rides existing rails instead of needing a new event source. It is also the only channel where escalation is social: anyone in the pod can decide, publicly. When v1.5 holds arrive, the same channel's card gains the `holding` state and real decision buttons. +- **Digest second.** The rollup read-model over events the in-pod channel already generates: "3 agents · 3 hours · 41 clean · one needs you." This is the retrospective pitch surface, not the system of record. +- **Push last.** Two lines, state first, conservative action only. A rendering, not a system. + +**Persistence, not repetition (in-pod) — bounded by expiry.** While a `holding` escalation is unresolved, the pod header carries one compact pinned needs-you indicator — the card cannot scroll out of existence and is never re-posted. One event, one persistent affordance, zero re-alarms ("chattering alarms" are the documented failure mode; off-delay consolidation is the standard remedy). The bound is as load-bearing as the pin: **every escalation carries a finite TTL**, the pin converts to the `expired` face on timeout, and pins never accumulate indefinitely — unbounded persistence is itself a named nuisance class ("stale alarms": annunciated for ~24h, desensitizing by presence), and a header of permanent pins is wallpaper, not signal. + +**The only-interrupter rule.** The escalation envelope is the *only* event class permitted to interrupt a human (push/ping/badge). Activity, "ran clean," social events are pull, always. The corrected flood line makes this necessary rather than prudent: ISA-18.2 puts alarm flood at **>10 per 10 minutes** — a single chatty non-escalation event class borrowing the push channel reaches flood almost immediately, and a channel in flood is a channel abandoned. + +**Demo scenario rule + candidate.** Any staged demo of a `holding` card must use a kernel-mediated destructive action so the hold is literally true. Candidate: **pod deletion** ("Nova wants to delete 'Old Sprint Board' — 1,400 messages") — kernel-mediated, genuinely irreversible, instantly legible. The hold rail attaches at the kernel API layer, not only at MCP tools, so any agent-authenticated destructive call can park — but the demo script must arrange that the agent actually has the delete permission (creator/owner) for the attempt to be real. Wrapper-local actions (an agent's own shell) are the poster children for `landed — flagged` (sketches 4–5). + +## Hold staging — what can honestly hold, when + +| Stage | Mechanism | Scope | Card state | +|---|---|---|---| +| v1 | none — observe-only | everything | `flagged` | +| v1.5 | **tool-layer refuse-and-park**: a `commonly_*` call returns "held, awaiting decision" + a pending-approval record (the 403+code pattern; no turn suspension) | kernel-mediated actions only | `holding` (real) | +| v2 | wrapper-cooperative turn suspension (H6-adjacent) | wrapper-local actions (agent's own shell) | `holding` | + +The v1.5 rung is the load-bearing correction from the design round: "holding" does **not** wait on resumable turns — it waits only on tool mediation, and only wrapper-local actions wait for v2. Demo rule: any staged demo of a `holding` card must use a kernel-mediated action so the hold is literally true. + +## Placement + +**Kernel-side.** Every input (intent records, action stream, decisions) is CAP-visible, so the same mechanism serves moltbots, codex wrappers, and webhook agents identically. Wrapper-side judging would see turns pre-landing but for one driver only — the abstraction leak rule 6 exists to prevent. Runs on the cheap-model tier; per-action cost is bounded by the no-transcript-crawl input contract. + +## Ratification points (Sam) + +1. Delivery channel order (in-pod first/primary is the joint recommendation after two design rounds). +2. Budget owner: recommended **the receiving human** (the protected resource is their attention), with optional per-agent sub-caps. The stub's alternatives (agent-owned, pod-owned) both protect the wrong thing. +3. The four-class taxonomy ships as-is with `other` as the escape valve — revisit after v1 data, not before. + +## Out of scope + +- H5 request-access (its slot: the action a non-joinable Discover row gains later — see ADR-016 state row 5). +- H6 interrupt/steer mechanics (v2 rung noted, not designed). +- Digest content beyond escalations (summaries, activity rollups — existing summarizer territory). + +## Consequences + +- The three "invisible differentiators" become renderable: the card quotes provenance (intent records), the hold demonstrates sandbox-grade control at the tool layer, and the in-pod decision makes the community surface the venue where oversight happens. +- Any new kernel action primitive must carry an explicit static irreversibility declaration at the tool layer (default `none`; absence is a lintable defect; the category set is closed at ADR level) — cheap at birth, unpayable as retrofit. +- A muted notifier is worse than none: if v1 digest open-rates collapse, the budget is wrong or the classes are wrong — the event log will say which, because every dismissal is attributed and classed. diff --git a/docs/development/review-checklist.md b/docs/development/review-checklist.md new file mode 100644 index 0000000000..aad05748a8 --- /dev/null +++ b/docs/development/review-checklist.md @@ -0,0 +1,46 @@ +# Reviewer checklist — incident-derived rules + +**Status:** Draft for adoption (assembled from milestone #11 *Sharpen*, 2026-07-28/29; assertion-inversion norm pending Sam's adopt-or-strike call) +**Audience:** reviewers, mid-PR. Distinct from `REVIEW.md`'s *Self-review checklist* (authors, pre-PR) — two checklists, two moments; retitled here to break the name collision. +**Scope:** applies to code review and to spec/document review; each rule names the incident that earned it. Companion to `/REVIEW.md` (the rubric); this file is the incident-derived checklist. +**Lands with (pointer edits, same PR):** index row in `docs/development/README.md` · companion pointer in `REVIEW.md` (cites §7) · mention beside REVIEW.md's required-reading line in `CLAUDE.md` · the CLAUDE.md sentinel-line correction (main still reads "sent verbatim" until this PR lands). + +## Tests and assertions + +1. **A test that passes without the fix is not a test.** Verify by mutation: revert the behavior under test and confirm exactly the paired assertion goes red, with no collateral. *(Earned: #772 — the join-gate, cascade, and 409 tests were each proven by single-test reverts; the one unproven half turned out to be the real gap.)* + +2. **Refusal cases pair the status assertion with invariant-preservation assertions.** "409" alone is half a test; the spec and the test must both say "409 AND the flags it refused to change are unchanged." A refusal path that silently mutates state passes the naive test. *(Earned: #772 — a test named "and leaves it untouched" never asserted the untouched half; a silent-publish mutation survived 19/19 on two branches.)* + +3. **Inverting an existing assertion on main requires citing the ruling that authorizes it** (in the test diff or PR body). Tests are the executable record of decided behavior; an uncited flip either implements an unrecorded decision or undoes a recorded one. *(Earned: #772 — a PR flipped `not.toContain` into `arrayContaining` implementing a struck spec line; the flip was the only signal, and nothing required it to be justified.)* — *pending adoption* + +4. **When two implementations share an author, diff their assertions, not just their logic.** Shared provenance leaks through tests: both branches of #772 got the route right and under-tested the same half of the same invariant. Blind spots replicate in what's *not* asserted. + +## Guards and predicates + +5. **A field predicate is only as real as the projection upstream of it** *(instance of §7)*. When reviewing any `if (doc.field …)` guard, grep for the query that produced `doc` and confirm the field is selected — an `undefined` never throws, it just never fires. The guard reads locally correct; the defect lives in a different expression, possibly a different file. *(Earned: #781 — an invite-only self-install guard was inert because `joinPolicy` was omitted from the Mongo `select`.)* + +6. **Predicates live in one module; a grep finding raw flag logic outside it is a regression.** Two surfaces that must agree (a query and an in-memory check) derive from one exported predicate, and the module exports the complete query — a fragment that callers must compose invites the third caller to compose it wrong. *(Earned: #772 — the join gate and discovery queries drifted for months because each open-coded the flags; fixed by `podListing.ts`, tightened when review showed the fragment/predicate mismatch.)* + +## Phantom cross-layer contracts + +7. **Phantom cross-layer contract** *(the general form; rule 5 is its projection instance)*: a value one layer reads that another layer promises — in prose — to provide, with nothing but a docstring holding the two together. "The query sets this field" / "the middleware sets this field," both false, both masked by a fallback close enough to hide it. Five instances in one sprint, in escalating severity: `joinPolicy` missing from a `.select()` → invite-only guard compares `undefined` and never fires; `req.agentTokenHash` documented as "set by agentRuntimeAuth" but never assigned → the preferred rate-limit key never executed, and the header-string fallback silently gave dual-header tokens a 2× budget; an unanchored sentinel match → correct today, with nothing holding it; a route docstring reading "List *public* pods" above a query that filters for nothing of the kind → every private pod's conversation summary served to any agent runtime token; an MCP tool *description* promising scoping the handler doesn't apply ("Discover pods this agent may be able to join" over that same unfiltered query) — the first instance that ships the false promise to the *consumer*: a model reading the description has every reason to trust the scoping, and cannot be expected to second-guess it. **Tool descriptions Mechanical check: **if a comment says another layer sets this, grep that the layer actually sets it** — and if a docstring names a filter, grep that the query applies it. Reviewable symptom: **any fallback chain where the preferred branch has no test proving it fires is a phantom until proven otherwise.** Durable fix, each time: **make the dependency a value the caller must pass or spread, not a convention the caller must remember** — export the field list next to the predicate and spread it into `.select()`; export the complete query rather than a fragment; anchor the sentinel in the matcher, not the style guide. *(Earned: #772/#781, 2026-07-29.)* + +8. **Collapse aliases at the semantic layer, not the transport layer.** Keys and predicates derive from the thing that *is* the identity, never from whichever transport carried it — hash the extracted token, not the header string; resolve display identity through `resolveAgentDisplayLabel`, not whichever raw field a call site grabbed. Alias paths then converge by construction, and the key is identical at every call site regardless of middleware ordering. Corollary: delete — don't revive — the never-set field; reviving it converts a header-split bug into a route-family-split bug and seeds the next phantom. *(Earned: #781 — the `agentTokenHash` fix that would have made it worse.)* + +## Sentinels and channels + +9. **Sentinels are two contracts, not one** — the codebase audit (2026-07-29) showed three matching layers agreeing on the first and splitting on the second: + - **Suppression is total-match.** Only a reply that is *entirely* the sentinel goes silent. Universally honored today (CLI, ensemble service, delivery layer all use exact equality for the suppression decision); written down so it stays true. Any future sentinel — wrapper, MCP, digest ingestion — inherits this or it silently eats a real message someday. + - **Mutation of non-suppressed content has ONE owner and ONE documented semantics — the LANDED contract (PR #785, 2026-07-29): bare-stripped, backtick-preserved.** The delivery layer treats a **bare** sentinel token in content as producer leakage and removes it (whitespace-preserving); a sentinel inside backticks or a code fence is a deliberate *mention* and survives verbatim (`systemExchangeTriggers` aligned in the same PR so no fourth semantics exists). **Strictly additive to prior behavior — zero assertion inversions**, verified fails-without-fix by review. Known edge, intended and to be pinned by a test: a fenced block containing *only* the sentinel vanishes (total-match runs before the fence check) — defensively correct, since a model wrapping its silent reply in a fence must not post a visible sentinel; the function comment claiming otherwise is corrected to match. Residual cost, documented: a bare *prose* mention is still edited — **backtick a sentinel to mention it.** Scope: **agent-authored messages only** — the human path stays verbatim *by design*; the asymmetry is intentional. Defense in depth, orthogonal to semantics: **escalation-card evidence renders from envelope fields, never through chat delivery.** Inheritance rule: **any new sentinel, at birth, gets total-match suppression + bare-stripped/backtick-preserved sanitization + one test for each.** History, kept so the tradeoff stays visible: the design seats had converged on *line-anchored* (blank only sentinel-run-only lines; every documented incident shape is line-shaped, and the sole mid-sentence regression self-labels "(pre-existing behavior)"), but #785 shipped the strictly-additive cut first and review judged it sharper — it preserves every quoting surface that matters while still catching in-prose leakage defensively. **Evidence gate for revisiting:** if bare prose mentions keep being silently edited in practice (KB posts, reviews, docs — tonight's four manglings were all this shape), that operational cost is the evidence that flips the residual toward line-anchored inline preservation; produce it and the edge reopens, no argument owed. The CLAUDE.md correction (pending, rides the next landing PR — main still reads "sent verbatim," now wrong in a new way): *bare sentinel in content is treated as producer leakage and removed; backtick a sentinel to mention it; suppression only ever total-match.* + + The failure mode this split names is the third one: not *swallowed*, not *verbatim*, but **quietly edited** — content survives with altered meaning, and the damage is **attributed to the sender**: the reader concludes the author was careless, not that the channel edited them. Surfaces that must display a literal sentinel (evidence quotes, docs) cannot rely on plain chat text; ADR-017 cards render evidence from the envelope, not through the chat path. Defense-in-depth asymmetry worth checking on any new sentinel: the one guarding the escalation path (`HEARTBEAT_OK`) has exactly one matching layer — the least-defended sentinel is the most important one. *(Earned: #781 + the 51726 live scrub; fork (`_external/clawdbot`) unaudited — submodule empty in the design workspace — so a fourth semantics there is still possible.)* + +## Review conduct + +10. **Say what you did NOT verify.** An unqualified approval on something unchecked is worse than a partial one; a scoped confirmation ("verified module exports, did not read test diffs") tells the next reader exactly where to look. *(Earned: #772 — a design-conformance pass that didn't name its limits let a test-guard defect ride one round longer than it should have.)* + +11. **Verify against the current head, not the diff you started reading.** State moves while reviews are written; a correct verdict about a superseded head is noise with confidence behind it. Name the commit you verified. *(Earned: crossed-in-flight incidents at least six times in the sprint that produced this doc — duplicate PR, stale verdicts, stale amendment lists, simultaneous mutual concessions — same failure shape each time; it is endemic to multi-agent rooms, and it is why ADR-017's envelope carries `basis`.)* + +12. **Verify the instrument before trusting a negative result — that it ran, AND what it covered.** A search that finds nothing, a grep with no hits, a log query returning empty: each is indistinguishable from a search that never ran. Confirm the tool works (a known-positive probe, a deliberate query that *should* match) before recording "not present" as a finding. Then confirm its **range**: a filter argument is not a coverage guarantee — `--since=48h` against a store holding 3 hours returns everything it has and reports nothing about the other 45. State the window you actually observed, not the one you asked for; **a negative over an unknown window is not a negative.** Asymmetric on purpose — positives announce themselves, negatives fail silently in the direction you already expected. *(Earned twice in one hour during the #781 disclosure hunt: a `timeout`-not-installed near-miss, then a "no exploitation in 48h" claim that was really 3 hours of retained ingress logs — corrected by its own author minutes after writing the first clause.)* + +13. **For a security-adjacent change, ask "does this PR newly *expose* the surface?" — not only "does it *introduce* the defect?"** They are different questions and the first is the one that matters. A leak can be pre-existing in a route yet newly *reachable* because this PR ships the named tool, documented endpoint, or UI affordance that makes an agent or user actually hit it. "Pre-existing, not a blocker" is a verdict about introduction; reachability can still make the PR the thing that turns a latent defect into a live one. *(Earned: #781 — the `/api/agents/runtime/pods` private-pod + `latestSummary` disclosure was a latent route until #781 added `commonly_list_pods` to the standard MCP toolset, making it a named tool every agent sees; a review that weighted only "introduces?" approved it, and the verdict was superseded on the reachability question.)* From 7ecc3c716550b158ed58e0e6e8233a6bd339d47d Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 17:31:08 -0700 Subject: [PATCH 02/12] =?UTF-8?q?docs:=20ADR-016=20=E2=80=94=20fix=20agent?= =?UTF-8?q?-admin=20reachable=20states,=20align=20joinPolicy=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both from sprint-review's #792 pass, re-verified against origin/main: agent-admin is in NON_LISTABLE_POD_TYPES and refused by both visibility writers, so calling it a plain room overstated the enumeration — states 3-6 are unreachable for it. Adds a third derived kind (admin-room): terminally private like a DM, for a different reason (listability, not cardinality). Total reachable states 7 -> 8. Migration step 3 normalized null joinPolicy to invite-only while the schema and creation path default to 'open'. Corrected to 'open': the narrowing lives in the tier (self-joinable <=> community AND open), so a private pod with joinPolicy 'open' is still not self-joinable, and the migration should not be the one writer that disagrees with the schema. Co-Authored-By: Claude Fable 5 --- docs/adr/ADR-016-pod-model-and-visibility.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/adr/ADR-016-pod-model-and-visibility.md b/docs/adr/ADR-016-pod-model-and-visibility.md index 01788a47ec..08a759ce3d 100644 --- a/docs/adr/ADR-016-pod-model-and-visibility.md +++ b/docs/adr/ADR-016-pod-model-and-visibility.md @@ -15,7 +15,13 @@ A pod's audience is described by two orthogonal axes — **kind** (dm / room, de ### Kind — derived, not chosen -`kind = 'dm'` if `type ∈ {agent-room, agent-dm}` (the ADR-001 §3.10 strictly-1:1 set), else `kind = 'room'`. (`agent-admin` is a room: N:1 by design.) +Three kinds, all derived from `type` — the second exists because listability, not cardinality, is what the visibility model turns on: + +- `kind = 'dm'` — `type ∈ {agent-room, agent-dm}` (ADR-001 §3.10, strictly 1:1) +- `kind = 'admin-room'` — `type = 'agent-admin'`: N:1, so not a DM, but in `NON_LISTABLE_POD_TYPES` and refused by both visibility writers, so **terminally private like a DM for a different reason** +- `kind = 'room'` — everything else (`team`, `chat`, `study`, `games`): the only listable kind + +An earlier draft called `agent-admin` a plain room, which overstated its reachable states — see the enumeration. - DMs are terminally private: never listable, never publicRead, membership fixed at 2. Every visibility writer refuses them (already true in PR #779's endpoints). - The behaviorally identical room types (`team`, `chat`, `study`, `games` — no backend branch keys on them) become **presentation labels**. We do not collapse the `type` column now: additive-not-destructive, and identity continuity says a stored discriminator outlives its UI. Answering the stub: yes to *conceptual* collapse, no to a column migration nothing needs yet. @@ -61,7 +67,11 @@ Rooms: 3 tiers × 2 join policies = **6 states**, all meaningful: | 5 | community | invite-only | world | **no** (until H5) | no | Listed, invite-only | | 6 | community | open | world | yes | **yes** | Open via Community | -DMs: exactly **1 state** (private, 2 members, invite/creation rail only). Total reachable: 7. +`admin-room` (`agent-admin`): exactly **1 state** — private, non-self-joinable. It is in `NON_LISTABLE_POD_TYPES` and both visibility writers refuse it, so rows 3–6 are unreachable for it and `joinPolicy` is inert (self-join requires the community tier it can never hold). Membership is by install, not by join. + +DMs: exactly **1 state** (private, 2 members, invite/creation rail only). + +**Total reachable: 8** — 6 for listable rooms, 1 for admin-rooms, 1 for DMs. Unreachable by construction after PR #779: `{publicRead:false, communityListed:true}` (writer refuses, cascade removes), and any dm kind outside state row "DM". @@ -71,7 +81,7 @@ One idempotent script (pattern: `scripts/migrate-agent-dm-multimember.ts`), each 1. **`{publicRead:false, communityListed:true}` rows** → `communityListed := false` (tier `private`). Faithful because the state never rendered anywhere: invisible to both discovery scopes, and its only behavior — joinable by raw id — was the #772 bug, already dead via the narrowed gate. **Members who entered through the bug keep their membership**: revoking reads is a moderation decision about people, not a data migration, and the model must not silently eject anyone. 2. **dm kinds with `publicRead` or `communityListed` set** → assert none exist; if found, clear flags + flag for operator review (that would be a live privacy incident, not a cleanup). -3. **`joinPolicy` absent/null** → normalize to `invite-only` (the conservative default; matches the narrowing principle). +3. **`joinPolicy` absent/null** → normalize to **`'open'`**, matching the schema default (`models/Pod.ts`) and the creation path. An earlier draft said `invite-only` "per the narrowing principle"; that was wrong on inspection — it would have made the migration the only writer in the system that disagrees with the schema, creating a second source of truth for a field whose value is *inert below the community tier anyway*. **The narrowing lives in the tier, not in `joinPolicy`**: a `private` pod with `joinPolicy: 'open'` is not self-joinable, because self-joinable ⟺ community tier ∧ open. Normalizing to the schema default is therefore both conservative and consistent — one canonical answer per field. 4. Emit a tier-distribution report (counts per state row above) so the first real numbers inform the #770 modal defaults. No schema change. No state is deleted, only re-expressed; the audit rows make every step reversible by hand. From 531cd10c0ca1bf2d1f554eb1941d882652372ab5 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 17:34:42 -0700 Subject: [PATCH 03/12] =?UTF-8?q?docs:=20ADR-017=20=E2=80=94=20authority?= =?UTF-8?q?=20boundary=20as=20primary=20trigger,=20per=20corpus=20labellin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sprint-review labelled this pod's own unattended run (238 messages, four agents, four days): 15 warranted interrupting a human (6.3%), sustained 0.16/hr, peak 31/10min raw vs 5/10min filtered. The finding that changed the design: "escalate on irreversibility" caught zero of fifteen. The dominant class (8/15) is not misbehaviour at all — an agent correctly finishing and hitting a wall only the human can pass. So the primary trigger is structural, not behavioural: has this agent reached a boundary it cannot cross? The system already knows, because the boundary is the permission set — a query, not an inference, and it covers the largest class with no model. - new Layer 0 recording the corpus, the four observed classes ranked, and the caveat (n=15, one pod, one decision-maker) - authority boundary promoted to primary feed, with evidence typed as { boundary, artifact, availableTransitions } so cards name the decision - irreversibility kept as a safety net, with its zero-fire record stated: unbounded false-negative cost, bounded false-positive cost - envelope feed/class enums updated to the observed taxonomy Co-Authored-By: Claude Fable 5 --- docs/adr/ADR-017-attention-routing.md | 47 +++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/docs/adr/ADR-017-attention-routing.md b/docs/adr/ADR-017-attention-routing.md index 6a65860780..5f252d381d 100644 --- a/docs/adr/ADR-017-attention-routing.md +++ b/docs/adr/ADR-017-attention-routing.md @@ -8,11 +8,42 @@ ## Decision, in one paragraph -Attention routing is three separable layers: **two detection feeds** (a cheap judge that flags divergence from the intent an agent accepted, and a static irreversibility classifier that needs no model at all), a **routing layer** that spends a visible escalation budget and learns from dismissal, and a **rendering layer** built around one invariant unit — the needs-you card — with digest, in-pod, and push as renderings of that card, shipped in that order. v1 is **observe-only**: it flags, it never suspends. Holds arrive in stages tied to what can honestly hold, never as a promise the mechanism can't keep. +Attention routing is three separable layers: **detection feeds** led by an **authority-boundary** trigger that needs no model at all (an agent has reached something only a human may do), backed by a divergence judge and an irreversibility safety net, a **routing layer** that spends a visible escalation budget and learns from dismissal, and a **rendering layer** built around one invariant unit — the needs-you card — with in-pod, digest, and push as renderings of that card, in that order. v1 is **observe-only**: it flags, it never suspends. Holds arrive in stages tied to what can honestly hold, never as a promise the mechanism can't keep. + +## Layer 0 — what the corpus actually showed (labelled 2026-08-01) + +This ADR's first draft was designed before any data existed. A labelling pass over this pod's own unattended run — **238 messages, four agents, four days** — corrected it, and the corrections are recorded here because *an ADR that records what didn't work is worth more than one that records only the design*. + +**15 of 238 messages (6.3%) warranted interrupting a human.** Sustained rate 0.16/hr; peak 31/10min raw, 5/10min after filtering to escalation-worthy — i.e. the raw stream breaches ISA-18.2's flood line (>10/10min) and the filtered stream does not. That is the whole case for routing in one number pair. + +**The observed classes, ranked by frequency:** + +| # | class | count | needs a model? | +|---|---|---|---| +| 1 | **blocked on authority only the human has** — ratify, merge, choose, veto, sequence | 8 | **no** | +| 2 | live exposure discovered | 4 | no (static) | +| 3 | a claim the human was relying on turned out false | 2 | partly | +| 4 | agents deadlocked, cannot self-resolve | 1 | partly | + +**The finding that changed the design: "escalate on irreversibility" caught zero of fifteen.** Not few — zero. Across four days no agent deleted, spent, or sent anything outward; the one real exposure was pre-existing, not agent-caused. The static feed was the part explicitly designed to work without a model, and against real data it never fired. Meanwhile the dominant class is not misbehaviour at all: it is **an agent correctly finishing its work and hitting a wall only a human can pass.** + +**So the primary trigger is structural, not behavioural.** Not *"is this agent misbehaving?"* but *"has this agent reached a boundary it cannot cross?"* — and the system already knows the answer, because the boundary **is the permission set**. No judge, no scoring, no corpus needed for the dominant 8-of-15 case. This inverts the draft's ordering: the model-free trigger is the frequent one, and the model-dependent one is the tail. + +Standing caveat: n=15 from one pod of four agents over four days, all doing sprint work with a single human decision-maker. The class ranking is evidence, not a law; v1's log re-measures it continuously, and class 1's dominance should be expected to shrink as agents gain authority. ## Layer 1 — detection feeds -### The judge (divergence feed) +### Authority boundary (primary trigger — no model) + +Fires when an agent's next step requires a permission it does not hold, or when it has produced a terminal artifact whose only remaining transition belongs to a human. Both are readable from state the kernel already has — the permission set, the artifact's status — so this feed is a **query, not an inference**: cheapest to run, impossible to hallucinate, and it covers the largest observed class. + +Observed instances, all class 1: a PR verified and green with merge reserved to the human; an ADR marked Proposed awaiting ratification; two agents holding opposed rulings where neither seat owns the call; a spec whose next action requires an operator-only credential (the Cloudflare retention check). In each, the agent did nothing wrong — it *finished*. + +**Evidence for this feed is the boundary itself**: which permission, which artifact, what the human's available transitions are. That makes the card actionable by construction — it names the decision rather than describing the situation. + +Design consequence worth stating: this trigger's frequency is a **measure of how much authority agents lack**. If class 1 stays at 8-in-15 as the system matures, that is a finding about delegation, not about attention. The right long-run response to a chronically firing authority boundary is usually to move the boundary, not to route more notifications across it. + +### The judge (divergence feed — secondary) Compares one action against the **accepted intent**. Deliberately *not* a correctness model — correctness needs ground truth, policy needs authoring, anomaly detection needs baseline volume; divergence needs only two things CAP already records. @@ -27,17 +58,19 @@ Compares one action against the **accepted intent**. Deliberately *not* a correc ``` { diverged: bool, - class: scope-expansion | target-change | irreversible-outside-intent | abandonment | other, + class: authority-boundary | exposure | false-claim | deadlock | scope-expansion | target-change | abandonment | other, evidence: { intent_quote, action_quote }, why: one sentence } ``` **Classes, not scores.** Scalars are miscalibrated and thresholds rot; classes map to human sentences ("did more than asked" / "changed target" / …) that are the card headline, and they are the unit the routing layer budgets and mutes. `other` (+ free-text why) is the taxonomy's escape valve: whether four classes are exhaustive is empirical, and observe-only v1 is the instrument that answers it before anything gates on the answer. -### Static irreversibility (H4 feed) +### Static irreversibility (H4 feed — safety net, kept despite firing zero times) A property of the tool call, determined without any model: outward-facing, spending, destructive. Evaluated at the kernel tool layer. Its evidence is computed from the action record itself (branch names, recipient count, dollar amount) — the floor is never "trust me," even where the judge is absent or wrong. +**It caught 0 of 15 in the observed corpus, and it stays anyway.** Not as the primary trigger it was drafted to be, but as a safety net, on an explicit asymmetry: its false-negative cost is unbounded (one unreviewed destructive action) while its false-positive cost is bounded by the budget and by rarity-by-construction. A trigger that never fires costs nothing; the one time it fires may be the only time it matters. What the zero *does* forbid is treating it as the design's centre of gravity — that was the drafting error, and it came from reasoning about agents from first principles instead of watching them work. + ## Layer 2 — the escalation event envelope Both feeds emit into one envelope; **evidence is required**, typed per feed: @@ -45,8 +78,8 @@ Both feeds emit into one envelope; **evidence is required**, typed per feed: ``` { escalationId, // stable id — every render, decision, and audit row references it action, // what happened / is pending - feed: judge | static, - class, // divergence class, or the irreversibility category + feed: authority | judge | static, + class, // observed class (authority-boundary, exposure, …) or irreversibility category evidence, // tagged union, discriminated by `feed` — see below acceptedIntent, // the quoted intent text the judge compared against (null for static-feed unprompted) state: flagged | held, // hold status of the UNDERLYING action — see staging; v1 emits only `flagged` @@ -63,7 +96,7 @@ Both feeds emit into one envelope; **evidence is required**, typed per feed: Why no tier may demote instead of re-evaluate: neither trigger is outside the monitored agent's reach — re-binding intent is ordinary agent behavior, and so is closing a PR or deleting a branch. Any demotion tier is therefore a self-suppression path: the party the escalation is about downgrades its attention as a side effect of working normally — the budget-unmutes-danger failure arriving through the staleness door. Re-evaluation removes the free downgrade while preserving both invariants exactly: a stale-but-confident escalation never interrupts, and **attention level is a function of the verdict against current state, never of who caused the drift.** -**Evidence is a tagged union discriminated by `feed`** — no separate type field, because the mapping is 1:1 and a redundant discriminator would drift. Judge feed: `{ intent_quote, action_quote }`, rendered as two attributed lines (intent vs action). Static feed: blast-radius facts, rendered as concrete nouns (names, counts, amounts). The card switches layout on `feed` and never guesses; if a future feed breaks the 1:1 mapping, add the explicit tag then, not before. +**Evidence is a tagged union discriminated by `feed`** — no separate type field, because the mapping is 1:1 and a redundant discriminator would drift. **Authority feed: `{ boundary, artifact, availableTransitions }`** — which permission is missing, which artifact is terminal, what the human can do about it — rendered as a named decision with its options, which is why class-1 cards are actionable rather than merely informative. Judge feed: `{ intent_quote, action_quote }`, rendered as two attributed lines (intent vs action). Static feed: blast-radius facts, rendered as concrete nouns (names, counts, amounts). The card switches layout on `feed` and never guesses; if a future feed breaks the 1:1 mapping, add the explicit tag then, not before. ### Decision authorization — enforced, not implied From 861dcb6a74e374377a3a257b24d6ce47304e4c29 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 17:37:17 -0700 Subject: [PATCH 04/12] docs: AX audit log + sharpen ADR-017's irreversibility caveat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The zero-irreversibility caveat now states the labeller's own distinction: this corpus had no delete/spend/send permissions in play, so the zero is strong evidence that irreversibility is the wrong PRIMARY trigger and weak evidence about its firing rate where agents hold destructive capability. The zero measures the permission profile, not the mechanism's worth. Adds docs/development/agent-experience-audit.md — the AX findings Sam asked the sprint agents for, which were accumulating only in pod chat. Four entries: the docstring is the interface; permitted verdicts are undiscoverable until refused; silent success and silent failure look identical; pod prose is not delivery. Recurring shape: an agent's model of the system comes almost entirely from names, docstrings and error messages. Where those lie or stay silent, it forms a confident wrong model — with no visual channel to correct it. Co-Authored-By: Claude Fable 5 --- docs/adr/ADR-017-attention-routing.md | 2 +- docs/development/agent-experience-audit.md | 33 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 docs/development/agent-experience-audit.md diff --git a/docs/adr/ADR-017-attention-routing.md b/docs/adr/ADR-017-attention-routing.md index 5f252d381d..81acfd2fa8 100644 --- a/docs/adr/ADR-017-attention-routing.md +++ b/docs/adr/ADR-017-attention-routing.md @@ -29,7 +29,7 @@ This ADR's first draft was designed before any data existed. A labelling pass ov **So the primary trigger is structural, not behavioural.** Not *"is this agent misbehaving?"* but *"has this agent reached a boundary it cannot cross?"* — and the system already knows the answer, because the boundary **is the permission set**. No judge, no scoring, no corpus needed for the dominant 8-of-15 case. This inverts the draft's ordering: the model-free trigger is the frequent one, and the model-dependent one is the tail. -Standing caveat: n=15 from one pod of four agents over four days, all doing sprint work with a single human decision-maker. The class ranking is evidence, not a law; v1's log re-measures it continuously, and class 1's dominance should be expected to shrink as agents gain authority. +**Standing caveat, in the labeller's own terms — the zero is strong evidence for one claim and weak for another.** This corpus is four agents doing review-and-docs work **with no delete/spend/send permissions in play**. So it is strong evidence that irreversibility is the wrong *primary* trigger, and weak evidence about how often that feed fires in a pod where agents actually hold destructive capability. Keeping it as a safety net is right for exactly that reason: the zero measures this permission profile, not the mechanism's worth. Also n=15, one pod, four days, a single human decision-maker — the class ranking is evidence, not a law. v1's log re-measures it continuously, and class 1's dominance should be expected to shrink as agents gain authority. ## Layer 1 — detection feeds diff --git a/docs/development/agent-experience-audit.md b/docs/development/agent-experience-audit.md new file mode 100644 index 0000000000..7fd5460050 --- /dev/null +++ b/docs/development/agent-experience-audit.md @@ -0,0 +1,33 @@ +# Agent-experience (AX) audit — findings from our own agent consumers + +**Status:** Open log, append-only. Started 2026-08-01 at Sam's request during milestone #11. +**Why this file exists:** the four sprint agents are currently the only agent consumers of this API. What confused them is data nobody else can produce, and it was evaporating into pod chat. +**How to add:** one entry, dated, naming the surface and what it taught you *incorrectly*. Owner merges; anyone may propose. + +The recurring shape so far: **an agent's model of the system is built almost entirely from names, docstrings, and error messages** — it cannot see the query, the permission table, or the handler. Where those three lie or stay silent, the agent forms a confident wrong model and acts on it. A human clicking the same surface usually gets corrected by what they *see*; an agent has no such channel. + +--- + +## 1. The docstring is the interface (2026-08-01, pod-architect) + +`GET /api/agents/runtime/pods` is documented *"List public pods the agent can discover and join."* The query filters neither — no `publicRead`, no `communityListed`, no membership — and returns `latestSummary` for every pod. Two agents believed the contract the name and comment advertised, twice, and only reading the handler corrected it. + +**Lesson:** for agents, a docstring is not documentation, it is the interface. A route whose comment describes a filter it does not apply is not a stale comment; it is an API that teaches a false model to its only readers. Where a name promises a scope, the query must enforce it — or the name must change. + +## 2. Permitted verdicts are undiscoverable until refused (2026-08-01, sprint-review) + +The reviewer seat could not discover *which review verdicts it was permitted to issue*. `gh pr review --approve` fails with `GraphQL: Review Can not approve your own pull request` — discoverable only by attempting it. Nothing in the tool surface says "you may comment, you may not approve," so six reviews landed as COMMENTED without the author knowing an alternative was blocked rather than unchosen. + +**Lesson:** capability boundaries must be legible *before* the attempt, not only in the failure. Same shape as #1: the system knows the answer and doesn't say it. This is also the exact class-1 authority-boundary case ADR-017 now centres on — an agent finishing correctly and hitting a wall only a human can move. + +## 3. Silent success and silent failure look identical (2026-08-01, pod-architect) + +Two instances in one session. Sentinel sanitization *edited* agent messages mid-content, so posts describing the rule arrived subtly wrong with no signal to the sender — the damage read as the author's carelessness. Separately, a log query with `--since=48h` against a 3-hour store returned everything it had and reported nothing about the gap. + +**Lesson:** any transform on agent-authored content, and any query with an implicit range, must tell the caller what it did. An agent cannot see its own message as delivered, and cannot see the shape of a store it did not build. + +## 4. Pod prose is not delivery (2026-08-01, pod-architect) + +Three artifacts — two ADRs and this repo's reviewer checklist — existed for three days only as pod attachments and untracked local files while being described as "delivered." The human, reading the repo, correctly saw them as outstanding and asked three times. + +**Lesson:** this one is on the agents, not the API, and it generalizes: **the deliverable is the artifact in the system of record**, not the message announcing it. In-pod discussion is not a review; an attachment is not a doc; a verdict in chat gates nothing. Where a seat's output has a canonical home (PR, file, review state), reaching that home is part of the work. From d9b2d3ce8d0e316a8668ae95b6375842dfcf2aa6 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 20:51:10 -0700 Subject: [PATCH 05/12] docs: bidirectional attention channel, #793 verified, AX entry 5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ADR-017 gains "the channel is bidirectional" — the missing inverse of everything else in it. Routing so far is agent -> human; the 2026-08-01 incident is system -> agent: the disclosure was fixed, merged, deployed and verified, and the pod was never told, so four agents kept planning around an exposure closed an hour earlier. Recorded as a principle, not a mechanism: an invalidation is not an escalation (the trigger is "a fact you relied on changed", which is observed class 3 pointed the other way — one mechanism, two directions), and its cost is silent and asymmetric (a missed escalation stalls one agent visibly; a missed invalidation leaves every agent producing correct-looking work over a dead premise). Explicitly do NOT build a subscription system: n=1 is not a mandate for a dependency graph. Notes that `basis` is already this signal read from the other end. ADR-016's enforcement-gap table updated against origin/main: #793 closed the gap by composing COMMONLY_LISTING_QUERY with the caller's authorized pods. Residual divergence recorded — it uses the flags-only fragment, not communityDiscoverQuery, so invite-only listed pods appear on the agent surface while excluded from the human one. Not a leak (all publicRead), but the route's own comment claims it cannot drift, and it still differs. AX audit: entry 5 (nothing tells an agent its premise expired), entry 1 marked closed by #793. Co-Authored-By: Claude Fable 5 --- docs/adr/ADR-016-pod-model-and-visibility.md | 6 ++++-- docs/adr/ADR-017-attention-routing.md | 15 +++++++++++++++ docs/development/agent-experience-audit.md | 8 ++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/adr/ADR-016-pod-model-and-visibility.md b/docs/adr/ADR-016-pod-model-and-visibility.md index 08a759ce3d..f87ac15c91 100644 --- a/docs/adr/ADR-016-pod-model-and-visibility.md +++ b/docs/adr/ADR-016-pod-model-and-visibility.md @@ -94,9 +94,11 @@ The invariants above are enforced at the **writers** and at the **human** read s |---|---|---|---| | `getAllPods` / `joinPod` (human) | ✅ `podListing` predicates | ✅ | n/a | | `POST /admin/pods/:id/{showcase,listing}` | ✅ 409 + cascade | ✅ refuses dm kinds | n/a | -| **`GET /api/agents/runtime/pods`** | ❌ **no `publicRead`/`communityListed`/membership filter** — `Pod.find({ type: { $nin: nonDiscoverableTypes } })` | ✅ (#781) | ❌ **returned for every pod listed** | +| **`GET /api/agents/runtime/pods`** | ✅ **closed by #793** — `$or: [COMMUNITY_LISTING_QUERY, { _id: { $in: authorizedPodIds } }]` | ✅ (#781) | ✅ consequentially — every pod now returned is community-listed (hence `publicRead`) or the caller's own | -Consequence, reproduced live 2026-08-01 before #781 and unchanged by it for non-DM types: any agent runtime token enumerates private unlisted `chat`/`team` pods and receives their generated conversation summaries. **This is the single highest-priority conformance gap in the model** and the reason ADR-016 is worth ratifying as more than description: the visibility tier is only real where every reader consults it. Fix: the route composes `communityDiscoverQuery` for discovery breadth plus the caller's `AgentInstallation` pods for membership, and omits `latestSummary` for non-member pods (existence and content are separable disclosures; leaking the latter is strictly worse). +**History, kept because the model earned its keep here.** Reproduced live 2026-08-01: before #781 this route returned 10 one-to-one DM pods to a non-member; after #781 it still returned 49-of-50 non-member pods including 5 carrying generated conversation summaries. #781 fixed only the type exclusion — which is *not* a visibility rule, it merely hides pods that are private by type. #793 closed the rest by composing the canonical listing flags with the caller's installed pods, which is the shape this ADR argues for: **an agent may see a pod when it is either discoverable to everyone or one it is actually in.** Two agents asserted this route was fixed before it was; both were corrected by someone re-reading the handler. That is the enforcement-gap table's reason to exist — a per-reader enumeration catches an absent predicate, which no grep for a present one can. + +**Residual divergence, not a leak (open, low priority).** #793 composes `COMMUNITY_LISTING_QUERY` (flags only) rather than `communityDiscoverQuery` (flags + invite-only exclusion + non-member clause), so **invite-only listed pods appear on the agent discovery surface while being excluded from the human one** (ruling of 2026-07-29: a Discover row you cannot join is a dead end until request-access exists). Nothing private is exposed — every such pod is `publicRead` — but the route's own comment says it reuses the flag "so this route cannot drift from the human-facing Discover surface again," and it does still differ. Either adopt `communityDiscoverQuery` or record the difference as intentional (an agent arguably *should* see rooms it could request access to). This is a one-line question for whoever next touches the route. **Rule this generalizes into (ADR-016's operative clause):** *terminal privacy and visibility tiers must be enforced at every read surface, not only at the writers that set them.* A tier enforced at 4 of 5 readers is not a tier. diff --git a/docs/adr/ADR-017-attention-routing.md b/docs/adr/ADR-017-attention-routing.md index 81acfd2fa8..6696aada4b 100644 --- a/docs/adr/ADR-017-attention-routing.md +++ b/docs/adr/ADR-017-attention-routing.md @@ -31,6 +31,21 @@ This ADR's first draft was designed before any data existed. A labelling pass ov **Standing caveat, in the labeller's own terms — the zero is strong evidence for one claim and weak for another.** This corpus is four agents doing review-and-docs work **with no delete/spend/send permissions in play**. So it is strong evidence that irreversibility is the wrong *primary* trigger, and weak evidence about how often that feed fires in a pod where agents actually hold destructive capability. Keeping it as a safety net is right for exactly that reason: the zero measures this permission profile, not the mechanism's worth. Also n=15, one pod, four days, a single human decision-maker — the class ranking is evidence, not a law. v1's log re-measures it continuously, and class 1's dominance should be expected to shrink as agents gain authority. +## The channel is bidirectional — and the reverse direction has no trigger today + +Everything above routes **agent → human**: which of an agent's actions deserves interrupting a person. The inverse direction is missing, and it cost real work on 2026-08-01 before anyone noticed it existed. + +**The incident.** The private-pod disclosure was fixed, merged (#793), deployed, and verified closed. The pod was not told. Four agents kept planning, specifying and sequencing around an exposure that had been shut for an hour, until one happened to re-measure it for an unrelated reason. Nothing escalated, because nothing went wrong: no divergence, no irreversible action, no authority boundary. **The world moved and the agents' snapshot didn't.** + +Two properties that make this a distinct primitive rather than a missing notification: + +1. **It is an invalidation, not an escalation.** The trigger is not *"an agent needs authority"* but *"a fact an agent is relying on has changed."* Note that this is the same shape as observed class 3 — *a claim the human was relying on turned out false* — pointed the other way. That symmetry is the argument for **one mechanism serving both directions**, not two features: in both cases something a party built reasoning on stopped being true, and the party doesn't know. +2. **The cost is silent and asymmetric.** A missed escalation stalls one agent, visibly, and someone eventually notices. A missed invalidation leaves *every* agent confidently producing correct-looking work over a dead premise, with nothing appearing wrong at all. This is the failure mode this sprint rediscovered in five different costumes — stale review verdicts, superseded ADR versions, a fixed-then-asserted route, phantom cross-layer contracts, an unbounded log window. Correct output over a broken premise is the house failure, and it is invisible by construction. + +**The principle for v1 (deliberately not a mechanism):** the attention channel is bidirectional. A merge or deploy touching a surface an agent has reasoned about should land in that agent's pod as a *fact*, not as a notification anyone has to compose. Cheap version first — the same event log that feeds the digest already knows what shipped; the missing piece is that nothing points it back at the agents. **Do not build a subscription system for this.** The measured need is one line per merge, and n=1 incident is not a mandate for a dependency graph. + +Design note connecting it to the rest of this ADR: `basis` (§envelope) already records *what state an escalation was computed against*. Invalidation is the same field read from the other end — the system knowing a basis went stale is precisely the signal an agent needs. One field, two directions. + ## Layer 1 — detection feeds ### Authority boundary (primary trigger — no model) diff --git a/docs/development/agent-experience-audit.md b/docs/development/agent-experience-audit.md index 7fd5460050..1c4a3498a0 100644 --- a/docs/development/agent-experience-audit.md +++ b/docs/development/agent-experience-audit.md @@ -14,6 +14,8 @@ The recurring shape so far: **an agent's model of the system is built almost ent **Lesson:** for agents, a docstring is not documentation, it is the interface. A route whose comment describes a filter it does not apply is not a stale comment; it is an API that teaches a false model to its only readers. Where a name promises a scope, the query must enforce it — or the name must change. +*Status: closed by #793 — the query now enforces what the name promised. The lesson stands; the incident is why the promise is worth enforcing.* + ## 2. Permitted verdicts are undiscoverable until refused (2026-08-01, sprint-review) The reviewer seat could not discover *which review verdicts it was permitted to issue*. `gh pr review --approve` fails with `GraphQL: Review Can not approve your own pull request` — discoverable only by attempting it. Nothing in the tool surface says "you may comment, you may not approve," so six reviews landed as COMMENTED without the author knowing an alternative was blocked rather than unchosen. @@ -31,3 +33,9 @@ Two instances in one session. Sentinel sanitization *edited* agent messages mid- Three artifacts — two ADRs and this repo's reviewer checklist — existed for three days only as pod attachments and untracked local files while being described as "delivered." The human, reading the repo, correctly saw them as outstanding and asked three times. **Lesson:** this one is on the agents, not the API, and it generalizes: **the deliverable is the artifact in the system of record**, not the message announcing it. In-pod discussion is not a review; an attachment is not a doc; a verdict in chat gates nothing. Where a seat's output has a canonical home (PR, file, review state), reaching that home is part of the work. + +## 5. Nothing tells an agent its premise expired (2026-08-01, ux-lead + sprint-review) + +The private-pod disclosure was fixed, merged, deployed and verified — and the pod was never told. Four agents kept specifying and sequencing around an exposure closed an hour earlier, until one re-measured it for an unrelated reason. No error, no signal, no wrongness anywhere: the world moved and the agents' snapshot didn't. + +**Lesson:** every AX affordance in this file so far is *pull* — an agent must think to re-check. There is no push of the form "a fact you reasoned about has changed." For a human this is partly covered by ambient awareness (they see the merge notification, the green check, the Slack line); an agent has no ambient channel at all, so a stale premise persists until something accidentally disturbs it. Detection habit that worked here: **two independent instruments agreeing localises a change to the server rather than the tool** — worth reaching for before concluding either your tooling or your memory is wrong. Design consequence recorded in ADR-017 (*the channel is bidirectional*). From 272f6708b4f98423b1820063140e225bca125467 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 20:53:54 -0700 Subject: [PATCH 06/12] =?UTF-8?q?docs:=20ADR-016=20=E2=80=94=20surface=20p?= =?UTF-8?q?arity=20is=20the=20rule,=20H5=20is=20the=20exception-point?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ux-lead's design call on the #793 residual, replacing the either/or I left open. The agent discovery surface adopts communityDiscoverQuery rather than the flags-only fragment: a comment asserting parity over a query that diverges is a phantom-contract seedling watering itself. The "agents should see request-access-able rooms" case is real but is the H5 case, and the 2026-07-29 dead-end ruling applies to agents equally — a discoverable row with no available action yields a 403 whose only use is relaying confusion, and that 403 is not machine-readable as "requestable later" either. Rule recorded: divergence between the human and agent visibility surfaces must be a decision with an affordance attached, never a side effect of which query constant a route imported. Co-Authored-By: Claude Fable 5 --- docs/adr/ADR-016-pod-model-and-visibility.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/adr/ADR-016-pod-model-and-visibility.md b/docs/adr/ADR-016-pod-model-and-visibility.md index f87ac15c91..5219ea9dc8 100644 --- a/docs/adr/ADR-016-pod-model-and-visibility.md +++ b/docs/adr/ADR-016-pod-model-and-visibility.md @@ -98,7 +98,9 @@ The invariants above are enforced at the **writers** and at the **human** read s **History, kept because the model earned its keep here.** Reproduced live 2026-08-01: before #781 this route returned 10 one-to-one DM pods to a non-member; after #781 it still returned 49-of-50 non-member pods including 5 carrying generated conversation summaries. #781 fixed only the type exclusion — which is *not* a visibility rule, it merely hides pods that are private by type. #793 closed the rest by composing the canonical listing flags with the caller's installed pods, which is the shape this ADR argues for: **an agent may see a pod when it is either discoverable to everyone or one it is actually in.** Two agents asserted this route was fixed before it was; both were corrected by someone re-reading the handler. That is the enforcement-gap table's reason to exist — a per-reader enumeration catches an absent predicate, which no grep for a present one can. -**Residual divergence, not a leak (open, low priority).** #793 composes `COMMUNITY_LISTING_QUERY` (flags only) rather than `communityDiscoverQuery` (flags + invite-only exclusion + non-member clause), so **invite-only listed pods appear on the agent discovery surface while being excluded from the human one** (ruling of 2026-07-29: a Discover row you cannot join is a dead end until request-access exists). Nothing private is exposed — every such pod is `publicRead` — but the route's own comment says it reuses the flag "so this route cannot drift from the human-facing Discover surface again," and it does still differ. Either adopt `communityDiscoverQuery` or record the difference as intentional (an agent arguably *should* see rooms it could request access to). This is a one-line question for whoever next touches the route. +**Residual divergence, not a leak (open, low priority).** #793 composes `COMMUNITY_LISTING_QUERY` (flags only) rather than `communityDiscoverQuery` (flags + invite-only exclusion + non-member clause), so **invite-only listed pods appear on the agent discovery surface while being excluded from the human one** (ruling of 2026-07-29: a Discover row you cannot join is a dead end until request-access exists). Nothing private is exposed — every such pod is `publicRead` — but the route's own comment says it reuses the flag "so this route cannot drift from the human-facing Discover surface again," and it does still differ. A comment asserting parity over a query that diverges is a phantom-contract seedling (§7 of the reviewer checklist) with its own comment watering it. + +**Rule: surface parity is the default — adopt `communityDiscoverQuery` on this route.** The "agents should see rooms they could request access to" case is real, but it is the *H5 request-access* case, and the 2026-07-29 dead-end ruling applies to agents with equal force: a discoverable row with no available action yields a 403 whose only use is relaying confusion — and today's 403 isn't even machine-readable as "requestable later." When H5 lands, both surfaces gain the row together (agents first, if we choose). **Divergence between the human and agent visibility surfaces must be a decision with an affordance attached, never a side effect of which query constant a route imported.** One builder, one predicate, parity by construction; H5 is the planned exception-point. **Rule this generalizes into (ADR-016's operative clause):** *terminal privacy and visibility tiers must be enforced at every read surface, not only at the writers that set them.* A tier enforced at 4 of 5 readers is not a tier. From f34bf5a281d7b8e48415a618fe972c22cbec3bf9 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 20:55:59 -0700 Subject: [PATCH 07/12] =?UTF-8?q?docs:=20ADR-016=20=E2=80=94=20parity=20is?= =?UTF-8?q?=20per-clause;=20"adopt=20the=20builder"=20was=20wrong?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sprint-review caught a defect in the rule committed one commit earlier. "Adopt communityDiscoverQuery on the agent route" treats three clauses as one decision; only the joinPolicy clause belongs there. - listing flags: shared (the visibility tier itself) - joinPolicy $ne invite-only: adopt — a row with no available action is a dead end for either reader, and the 403 isn't machine-readable as "requestable later" - members $ne callerId: never — the surfaces have different jobs, and it is subtly unsafe here: the route's second $or branch keys on installations, not membership, so a pod the agent is a member of without an active installation would be excluded by the clause and not restored by the branch Shared unit is therefore a fragment (flags + joinPolicy) that both surfaces compose, each adding its own caller clause — the same lesson as the original fragment/builder split, one level down. Urgency recorded as none: 3 community-listed pods, 0 invite-only, so the divergence is theoretical and a test would pass vacuously today. Revisit trigger is H5 landing, when joinPolicy drops from both surfaces together. Co-Authored-By: Claude Fable 5 --- docs/adr/ADR-016-pod-model-and-visibility.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/adr/ADR-016-pod-model-and-visibility.md b/docs/adr/ADR-016-pod-model-and-visibility.md index 5219ea9dc8..883816be76 100644 --- a/docs/adr/ADR-016-pod-model-and-visibility.md +++ b/docs/adr/ADR-016-pod-model-and-visibility.md @@ -100,7 +100,21 @@ The invariants above are enforced at the **writers** and at the **human** read s **Residual divergence, not a leak (open, low priority).** #793 composes `COMMUNITY_LISTING_QUERY` (flags only) rather than `communityDiscoverQuery` (flags + invite-only exclusion + non-member clause), so **invite-only listed pods appear on the agent discovery surface while being excluded from the human one** (ruling of 2026-07-29: a Discover row you cannot join is a dead end until request-access exists). Nothing private is exposed — every such pod is `publicRead` — but the route's own comment says it reuses the flag "so this route cannot drift from the human-facing Discover surface again," and it does still differ. A comment asserting parity over a query that diverges is a phantom-contract seedling (§7 of the reviewer checklist) with its own comment watering it. -**Rule: surface parity is the default — adopt `communityDiscoverQuery` on this route.** The "agents should see rooms they could request access to" case is real, but it is the *H5 request-access* case, and the 2026-07-29 dead-end ruling applies to agents with equal force: a discoverable row with no available action yields a 403 whose only use is relaying confusion — and today's 403 isn't even machine-readable as "requestable later." When H5 lands, both surfaces gain the row together (agents first, if we choose). **Divergence between the human and agent visibility surfaces must be a decision with an affordance attached, never a side effect of which query constant a route imported.** One builder, one predicate, parity by construction; H5 is the planned exception-point. +**Rule: parity is per-clause, not per-query — and "adopt `communityDiscoverQuery`" wholesale is wrong.** An earlier revision of this ADR said exactly that; review caught it. The builder carries three clauses and only one of them belongs on the agent surface: + +| clause | human Discover | agent surface | why | +|---|---|---|---| +| listing flags (`publicRead` + `communityListed`) | ✅ | ✅ | the visibility tier itself — always shared | +| `joinPolicy: { $ne: 'invite-only' }` | ✅ | **✅ adopt** | a row with no available action is a dead end for either reader — the 2026-07-29 ruling applies to agents with equal force, and today's 403 isn't machine-readable as "requestable later" | +| `members: { $ne: callerId }` | ✅ | **❌ never** | the surfaces have different *jobs*: human Discover answers "find something new", the agent route answers "what may I see" and deliberately includes the caller's own pods via its `$or` | + +The `members` clause is also subtly unsafe here rather than merely redundant: the route's second `$or` branch keys on **installations** (`agentAuthorizedPodIds`), not membership, so a pod where the agent is a `members` entry *without* an active installation would be excluded by clause 3 and not restored by that branch — disappearing a publicly-listed room from the one reader that just joined it. + +**So the shared unit is a fragment, not the builder:** listing flags + `joinPolicy` compose into both surfaces; each adds its own caller clause. One predicate, composed differently at the edges — which is the same lesson as the original `COMMUNITY_LISTING_QUERY`-vs-`communityDiscoverQuery` split, one level down. + +**Standing principle either way:** divergence between the human and agent visibility surfaces must be a decision with an affordance attached, never a side effect of which query constant a route imported. **Revisit trigger:** H5 request-access landing — at which point the `joinPolicy` clause is removed from *both* surfaces together, because the row finally acquires a verb. + +**Urgency: none, measured.** 3 community-listed pods exist and 0 are invite-only, so the divergence is currently theoretical and a regression test for it would pass vacuously against production data. Fix it when the route is next touched; write the test when an invite-only listed pod exists to test against. **Rule this generalizes into (ADR-016's operative clause):** *terminal privacy and visibility tiers must be enforced at every read surface, not only at the writers that set them.* A tier enforced at 4 of 5 readers is not a tier. From 932ec6eb90096a3768b776c3e630fea57cd1e24b Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 21:01:08 -0700 Subject: [PATCH 08/12] =?UTF-8?q?docs:=20ADR-017=20=E2=80=94=20fix=20seven?= =?UTF-8?q?=20inconsistencies=20from=20the=20end-to-end=20read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sprint-review's full pass (PR #792 review 7) found seven locally-correct edits that had stopped agreeing with each other. All were introduced by incremental rewrites and none were caught by incremental review. 1. Judge's class enum conflated two taxonomies. The judge cannot detect authority-boundary or deadlock — those come from the no-model query feed. Judge now emits divergenceClass (scope-expansion, target-change, abandonment, other); the envelope's top-level class carries the observed taxonomy, with a comment stating they are never merged. 2. "Both feeds" / "two feeds" -> three feeds, four routing inputs. 3. Ratification point 3 asked Sam to ratify a "four-class taxonomy" that no longer exists. Now names both taxonomies explicitly. 4. Override statistic appeared as both 49-96% (pre-verification) and 46-96% (verified). Unified on the verified figure. 5. "Two-tier staleness rule:" lead-in survived the unification that replaced it with one rule. 6. "Latest human word wins" contradicted "re-binding is ordinary agent behavior". The latter is correct and verified in code; corrected to ordering-not-identity, with an explicit warning never to write a human-only gate since no issuer field exists to build it on. 7. Deadlock listed under class-1 instances; it is class 4. Co-Authored-By: Claude Fable 5 --- docs/adr/ADR-017-attention-routing.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/adr/ADR-017-attention-routing.md b/docs/adr/ADR-017-attention-routing.md index 6696aada4b..46ee183334 100644 --- a/docs/adr/ADR-017-attention-routing.md +++ b/docs/adr/ADR-017-attention-routing.md @@ -52,7 +52,7 @@ Design note connecting it to the rest of this ADR: `basis` (§envelope) already Fires when an agent's next step requires a permission it does not hold, or when it has produced a terminal artifact whose only remaining transition belongs to a human. Both are readable from state the kernel already has — the permission set, the artifact's status — so this feed is a **query, not an inference**: cheapest to run, impossible to hallucinate, and it covers the largest observed class. -Observed instances, all class 1: a PR verified and green with merge reserved to the human; an ADR marked Proposed awaiting ratification; two agents holding opposed rulings where neither seat owns the call; a spec whose next action requires an operator-only credential (the Cloudflare retention check). In each, the agent did nothing wrong — it *finished*. +Observed class-1 instances: a PR verified and green with merge reserved to the human; an ADR marked Proposed awaiting ratification; a spec whose next action requires an operator-only credential (the Cloudflare retention check). (The deadlock case — two agents holding opposed rulings where neither seat owns the call — is class 4, not class 1; it reaches the same human by a different route.) In each, the agent did nothing wrong — it *finished*. **Evidence for this feed is the boundary itself**: which permission, which artifact, what the human's available transitions are. That makes the card actionable by construction — it names the decision rather than describing the situation. @@ -67,18 +67,18 @@ Compares one action against the **accepted intent**. Deliberately *not* a correc 2. the `chat.mention` payload the agent replied to (the reply is the acceptance) 3. the pod goal (fallback for unprompted work, e.g. heartbeat) -**Re-bindable intent:** any later in-thread message from the intent's issuer addressed to the agent supersedes the accepted intent for subsequent actions. Latest human word wins — ordering, not semantics. Rendering consequence (ux-lead): the card must quote the *superseding* message, or every flag on a renegotiated task reads as a false positive and trains dismissal. +**Re-bindable intent:** any later in-thread message from the intent's issuer addressed to the agent supersedes the accepted intent for subsequent actions. Latest word wins — **ordering, not identity**: the superseding message may come from a human or an agent, because intent issuers can be either (`Task` carries no issuer provenance, and `Task.source` is caller-supplied). Never write a human-only re-bind gate; there is no field to build it on. See the staleness rule, which is what makes this safe. Rendering consequence (ux-lead): the card must quote the *superseding* message, or every flag on a renegotiated task reads as a false positive and trains dismissal. **Contract:** per-action, stateless, small-model. Input: intent text, one action record, one line of pod context — no transcript crawl. Output: ``` { diverged: bool, - class: authority-boundary | exposure | false-claim | deadlock | scope-expansion | target-change | abandonment | other, + divergenceClass: scope-expansion | target-change | abandonment | other, evidence: { intent_quote, action_quote }, why: one sentence } ``` -**Classes, not scores.** Scalars are miscalibrated and thresholds rot; classes map to human sentences ("did more than asked" / "changed target" / …) that are the card headline, and they are the unit the routing layer budgets and mutes. `other` (+ free-text why) is the taxonomy's escape valve: whether four classes are exhaustive is empirical, and observe-only v1 is the instrument that answers it before anything gates on the answer. +**Classes, not scores.** Scalars are miscalibrated and thresholds rot; classes map to human sentences ("did more than asked" / "changed target" / …) that are the card headline, and they are the unit the routing layer budgets and mutes. `other` (+ free-text why) is the taxonomy's escape valve: whether the divergence classes are exhaustive is empirical, and observe-only v1 is the instrument that answers it before anything gates on the answer. ### Static irreversibility (H4 feed — safety net, kept despite firing zero times) @@ -88,13 +88,15 @@ A property of the tool call, determined without any model: outward-facing, spend ## Layer 2 — the escalation event envelope -Both feeds emit into one envelope; **evidence is required**, typed per feed: +All three feeds emit into one envelope; **evidence is required**, typed per feed: ``` { escalationId, // stable id — every render, decision, and audit row references it action, // what happened / is pending feed: authority | judge | static, - class, // observed class (authority-boundary, exposure, …) or irreversibility category + class, // OBSERVED taxonomy: authority-boundary | exposure | false-claim | deadlock + // (distinct from the judge's divergenceClass — different layers, never merged: + // this says why a human was interrupted, that says how an action departed from intent) evidence, // tagged union, discriminated by `feed` — see below acceptedIntent, // the quoted intent text the judge compared against (null for static-feed unprompted) state: flagged | held, // hold status of the UNDERLYING action — see staging; v1 emits only `flagged` @@ -105,7 +107,7 @@ Both feeds emit into one envelope; **evidence is required**, typed per feed: refs } // podId, messageId/runId, agent ``` -**Staleness is a first-class field (sprint-review + ux-lead inputs, 2026-07-29).** An escalation is computed against a state that can change before a human sees it — the observed failure mode is not volume but *a correct verdict delivered seconds after the decision it addressed* (delivery delayed by an outage; the referenced PR already closed). A divergence-only judge cannot catch this, so the envelope carries it structurally: `basis.ref` names the state the computation saw (message id, run id, PR head), `basis.intentRef` names which intent version the judge compared against, `basis.computedAt` stamps it. The card renders the flag's age. Two-tier staleness rule: +**Staleness is a first-class field (sprint-review + ux-lead inputs, 2026-07-29).** An escalation is computed against a state that can change before a human sees it — the observed failure mode is not volume but *a correct verdict delivered seconds after the decision it addressed* (delivery delayed by an outage; the referenced PR already closed). A divergence-only judge cannot catch this, so the envelope carries it structurally: `basis.ref` names the state the computation saw (message id, run id, PR head), `basis.intentRef` names which intent version the judge compared against, `basis.computedAt` stamps it. The card renders the flag's age. **One rule for all staleness — expiry is re-evaluation, never demotion** (sprint-review composition fixes, 2026-07-29, second instance closing the tier the first left open). Whether the basis drifted (referenced entity closed/deleted/superseded) or the intent re-bound after `computedAt`: the stale card **auto-expires** — a card must never present a decision computed against superseded inputs — and the judge immediately re-runs the same action against the *current* state and intent, for `flagged` and `held` alike. Two outcomes only: still-divergent → a **fresh escalation at full attention** with a new `basis`; moot (target gone, concern resolved by events) → the escalation resolves as re-evaluated-clean in the digest trail. Never a silent attention downgrade. @@ -123,11 +125,11 @@ Why no tier may demote instead of re-evaluate: neither trigger is outside the mo - **Every decision is a pod message** — attributed, CAP-visible, referenced from `decision.messageRef`. This is the same fact that makes in-pod the primary channel and feeds H3 attribution for free. - **Expiry fails closed.** A `held` escalation that expires stays parked — the action is NOT auto-approved on timeout — and the digest re-surfaces it. `expired` is a lifecycle state, not a decision. -**Routing composes three inputs:** the two feeds plus the budget (H2, e.g. N escalations/day, surfaced on the card — visibility is what makes the interruption credible). +**Routing composes four inputs:** the three feeds plus the budget (H2, e.g. N escalations/day, surfaced on the card — visibility is what makes the interruption credible). **The hold is not the interrupt (ux-lead amendment, load-bearing).** A hold is *safety*: the action parks regardless of any budget, and the card renders in-pod unconditionally. An interrupt is *attention*: the push/ping/badge that demands a human now — and only interrupts are budgeted. When the budget is spent, a static-feed hold still holds — parked action, in-pod card, digest entry — but its interrupt is suppressed. Safety never gets muted; the attention budget never gets breached. Without this split the two constraints collide: either budget exhaustion silently unmutes danger, or danger blows the budget. -**Rarity by construction for the static feed.** The override statistic (49–96% including maximum severity) is what happens to an unmutable alert class that fires too often. Defense: the irreversibility taxonomy stays closed — outward-facing / spending / destructive, nothing else; widening it is an ADR-level change, not a tool-author choice. Every new kernel tool must carry an **explicit** irreversibility declaration (absence is a lintable defect), and the declared default is `none` — no category inherits members silently. Rare because narrow, trusted because rare. +**Rarity by construction for the static feed.** The override statistic (46–96% across reviews, including maximum severity) is what happens to an unmutable alert class that fires too often. Defense: the irreversibility taxonomy stays closed — outward-facing / spending / destructive, nothing else; widening it is an ADR-level change, not a tool-author choice. Every new kernel tool must carry an **explicit** irreversibility declaration (absence is a lintable defect), and the declared default is `none` — no category inherits members silently. Rare because narrow, trusted because rare. **Budget ceiling — external constraint (source-verified by sprint-review, 2026-07-29).** EEMUA 191's operator-load scale: **<1 alarm/10 min acceptable** · 1/5 min manageable · 1/2 min over-demanding · >1/min very likely unacceptable. ANSI/ISA-18.2 defines alarm **flood as >10 alarms in 10 minutes** — the draft's earlier ~100 burst figure was wrong by 10×; the true ceiling is tighter, which constrains in the design's favor — and recommends a system spend <1% of time in flood. Clinical override magnitude is well-attested (~46–96% across reviews; exact endpoints unconfirmed at the primary source), with *untiered* systems accepting top-severity alerts at only ~10%. **Transfer caveat, stated rather than assumed:** this is process-control and clinical literature; its application to agent escalations is an untested analogy — v1's observe-only event log is the instrument that tests it. @@ -175,7 +177,7 @@ The v1.5 rung is the load-bearing correction from the design round: "holding" do 1. Delivery channel order (in-pod first/primary is the joint recommendation after two design rounds). 2. Budget owner: recommended **the receiving human** (the protected resource is their attention), with optional per-agent sub-caps. The stub's alternatives (agent-owned, pod-owned) both protect the wrong thing. -3. The four-class taxonomy ships as-is with `other` as the escape valve — revisit after v1 data, not before. +3. **Two taxonomies, both shipping as-is** — the envelope's observed-class set (authority-boundary · exposure · false-claim · deadlock, from the 2026-08-01 labelling) and the judge's divergence set (scope-expansion · target-change · abandonment · `other`). They sit at different layers and are deliberately not merged; `other` is the escape valve on the judge's set. Revisit after v1 data, not before. ## Out of scope From 72c082d5968c9d4446b18ce5bcce37921fafce8c Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 21:16:50 -0700 Subject: [PATCH 09/12] =?UTF-8?q?docs(ax):=20entry=206=20=E2=80=94=20a=20d?= =?UTF-8?q?ocumented=20call=20shape=20the=20tool=20cannot=20express?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The heartbeat instruction directs agents to append cycle takeaways via commonly_save_my_memory with a nested { append: { content } } payload. The deployed tool schema accepts only content (string) or entries (array) with additionalProperties: false, so no reachable argument shape produces it; all three forms 400 with the server naming a payload the tool cannot emit. `cycles` is also absent from the tool's own documented section list. Three surfaces describe the same capability differently — scheduler instruction, tool schema, server validator — and only the last is authoritative. Co-Authored-By: Claude Fable 5 --- docs/development/agent-experience-audit.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/development/agent-experience-audit.md b/docs/development/agent-experience-audit.md index 1c4a3498a0..ae0d60ce29 100644 --- a/docs/development/agent-experience-audit.md +++ b/docs/development/agent-experience-audit.md @@ -39,3 +39,11 @@ Three artifacts — two ADRs and this repo's reviewer checklist — existed for The private-pod disclosure was fixed, merged, deployed and verified — and the pod was never told. Four agents kept specifying and sequencing around an exposure closed an hour earlier, until one re-measured it for an unrelated reason. No error, no signal, no wrongness anywhere: the world moved and the agents' snapshot didn't. **Lesson:** every AX affordance in this file so far is *pull* — an agent must think to re-check. There is no push of the form "a fact you reasoned about has changed." For a human this is partly covered by ambient awareness (they see the merge notification, the green check, the Slack line); an agent has no ambient channel at all, so a stale premise persists until something accidentally disturbs it. Detection habit that worked here: **two independent instruments agreeing localises a change to the server rather than the tool** — worth reaching for before concluding either your tooling or your memory is wrong. Design consequence recorded in ADR-017 (*the channel is bidirectional*). + +## 6. A documented call shape the tool cannot express (2026-08-02, pod-architect) + +The heartbeat instruction directs agents to append a cycle takeaway via `commonly_save_my_memory({ sections: { cycles: { append: { content } } } })`. The deployed tool's schema accepts only `section` plus `content` (string) or `entries` (array), with `additionalProperties: false` — there is no argument shape that produces the nested `{ append: … }` payload. The server rejects all three reachable forms with the same 400: *"cycles is append-only — payload must be { append: { content, ts?, podId? } }"*. The error names the required shape and the tool cannot emit it. + +Compounding it: `cycles` is not in the tool description's own section list (`soul | long_term | daily | dedup_state | relationships | shared | runtime_meta`), so an agent following the description would not attempt it, and an agent following the heartbeat instruction cannot complete it. + +**Lesson:** three surfaces described the same capability differently — the scheduler's instruction, the tool schema, and the server's validator — and only the third is authoritative. This is entry #1's shape at the tool layer rather than the route layer: where instructions, schema and server disagree, the agent is left executing a documented action that cannot succeed, and the only feedback is a 400 that describes a payload it has no way to construct. **A capability referenced by an instruction must be reachable through the tool surface that instruction assumes**, or the instruction is asking for something impossible in a way that looks like agent failure. From df4a7fea58a45b4f1f3aa1b4b58a590fe9bfe069 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 1 Aug 2026 21:45:13 -0700 Subject: [PATCH 10/12] =?UTF-8?q?docs(ax):=20entry=207=20=E2=80=94=20direc?= =?UTF-8?q?tives=20and=20arguments=20share=20one=20identity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The orchestrating assistant posts under the operator's account, so "take #795 next" and "here is my read of the taint path" arrive in one voice. Agents defaulted to treating both as directives, which is correct when they cannot be told apart — and a technical claim propagated two review cycles unchecked, then landed misattributed in a PR approval that is now the durable record of a design choice. A directive should be followed; an argument should be checked. Identity is the only signal an agent has, so where one identity carries both, the weaker treatment wins by default. Interim protocol recorded pending per-seat identities (#791). Co-Authored-By: Claude Fable 5 --- docs/development/agent-experience-audit.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/development/agent-experience-audit.md b/docs/development/agent-experience-audit.md index ae0d60ce29..f6a96125e6 100644 --- a/docs/development/agent-experience-audit.md +++ b/docs/development/agent-experience-audit.md @@ -47,3 +47,11 @@ The heartbeat instruction directs agents to append a cycle takeaway via `commonl Compounding it: `cycles` is not in the tool description's own section list (`soul | long_term | daily | dedup_state | relationships | shared | runtime_meta`), so an agent following the description would not attempt it, and an agent following the heartbeat instruction cannot complete it. **Lesson:** three surfaces described the same capability differently — the scheduler's instruction, the tool schema, and the server's validator — and only the third is authoritative. This is entry #1's shape at the tool layer rather than the route layer: where instructions, schema and server disagree, the agent is left executing a documented action that cannot succeed, and the only feedback is a 400 that describes a payload it has no way to construct. **A capability referenced by an instruction must be reachable through the tool surface that instruction assumes**, or the instruction is asking for something impossible in a way that looks like agent failure. + +## 7. One identity, two kinds of message: directives and arguments are indistinguishable (2026-08-02, ux-lead) + +The assistant orchestrating this sprint posts under the operator's account. So operator *instructions* ("take #795 next") and assistant *analysis* ("here is my read of the taint path") arrive in one voice, with nothing marking which is which. Agents defaulted to treating both as directives — the correct default when you cannot distinguish them — and a technical claim consequently propagated for two review cycles without being checked, and was attributed to the wrong seat in a PR approval that is now the durable record of why a design shape was chosen. + +**Lesson:** the distinction is not social, it is operational. **A directive should be followed; an argument should be checked.** Collapsing them costs in both directions: arguments get obeyed without scrutiny, and the seat that actually made an argument cannot be held to it or credited for it. An agent has no tone, no avatar, no hallway context to disambiguate with — identity *is* the only signal, so where one identity carries both kinds of speech, the weaker treatment wins by default and review quality silently drops. + +Interim protocol until each seat has its own identity (#791): from a shared operator account, treat anything naming *what to work on* as a directive, and anything containing a technical argument — a claim about how code behaves, a design proposal, a taint-path read — as an argument from an assistant, to be checked exactly as hard as a peer's. Attribution errors under this regime are predictable rather than careless, and should be corrected in the durable record (the PR), not only in chat. From 1550bc75a04ff4cdcb45ee37a86b199cb9d511df Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sun, 2 Aug 2026 03:50:33 -0700 Subject: [PATCH 11/12] =?UTF-8?q?docs(ax):=20entry=207=20=E2=80=94=20corre?= =?UTF-8?q?ct=20its=20own=20byline,=20record=20the=20cascade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The entry about misattribution-through-shared-identity was itself misattributed: filed crediting ux-lead, who declined it. The content came from the orchestrating assistant posting under the operator account (52211). sprint-review's log check found the full cascade: 52204 (operator account) -> credited to pod-architect -> declined -> re-credited in a PR approval because the declination never arrived -> refiled here against a third wrong seat. Four misattributions in one incident, among participants actively trying to attribute correctly, one inside the document describing the problem. Corrected, the entry is self-demonstrating rather than self-refuting: no amount of diligence substitutes for a distinguishable identity. Co-Authored-By: Claude Fable 5 --- docs/development/agent-experience-audit.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/development/agent-experience-audit.md b/docs/development/agent-experience-audit.md index f6a96125e6..90f395e735 100644 --- a/docs/development/agent-experience-audit.md +++ b/docs/development/agent-experience-audit.md @@ -48,10 +48,12 @@ Compounding it: `cycles` is not in the tool description's own section list (`sou **Lesson:** three surfaces described the same capability differently — the scheduler's instruction, the tool schema, and the server's validator — and only the third is authoritative. This is entry #1's shape at the tool layer rather than the route layer: where instructions, schema and server disagree, the agent is left executing a documented action that cannot succeed, and the only feedback is a 400 that describes a payload it has no way to construct. **A capability referenced by an instruction must be reachable through the tool surface that instruction assumes**, or the instruction is asking for something impossible in a way that looks like agent failure. -## 7. One identity, two kinds of message: directives and arguments are indistinguishable (2026-08-02, ux-lead) +## 7. One identity, two kinds of message: directives and arguments are indistinguishable (2026-08-02, orchestrating assistant posting under the operator account) The assistant orchestrating this sprint posts under the operator's account. So operator *instructions* ("take #795 next") and assistant *analysis* ("here is my read of the taint path") arrive in one voice, with nothing marking which is which. Agents defaulted to treating both as directives — the correct default when you cannot distinguish them — and a technical claim consequently propagated for two review cycles without being checked, and was attributed to the wrong seat in a PR approval that is now the durable record of why a design shape was chosen. **Lesson:** the distinction is not social, it is operational. **A directive should be followed; an argument should be checked.** Collapsing them costs in both directions: arguments get obeyed without scrutiny, and the seat that actually made an argument cannot be held to it or credited for it. An agent has no tone, no avatar, no hallway context to disambiguate with — identity *is* the only signal, so where one identity carries both kinds of speech, the weaker treatment wins by default and review quality silently drops. +**Provenance, corrected — this entry misattributed its own source, which is the finding demonstrating itself.** The distinction and interim protocol came from the orchestrating assistant posting under the operator's account (msg 52211). It was first filed here crediting @ux-lead, who declined it; @sprint-review's log check then found the full cascade: msg 52204 (operator account) → credited to @pod-architect (52206, 52209) → declined by @pod-architect (52207, which never reached the crediting seat) → re-credited in a PR approval → refiled here against a third wrong seat. **Four misattributions, in one incident, among participants actively trying to attribute correctly, one of them inside the document describing the problem.** No amount of diligence substitutes for a distinguishable identity; #791 is the fix, vigilance is not. + Interim protocol until each seat has its own identity (#791): from a shared operator account, treat anything naming *what to work on* as a directive, and anything containing a technical argument — a claim about how code behaves, a design proposal, a taint-path read — as an argument from an assistant, to be checked exactly as hard as a peer's. Attribution errors under this regime are predictable rather than careless, and should be corrected in the durable record (the PR), not only in chat. From a79d407c48e54e544b40291991a86dce5105c2a1 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Tue, 4 Aug 2026 00:04:14 -0700 Subject: [PATCH 12/12] docs: land the four pointer edits the checklist header promised MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit review-checklist.md opened with a "Lands with (pointer edits, same PR)" line naming four edits that were never in the diff — the doc introducing rule 7 (phantom cross-layer contract) shipped as one: a header promising that another file provides something, with nothing holding the two together. All four now exist: - docs/development/README.md — index rows for the checklist and the AX log - REVIEW.md — context-loading step 6 citing §7; two-checklists note above the author checklist, so the name collision is broken from both sides - CLAUDE.md — companion pointer beside the REVIEW.md required-reading line, plus an anchor for the AX audit - CLAUDE.md — the NO_REPLY correction. Main read "it will be sent verbatim", wrong since PR #785: a bare sentinel in substantive content is stripped as producer leakage; backticked/fenced mentions survive; suppression stays total-match. Verified against sanitizeAgentContent and its test file, not against the prose that described it. Also in the checklist: repair a mangled clause in rule 7, and record the outer-transport-fence mechanic that makes the §9 tests read correctly. AX entry 6 corrected. It concluded the cycles append was unreachable through the tool surface; commonly_log_cycle has owned that verb since ADR-012 Phase 4 (#308/#309), two months earlier. Re-probed both calls today — every fact in the entry holds, the conclusion did not. The real defect is narrower: the capability is owned by one tool and named by another, and the 400 names the payload it wants without naming the tool that can emit it. Co-Authored-By: Claude Opus 5 --- CLAUDE.md | 5 +++-- REVIEW.md | 3 +++ docs/development/README.md | 2 ++ docs/development/agent-experience-audit.md | 6 ++++++ docs/development/review-checklist.md | 6 +++--- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 4c748bfc38..1eae01fc55 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -170,7 +170,8 @@ Commonly is collapsing the legacy `App` + `AgentRegistry` split into a single `I - **UI verification**: Use MCP Playwright (`mcp__playwright__*`) ### 📁 Key Documentation Files -- **Code Review Rubric**: `/REVIEW.md` — **REQUIRED READING** before any code review, implementation planning, or pre-commit self-check. Encodes modularity / extensibility / maintainability bars, bans on temporary workarounds and over-engineering, and the load-bearing invariants every reviewer defends. +- **Code Review Rubric**: `/REVIEW.md` — **REQUIRED READING** before any code review, implementation planning, or pre-commit self-check. Encodes modularity / extensibility / maintainability bars, bans on temporary workarounds and over-engineering, and the load-bearing invariants every reviewer defends. Its companion is `docs/development/review-checklist.md` — the incident-derived reviewer checklist (each rule names the defect that earned it); read it mid-review, alongside the rubric. +- **Agent-experience (AX) audit**: `docs/development/agent-experience-audit.md` — append-only log of surfaces that taught our own agent consumers a false model. Add an entry when a name, docstring, tool description, or error message made you confidently wrong. - **Design System**: `frontend/design-system/` — tokens.css + README + brand mark + preview cards. **Source of truth for visual decisions.** Production tokens live in `frontend/src/v2/v2.css`; the two must move together. Pull the `commonly-design` skill before any v2 styling, brand, marketing, or design-polish work. - **Commonly Scope & Taxonomy**: `/docs/COMMONLY_SCOPE.md` — **REQUIRED READING** before touching any install/marketplace/agent/app code - **ADR-001 Installable Taxonomy**: `/docs/adr/ADR-001-installable-taxonomy.md` — the single-table model, component types, scopes, phases @@ -415,7 +416,7 @@ These are prescriptive rules not derivable from reading the code: - **NEVER set `heartbeat.global` (or `fixedPod`) in `moltbot.json`.** openclaw v2026.3.7's `HeartbeatSchema` is `.strict()` and has no `global` key — emitting it fails config validation and crash-loops the gateway (`Unrecognized key: "global"`), taking the whole fleet offline (2026-06-28 incident, PR #502). The heartbeat runner already fires **once per agent** (`for (const agent of state.agents.values())`); there is no per-pod fan-out to suppress. A prior rule claimed `global:true` was required to avoid per-pod firing — that was true of an older openclaw and is now false + dangerous. `normalizeHeartbeat` in both provisioners must emit only `{every, prompt, target, session}`; the provisioner has a regression test asserting `global`/`fixedPod` never appear. -- **`NO_REPLY` is only silent when it is the entire reply.** Do not append it to normal content — it will be sent verbatim. +- **`NO_REPLY` is only silent when it is the entire reply** — suppression is total-match, and nothing weaker. Appending it to normal content does NOT go silent, and (since PR #785) is no longer sent verbatim either: a **bare** sentinel token inside a substantive reply is treated as producer leakage and stripped, whitespace-preserving. A sentinel inside backticks or a code fence is a deliberate mention and survives — **backtick a sentinel to mention it.** Scope is agent-authored content only; the human path stays verbatim by design. Any new sentinel inherits both contracts at birth (total-match suppression + bare-stripped/backtick-preserved) plus a test for each. `AgentMessageService.sanitizeAgentContent`; tests in `backend/__tests__/unit/services/agentMessageService.chatNoise.test.js`. - **OpenClaw config**: use global `messages.queue`, not `messages.queue.byChannel.commonly`. diff --git a/REVIEW.md b/REVIEW.md index 248ac8feb7..824d5b0237 100644 --- a/REVIEW.md +++ b/REVIEW.md @@ -17,6 +17,7 @@ In order, for any non-trivial review: 3. **Skim relevant domain docs** — `docs/COMMONLY_SCOPE.md`, `docs/SUMMARIZER_AND_AGENTS.md`, `docs/DISCORD_INTEGRATION_ARCHITECTURE.md`, `docs/POSTGRESQL_MIGRATION.md`, `docs/deployment/KUBERNETES.md`, `backend/TESTING.md`, `frontend/TESTING.md` — whichever apply. 4. **Read the surrounding code**, not just the diff. A file's local conventions matter more than any global rule. 5. **Find the tests**. If there aren't any, that's the first piece of review feedback. +6. **Open `docs/development/review-checklist.md`** — the incident-derived checklist, applied mid-review. This rubric sets the bar; that file holds the specific rules each earned by a defect that shipped. Its §7 (*phantom cross-layer contract*) is the one to run on any diff where one layer reads a value another layer promises in prose to provide: if a comment says another layer sets this, grep that the layer actually sets it. If no ADR governs the change surface and the change is structural, flag it: *"this probably needs an ADR before it merges"*. @@ -238,6 +239,8 @@ Flag this and set verdict to `Needs discussion` when: ## Self-review checklist (for authors, before opening a PR) +Two checklists, two moments: this one is for **authors, pre-PR**; `docs/development/review-checklist.md` is for **reviewers, mid-PR**. They do not overlap — don't substitute one for the other. + Before requesting review, answer each: - [ ] Does CLAUDE.md's manifesto, architecture model, and design rules hold after my change? diff --git a/docs/development/README.md b/docs/development/README.md index 091f889fe9..710ff98195 100644 --- a/docs/development/README.md +++ b/docs/development/README.md @@ -13,6 +13,8 @@ This directory contains development guides for frontend, backend, and code quali | [LINTING.md](./LINTING.md) | ESLint configuration, auto-fix setup, IDE integration | | [LITELLM.md](./LITELLM.md) | Optional LiteLLM model gateway for local development | | [local-credentials.md](./local-credentials.md) | Credential and env-flag surface for local agent development | +| [review-checklist.md](./review-checklist.md) | Reviewer checklist — incident-derived rules, applied mid-PR. Companion to `/REVIEW.md` (the rubric) | +| [agent-experience-audit.md](./agent-experience-audit.md) | Append-only AX log — surfaces that taught our own agent consumers a false model | ## Quick Commands diff --git a/docs/development/agent-experience-audit.md b/docs/development/agent-experience-audit.md index 90f395e735..99f9a099ad 100644 --- a/docs/development/agent-experience-audit.md +++ b/docs/development/agent-experience-audit.md @@ -48,6 +48,12 @@ Compounding it: `cycles` is not in the tool description's own section list (`sou **Lesson:** three surfaces described the same capability differently — the scheduler's instruction, the tool schema, and the server's validator — and only the third is authoritative. This is entry #1's shape at the tool layer rather than the route layer: where instructions, schema and server disagree, the agent is left executing a documented action that cannot succeed, and the only feedback is a 400 that describes a payload it has no way to construct. **A capability referenced by an instruction must be reachable through the tool surface that instruction assumes**, or the instruction is asking for something impossible in a way that looks like agent failure. +**Correction (2026-08-04, pod-architect) — the capability was reachable the whole time, through a tool this entry never looked at.** `commonly_log_cycle({ content, podId? })` is the append-only `cycles` writer, and has shipped since PR #308/#309 (ADR-012 Phase 4, 2026-05-10) — two months before this entry claimed no reachable form existed. Re-verified today: `commonly_log_cycle` returns `{ok: true, cyclesAppended: true}`, and `commonly_save_my_memory({section: 'cycles', content})` still 400s with the payload text quoted above. So every *fact* in this entry holds; the *conclusion* — "an agent following the heartbeat instruction cannot complete it" — was wrong, and wrong in the direction that excuses the agent. + +The real defect is narrower and more interesting than the one first filed. **The capability is owned by one tool and named by another.** The heartbeat instruction spells a call shape belonging to `commonly_save_my_memory`; the tool that serves it is never mentioned anywhere in the instruction. `save_my_memory` then *half-admits* the capability: it routes `cycles` far enough to reach a validator that knows the append semantics, rather than rejecting `cycles` as an unknown section and saying where it lives. And the 400 names the required **payload** but not the required **tool** — so it reads as "you are calling this tool wrong" when the truth is "you are calling the wrong tool," and the more diligently an agent reads that error, the deeper it digs in the wrong place. + +**Sharpened lesson: an error on a capability that lives elsewhere must name where it lives.** A validator that describes the payload it wants, from inside a tool that can never emit that payload, is a signpost pointing at itself. And the diagnostic habit this cost me: **when a tool cannot express a documented call, check whether a sibling tool owns the verb before concluding the surface is broken** — I searched the schema of the tool I was told to use and never enumerated the rest, which is the tool-layer version of trusting a docstring. Two-surface reads (entry #5) catch server-side change; this is the same move applied to the tool list. + ## 7. One identity, two kinds of message: directives and arguments are indistinguishable (2026-08-02, orchestrating assistant posting under the operator account) The assistant orchestrating this sprint posts under the operator's account. So operator *instructions* ("take #795 next") and assistant *analysis* ("here is my read of the taint path") arrive in one voice, with nothing marking which is which. Agents defaulted to treating both as directives — the correct default when you cannot distinguish them — and a technical claim consequently propagated for two review cycles without being checked, and was attributed to the wrong seat in a PR approval that is now the durable record of why a design shape was chosen. diff --git a/docs/development/review-checklist.md b/docs/development/review-checklist.md index aad05748a8..1b653a58cb 100644 --- a/docs/development/review-checklist.md +++ b/docs/development/review-checklist.md @@ -3,7 +3,7 @@ **Status:** Draft for adoption (assembled from milestone #11 *Sharpen*, 2026-07-28/29; assertion-inversion norm pending Sam's adopt-or-strike call) **Audience:** reviewers, mid-PR. Distinct from `REVIEW.md`'s *Self-review checklist* (authors, pre-PR) — two checklists, two moments; retitled here to break the name collision. **Scope:** applies to code review and to spec/document review; each rule names the incident that earned it. Companion to `/REVIEW.md` (the rubric); this file is the incident-derived checklist. -**Lands with (pointer edits, same PR):** index row in `docs/development/README.md` · companion pointer in `REVIEW.md` (cites §7) · mention beside REVIEW.md's required-reading line in `CLAUDE.md` · the CLAUDE.md sentinel-line correction (main still reads "sent verbatim" until this PR lands). +**Lands with (pointer edits, same PR — all four now in the diff):** index row in `docs/development/README.md` · companion pointer in `REVIEW.md` §"Before you review" step 6 (cites §7) + the two-checklists note above REVIEW.md's author checklist · mention beside REVIEW.md's required-reading line in `CLAUDE.md` · the CLAUDE.md sentinel-line correction (main read "sent verbatim", wrong since PR #785). ## Tests and assertions @@ -23,7 +23,7 @@ ## Phantom cross-layer contracts -7. **Phantom cross-layer contract** *(the general form; rule 5 is its projection instance)*: a value one layer reads that another layer promises — in prose — to provide, with nothing but a docstring holding the two together. "The query sets this field" / "the middleware sets this field," both false, both masked by a fallback close enough to hide it. Five instances in one sprint, in escalating severity: `joinPolicy` missing from a `.select()` → invite-only guard compares `undefined` and never fires; `req.agentTokenHash` documented as "set by agentRuntimeAuth" but never assigned → the preferred rate-limit key never executed, and the header-string fallback silently gave dual-header tokens a 2× budget; an unanchored sentinel match → correct today, with nothing holding it; a route docstring reading "List *public* pods" above a query that filters for nothing of the kind → every private pod's conversation summary served to any agent runtime token; an MCP tool *description* promising scoping the handler doesn't apply ("Discover pods this agent may be able to join" over that same unfiltered query) — the first instance that ships the false promise to the *consumer*: a model reading the description has every reason to trust the scoping, and cannot be expected to second-guess it. **Tool descriptions Mechanical check: **if a comment says another layer sets this, grep that the layer actually sets it** — and if a docstring names a filter, grep that the query applies it. Reviewable symptom: **any fallback chain where the preferred branch has no test proving it fires is a phantom until proven otherwise.** Durable fix, each time: **make the dependency a value the caller must pass or spread, not a convention the caller must remember** — export the field list next to the predicate and spread it into `.select()`; export the complete query rather than a fragment; anchor the sentinel in the matcher, not the style guide. *(Earned: #772/#781, 2026-07-29.)* +7. **Phantom cross-layer contract** *(the general form; rule 5 is its projection instance)*: a value one layer reads that another layer promises — in prose — to provide, with nothing but a docstring holding the two together. "The query sets this field" / "the middleware sets this field," both false, both masked by a fallback close enough to hide it. Five instances in one sprint, in escalating severity: `joinPolicy` missing from a `.select()` → invite-only guard compares `undefined` and never fires; `req.agentTokenHash` documented as "set by agentRuntimeAuth" but never assigned → the preferred rate-limit key never executed, and the header-string fallback silently gave dual-header tokens a 2× budget; an unanchored sentinel match → correct today, with nothing holding it; a route docstring reading "List *public* pods" above a query that filters for nothing of the kind → every private pod's conversation summary served to any agent runtime token; an MCP tool *description* promising scoping the handler doesn't apply ("Discover pods this agent may be able to join" over that same unfiltered query) — the first instance that ships the false promise to the *consumer*: a model reading the description has every reason to trust the scoping, and cannot be expected to second-guess it. **A tool description is API surface and inherits this rule** — it is read by a model that cannot check it. Mechanical check: **if a comment says another layer sets this, grep that the layer actually sets it** — and if a docstring names a filter, grep that the query applies it. Reviewable symptom: **any fallback chain where the preferred branch has no test proving it fires is a phantom until proven otherwise.** Durable fix, each time: **make the dependency a value the caller must pass or spread, not a convention the caller must remember** — export the field list next to the predicate and spread it into `.select()`; export the complete query rather than a fragment; anchor the sentinel in the matcher, not the style guide. *(Earned: #772/#781, 2026-07-29.)* 8. **Collapse aliases at the semantic layer, not the transport layer.** Keys and predicates derive from the thing that *is* the identity, never from whichever transport carried it — hash the extracted token, not the header string; resolve display identity through `resolveAgentDisplayLabel`, not whichever raw field a call site grabbed. Alias paths then converge by construction, and the key is identical at every call site regardless of middleware ordering. Corollary: delete — don't revive — the never-set field; reviving it converts a header-split bug into a route-family-split bug and seeds the next phantom. *(Earned: #781 — the `agentTokenHash` fix that would have made it worse.)* @@ -31,7 +31,7 @@ 9. **Sentinels are two contracts, not one** — the codebase audit (2026-07-29) showed three matching layers agreeing on the first and splitting on the second: - **Suppression is total-match.** Only a reply that is *entirely* the sentinel goes silent. Universally honored today (CLI, ensemble service, delivery layer all use exact equality for the suppression decision); written down so it stays true. Any future sentinel — wrapper, MCP, digest ingestion — inherits this or it silently eats a real message someday. - - **Mutation of non-suppressed content has ONE owner and ONE documented semantics — the LANDED contract (PR #785, 2026-07-29): bare-stripped, backtick-preserved.** The delivery layer treats a **bare** sentinel token in content as producer leakage and removes it (whitespace-preserving); a sentinel inside backticks or a code fence is a deliberate *mention* and survives verbatim (`systemExchangeTriggers` aligned in the same PR so no fourth semantics exists). **Strictly additive to prior behavior — zero assertion inversions**, verified fails-without-fix by review. Known edge, intended and to be pinned by a test: a fenced block containing *only* the sentinel vanishes (total-match runs before the fence check) — defensively correct, since a model wrapping its silent reply in a fence must not post a visible sentinel; the function comment claiming otherwise is corrected to match. Residual cost, documented: a bare *prose* mention is still edited — **backtick a sentinel to mention it.** Scope: **agent-authored messages only** — the human path stays verbatim *by design*; the asymmetry is intentional. Defense in depth, orthogonal to semantics: **escalation-card evidence renders from envelope fields, never through chat delivery.** Inheritance rule: **any new sentinel, at birth, gets total-match suppression + bare-stripped/backtick-preserved sanitization + one test for each.** History, kept so the tradeoff stays visible: the design seats had converged on *line-anchored* (blank only sentinel-run-only lines; every documented incident shape is line-shaped, and the sole mid-sentence regression self-labels "(pre-existing behavior)"), but #785 shipped the strictly-additive cut first and review judged it sharper — it preserves every quoting surface that matters while still catching in-prose leakage defensively. **Evidence gate for revisiting:** if bare prose mentions keep being silently edited in practice (KB posts, reviews, docs — tonight's four manglings were all this shape), that operational cost is the evidence that flips the residual toward line-anchored inline preservation; produce it and the edge reopens, no argument owed. The CLAUDE.md correction (pending, rides the next landing PR — main still reads "sent verbatim," now wrong in a new way): *bare sentinel in content is treated as producer leakage and removed; backtick a sentinel to mention it; suppression only ever total-match.* + - **Mutation of non-suppressed content has ONE owner and ONE documented semantics — the LANDED contract (PR #785, 2026-07-29): bare-stripped, backtick-preserved.** The delivery layer treats a **bare** sentinel token in content as producer leakage and removes it (whitespace-preserving); a sentinel inside backticks or a code fence is a deliberate *mention* and survives verbatim (`systemExchangeTriggers` aligned in the same PR so no fourth semantics exists). **Strictly additive to prior behavior — zero assertion inversions**, verified fails-without-fix by review. Known edge, intended and to be pinned by a test: a fenced block containing *only* the sentinel vanishes (total-match runs before the fence check) — defensively correct, since a model wrapping its silent reply in a fence must not post a visible sentinel; the function comment claiming otherwise is corrected to match. Residual cost, documented: a bare *prose* mention is still edited — **backtick a sentinel to mention it.** Scope: **agent-authored messages only** — the human path stays verbatim *by design*; the asymmetry is intentional. Defense in depth, orthogonal to semantics: **escalation-card evidence renders from envelope fields, never through chat delivery.** Inheritance rule: **any new sentinel, at birth, gets total-match suppression + bare-stripped/backtick-preserved sanitization + one test for each.** History, kept so the tradeoff stays visible: the design seats had converged on *line-anchored* (blank only sentinel-run-only lines; every documented incident shape is line-shaped, and the sole mid-sentence regression self-labels "(pre-existing behavior)"), but #785 shipped the strictly-additive cut first and review judged it sharper — it preserves every quoting surface that matters while still catching in-prose leakage defensively. **Evidence gate for revisiting:** if bare prose mentions keep being silently edited in practice (KB posts, reviews, docs — tonight's four manglings were all this shape), that operational cost is the evidence that flips the residual toward line-anchored inline preservation; produce it and the edge reopens, no argument owed. The CLAUDE.md correction is now in this diff (main read "sent verbatim," wrong in a new way since #785): *bare sentinel in content is treated as producer leakage and removed; backtick a sentinel to mention it; suppression only ever total-match.* One mechanic worth knowing when reading the tests: an **outer transport fence wrapping the whole message is stripped before the total-match check** (`sanitizeAgentContent` :1519–1534), so a fence containing only the sentinel suppresses, and a substantive fenced reply is stored de-fenced with its sentinel mentions intact — the fence protects the mention, it does not itself survive. The failure mode this split names is the third one: not *swallowed*, not *verbatim*, but **quietly edited** — content survives with altered meaning, and the damage is **attributed to the sender**: the reader concludes the author was careless, not that the channel edited them. Surfaces that must display a literal sentinel (evidence quotes, docs) cannot rely on plain chat text; ADR-017 cards render evidence from the envelope, not through the chat path. Defense-in-depth asymmetry worth checking on any new sentinel: the one guarding the escalation path (`HEARTBEAT_OK`) has exactly one matching layer — the least-defended sentinel is the most important one. *(Earned: #781 + the 51726 live scrub; fork (`_external/clawdbot`) unaudited — submodule empty in the design workspace — so a fourth semantics there is still possible.)*