harness: the pre-push gate has no docs tier, so a bare %% in a .mermaid source only reds in CI (GOTCHAS #143, 2nd time) #2068

Closed
opened 2026-10-23 18:42:52 +00:00 by matou-build-agent · 4 comments

Filed by the swarm healer from a ci red on PR #2067 (run 52773, signature
93e101f240ab).

Symptom

A docs-only push lands on a branch, then ci reds at stage
Docs: every mermaid diagram block parses (#343):

✖ mermaid-parse check FAILED — 1 of 75 block(s) will not parse:
  docs/slices/report-and-request.mermaid  (block #1, opens at line 1)
      Parse error on line 1:
      %%flowchart TD
      ^
      Expecting 'NEWLINE', 'SPACE', 'GRAPH', got 'NODE_STRING'

This is GOTCHAS #143 (bare %% glues onto the header) happening a second time
— first in docs/ux/flows/p6-members-idip.mermaid (#1071, signature
933612b60e72), now in a slice DAG. The hazard is written down, the checker
names the cause in its own hint, and the repo still has no door that stops it
before CI.

Root cause (the harness half)

gate_langs_for_files in .sandcastle/gate-lib.sh:28 maps paths to go and
ts only. A change that touches just docs/** (*.mermaid, *.md) yields no
language token, so gate_run prints gate: no gated language touched — nothing to check and the pre-push hook passes. Every docs-class contract the
seam enforces (mermaid parse #343, slice-map YAML #834, and the other Docs:
stages in scripts/seam-smoke.sh) is therefore CI-only: an agent that writes a
diagram discovers the break one full run later, on a branch a human has to
re-open.

What to build

A third docs tier in the push gate: when the pushed diff touches
docs/architecture/**, docs/slices/** or docs/ux/flows/**, run the cheap
in-repo checkers (node scripts/check-mermaid.mjs, node scripts/check-slices-yaml.mjs) against the repo, mirroring how go_tier=gofmt
gives the host path a cheap Go door (#1458).

Read GOTCHAS #400 before shipping it. Gate 3b's gofmt scan refused every
Go push from a swarm workdir for days because its input set was wrong; a docs
gate has the same shape of tail risk and a specific trigger for it:
check-mermaid.mjs resolves happy-dom out of app/node_modules
(scripts/check-mermaid.mjs:44), and .sandcastle/Dockerfile runs no pnpm install. In a sandbox without an installed app tree the checker exits 2
(crash, not a parse failure), which would red every docs push. So the stage
must either run inside the shell that guarantees the dep, or detect a missing
happy-dom and fail loudly as a harness fault with that name in the message
— never silently skip, and never report a crash as a broken diagram.

Acceptance criteria

  • A push whose diff touches only docs/slices/*.mermaid runs the mermaid
    checker and is REFUSED when a block will not parse.
  • The bare-%% source from this incident is the test fixture: the gate rejects
    it, and accepts the same file with line 5 given content.
  • A push touching no docs/go/ts path still prints nothing to check and passes.
  • Driven offline by .sandcastle/tests/gate-lib-test.sh (the existing seam for
    gate_langs_for_files / gate_run), with a case proving a missing
    happy-dom is reported as a harness fault, not as a parse failure.
  • docs/GOTCHAS.md #143's Rule gains the pointer that the push gate now
    catches this.

The content fault that triggered the run is NOT part of this ticket — it is one
line on PR #2067's branch and is called out there.

<!-- origin: app-report #2047 --> Filed by the swarm healer from a `ci` red on PR #2067 (run 52773, signature `93e101f240ab`). ## Symptom A docs-only push lands on a branch, then `ci` reds at stage `Docs: every mermaid diagram block parses (#343)`: ``` ✖ mermaid-parse check FAILED — 1 of 75 block(s) will not parse: docs/slices/report-and-request.mermaid (block #1, opens at line 1) Parse error on line 1: %%flowchart TD ^ Expecting 'NEWLINE', 'SPACE', 'GRAPH', got 'NODE_STRING' ``` This is GOTCHAS #143 (bare `%%` glues onto the header) happening a second time — first in `docs/ux/flows/p6-members-idip.mermaid` (#1071, signature `933612b60e72`), now in a slice DAG. The hazard is written down, the checker names the cause in its own hint, and the repo still has no door that stops it before CI. ## Root cause (the harness half) `gate_langs_for_files` in `.sandcastle/gate-lib.sh:28` maps paths to `go` and `ts` only. A change that touches just `docs/**` (`*.mermaid`, `*.md`) yields no language token, so `gate_run` prints `gate: no gated language touched — nothing to check` and the pre-push hook passes. Every docs-class contract the seam enforces (mermaid parse #343, slice-map YAML #834, and the other `Docs:` stages in `scripts/seam-smoke.sh`) is therefore CI-only: an agent that writes a diagram discovers the break one full run later, on a branch a human has to re-open. ## What to build A third `docs` tier in the push gate: when the pushed diff touches `docs/architecture/**`, `docs/slices/**` or `docs/ux/flows/**`, run the cheap in-repo checkers (`node scripts/check-mermaid.mjs`, `node scripts/check-slices-yaml.mjs`) against the repo, mirroring how `go_tier=gofmt` gives the host path a cheap Go door (#1458). **Read GOTCHAS #400 before shipping it.** Gate 3b's gofmt scan refused *every* Go push from a swarm workdir for days because its input set was wrong; a docs gate has the same shape of tail risk and a specific trigger for it: `check-mermaid.mjs` resolves `happy-dom` out of `app/node_modules` (`scripts/check-mermaid.mjs:44`), and `.sandcastle/Dockerfile` runs no `pnpm install`. In a sandbox without an installed app tree the checker exits **2** (crash, not a parse failure), which would red every docs push. So the stage must either run inside the shell that guarantees the dep, or detect a missing `happy-dom` and fail loudly as a *harness* fault with that name in the message — never silently skip, and never report a crash as a broken diagram. ## Acceptance criteria - A push whose diff touches only `docs/slices/*.mermaid` runs the mermaid checker and is REFUSED when a block will not parse. - The bare-`%%` source from this incident is the test fixture: the gate rejects it, and accepts the same file with line 5 given content. - A push touching no docs/go/ts path still prints `nothing to check` and passes. - Driven offline by `.sandcastle/tests/gate-lib-test.sh` (the existing seam for `gate_langs_for_files` / `gate_run`), with a case proving a missing `happy-dom` is reported as a harness fault, not as a parse failure. - `docs/GOTCHAS.md` #143's Rule gains the pointer that the push gate now catches this. The content fault that triggered the run is NOT part of this ticket — it is one line on PR #2067's branch and is called out there.
Author
Member

Routed to a session — ruled by agent under ADR 0174 (veto anytime)

This ticket's entire deliverable is a change to protected .sandcastle/
machinery
, so a Sandcastle swarm worker cannot land it.

What the ticket asks for, and where it must live:

  • A third docs tier in the push gate — a new path→token mapping in
    gate_langs_for_files and its dispatch in gate_run. Both live in
    .sandcastle/gate-lib.sh.
  • The offline proof — a new case (including the missing-happy-dom
    harness-fault case) in .sandcastle/tests/gate-lib-test.sh.

The push gate has no implementation surface outside .sandcastle/: the
checkers it would call (scripts/check-mermaid.mjs,
scripts/check-slices-yaml.mjs) already exist and are non-protected, but the
tier that decides when to run them on a docs-only diff is the gate dispatch
itself, which is pure machinery. The per-repo override hooks (go-gate.sh,
ts-gate.sh) also live under .sandcastle/. So every acceptance clause here
requires editing gate-lib.sh and/or gate-lib-test.sh.

The protected-paths boundary (#445, .sandcastle/protected-paths-lib.sh)
fingerprints .sandcastle/ before and after each worker run and rolls back
plus fails loud
on any introduced change. A swarm worker therefore cannot
implement this ticket at all.

Ruling (ADR 0174 — two-way door): relabel ready-for-agent →
ready-for-session. A protected .sandcastle/ change needs an interactive
session's standing (ADR 0174 / rule 9 of the worker contract). This is fully
revertible (a relabel) and provable (the deliverable is wholly inside protected
paths), so it is mine to rule; veto anytime by relabelling.

landing-pr and the <!-- origin: app-report #2047 --> marker are left
untouched — this stays a PR-landing ticket; a session works it and lands it by
pull request for a human merge.

No code change was made this iteration (none was possible without editing a
protected path). docs/GOTCHAS.md #143's Rule pointer is intentionally not
updated, because its acceptance ("the push gate now catches this") would be
false until the gate tier actually lands — the session that builds the tier
should land that pointer in the same change.

## Routed to a session — ruled by agent under ADR 0174 (veto anytime) This ticket's entire deliverable is a change to **protected `.sandcastle/` machinery**, so a Sandcastle swarm worker cannot land it. **What the ticket asks for, and where it must live:** - A third `docs` tier in the push gate — a new path→token mapping in `gate_langs_for_files` and its dispatch in `gate_run`. Both live in `.sandcastle/gate-lib.sh`. - The offline proof — a new case (including the missing-`happy-dom` harness-fault case) in `.sandcastle/tests/gate-lib-test.sh`. The push gate has **no implementation surface outside `.sandcastle/`**: the checkers it would call (`scripts/check-mermaid.mjs`, `scripts/check-slices-yaml.mjs`) already exist and are non-protected, but the tier that decides *when to run them on a docs-only diff* is the gate dispatch itself, which is pure machinery. The per-repo override hooks (`go-gate.sh`, `ts-gate.sh`) also live under `.sandcastle/`. So every acceptance clause here requires editing `gate-lib.sh` and/or `gate-lib-test.sh`. The protected-paths boundary (#445, `.sandcastle/protected-paths-lib.sh`) fingerprints `.sandcastle/` before and after each worker run and **rolls back plus fails loud** on any introduced change. A swarm worker therefore cannot implement this ticket at all. **Ruling (ADR 0174 — two-way door):** relabel `ready-for-agent` → `ready-for-session`. A protected `.sandcastle/` change needs an interactive session's standing (ADR 0174 / rule 9 of the worker contract). This is fully revertible (a relabel) and provable (the deliverable is wholly inside protected paths), so it is mine to rule; veto anytime by relabelling. `landing-pr` and the `<!-- origin: app-report #2047 -->` marker are left untouched — this stays a PR-landing ticket; a session works it and lands it by pull request for a human merge. No code change was made this iteration (none was possible without editing a protected path). `docs/GOTCHAS.md` #143's Rule pointer is intentionally **not** updated, because its acceptance ("the push gate now catches this") would be false until the gate tier actually lands — the session that builds the tier should land that pointer in the same change.
Author
Member

Close-report (pr-mode — PR open, a human merges) — Ruled by agent under ADR 0174, veto anytime.

Lands via PR #2109 (closes #2068, branch agent/issue-2068; the pre-push gate ran clean — no gated language touched).

What landed. A third docs tier in the vendored pre-push gate:

  • gate_langs_for_files emits docs for docs/architecture/**, docs/slices/**, docs/ux/flows/** — the trees whose mermaid (#343) / slice-map YAML (#834) contracts the seam enforces but which carry no go/ts token, so a docs-only change was invisible to the gate and its break was CI-only (this is GOTCHAS #143 a 2nd time, sig 93e101f240ab).
  • gate_docs_stage resolves GATE_DOCS_CMD → executable .sandcastle/docs-gate.sh → node (gate_docs_default_cmd) and FAILS CLOSED when none resolve — the Go/TS precedence, mirrored.
  • gate_docs_default_cmd runs the in-repo check-mermaid.mjs + check-slices-yaml.mjs and honours the checker's exit-code contract: exit 1 = a broken diagram (refuse); any other non-zero = a CRASH reported LOUDLY as a harness fault naming happy-dom (the GOTCHAS #400 shape: a sandbox with no pnpm install) — never as a parse failure, never silently skipped.
  • gate_run dispatches it on every push path (cheap, independent of go_tier).

Acceptance criteria — all met:

  • A push touching only docs/slices/*.mermaid runs the mermaid checker and is REFUSED on a parse failure ✓
  • The bare-%% incident source is the test fixture — rejected, then accepted with line 5 given content (real-checker test) ✓
  • A push touching no docs/go/ts path still prints nothing to check and passes ✓ (confirmed by this very push's gate output)
  • Offline-driven by .sandcastle/tests/gate-lib-test.sh, including the missing-happy-dom-is-a-harness-fault case ✓
  • GOTCHAS #143's Rule gains the push-gate pointer ✓

Vendoring (ADR 0180). The gate is factory-vendored, so it landed in Matou/dev-factory first: branch backport/idss-2068, SHA f36604c1b02d086a56b15da1316e1e568bced002 (off the pin 06f65763, #1684 still open). idss re-vendored at that SHA — FACTORY_REF 06f65763→f36604c, gate-lib.sh + tests/gate-lib-test.sh byte-identical to the backport, FACTORY_MANIFEST no churn, drift-gate OK inline.

Proof. bash .sandcastle/tests/gate-lib-test.sh → gate-lib: 56 checks passed (53→56; the 3 real-node checks — bare-%% reject/accept + happy-dom harness-fault — skip in the factory's bash-only env, run here). gate_docs_default_cmd over the live docs trees: 78/78 mermaid blocks parse, 17 slice YAMLs clean.

Commits. idss e74457e1; dev-factory f36604c1.

Owed (filed): #2108 — forward-port the docs tier onto dev-factory main (a reviewed PR; dev-factory is LANDING=pr), carrying the inherited <!-- origin: app-report #2047 --> marker + landing-pr.

Two-way door: fully revertible (git revert the idss commit + reset the backport branch); provable (the vendored red-before-green suite + the real-checker fixture). Leaving #2068 open with its PR open per pr-mode — the human's merge closes it via closes #2068.

**Close-report (pr-mode — PR open, a human merges) — Ruled by agent under ADR 0174, veto anytime.** **Lands via PR #2109** (`closes #2068`, branch `agent/issue-2068`; the pre-push gate ran clean — `no gated language touched`). **What landed.** A third `docs` tier in the vendored pre-push gate: - `gate_langs_for_files` emits `docs` for `docs/architecture/**`, `docs/slices/**`, `docs/ux/flows/**` — the trees whose mermaid (#343) / slice-map YAML (#834) contracts the seam enforces but which carry no go/ts token, so a docs-only change was invisible to the gate and its break was CI-only (this is GOTCHAS #143 a 2nd time, sig `93e101f240ab`). - `gate_docs_stage` resolves `GATE_DOCS_CMD` → executable `.sandcastle/docs-gate.sh` → `node` (`gate_docs_default_cmd`) and FAILS CLOSED when none resolve — the Go/TS precedence, mirrored. - `gate_docs_default_cmd` runs the in-repo `check-mermaid.mjs` + `check-slices-yaml.mjs` and honours the checker's exit-code contract: exit 1 = a broken diagram (refuse); any other non-zero = a CRASH reported LOUDLY as a harness fault **naming happy-dom** (the GOTCHAS #400 shape: a sandbox with no `pnpm install`) — never as a parse failure, never silently skipped. - `gate_run` dispatches it on every push path (cheap, independent of `go_tier`). **Acceptance criteria — all met:** - A push touching only `docs/slices/*.mermaid` runs the mermaid checker and is REFUSED on a parse failure ✓ - The bare-`%%` incident source is the test fixture — rejected, then accepted with line 5 given content (real-checker test) ✓ - A push touching no docs/go/ts path still prints `nothing to check` and passes ✓ (confirmed by this very push's gate output) - Offline-driven by `.sandcastle/tests/gate-lib-test.sh`, including the missing-`happy-dom`-is-a-harness-fault case ✓ - GOTCHAS #143's Rule gains the push-gate pointer ✓ **Vendoring (ADR 0180).** The gate is factory-vendored, so it landed in `Matou/dev-factory` first: branch `backport/idss-2068`, SHA `f36604c1b02d086a56b15da1316e1e568bced002` (off the pin `06f65763`, #1684 still open). idss re-vendored at that SHA — `FACTORY_REF` `06f65763`→`f36604c`, `gate-lib.sh` + `tests/gate-lib-test.sh` byte-identical to the backport, `FACTORY_MANIFEST` no churn, drift-gate OK inline. **Proof.** `bash .sandcastle/tests/gate-lib-test.sh` → `gate-lib: 56 checks passed` (53→56; the 3 real-node checks — bare-`%%` reject/accept + happy-dom harness-fault — skip in the factory's bash-only env, run here). `gate_docs_default_cmd` over the live docs trees: 78/78 mermaid blocks parse, 17 slice YAMLs clean. **Commits.** idss `e74457e1`; dev-factory `f36604c1`. **Owed (filed):** #2108 — forward-port the docs tier onto dev-factory `main` (a reviewed PR; dev-factory is `LANDING=pr`), carrying the inherited `<!-- origin: app-report #2047 -->` marker + `landing-pr`. **Two-way door:** fully revertible (`git revert` the idss commit + reset the backport branch); provable (the vendored red-before-green suite + the real-checker fixture). Leaving #2068 open with its PR open per pr-mode — the human's merge closes it via `closes #2068`.
Author
Member

This was generated by AI during triage.

Triage Notes

State: ready-for-human (category bug kept, landing-pr + <!-- origin: app-report #2047 --> kept).

What's established: the docs-tier push gate this ticket asked for is built and proven (close-report above, idss commit e74457e1, dev-factory f36604c1) and lands via PR #2109 (closes #2068, branch agent/issue-2068). No agent work remains on the ticket itself. All acceptance criteria are met per the close-report.

Why human

This is a landing-pr ticket (inherited app-report policy, ADR 0267): it reaches main only by a human-approved merge of PR #2109, never a push. The issue stays OPEN until that merge closes it via closes #2068. The residue is: Ben reviews + merges idss PR #2109. That merge is the one-way door — no agent lands a landing-pr ticket on main.

(The forward-port of this tier onto dev-factory main is tracked separately as #2108.)

> *This was generated by AI during triage.* ## Triage Notes **State: `ready-for-human`** (category `bug` kept, `landing-pr` + `<!-- origin: app-report #2047 -->` kept). **What's established:** the docs-tier push gate this ticket asked for is **built and proven** (close-report above, idss commit `e74457e1`, dev-factory `f36604c1`) and lands via **PR [#2109](https://git.matou.nz/Matou/idss/pulls/2109)** (`closes #2068`, branch `agent/issue-2068`). No agent work remains on the ticket itself. All acceptance criteria are met per the close-report. ## Why human This is a `landing-pr` ticket (inherited app-report policy, ADR 0267): it reaches `main` only by a **human-approved merge of PR #2109**, never a push. The issue stays OPEN until that merge closes it via `closes #2068`. The residue is: **Ben reviews + merges idss PR #2109.** That merge is the one-way door — no agent lands a `landing-pr` ticket on `main`. (The forward-port of this tier onto dev-factory `main` is tracked separately as #2108.)
ben closed this issue 2026-11-17 12:55:36 +00:00
Owner

Landed on main in a7483d0e (FACTORY_REF → bbcf34e). Drift check OK; gate-lib, body-marker-lib and session-host-lib tests pass. The real docs gate refuses a bare %% in a slice DAG.

Landed on main in a7483d0e (FACTORY_REF → bbcf34e). Drift check OK; gate-lib, body-marker-lib and session-host-lib tests pass. The real docs gate refuses a bare `%%` in a slice DAG.
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#2068
No description provided.