run-triage.sh's /triage prompt still points at Matou/idss's docs/adr/0174-*.md, which 404s in every other consumer #42

Closed
opened 2026-08-23 23:10:13 +00:00 by matou-build-agent · 1 comment

Why

Found while landing #33 (which fixed the same defect in prompts/session-runner-prompt.md). The remaining occurrence of a path to another repo's decision record in live prompt text is in a harness shell script, where #1's {{ENRICH:<slot>}} mechanism cannot reach:

  • run-triage.sh:99 — the headless /triage prompt string handed to Claude on every triage run says:

    When you hit ambiguity or a judgement call you would normally ask a human about, first try to RULE it yourself under ADR 0174 (docs/adr/0174-*.md)

    docs/adr/0174-*.md exists only in Matou/idss. In this repo (ADRs 0001-0005) and in matou-app it 404s — a triage agent following it literally reads nothing. Same defect class as #33.

  • protected-paths-lib.sh:69 mentions "ADR 0174:" with no path. #33 ruled the bare number is fine (inherited factory audit-trail vocabulary — docs/agents/triage-labels.md and this repo's own ADR headers all use it; it cannot 404). Named here only so the next session does not re-open it: the path is the hazard, not the number.

#33's ratchet (tests/judgement-call-prompts-test.sh) deliberately covers only markdown — prompt skeletons and a repo's own rendered prompts/enrichments. It does NOT scan .sh prompt strings, so this occurrence is unratcheted today.

Ask

Decide where a per-repo two-way-door pointer comes from for prompt text embedded in harness .sh files, then apply it and extend the ratchet to cover .sh prompt strings:

  • Option A — drop the path, keep the number ("under ADR 0174, your repo's two-way-door record"). Zero mechanism, but a triage agent has nothing local to read.
  • Option B — source it from the identity/policy layer (a TWO_WAY_DOOR_DOC-style per-repo value, à la RUNNER_HOST), interpolated into the prompt string. Consistent with #33 and ADR 0001 pt 2, but adds an identity-contract key (see identity-lib.sh's IDENTITY_CONTRACT and #31 — an added key is a contract bump, and consumers lag by a pin).
  • Option C — read the pointer from the consumer's own prompt-enrichments/ at run time. Breaks #1's "never computed at run time" property for prompts; probably a no.

Note run-triage.sh is a vendored harness file: a change reaches every consumer at its next pin bump, and tests/judgement-call-prompts-test.sh already asserts four phrases of that same prompt string.

ready-for-session: live prompt text with factory-wide blast radius plus an identity-contract decision — design work, per CLAUDE.md's blast-radius rules.

## Why Found while landing #33 (which fixed the same defect in `prompts/session-runner-prompt.md`). The remaining occurrence of a *path* to another repo's decision record in live prompt text is in a harness **shell script**, where #1's `{{ENRICH:<slot>}}` mechanism cannot reach: - `run-triage.sh:99` — the headless `/triage` prompt string handed to Claude on every triage run says: > When you hit ambiguity or a judgement call you would normally ask a human about, first try to RULE it yourself under ADR 0174 (`docs/adr/0174-*.md`) `docs/adr/0174-*.md` exists only in `Matou/idss`. In this repo (ADRs 0001-0005) and in `matou-app` it 404s — a triage agent following it literally reads nothing. Same defect class as #33. - `protected-paths-lib.sh:69` mentions "ADR 0174:" with **no path**. #33 ruled the bare number is fine (inherited factory audit-trail vocabulary — `docs/agents/triage-labels.md` and this repo's own ADR headers all use it; it cannot 404). Named here only so the next session does not re-open it: **the path is the hazard, not the number.** #33's ratchet (`tests/judgement-call-prompts-test.sh`) deliberately covers only markdown — prompt skeletons and a repo's own rendered prompts/enrichments. It does NOT scan `.sh` prompt strings, so this occurrence is unratcheted today. ## Ask Decide where a per-repo two-way-door pointer comes from for prompt text embedded in harness `.sh` files, then apply it and extend the ratchet to cover `.sh` prompt strings: - Option A — drop the path, keep the number ("under ADR 0174, your repo's two-way-door record"). Zero mechanism, but a triage agent has nothing local to read. - Option B — source it from the identity/policy layer (a `TWO_WAY_DOOR_DOC`-style per-repo value, à la `RUNNER_HOST`), interpolated into the prompt string. Consistent with #33 and ADR 0001 pt 2, but adds an identity-contract key (see `identity-lib.sh`'s `IDENTITY_CONTRACT` and #31 — an added key is a contract bump, and consumers lag by a pin). - Option C — read the pointer from the consumer's own `prompt-enrichments/` at run time. Breaks #1's "never computed at run time" property for prompts; probably a no. Note `run-triage.sh` is a vendored harness file: a change reaches every consumer at its next pin bump, and `tests/judgement-call-prompts-test.sh` already asserts four phrases of that same prompt string. `ready-for-session`: live prompt text with factory-wide blast radius plus an identity-contract decision — design work, per CLAUDE.md's blast-radius rules.
Author
Member

