adopt the prompt-render pipeline: swarm-policy.sh + prompt-enrichments/ so worker prompts derive from declared policy (judgement-call-prompts-test red since pin 343d26f) #857

Closed
opened 2026-08-25 20:48:09 +00:00 by ben · 2 comments
Owner

Found at the #715 pin bump (FACTORY_REF 343d26f, 2026-08-25)

The factory's prompt-render pipeline (dev-factory #1/#14: prompts/*.md skeletons + {{ENRICH:<slot>}} splices + {{HANDOFF_RULES}} generated from swarm-policy.sh's HUMAN_LABELS) is now vendored in, but this repo has never adopted it: there is no .sandcastle/swarm-policy.sh and no .sandcastle/prompt-enrichments/, so onboard.sh render-prompts refuses (heal-prompt.md needs {{ENRICH:ops-context}}) and the live worker prompts (.sandcastle/prompt.md, heal-prompt.md, session-runner-prompt.md, rehearsal-*-prompt.md) stay hand-maintained.

The vendored tests/judgement-call-prompts-test.sh names the cost: the hand-maintained prompts' blocked-path routing has drifted from the policy-derived contract ("the blocked path must route its human label by an explicit one-way-door trigger"). This is exactly the drift the pipeline exists to retire — Ben's 2026-08-22 ruling (recorded in prompt-render-lib.sh): the human labels are declared ONCE in swarm-policy.sh and the routing prose is derived, never hand-maintained beside it.

What to do

  1. Mint .sandcastle/swarm-policy.sh declaring this repo's actual policy (LANDING=push, SESSION_RUNNER=on, and the real HUMAN_LABELS set: ready-for-human, ready-for-session, … with their triggers — read policy-lib.sh for the schema; note the defaults' agent-blocked/needs-info are NOT this repo's labels).
  2. Author prompt-enrichments/<slot>.md for every {{ENRICH:…}} slot the skeletons reference, carrying the idss-specific prose the current hand-maintained prompts hold.
  3. onboard.sh render-prompts .sandcastle and diff the rendered output against the current prompts — the diff IS the review; no behavioural drift beyond the derived hand-off section without a named reason.
  4. tests/judgement-call-prompts-test.sh green is the door-stays-shut proof.

Routing: ready-for-session, not ready-for-agent — every file here is under .sandcastle/ (protected path; workers must not edit the machinery that runs them), and the rendered prompts are live text handed to every future worker.

## Found at the #715 pin bump (FACTORY_REF 343d26f, 2026-08-25) The factory's prompt-render pipeline (dev-factory #1/#14: `prompts/*.md` skeletons + `{{ENRICH:<slot>}}` splices + `{{HANDOFF_RULES}}` generated from `swarm-policy.sh`'s `HUMAN_LABELS`) is now vendored in, but this repo has never adopted it: there is no `.sandcastle/swarm-policy.sh` and no `.sandcastle/prompt-enrichments/`, so `onboard.sh render-prompts` refuses (`heal-prompt.md needs {{ENRICH:ops-context}}`) and the live worker prompts (`.sandcastle/prompt.md`, `heal-prompt.md`, `session-runner-prompt.md`, `rehearsal-*-prompt.md`) stay hand-maintained. The vendored `tests/judgement-call-prompts-test.sh` names the cost: the hand-maintained prompts' blocked-path routing has drifted from the policy-derived contract ("the blocked path must route its human label by an explicit one-way-door trigger"). This is exactly the drift the pipeline exists to retire — Ben's 2026-08-22 ruling (recorded in prompt-render-lib.sh): the human labels are declared ONCE in `swarm-policy.sh` and the routing prose is derived, never hand-maintained beside it. ## What to do 1. Mint `.sandcastle/swarm-policy.sh` declaring this repo's actual policy (LANDING=push, SESSION_RUNNER=on, and the real `HUMAN_LABELS` set: `ready-for-human`, `ready-for-session`, … with their triggers — read `policy-lib.sh` for the schema; note the defaults' `agent-blocked`/`needs-info` are NOT this repo's labels). 2. Author `prompt-enrichments/<slot>.md` for every `{{ENRICH:…}}` slot the skeletons reference, carrying the idss-specific prose the current hand-maintained prompts hold. 3. `onboard.sh render-prompts .sandcastle` and diff the rendered output against the current prompts — the diff IS the review; no behavioural drift beyond the derived hand-off section without a named reason. 4. `tests/judgement-call-prompts-test.sh` green is the door-stays-shut proof. **Routing: `ready-for-session`, not `ready-for-agent`** — every file here is under `.sandcastle/` (protected path; workers must not edit the machinery that runs them), and the rendered prompts are live text handed to every future worker.

