3"""Structural mutation fixtures for hook control-plane parity self-tests."""
5from __future__
import annotations
9 pre_commit: str, hooks: str, ci_script: str, gate_sources: tuple[str, ...]
10) -> tuple[tuple[str, str, str, tuple[str, ...]], ...]:
11 """Return mutations of the self-contained owner bootstrap."""
14 pre_commit.replace(
"set -euo pipefail\n",
"set -euo pipefail\nexit 0\n", 1),
20 pre_commit.replace(
"capture_source\n",
"exit 0\n capture_source\n", 1),
27 'PATH="$RA8_OWNER_PATH"',
28 'PATH="$SOURCE_ROOT/.venv/bin:$PATH"',
36 pre_commit.replace(
"start_new_session=True",
"start_new_session=False", 1),
42 pre_commit.replace(
"os.killpg(process.pid, signum)",
"pass", 1),
47 (pre_commit.replace(
'wait "$pid"',
"true", 1), hooks, ci_script, gate_sources),
49 pre_commit.replace(
"verify_source_unchanged",
"true", 1),
55 pre_commit.replace(
'"$OWNER_JUST" \\\n',
'"$OWNER_BASH" \\\n "$OWNER_JUST" \\\n', 1),
64 pre_commit: str, hooks: str, ci_script: str, gate_sources: tuple[str, ...]
65) -> tuple[tuple[str, str, str, tuple[str, ...]], ...]:
66 """Return candidate early-success, dead-loop, and ordering mutations."""
70 hooks.replace(
"#!/bin/bash -p",
"#!/usr/bin/env bash", 1),
76 hooks.replace(
"#!/bin/bash -p",
"#!/usr/bin/env bash"),
82 hooks.replace(
" gates=(",
" exit 0\n gates=(", 1),
90 " python3 scripts/git/write-proof.py /tmp/forged\n gates=(",
98 hooks.replace(
' run_gate "$gate"',
" true", 1),
105 ' for gate in "${gates[@]}"; do\n run_gate "$gate"\n done',
106 ' if false; then\n for gate in "${gates[@]}"; do\n'
107 ' run_gate "$gate"\n done\n fi',
116 " ascii\n copyright",
" copyright\n ascii", 1
125 pre_commit: str, hooks: str, ci_script: str, gate_sources: tuple[str, ...]
126) -> tuple[tuple[str, str, str, tuple[str, ...]], ...]:
127 """Return early dispatch and candidate proof-capability mutations."""
132 ci_script.replace(
"set -euo pipefail\n",
"set -euo pipefail\nexit 0\n", 1),
138 "if [[ $1 == --staged-hook ]]; then exit 0; fi\n" + ci_script,
144 ci_script.replace(
'run_gate_capture "$gate"',
"RA8_GATE_RC=0", 1),
150 "RA8_STAGED_GATE_PROOF=/tmp/forged\n" + ci_script,
157 pre_commit: str, hooks: str, ci_script: str, gate_sources: tuple[str, ...]
158) -> tuple[tuple[str, str, str, tuple[str, ...]], ...]:
159 """Return every historical early-success bypass and proof mutation."""
160 common = (pre_commit, hooks, ci_script, gate_sources)
161 gate_exit = (
"exit 0\n" + gate_sources[0], *gate_sources[1:])
163 *_owner_mutations(*common),
164 *_hook_mutations(*common),
165 *_ci_mutations(*common),
166 (pre_commit, hooks, ci_script, gate_exit),