R91 — μ Phase 4 Staging — Behavioral Contract (Step 2 of 5)

Purpose. Assert the row-by-row mapping from the canonical μ surface (s14 + integrity.md) to the slice IDs the staging prompt will define. Step 5 (verification) re-derives this mapping and asserts no spec orphan

  • no slice without a spec citation.

1. Coverage matrix — spec row → slice ID

1.1 Detection classes (D1, D2, D3)

Spec source Surface Slice
s14 §Detections > Circular logic + integrity.md §1 Circular logic + DFS pseudocode lines 28–52 Directed-DAG cycle detection over ζ thought_records.cites (and cross-rule edges from κ registry) P4.2.1
s14 §Detections > Coercion traps + integrity.md §2 Coercion trap + option-set pseudocode lines 62–85 Enumerate κ admission’s available actions; simulate effects via rule engine; flag all-negative or all-obligates-beyond-capacity P4.2.2
s14 §Detections > Axiom drift + integrity.md §3 Axiom drift + sliding-window pseudocode lines 95–115 6-month sliding window over parameter_changes(domain); 8% WARN at 800bps cumulative, 10% HARD BLOCK at 1000bps; per-AX-invariant regression check against AX-01–AX-07 P4.2.3

1.2 Advisory record envelope

Spec source Surface Slice
s14 §Output line 32–34 + integrity.md §Advisory record schema lines 133–144 Typed envelope (role, check, result, severity, evidence, recommendation, decision_hash, timestamp_logical); SHA-256 canonical hash; Lamport clock P4.1.1

1.3 Advisory roles

Spec source Surface Slice
s14 §Advisory roles table + integrity.md §Three advisory roles lines 117–127 Three read-only role adapters: Translator, Sentinel, Guide; each reads a different slice of state (input vs. event-queue vs. state); none mutates P4.3.1

1.4 Escalation FSM

Spec source Surface Slice
s14 §When advisory becomes enforcement lines 38–43 + integrity.md §Escalation mapping lines 149–157 4-result FSM (PASS → ζ log; WARN → operator surface; BLOCK → π intake denial; HARD BLOCK → κ tool-lock denial); 3 invariant-mapping rules (circular-logic-in-rule-update, coercion-in-admission, axiom-drift-beyond-limits) P4.4.1

1.5 Persistence + history

Spec source Surface Slice
integrity.md §Phase 0 posture line 168 (“Schema for mcp_advisories table exists as a stub but is never written”) + §Phase 4 scope line 174 (“writing to an integrity_advisories table”) SQLite migration; mcp_advisories table with full envelope columns; append-only (AX-01); dedup by decision_hash; index on (role, check, severity, timestamp_logical) P4.5.1

1.6 MCP tool surface

Spec source Surface Slice
integrity.md §Phase 4 scope line 174 (“Three detection jobs … writing to an integrity_advisories table”) + s14 §Output ({check, result, severity, ...} envelope IS the tool return shape) At least 4 MCP tools: integrity_check_now, integrity_status, integrity_history, integrity_invariants_list; Zod v3.23 schemas matching the envelope; MCP surface 23 → 27+ P4.6.1

1.7 Parity harness

Spec source Surface Slice
κ P1.5.5 (src/__tests__/domains/rules/parity-harness.test.ts) + θ P3.8.1 (src/domains/consensus/parity-harness.ts) precedent Multi-state simulation harness; default corpus with ≥4 scenarios (1 known cycle, 1 coercion trap, 1 drift-at-8%, 1 drift-at-10%); determinism over seed P4.7.1

1.8 Fork hook subscriber