Ruling — the layer a shell prompt string reads

Ruled by agent under ADR 0174 — veto anytime.

Option B, but on the POLICY layer, not the identity layer — and Option A
survives as the honest degraded case.
The general rule, now recorded as an
ADR 0002 amendment so the next .sh prompt string does not re-litigate it:

  • a per-repo value in a shell prompt string comes from the identity layer
    if it is a FACT about the repo or its deployment (REPO_SLUG,
    RUNNER_HOST);
  • it comes from the policy layer if it is per-repo doctrine — which
    decision record carries a repo's two-way-door rule is doctrine.

So: TWO_WAY_DOOR_DOC in swarm-policy.sh, default EMPTY, spliced into
the /triage prompt by run-triage.sh.

Why not the identity layer, as the ask sketched it. The ask already names
the cost and it is decisive: an identity key the harness REQUIRES is an
IDENTITY_CONTRACT bump (#31), and identity_require fails closed — every
consumer's harness refuses to run until it regenerates its identity file. That
is a fleet-wide hard stop bought for one sentence of prose. A policy key is
additive in the direction that matters at a pin bump: a NEW policy-lib.sh
tolerates an OLD swarm-policy.sh (the key is unset, the default applies).
The layer is also the semantically right one — policy-lib.sh already carries
the one-way-door trigger and its guidance, and already says in a comment that
"each repo states its own two-way-door doctrine".

Why Option A is not discarded but demoted to the undeclared case. A repo
that HAS a record should be able to send its triage agent to it. A repo that
has none now gets, in words:

under ADR 0174 (the factory's inherited two-way-door doctrine; this repo
declares no local record of it (set TWO_WAY_DOOR_DOC in swarm-policy.sh), so
the bar stated here is the whole test)

That costs the agent nothing, because the prompt already states the
doctrine's whole test inline
(revertible by a later commit/label change,
provable by an existing test/drive/probe, not on the one-way-door list). The
404 was decoration, not load-bearing — which is exactly why an empty default is
honest and a defaulted path never could be (CLAUDE.md: never default a per-repo
value to any product).

Why not Option C, on a corrected ground. The ask says C breaks #1's
"never computed at run time" property. It does not — a shell prompt string is
computed at run time by construction; that property is about the five
RENDERED prompts. C is declined for a different reason: it would add a second,
un-rendered, unvalidated prose-splice mechanism for what is one path.

The bare number stays, per #33 and as the ticket asked: "ADR 0174" is the
factory's inherited audit-trail vocabulary, names no path, cannot 404. The path
was the hazard.

What proves it

Every check was proven RED before the fix:

  • tests/judgement-call-prompts-test.sh 18 → 21 checks, gaining the .sh
    scan the ticket asks for: (c) no harness .sh may name a docs/adr/
    path in EXECUTABLE text — comment lines exempt, following
    actions-endpoint-test.sh (#28), so the hazard stays explainable next to the
    code it constrains; scanned non-recursively so the same surface is covered in
    this root and in a consumer's vendored .sandcastle/ (#23). (d) a
    pointer a repo DOES declare must resolve in that repo — the same bar #33 set
    for rendered prose. Proven red against the exact pre-fix prompt line, and (d)
    proven red against a declared docs/adr/0174-*.md, then green against
    0001-*.md.
    • Writing it caught a flaw in the check itself: the first version redded on
      swarm-policy.sh — the very file the fix asks a repo to declare its pointer
      IN. The per-repo identity/policy layer is now exempt by name, on the ground
      that a path in a vendor-EXCLUDED, consumer-owned file cannot reach another
      repo. That is what (d) is for.
  • tests/run-triage-test.sh 3 → 5 scenarios, driving the REAL script with
    a shimmed claude that now logs its argv: a declared record reaches the
    prompt with no other repo's path in it; an undeclared repo's prompt contains
    no docs/adr/ path at all and says so in words.
  • tests/policy-lib-test.sh 43 → 50 (empty default, verbatim load with the
    glob intact, refusals for an absolute host path — #37/#43's defect family —
    a .. escape, and prose instead of a path).
  • onboarding/tests/onboard-lib-test.sh 158 → 161 (onboard_write_policy
    carries the key with its glob and still refuses an absolute path).
  • Full offline suite green, 67 files. Additionally, all three consumer
    states (undeclared / declared-and-resolves / declared-and-404s) were proven
    standalone in a scratch .sandcastle/-shaped tree with the repo's docs one
    level up, including the loud skeleton SKIP on a pin that predates prompts/.

Close report

Landed in c77b647 on main (root only — nothing under .sandcastle/):

  • run-triage.sh — sources policy-lib.sh, policy_load "${SWARM_POLICY_FILE:-}"
    (the established test-only seam), interpolates the pointer clause.
  • policy-lib.sh — TWO_WAY_DOOR_DOC knob, empty default, exported as
    SWARM_POLICY_TWO_WAY_DOOR_DOC, added to the closed key set, validated as
    one repo-relative path.
  • onboarding/onboard-lib.sh — onboard_write_policy accepts the key.
  • docs/adr/0002-per-repo-policy-layer.md — the amendment above.
  • docs/GOTCHAS.md 17 — the rollout order this makes mandatory (below).
  • onboarding/README.md, STATUS.md (header + "Where things stand" +
    milestone log), and the four test files.

Two things a reader needs to know

  1. Rollout order is not optional (GOTCHAS 17). The policy key set is CLOSED
    and policy_validate fails closed, so the additivity runs one way only: a
    new pin tolerates an old policy file, but an old pin REFUSES a new key
    (policy: unknown key TWO_WAY_DOOR_DOC, in preflight, before any worker
    spawns). Bump FACTORY_REF first, declare TWO_WAY_DOOR_DOC second.
  2. This repo has not declared its own pointer yet, deliberately.
    .sandcastle/ is pinned at bd48fd6, whose policy-lib.sh predates even
    SESSION_RUNNER — declaring the key now would red this repo's own swarm by
    rule 1. Its TWO_WAY_DOOR_DOC=docs/adr/0001-*.md waits for the human pin
    bump (bash onboarding/onboard.sh vendor .sandcastle <sha>, GOTCHAS 4);
    until then this repo's triage runs keep the old prompt text. The ratchet
    already proves that exact value resolves here.

Follow-up filed: #47 (ready-for-session) — the same prompt's
docs/agents/triage-labels.md pointer sits in a vendor-EXCLUDED dir, so it
resolves only in a consumer that happens to carry its own copy. It is
deliberately OUT of the new ratchet's scan: unlike the ADR pointer, a consumer
has no knob to fix a docs/agents/ path in a vendored script, so redding on it
would trap the consumer rather than route them.

## Ruling — the layer a *shell* prompt string reads Ruled by agent under ADR 0174 — veto anytime. **Option B, but on the POLICY layer, not the identity layer — and Option A survives as the honest degraded case.** The general rule, now recorded as an ADR 0002 amendment so the next `.sh` prompt string does not re-litigate it: - a per-repo value in a shell prompt string comes from the **identity** layer if it is a FACT about the repo or its deployment (`REPO_SLUG`, `RUNNER_HOST`); - it comes from the **policy** layer if it is per-repo **doctrine** — which decision record carries a repo's two-way-door rule is doctrine. So: **`TWO_WAY_DOOR_DOC` in `swarm-policy.sh`, default EMPTY**, spliced into the `/triage` prompt by `run-triage.sh`. **Why not the identity layer, as the ask sketched it.** The ask already names the cost and it is decisive: an identity key the harness REQUIRES is an `IDENTITY_CONTRACT` bump (#31), and `identity_require` fails closed — every consumer's harness refuses to run until it regenerates its identity file. That is a fleet-wide hard stop bought for one sentence of prose. A policy key is additive in the direction that matters at a pin bump: a NEW `policy-lib.sh` tolerates an OLD `swarm-policy.sh` (the key is unset, the default applies). The layer is also the semantically right one — `policy-lib.sh` already carries the `one-way-door` trigger and its guidance, and already says in a comment that "each repo states its own two-way-door doctrine". **Why Option A is not discarded but demoted to the undeclared case.** A repo that HAS a record should be able to send its triage agent to it. A repo that has none now gets, in words: > under ADR 0174 (the factory's inherited two-way-door doctrine; this repo > declares no local record of it (set TWO_WAY_DOOR_DOC in swarm-policy.sh), so > the bar stated here is the whole test) That costs the agent nothing, because the prompt already **states the doctrine's whole test inline** (revertible by a later commit/label change, provable by an existing test/drive/probe, not on the one-way-door list). The 404 was decoration, not load-bearing — which is exactly why an empty default is honest and a defaulted path never could be (CLAUDE.md: never default a per-repo value to any product). **Why not Option C, on a corrected ground.** The ask says C breaks #1's "never computed at run time" property. It does not — a shell prompt string is computed at run time *by construction*; that property is about the five RENDERED prompts. C is declined for a different reason: it would add a second, un-rendered, unvalidated prose-splice mechanism for what is one path. **The bare number stays**, per #33 and as the ticket asked: "ADR 0174" is the factory's inherited audit-trail vocabulary, names no path, cannot 404. The path was the hazard. ## What proves it Every check was proven RED before the fix: - `tests/judgement-call-prompts-test.sh` **18 → 21 checks**, gaining the `.sh` scan the ticket asks for: **(c)** no harness `.sh` may name a `docs/adr/` path in EXECUTABLE text — comment lines exempt, following `actions-endpoint-test.sh` (#28), so the hazard stays explainable next to the code it constrains; scanned non-recursively so the same surface is covered in this root and in a consumer's vendored `.sandcastle/` (#23). **(d)** a pointer a repo DOES declare must resolve in that repo — the same bar #33 set for rendered prose. Proven red against the exact pre-fix prompt line, and (d) proven red against a declared `docs/adr/0174-*.md`, then green against `0001-*.md`. - Writing it caught a flaw in the check itself: the first version redded on `swarm-policy.sh` — the very file the fix asks a repo to declare its pointer IN. The per-repo identity/policy layer is now exempt by name, on the ground that a path in a vendor-EXCLUDED, consumer-owned file cannot reach another repo. That is what (d) is for. - `tests/run-triage-test.sh` **3 → 5 scenarios**, driving the REAL script with a shimmed `claude` that now logs its argv: a declared record reaches the prompt with no other repo's path in it; an undeclared repo's prompt contains no `docs/adr/` path at all and says so in words. - `tests/policy-lib-test.sh` **43 → 50** (empty default, verbatim load with the glob intact, refusals for an absolute host path — #37/#43's defect family — a `..` escape, and prose instead of a path). - `onboarding/tests/onboard-lib-test.sh` **158 → 161** (`onboard_write_policy` carries the key with its glob and still refuses an absolute path). - **Full offline suite green, 67 files.** Additionally, all three consumer states (undeclared / declared-and-resolves / declared-and-404s) were proven standalone in a scratch `.sandcastle/`-shaped tree with the repo's docs one level up, including the loud skeleton SKIP on a pin that predates `prompts/`. ## Close report Landed in `c77b647` on `main` (root only — nothing under `.sandcastle/`): - `run-triage.sh` — sources `policy-lib.sh`, `policy_load "${SWARM_POLICY_FILE:-}"` (the established test-only seam), interpolates the pointer clause. - `policy-lib.sh` — `TWO_WAY_DOOR_DOC` knob, empty default, exported as `SWARM_POLICY_TWO_WAY_DOOR_DOC`, added to the closed key set, validated as one repo-relative path. - `onboarding/onboard-lib.sh` — `onboard_write_policy` accepts the key. - `docs/adr/0002-per-repo-policy-layer.md` — the amendment above. - `docs/GOTCHAS.md` **17** — the rollout order this makes mandatory (below). - `onboarding/README.md`, `STATUS.md` (header + "Where things stand" + milestone log), and the four test files. ### Two things a reader needs to know 1. **Rollout order is not optional (GOTCHAS 17).** The policy key set is CLOSED and `policy_validate` fails closed, so the additivity runs one way only: a new pin tolerates an old policy file, but an **old pin REFUSES a new key** (`policy: unknown key TWO_WAY_DOOR_DOC`, in preflight, before any worker spawns). **Bump `FACTORY_REF` first, declare `TWO_WAY_DOOR_DOC` second.** 2. **This repo has not declared its own pointer yet, deliberately.** `.sandcastle/` is pinned at `bd48fd6`, whose `policy-lib.sh` predates even `SESSION_RUNNER` — declaring the key now would red this repo's own swarm by rule 1. Its `TWO_WAY_DOOR_DOC=docs/adr/0001-*.md` waits for the human pin bump (`bash onboarding/onboard.sh vendor .sandcastle <sha>`, GOTCHAS 4); until then this repo's triage runs keep the old prompt text. The ratchet already proves that exact value resolves here. Follow-up filed: **#47** (`ready-for-session`) — the same prompt's `docs/agents/triage-labels.md` pointer sits in a vendor-EXCLUDED dir, so it resolves only in a consumer that happens to carry its own copy. It is deliberately OUT of the new ratchet's scan: unlike the ADR pointer, a consumer has no knob to fix a `docs/agents/` path in a vendored script, so redding on it would trap the consumer rather than route them.
matou-build-agent 2026-08-24 01:46:17 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#42
No description provided.