Ruled by agent under ADR 0174 — veto anytime

Three rulings this ticket needed, all two-way doors (each is one line in a committed file, revertible by a later commit, and provable by tests/judgement-call-prompts-test.sh + tests/policy-lib-test.sh).

1. The ticket's premise about the label set is wrong, and the defaults are right. The ticket says "note the defaults' agent-blocked/needs-info are NOT this repo's labels". They are:

  • both are minted here — agent-blocked id 48, needs-info id 35 (GET $FORGEJO_API/labels);
  • both are in docs/agents/triage-labels.md's canonical table;
  • the harness itself drives them: session-runner.sh escalates two unadvanced attempts to agent-blocked, landing-lib.sh parks a red PR there, close-report.sh names it after two refused closes, and run-triage.sh's /triage prompt names needs-info for a reporter-supplies-info block.

So HUMAN_LABELS="ready-for-human:one-way-door agent-blocked:cannot-proceed needs-info:missing-context" — declared explicitly rather than inherited, which is the point of the file.

2. ready-for-session is deliberately NOT in HUMAN_LABELS, despite the ticket asking for it. HUMAN_LABELS is the human loop-in state machine, and the trigger vocabulary is fixed and closed (one-way-door, cannot-proceed, missing-context, product-decision — policy-lib.sh fails loud on anything else). ready-for-session is not a hand-off to a human at all, and there is no key in that vocabulary that separates it from agent-blocked: giving it cannot-proceed would render two bullets with byte-identical guidance under an instruction that says "add the ONE hand-off label below whose trigger matches why you stopped" — ambiguity manufactured in the exact place the pipeline exists to remove it. Widening the vocabulary means editing policy-lib.sh, a vendored factory file, which is a fork, not an adoption.

Its routing is already precise where it lives: rule 9 of prompt-enrichments/rules.md tells a worker to FILE a ready-for-session issue for a machinery change rather than park its own ticket there. Cost of being wrong: one line in swarm-policy.sh and a re-render.

3. TWO_WAY_DOOR_DOC=docs/adr/0174-two-way-door-rulings-default-to-the-agent.md is declared, not left empty. run-triage.sh splices this into its headless /triage prompt; with it empty the triage agent was being told "this repo declares no local record of it" while docs/adr/0174-*.md sat right there. The test's check (d) proves the declared path resolves in this repo.