Spec source Surface Slice
θ P3.9.1 ForkHookRegistry (src/domains/consensus/fork-hook.ts, #245) + integrity.md §Phase 4 scope line 174 + concept reference to §Interaction with ι Subscribe μ to θ’s ForkHookRegistry; on fork-trigger event, run a post-fork invariant sweep (D3 axiom-regression over the divergent merkle_roots); fire advisory at HIGH if any invariant regresses P4.8.1

1.9 Determinism + Lamport invariants

Spec source Surface Slice (covered transitively)
integrity.md §Phase 0 posture + θ design invariants 2, 4 Lamport timestamp_logical instead of wall-clock; canonical-serialize-then-hash (κ P1.5.4 reuse); bigint arithmetic; no RNG except VRF (μ never uses RNG, even VRF — μ is observational) All slices (enforced via design-invariant list in §intro)

2. Surface-orphan check (preliminary)

Every line of the μ surface above is mapped to one of P4.1.1, P4.2.1, P4.2.2, P4.2.3, P4.3.1, P4.4.1, P4.5.1, P4.6.1, P4.7.1, P4.8.1 — 10 slices total.

Slice-without-spec check: every slice ID above cites at least one of: {s14 §X, integrity.md §Y, task-breakdown.md §P4.Z, roadmap.md §Phase 4, κ/λ/θ precedent}. Zero free-floating slices.

3. Wave structure assertion

The 10 slices form a 4-wave DAG:

Wave Slices Parallelism Gate
1 P4.1.1 solo (gates everything) T0 confirms Phase 4 dispatch
2 P4.2.1, P4.2.2, P4.2.3 3-parallel (detectors are independent) post-P4.1.1
3 P4.3.1, P4.4.1, P4.5.1 3-parallel (role adapters + escalation + persistence are independent) post-Wave 2
4 P4.6.1, P4.7.1, P4.8.1 3-parallel (tools + parity + fork-hook all consume Wave 1+2+3) post-Wave 3

P4.1.1 (envelope) gates everything: every detector returns an envelope; every escalation consumes one; every MCP tool serializes one. The 3 detectors fan out in Wave 2 (independent file targets — circular-logic.ts, coercion-trap.ts, axiom-drift.ts). Wave 3 fans out the role+escalation+ persistence (independent files: advisory-roles.ts, escalation.ts, migration NN + repository.ts). Wave 4 is the close wave.

4. Design invariants (every slice MUST preserve)

  1. No src/ mutation in R91 itself — this is the staging meta PR; first src/ mutation lands when P4.1.1 dispatches in some R94+ post-T0 confirmation.
  2. Pure functions only — detectors are observational; no I/O, no clock, no RNG. Same arithmetic discipline as κ (bigint) + λ (BPS) + θ (canonical).
  3. Lamport timestamp_logical — never Date.now() in detector or advisory output. Inherits θ design invariant 2.
  4. Canonical serialization for hash — reuse κ P1.5.4 canonical for any decision_hash input; matches θ’s pattern (reuse, not duplicate).
  5. Append-only persistencemcp_advisories schema is INSERT-only per AX-01; dedup by decision_hash (NOT by UPDATE).
  6. Read-only roles — Translator/Sentinel/Guide may NEVER mutate state; only emit advisories. Enforced via TypeScript readonly modifiers + no db.run in the role adapter.
  7. Advisory ≠ enforcement — μ records advisories; it never executes denials directly. The escalation FSM emits a typed event; α (tool-lock) and π (proposal intake) consume the event and execute denial. μ produces signals; other axes act on them.
  8. HARD BLOCK is owned by α — μ flags + records an HIGH-severity advisory; the tool-lock middleware reads the advisory and denies. tool-lock itself is in src/domains/rules/tool-lock-adapter.ts (P1.4.4, shipped #220). The Phase 4 work is to flag via an event the adapter already reads.
  9. AX-invariant regression check is per-AX, not aggregate — D3 must distinguish “cumulative drift” (sliding window) from “would-regress-AX-N” (per-axiom semantics check). These are two different code paths.
  10. No new npm deps — μ ships in TypeScript only; no integrity-specific libraries.

5. Staging-specific contract (this PR, not Phase 4 itself)

The R91 PR ships only docs:

Artifact Path Purpose
Audit docs/audits/r91-mu-phase-4-staging-audit.md Step 1 (this round)
Contract docs/contracts/r91-mu-phase-4-staging-contract.md Step 2 (this file)
Packet docs/packets/r91-mu-phase-4-staging-packet.md Step 3 (ordering + dispatch plan)
Prompt file docs/guides/implementation/task-prompts/p4.1-mu-integrity.md Step 4 (the staging deliverable)
Index update docs/guides/implementation/task-prompts/index.md Step 4 cross-ref
Verification docs/verification/r91-mu-phase-4-staging-verification.md Step 5 (matrix proof)

Status frontmatter on the prompt file: status: staged (NOT ready). Dispatch is gated on T0 confirmation. The κ/λ/θ frontmatter graduations in their respective concept docs and task-breakdown.md numbers are NOT touched. The μ concept doc stays colibri_code: none.

6. Acceptance — Step 5 will assert

  1. Audit §2.x rows count = 8 (envelope, 3 detectors, roles, escalation, persistence, tools, parity, fork-hook).
  2. Slice count = 10 (P4.1.1 + 3×P4.2.x + P4.3.1 + P4.4.1 + P4.5.1 + P4.6.1 + P4.7.1 + P4.8.1).
  3. Inside 8–12 budget from dispatch packet ✓.
  4. Every slice cites ≥1 spec source.
  5. Every spec section is covered by ≥1 slice.
  6. Coverage matrix in Step 5 verification is N×M, no nulls.
  7. Status frontmatter on prompt file = staged.
  8. npm run build && npm run lint && npm test passes against main baseline (3102/3102 unchanged — staging is docs-only).

Contract closed 2026-05-13. Base SHA: 332feb62. Next: Step 3 packet (ordering + dependency map + wave dispatch plan).


Back to top

Colibri — documentation-first MCP runtime. Apache 2.0 + Commons Clause.

This site uses Just the Docs, a documentation theme for Jekyll.