## Ruled by agent under ADR 0174 — veto anytime Three rulings this ticket needed, all two-way doors (each is one line in a committed file, revertible by a later commit, and provable by `tests/judgement-call-prompts-test.sh` + `tests/policy-lib-test.sh`). **1. The ticket's premise about the label set is wrong, and the defaults are right.** The ticket says "note the defaults' `agent-blocked`/`needs-info` are NOT this repo's labels". They are: - both are minted here — `agent-blocked` id 48, `needs-info` id 35 (`GET $FORGEJO_API/labels`); - both are in `docs/agents/triage-labels.md`'s canonical table; - the harness itself drives them: `session-runner.sh` escalates two unadvanced attempts to `agent-blocked`, `landing-lib.sh` parks a red PR there, `close-report.sh` names it after two refused closes, and `run-triage.sh`'s `/triage` prompt names `needs-info` for a reporter-supplies-info block. So `HUMAN_LABELS="ready-for-human:one-way-door agent-blocked:cannot-proceed needs-info:missing-context"` — declared explicitly rather than inherited, which is the point of the file. **2. `ready-for-session` is deliberately NOT in `HUMAN_LABELS`,** despite the ticket asking for it. `HUMAN_LABELS` is the *human* loop-in state machine, and the trigger vocabulary is fixed and closed (`one-way-door`, `cannot-proceed`, `missing-context`, `product-decision` — `policy-lib.sh` fails loud on anything else). `ready-for-session` is not a hand-off to a human at all, and there is no key in that vocabulary that separates it from `agent-blocked`: giving it `cannot-proceed` would render two bullets with byte-identical guidance under an instruction that says "add the ONE hand-off label below whose trigger matches why you stopped" — ambiguity manufactured in the exact place the pipeline exists to remove it. Widening the vocabulary means editing `policy-lib.sh`, a vendored factory file, which is a fork, not an adoption. Its routing is already precise where it lives: rule 9 of `prompt-enrichments/rules.md` tells a worker to FILE a `ready-for-session` issue for a machinery change rather than park its own ticket there. Cost of being wrong: one line in `swarm-policy.sh` and a re-render. **3. `TWO_WAY_DOOR_DOC=docs/adr/0174-two-way-door-rulings-default-to-the-agent.md`** is declared, not left empty. `run-triage.sh` splices this into its headless `/triage` prompt; with it empty the triage agent was being told "this repo declares no local record of it" while `docs/adr/0174-*.md` sat right there. The test's check (d) proves the declared path resolves in this repo.

Close report — #857 done

Commit 67b7a5ece9bebd1fe87a8974c4b259628e180da1, reachable from origin/main.

What landed

Path
.sandcastle/swarm-policy.sh new — this repo's POLICY layer
.sandcastle/prompt-enrichments/*.md new — the ten {{ENRICH:<slot>}} files
.sandcastle/prompt.md, session-runner-prompt.md, rehearsal-heal-prompt.md, rehearsal-report-prompt.md re-rendered
.sandcastle/heal-prompt.md rendered, byte-unchanged
STATUS.md new lead (new artifact class)

Policy declared: LANDING=push, MERGE_AUTHORITY=human, SESSION_RUNNER=on, PROTECTED_PATHS=".sandcastle .forgejo", HUMAN_LABELS="ready-for-human:one-way-door agent-blocked:cannot-proceed needs-info:missing-context", TWO_WAY_DOOR_DOC=docs/adr/0174-two-way-door-rulings-default-to-the-agent.md. Reasoning for each is in the ruling comment above.

The render, and the diff that IS the review

bash onboarding/onboard.sh render-prompts .sandcastle (run from a Matou/dev-factory checkout at this repo's exact pin 29c2c946 — onboard.sh is factory-only and not vendored; check-harness-drift.sh calls the same prompt_render_one):

render-prompts: heal-prompt.md unchanged
render-prompts: prompt.md updated
render-prompts: rehearsal-heal-prompt.md updated
render-prompts: rehearsal-report-prompt.md updated
render-prompts: session-runner-prompt.md updated

Three behavioural deltas, each with its reason:

  1. prompt.md "When you are blocked" is now GENERATED from HUMAN_LABELS. The hand-maintained prose hardcoded THIS repo's numeric label ids (ready-for-agent=36, agent-blocked=48) — wrong in every repo that copied the file, and precisely what the test bans. The derived text resolves every id by NAME at run time and lists a third destination the hand-maintained text never offered: needs-info, with its trigger and its one sentence of guidance. The old parenthetical ("a two-way-door call should already have been ruled under rule 6, not parked here") survives as the derived block's own line.
  2. rehearsal-report-prompt.md / rehearsal-heal-prompt.md take the pinned skeletons' restructure. The evidence ANCHOR now names only records the harness itself reads (artifacts/legs.json, artifacts/verdict.json); artifacts/journey.json — which no harness script has ever read or written — moves into this repo's own rehearsal-drive-intro.md, where per-repo evidence belongs (factory #56). The live box is described by role rather than as a droplet, and the reporter no longer asserts "once #414 lands" as a fact in the skeleton (factory #51).
  3. session-runner-prompt.md drops the literal (#538) and generalises the SSH-door clause — a skeleton may not name a tracker number.

Nothing else moved: heal-prompt.md rendered byte-identical to the file it replaced, which is the cleanest possible evidence that the ten enrichments carry the hand-maintained prose faithfully.

Proof

Check Result
bash .sandcastle/tests/judgement-call-prompts-test.sh 35 checks passed (exit 0) — was RED on "the blocked path must route its human label by an explicit one-way-door trigger"
bash .sandcastle/tests/policy-lib-test.sh 50 checks passed
bash .sandcastle/tests/prompt-render-lib-test.sh 33 passed, 0 failed
policy_validate against the live tracker green — every HUMAN_LABELS name is minted here
all five rendered prompts vs onboarding/tests/fixtures/idss-prompts/ byte-identical — the factory's own reference render for Matou/idss at this pin
check-harness-drift.sh stale-render advisory silent (the rendered files match the pinned skeletons)
full .sandcastle/tests/*.sh suite (70 files) one regression, below; box-vocabulary-test.sh and rehearsal-droplet-test.sh red BEFORE this change too (verified by stashing)

One regression, filed not hidden

tests/run-swarm-stages-test.sh went green → red. It runs the real run-swarm.sh against the real .sandcastle/ and asserts the absent-policy log branch (policy: defaults (LANDING=push MERGE_AUTHORITY=human)); with a swarm-policy.sh present the gate correctly logs the other branch. That is a vendored factory test asserting a consumer-owned identity-layer fact — it reds in ANY consumer that completes onboarding step 4 — so the fix belongs upstream, not as a fork here: Matou/dev-factory#101. Not a CI gate in this repo (scripts/seam-smoke.sh runs check-harness-drift.sh only); idss picks the fix up at its next FACTORY_REF bump.

Also filed

#867 — pre-existing and unrelated to this ticket, found while running the suite: #865's sticky-account change edited vendored limit-lib.sh + tests/limit-lib-test.sh here without landing them in Matou/dev-factory, so check-harness-drift.sh is RED. Reproduced on 2bda2096 with this ticket's changes stashed. It also blocks the pin bump that would pick up dev-factory#101, so the two want doing together.

Two-way doors only

No one-way door was touched: no credential, no security-posture change, no member-facing accept, no data destroyed, no spend. Every file here is committed text, revertible by git revert 67b7a5ec.

## Close report — #857 done Commit **`67b7a5ece9bebd1fe87a8974c4b259628e180da1`**, reachable from `origin/main`. ### What landed | Path | | | --- | --- | | `.sandcastle/swarm-policy.sh` | new — this repo's POLICY layer | | `.sandcastle/prompt-enrichments/*.md` | new — the ten `{{ENRICH:<slot>}}` files | | `.sandcastle/prompt.md`, `session-runner-prompt.md`, `rehearsal-heal-prompt.md`, `rehearsal-report-prompt.md` | re-rendered | | `.sandcastle/heal-prompt.md` | rendered, byte-unchanged | | `STATUS.md` | new lead (new artifact class) | Policy declared: `LANDING=push`, `MERGE_AUTHORITY=human`, `SESSION_RUNNER=on`, `PROTECTED_PATHS=".sandcastle .forgejo"`, `HUMAN_LABELS="ready-for-human:one-way-door agent-blocked:cannot-proceed needs-info:missing-context"`, `TWO_WAY_DOOR_DOC=docs/adr/0174-two-way-door-rulings-default-to-the-agent.md`. Reasoning for each is in the ruling comment above. ### The render, and the diff that IS the review `bash onboarding/onboard.sh render-prompts .sandcastle` (run from a `Matou/dev-factory` checkout at this repo's exact pin `29c2c946` — `onboard.sh` is factory-only and not vendored; `check-harness-drift.sh` calls the same `prompt_render_one`): ``` render-prompts: heal-prompt.md unchanged render-prompts: prompt.md updated render-prompts: rehearsal-heal-prompt.md updated render-prompts: rehearsal-report-prompt.md updated render-prompts: session-runner-prompt.md updated ``` Three behavioural deltas, each with its reason: 1. **`prompt.md` "When you are blocked" is now GENERATED from `HUMAN_LABELS`.** The hand-maintained prose hardcoded THIS repo's numeric label ids (`ready-for-agent=36`, `agent-blocked=48`) — wrong in every repo that copied the file, and precisely what the test bans. The derived text resolves every id by NAME at run time and lists a third destination the hand-maintained text never offered: `needs-info`, with its trigger and its one sentence of guidance. The old parenthetical ("a two-way-door call should already have been ruled under rule 6, not parked here") survives as the derived block's own line. 2. **`rehearsal-report-prompt.md` / `rehearsal-heal-prompt.md` take the pinned skeletons' restructure.** The evidence ANCHOR now names only records the harness itself reads (`artifacts/legs.json`, `artifacts/verdict.json`); `artifacts/journey.json` — which no harness script has ever read or written — moves into this repo's own `rehearsal-drive-intro.md`, where per-repo evidence belongs (factory #56). The live box is described by role rather than as a droplet, and the reporter no longer asserts "once #414 lands" as a fact in the skeleton (factory #51). 3. **`session-runner-prompt.md`** drops the literal `(#538)` and generalises the SSH-door clause — a skeleton may not name a tracker number. Nothing else moved: `heal-prompt.md` rendered byte-identical to the file it replaced, which is the cleanest possible evidence that the ten enrichments carry the hand-maintained prose faithfully. ### Proof | Check | Result | | --- | --- | | `bash .sandcastle/tests/judgement-call-prompts-test.sh` | **35 checks passed** (exit 0) — was RED on "the blocked path must route its human label by an explicit one-way-door trigger" | | `bash .sandcastle/tests/policy-lib-test.sh` | 50 checks passed | | `bash .sandcastle/tests/prompt-render-lib-test.sh` | 33 passed, 0 failed | | `policy_validate` against the live tracker | green — every `HUMAN_LABELS` name is minted here | | all five rendered prompts vs `onboarding/tests/fixtures/idss-prompts/` | **byte-identical** — the factory's own reference render for `Matou/idss` at this pin | | `check-harness-drift.sh` stale-render advisory | silent (the rendered files match the pinned skeletons) | | full `.sandcastle/tests/*.sh` suite (70 files) | one regression, below; `box-vocabulary-test.sh` and `rehearsal-droplet-test.sh` red BEFORE this change too (verified by stashing) | ### One regression, filed not hidden `tests/run-swarm-stages-test.sh` went green → red. It runs the real `run-swarm.sh` against the real `.sandcastle/` and asserts the **absent-policy** log branch (`policy: defaults (LANDING=push MERGE_AUTHORITY=human)`); with a `swarm-policy.sh` present the gate correctly logs the other branch. That is a vendored factory test asserting a consumer-owned identity-layer fact — it reds in ANY consumer that completes onboarding step 4 — so the fix belongs upstream, not as a fork here: **`Matou/dev-factory#101`**. Not a CI gate in this repo (`scripts/seam-smoke.sh` runs `check-harness-drift.sh` only); idss picks the fix up at its next `FACTORY_REF` bump. ### Also filed **#867** — pre-existing and unrelated to this ticket, found while running the suite: #865's sticky-account change edited vendored `limit-lib.sh` + `tests/limit-lib-test.sh` here without landing them in `Matou/dev-factory`, so `check-harness-drift.sh` is RED. Reproduced on `2bda2096` with this ticket's changes stashed. It also blocks the pin bump that would pick up `dev-factory#101`, so the two want doing together. ### Two-way doors only No one-way door was touched: no credential, no security-posture change, no member-facing accept, no data destroyed, no spend. Every file here is committed text, revertible by `git revert 67b7a5ec`.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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/idss#857
No description provided.