Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: align the T0/T1/T2 orchestrator with the documented contract
Alfredo Lopeze908e035a8f4
diff --git a/.agents/skills/minikube-t0-t1-t2/SKILL.md b/.agents/skills/minikube-t0-t1-t2/SKILL.mdnew file mode 100644index 000000000..03f6a3b6c--- /dev/null+++ b/.agents/skills/minikube-t0-t1-t2/SKILL.md@@ -0,0 +1,12 @@+---+name: minikube-t0-t1-t2+description: Certifies local Minikube T0/T1/T2 lanes for the Evenfire repository. Use when the user asks to run, close, or certify T0, T1, T2, "cierra T2", minikube-t2, certification, preflight, pre-gate-sync, or Real PostgreSQL suites.+---++# Minikube T0/T1/T2 certification (pointer)++The canonical copy of this skill lives at+`.cursor/skills/minikube-t0-t1-t2/SKILL.md` (workflow, checklist, decision+tree) with `.cursor/skills/minikube-t0-t1-t2/reference.md` (anti-patterns,+failure codes, recovery). Read and follow those files; do not duplicate their+content here.diff --git a/.cursor/rules/minikube-t0-t1-t2.mdc b/.cursor/rules/minikube-t0-t1-t2.mdcnew file mode 100644index 000000000..438ec5379--- /dev/null+++ b/.cursor/rules/minikube-t0-t1-t2.mdc@@ -0,0 +1,50 @@+---+description: Local Minikube T0/T1/T2 certification contract — entry points, what counts as a T2 verdict, profile ownership, and evidence rules+alwaysApply: true+---++# Local Minikube T0/T1/T2 contract++Development-only. Requires a clean branch descended from `origin/dev`, the+branch-owned `MINIKUBE_PROFILE`, and an explicit Kubernetes context. Never a+production/GKE/Cloudflare/staging runbook. `evenfire-infra` is a different+repository — never mix its PRs or clusters into this lane.++## Entry points (only these)++- `make minikube-t2-preflight` — read-only planner. NOT T0/T1/T2. Default+ `T2_PLAN_MODE=false` fails loud (`BOOTSTRAP_REQUIRED`) on an unbootstrapped+ profile and never calls `pre-gate-sync`.+- `make minikube-t2` — full orchestrator: T0, planner (`T2_PLAN_MODE=true` so+ `full-bootstrap` is reachable), bootstrap/reconcile, T1, then the T2 verdict.+- `make minikube-t2-runtime` — closes T2 only (`T2_RUN_T0=false T2_RUN_T1=false`)+ when T0 and T1 are already green on the same HEAD and the pre-gate marker is+ `already-synced`. Never use those flags to skip an uncertified lane.++## What T2 is / is not++- A T2 verdict is ONLY the final exact-head preflight inside `make minikube-t2`+ or `make minikube-t2-runtime`: it runs with `T2_PLAN_MODE=false` and the plan+ state must be `already-synced`, ending in `MINIKUBE_T2_PASS` with+ `T0=`/`T1=`/`T2=` statuses.+- `T2_PREFLIGHT_PASS` from the standalone planner is NOT T2.+- `make minikube-pre-gate-sync` is NOT T2.+- Product E2E scripts (e.g. `scripts/e2e/e2e-hcc-rollout-readiness.sh`), CI,+ unit suites, and Playwright are separate lanes; none stands in for T2.+- Health/Playwright are opt-in via `T2_HEALTHCHECK_COMMAND` /+ `T2_PLAYWRIGHT_COMMAND` (`T2_REQUIRE_PLAYWRIGHT=true` refuses `NOT_RUN`).++## Profile and evidence++- Reuse the owned `MINIKUBE_PROFILE`; do not create a new profile because HEAD+ changed. Never touch another worktree's profile or its port-forwards.+- Every `kubectl` uses `--context=<owned profile>`; never switch the global+ current-context.+- Bootstrap/reconcile must build the worktree: `IMAGE_SOURCE=local`.+- T1 is fail-loud: unavailable DSN or zero executed tests is FAIL, never green.+ Role-reset suites use the throwaway `postgres:16-alpine`, never shared+ `control-postgres`.+- Evidence lives under ignored `.local-notes/infra/runs/`; never commit it.++Full workflow: skill `.cursor/skills/minikube-t0-t1-t2/SKILL.md`.+Deep contract: `docs/testing/minikube-t2-runbook.md`.diff --git a/.cursor/rules/minikube-t2-harness.mdc b/.cursor/rules/minikube-t2-harness.mdcnew file mode 100644index 000000000..9fa8f1721--- /dev/null+++ b/.cursor/rules/minikube-t2-harness.mdc@@ -0,0 +1,45 @@+---+description: Keep the Minikube T2 harness, its contract tests, docs, rule, and skill in sync when editing harness code+globs:+ - scripts/minikube/t2*.sh+ - scripts/minikube/pf-all-stack.sh+ - scripts/minikube/pre-gate-sync.sh+ - scripts/e2e/minikube-real-postgres.sh+ - scripts/tests/test-minikube-t2-*.sh+ - Makefile+alwaysApply: false+---++# T2 harness change discipline++When editing the T0/T1/T2 harness (these globs), the contract is duplicated in+docs and guidance. A behavior change here MUST update, in the same change:++- `scripts/tests/test-minikube-t2-contract.sh` and+ `scripts/tests/test-minikube-t2-scenarios.sh` (they assert harness behavior)+- `docs/testing/minikube-t2-runbook.md`+- `.cursor/rules/minikube-t0-t1-t2.mdc` and+ `.cursor/skills/minikube-t0-t1-t2/` (SKILL.md + reference.md)+- the T0/T1/T2 sections of `AGENTS.md` and `CLAUDE.md`++Invariants that must never regress:++- Final T2 verdict = `t2.sh run_final_preflight` with `T2_PLAN_MODE=false`+ and plan state `already-synced`; anything else is `HEAD_MARKER_MISMATCH`.+- Planner mode `T2_PLAN_MODE=true` exists only inside the orchestrator so+ `full-bootstrap` is reachable; standalone preflight stays fail-loud.+- T1 stays fail-loud (no green on unavailable DSN or zero tests); role-reset+ suites keep the throwaway Postgres 16.+- `t2.sh` keeps `IMAGE_SOURCE=local` for bootstrap/reconcile and calls+ `pre-gate-sync` with `--skip-port-forwards`.+- `t2_process_check` accepts only real `kubectl` (`comm=kubectl`) port-forward+ PIDs recorded in the profile cache or legacy `/tmp/pf-<profile>-*.pid`.+- Stable failure codes (`BOOTSTRAP_REQUIRED`, `HEAD_MARKER_MISMATCH`,+ `PORT_FORWARD_CONFLICT`, `PROFILE_BUSY`, ...) keep their meanings.++Run T0 locally before proposing harness changes:++```bash+bash scripts/tests/test-minikube-t2-contract.sh+bash scripts/tests/test-minikube-t2-scenarios.sh+```diff --git a/.cursor/skills/minikube-t0-t1-t2/SKILL.md b/.cursor/skills/minikube-t0-t1-t2/SKILL.mdnew file mode 100644index 000000000..dc667c6a4--- /dev/null+++ b/.cursor/skills/minikube-t0-t1-t2/SKILL.md@@ -0,0 +1,114 @@+---+name: minikube-t0-t1-t2+description: Certifies local Minikube T0/T1/T2 lanes for the Evenfire repository. Use when the user asks to run, close, or certify T0, T1, T2, "cierra T2", minikube-t2, certification, preflight, pre-gate-sync, Real PostgreSQL suites, or asks whether a run counts as a T2 verdict.+---++# Minikube T0/T1/T2 certification workflow++This is the ONLY supported way to certify the local runtime lanes. It is+development-only, runs against the branch-owned Minikube profile, and produces+a T2 verdict solely through the final exact-head preflight inside the+orchestrator (`T2_PLAN_MODE=false`, plan state `already-synced`).++Anti-patterns and failure codes: see `reference.md` in this skill directory.+Deep contract: `docs/testing/minikube-t2-runbook.md`.++## Step 0 — Preconditions checklist++Before running anything, verify ALL of these:++- [ ] Clean development branch descended from current `origin/dev`+ (`git status --porcelain` empty of unexpected changes; not a protected+ branch).+- [ ] Identify the branch-owned `MINIKUBE_PROFILE` for THIS worktree. Reuse it.+ Do NOT create a new profile because HEAD, gate, or command changed.+- [ ] Confirm the profile is not owned by another active branch/worktree. If+ ownership is ambiguous, stop and use a dedicated profile instead.+- [ ] Every `kubectl` you run manually uses `--context=<owned profile>`.+ Never change the global kubectl current-context.+- [ ] Never read `~/.cache/clerum/minikube-profiles/` directly (HARD DENY —+ it holds private profile state). The harness reads it for you.++## Step 1 — Plan (read-only)++```bash+make minikube-t2-preflight MINIKUBE_PROFILE=<owned-profile>+```++This is a planner, NOT a lane. `T2_PREFLIGHT_PASS` is NOT a T2 verdict.+It prints `transition=<state>`; use that in the decision tree below. On an+unbootstrapped profile it fails loud with `BOOTSTRAP_REQUIRED` — that is+expected, not an error to work around.++## Step 2 — Decision tree++```text+transition = already-synced AND T0+T1 already green on this exact HEAD?+ └── yes → make minikube-t2-runtime MINIKUBE_PROFILE=<owned-profile>+ (T2-only close; refused unless marker matches HEAD)+ └── no → make minikube-t2 MINIKUBE_PROFILE=<owned-profile>+ (full: T0 → bootstrap/reconcile/targeted-sync → T1 → T2 verdict)++transition = full-bootstrap (fresh/uninitialized profile)?+ └── make minikube-t2 runs the supported bootstrap itself+ (its internal planner uses T2_PLAN_MODE=true so full-bootstrap is+ reachable; IMAGE_SOURCE=local is enforced by the orchestrator).++transition = full-reconcile (deploy/* or charts/* changed)?+ └── make minikube-t2. Never downgrade an infra change to a+ service-only restart.++transition = targeted-sync (service-only diff)?+ └── make minikube-t2 performs the targeted deploy; record it as a+ targeted sync, never as a full reconcile.+```++Rules that override any shortcut idea:++- T0 and T1 green on the SAME HEAD is the only justification for+ `minikube-t2-runtime`. Do not re-run the full `make minikube-t2` just to+ "close T2" in that situation — use the runtime target.+- Never set `T2_RUN_T0=false` / `T2_RUN_T1=false` by hand to skip a lane that+ was not certified on this HEAD; the harness refuses it unless the plan is+ `already-synced`, and evidence must show the earlier green runs.++## Step 3 — T1 specifics (Real PostgreSQL)++T1 runs inside `make minikube-t2`, or explicitly via+`make minikube-t2-real-postgres MINIKUBE_PROFILE=<owned-profile>`.++- T1 is fail-loud: an unavailable DSN, an isolated server that did not start,+ or zero executed tests is FAIL. Never report green from skipped suites.+- Role-reset suites (cluster-global role drop/rewrite) run against a+ throwaway `postgres:16-alpine`, never the shared `control-postgres`.+- The admin DSN is resolved in-process from the cluster Secret; never print,+ export, or persist it.++## Step 4 — Verdict and evidence reporting++A run is T2 ONLY when the orchestrator prints:++```text+MINIKUBE_T2_PASS+T0=PASS|SKIPPED+T1=PASS|SKIPPED+T2=PASS+Playwright=PASS|NOT_RUN+evidence=<path under .local-notes/infra/runs/>+```++Report to the user exactly these lane statuses plus HEAD, profile, and the+evidence path. `SKIPPED` is legitimate only for T0/T1 previously green on the+same HEAD (say so explicitly). Optional user-facing checks are opt-in:+`T2_HEALTHCHECK_COMMAND`, `T2_PLAYWRIGHT_COMMAND`+(`T2_REQUIRE_PLAYWRIGHT=true` refuses a missing journey).++Evidence stays under the ignored `.local-notes/infra/runs/`. Never commit it.+Before committing anything else, run `make minikube-t2-public-boundary`.++## Step 5 — On failure++Failures print a stable code and a next safe command. Repair the FIRST+reported precondition and re-run the same entry point on the same HEAD.+Do not widen the command, switch clusters, reset PVCs, or delete locks with a+live owner. Code-by-code guidance is in `reference.md`.diff --git a/.cursor/skills/minikube-t0-t1-t2/reference.md b/.cursor/skills/minikube-t0-t1-t2/reference.mdnew file mode 100644index 000000000..c06c51e50--- /dev/null+++ b/.cursor/skills/minikube-t0-t1-t2/reference.md@@ -0,0 +1,64 @@+# Minikube T0/T1/T2 reference — anti-patterns, codes, recovery++Companion to `SKILL.md`. Source of truth: `scripts/minikube/t2.sh`,+`scripts/minikube/t2-preflight.sh`, `scripts/minikube/t2-common.sh`, and+`docs/testing/minikube-t2-runbook.md`.++## HARD DENY anti-patterns (these burned real sessions)++- **Do not treat `T2_PREFLIGHT_PASS` as T2.** The standalone planner is not a+ lane. Only `MINIKUBE_T2_PASS` from `make minikube-t2` /+ `make minikube-t2-runtime` is a T2 verdict.+- **Do not call `scripts/e2e/e2e-hcc-rollout-readiness.sh` "T2".** It is a+ product E2E lane (e.g. issue #391 readiness), a separate evidence lane.+- **Do not re-run full `make minikube-t2` to "close T2"** when T0 and T1 are+ already green on the same HEAD — use `make minikube-t2-runtime`.+- **Do not `ls`/`cat` `~/.cache/clerum/minikube-profiles/`.** Private profile+ state (ports, pids, markers). The harness is the only reader.+- **Do not invent `ADMIN_PASSWORD`** or any credential. When a product E2E+ needs it, load it from the primary checkout `.env`; never echo it.+- **Do not reset PVCs** outside the explicit `T2_RESET_PVC=true` ++ `T2_EXPECTED_PVC_UID=<exact uid>` development path, and **do not use shared+ fixed localhost ports** — only the profile-owned random port mapping.+- **Do not touch another worktree's Minikube profile** (e.g. an NP-08 lane+ profile) or kill its port-forwards, even if it looks idle.+- **Do not pack `kubectl` + `port-forward` + profile name into one wrapper+ argv** when avoidable. `t2_process_check` accepts only real `kubectl`+ processes (`comm=kubectl`) whose PIDs are recorded in the profile cache or+ legacy `/tmp/pf-<profile>-*.pid`; a lookalike wrapper trips+ `PORT_FORWARD_CONFLICT`.+- **Do not commit** `.local-notes/`, lockfiles produced by an incidental+ `npm ci`, generated ports/profile metadata, or anything secret-like. Run+ `make minikube-t2-public-boundary` first.+- **Do not weaken fail-loud T1**: no green on unavailable DSN, zero executed+ tests, or silently skipped suites; role-reset suites stay on the throwaway+ `postgres:16-alpine` (#412), never shared `control-postgres`.++## Stable failure codes++| Code | Meaning | Safe next step |+| --- | --- | --- |+| `BOOTSTRAP_REQUIRED` | Profile missing/uninitialized, or the planner produced no transition. Standalone preflight refuses to bootstrap. | Run `make minikube-t2` — its internal planner (`T2_PLAN_MODE=true`) makes `full-bootstrap` reachable and runs the supported setup with `IMAGE_SOURCE=local`. |+| `HEAD_MARKER_MISMATCH` | Pre-gate marker does not match this worktree/HEAD; the final T2 preflight selected something other than `already-synced`. | Re-run `make minikube-t2` on this HEAD so `pre-gate-sync` updates the marker. Never hand-edit the marker. |+| `PORT_FORWARD_CONFLICT` | A port-forward for this profile is owned by a process not recorded for it (or not a real `kubectl`). | Identify the foreign owner; if it belongs to another lane, stop. Restart forwards via `scripts/minikube/pf-all-stack.sh` for this profile only. |+| `PROFILE_BUSY` | Profile lock held. Live owner PID → genuinely busy. No valid owner PID → orphaned lock. | Live owner: wait or coordinate; never remove. Orphan: verify no T2 process owns the profile, then remove ONLY `$T2_LOCK_ROOT/<profile>.lock` and retry. Never remove the lock root. |+| `DEVELOPMENT_SCOPE_REQUIRED` | Preflight/final preflight failed a precondition, or T2-only mode was attempted without `already-synced`. | Repair the first reported condition; if T2-only was refused, run full `make minikube-t2`. |+| `ZERO_TESTS_EXECUTED` | A lane was configured off or executed nothing (including a required-but-missing Playwright journey). | Re-run with the lane enabled, or supply the required `T2_PLAYWRIGHT_COMMAND`. |+| `POSTGRES_NOT_READY` | PostgreSQL precondition failed, or a PVC reset was requested without the exact expected UID. | Fix DB readiness; never guess a PVC UID. |+| `PROFILE_UNHEALTHY` | Opt-in user-facing health command failed. | Fix the failing endpoint, re-run T2 on the same HEAD. |++## GFS restore pointers (high level, no secrets)++GFS T1 real-Postgres coverage has its own gate+(`make test-gfs-real-postgres-minikube`) against the validated branch-owned+profile. Restore/DSN provisioning for `gfs` is ordered by full-setup /+`pre-gate-sync` (it stays fail-closed until `control-api` is Ready — see the+`minikube-deploy-all` note in the Makefile). Do not hand-provision GFS DSNs,+and never copy DSNs or credentials between namespaces or into evidence.++## Dual-repo note++This contract belongs to `evenfire-ai/evenfire` only. `evenfire-infra` is a+different repository with different clusters and PR flow. Never point this+harness at an infra cluster, mix PRs across the repos, or present infra+evidence as an evenfire T2 verdict (and vice versa).diff --git a/AGENTS.md b/AGENTS.mdindex 9ed8bd751..7e5a527f3 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -41,15 +41,16 @@ Examples: `control-api` / `control-plane` / `control-api`,image-only primitive; do not call the all-image builder for a knownsingle-service change.-Use `make minikube-pre-gate-sync` for a full T2 gate after T1 passes. It owns-the cluster fingerprint, migration ordering, rollout checks, and runtime-marker. It compares the deployed marker to the current worktree, rebuilds only-the known affected image selectors, and restarts only their deployments. A-fresh profile, an explicit forced sync, or an unmapped runtime path must fall-back to the established complete image build. A service-only T2 may use the-targeted path when the profile is already healthy; record it as a *targeted-T2* and prove the affected deployment is Ready plus its user-facing health-endpoint. Do not report that as a full reconcile.+Use `make minikube-pre-gate-sync` to reconcile the owned profile after T1+inputs change. It owns the cluster fingerprint, migration ordering, rollout+checks, and runtime marker. It is not a T2 verdict. It compares the deployed+marker to the current worktree, rebuilds only the known affected image+selectors, and restarts only their deployments. A fresh profile, an explicit+forced sync, or an unmapped runtime path must fall back to the established+complete image build. A service-only update may use the targeted path when the+profile is already healthy; record it as a *targeted sync* and prove the+affected deployment is Ready plus its user-facing health endpoint. Do not+report that as a full reconcile or as T2.Expect a full reconcile when deployment manifests, CRDs, charts, networkpolicy, or other infrastructure inputs changed; do not replace that safe path@@ -69,20 +70,41 @@ Use these canonical entry points:```textmake minikube-t2-preflightmake minikube-t2+make minikube-t2-runtime```-A fresh or uninitialized profile must complete the supported bootstrap before-`pre-gate-sync` is invoked. The preflight refuses to call that sync on an-incomplete profile. Real PostgreSQL suites are opt-in in the ordinary test+`make minikube-t2-preflight` is a read-only planner. It is not T0, T1, or T2.+With the default `T2_PLAN_MODE=false` it fails loud on an unbootstrapped+profile and does not call `pre-gate-sync`. `make minikube-t2` is the full+orchestrator: T0, the selected bootstrap/reconcile, T1, then T2. A T2 verdict+is produced only by the final exact-head preflight inside that orchestrator+(`T2_PLAN_MODE=false` with plan state `already-synced`; `T2_PLAN_MODE=true` is+only the internal planner so `full-bootstrap` is reachable).+`make minikube-pre-gate-sync` alone never constitutes T2 evidence.+Follow the rule `.cursor/rules/minikube-t0-t1-t2.mdc` and the skill+`.cursor/skills/minikube-t0-t1-t2/SKILL.md` for the certification workflow.++After T0 and T1 are already green on the same HEAD and owned profile, close+T2 with `make minikube-t2-runtime` (`T2_RUN_T0=false T2_RUN_T1=false`). That+path is valid only when the pre-gate marker already matches HEAD+(`already-synced`). Do not set those flags to skip an uncertified lane.++A fresh or uninitialized profile must complete the supported bootstrap. The+standalone preflight refuses to call `pre-gate-sync` on an incomplete profile;+`make minikube-t2` runs the supported setup when its planner selects+`full-bootstrap`. Real PostgreSQL suites are opt-in in the ordinary testmatrix, but a T1 run that requires them must fail when the database/DSN isunavailable or when zero tests execute; a green run must never be produced bysilently skipping the suites. Suites that drop or rewrite cluster-global rolesmust use the harness throwaway Postgres 16, never the shared `control-postgres`.T0 (static/unit/contract checks), T1 (real PostgreSQL), T2 (validated runtime),-CI, and Control UI/Desktop Playwright are separate evidence lanes. One lane-does not stand in for another. Private operational state, generated ports,-profile metadata, logs, and evidence belong under the ignored+CI, Control UI/Desktop Playwright, and product E2E scripts such as+`scripts/e2e/e2e-hcc-rollout-readiness.sh` are separate evidence lanes. One+lane does not stand in for another. User-facing health and Playwright journeys+are opt-in on T2 via `T2_HEALTHCHECK_COMMAND` and `T2_PLAYWRIGHT_COMMAND`+(`T2_REQUIRE_PLAYWRIGHT=true` to refuse `NOT_RUN`). Private operational state,+generated ports, profile metadata, logs, and evidence belong under the ignored`.local-notes/infra/runs/` path and must never be committed.## Desktop Electron installation invariantdiff --git a/CLAUDE.md b/CLAUDE.mdindex aca92b458..e7aa5811e 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -9,8 +9,16 @@ Labs reference. Use the repository's conventional prefixes instead: `feat/*`,`build/*`, `perf/*`, or `revert/*`.The local Minikube T0/T1/T2 contract is development-only. Follow the-canonical `make minikube-t2-preflight` and `make minikube-t2` entry points and-the ownership, secret-safety, and evidence rules in `AGENTS.md`.+canonical `make minikube-t2-preflight`, `make minikube-t2`, and+`make minikube-t2-runtime` entry points and the ownership, secret-safety, and+evidence rules in `AGENTS.md` and `docs/testing/minikube-t2-runbook.md`.+`make minikube-t2-preflight` is a planner, not a lane verdict. A T2 verdict is+produced only by the final exact-head preflight inside `make minikube-t2` (or+`make minikube-t2-runtime` after T0 and T1 are already green on the same HEAD).+`make minikube-pre-gate-sync` alone is not T2. Playwright and product E2E+scripts are separate lanes. Follow the rule `.cursor/rules/minikube-t0-t1-t2.mdc`+and the skill `.cursor/skills/minikube-t0-t1-t2/SKILL.md` for the certification+workflow.## Logging standarddiff --git a/Makefile b/Makefileindex fea7f0dd8..ad34a9875 100644--- a/Makefile+++ b/Makefile@@ -425,17 +425,22 @@ test-gfs-real-postgres-minikube: ## Run GFS T1 real-Postgres suites against a va@CONTEXT="$(MINIKUBE_PROFILE)" bash scripts/e2e/gfs-real-pg-minikube-gate.sh.PHONY: minikube-t2-preflight-minikube-t2-preflight: ## Read-only, fail-loud T0/T1/T2 preflight for the explicit branch-owned Minikube profile+minikube-t2-preflight: ## Read-only readiness planner (not T0/T1/T2); fail-loud on an unbootstrapped profile@MINIKUBE_PROFILE="$(MINIKUBE_PROFILE)" CONTROL_API_REAL_PG_CONTEXT="$(CONTROL_API_REAL_PG_CONTEXT)" \scripts/minikube/t2-preflight.sh.PHONY: minikube-t2-minikube-t2: ## Run the local development T0, Real PostgreSQL T1, and exact-head T2 contract+minikube-t2: ## Full orchestrator: T0, Real PostgreSQL T1, then exact-head T2@MINIKUBE_PROFILE="$(MINIKUBE_PROFILE)" CONTROL_API_REAL_PG_CONTEXT="$(CONTROL_API_REAL_PG_CONTEXT)" \scripts/minikube/t2.sh.PHONY: minikube-t2-np08-hcc-authorizationminikube-t2-np08-hcc-authorization: minikube-t2 ## Run canonical T2 including the required deployed NP-08 Host-to-HCC authorization journey+.PHONY: minikube-t2-runtime+minikube-t2-runtime: ## Exact-head T2 after T0 and T1 already passed on this HEAD and profile+ @T2_RUN_T0=false T2_RUN_T1=false \+ MINIKUBE_PROFILE="$(MINIKUBE_PROFILE)" CONTROL_API_REAL_PG_CONTEXT="$(CONTROL_API_REAL_PG_CONTEXT)" \+ scripts/minikube/t2.sh.PHONY: minikube-t2-real-postgresminikube-t2-real-postgres: ## Run the explicit local Real PostgreSQL lane without changing CI's DSN contractdiff --git a/docs/testing/minikube-t2-runbook.md b/docs/testing/minikube-t2-runbook.mdindex b240d3c57..85b7be21b 100644--- a/docs/testing/minikube-t2-runbook.md+++ b/docs/testing/minikube-t2-runbook.md@@ -13,19 +13,34 @@ It refuses protected branches, production/GKE/Cloudflare contexts, sharedprofiles, ambiguous ownership, and Kubernetes contexts whose cluster endpointdoes not resolve to a local Minikube address.-Run the read-only preflight first:+Run the read-only planner first. It is not T0, T1, or T2. Default+`T2_PLAN_MODE=false` fails loud on `full-bootstrap` and never calls+`pre-gate-sync`:```bashmake minikube-t2-preflight MINIKUBE_PROFILE=<generated-profile>```-The full T2 orchestrator uses the same checks and then performs the selected-state transition:+The full orchestrator uses the same checks as a planner (`T2_PLAN_MODE=true`+so `full-bootstrap` is reachable), then performs the selected state+transition, T0, T1, and the exact-head T2 verdict (`T2_PLAN_MODE=false` and+the plan must be `already-synced`):```bashmake minikube-t2 MINIKUBE_PROFILE=<generated-profile>```+After T0 and T1 are already green on the same HEAD and owned profile, close+T2 without re-running those lanes:++```bash+make minikube-t2-runtime MINIKUBE_PROFILE=<generated-profile>+```++`make minikube-t2-runtime` is valid only when the pre-gate marker already+matches HEAD. `make minikube-pre-gate-sync` reconciles the profile; it does+not emit a T2 verdict.+The profile helper that generated the profile remains the source of truth forthe profile metadata and random localhost port mapping. Do not copy ports fromanother worktree or use shared fixed ports.@@ -35,24 +50,32 @@ another worktree or use shared fixed ports.### BootstrapA missing or uninitialized profile has no trusted pre-gate marker, image-manifest, or ready PostgreSQL state. The runner reports `BOOTSTRAP_REQUIRED`-and, when invoked through `make minikube-t2`, runs the supported full setup.-Bootstrap orders Secret/ConfigMap validation, PostgreSQL readiness, migrations-and roles, and only then `pre-gate-sync`. It does not delete a PVC by default.+manifest, or ready PostgreSQL state. Standalone `make minikube-t2-preflight`+reports `BOOTSTRAP_REQUIRED` and stops. `make minikube-t2` uses planner mode+(`T2_PLAN_MODE=true`) so that transition is reachable and then runs the+supported full setup. Bootstrap orders Secret/ConfigMap validation, PostgreSQL+readiness, migrations and roles, and only then `pre-gate-sync`. It does not+delete a PVC by default.### Targeted sync-An already healthy profile may use a targeted image/deployment update only when-the marker exactly matches the worktree path and `HEAD`, the image acquisition-manifest is current, and the diff is limited to a known service source change.-The affected deployment must become Ready and its user-facing health check must-pass. This is recorded as a targeted T2, not as a full reconcile.+When the pre-gate marker already matches the current worktree path and `HEAD`,+the planner selects `already-synced` and `make minikube-t2` skips setup and+`pre-gate-sync`. That is the T2-runtime precondition.++An already healthy profile whose marker is stale may use a targeted+image/deployment update only when the diff since `origin/dev` is limited to a+known service, package, harness, or documentation change. The affected+deployment must become Ready and its user-facing health check must pass. This+is recorded as a targeted sync, not as a full reconcile and not as T2.### Full reconcile-Changes to CRDs, manifests, charts, NetworkPolicies, PVC/storage definitions,-the Minikube overlay, or other infrastructure inputs require a full reconcile.-The runner refuses to downgrade those changes to a service-only restart.+Changes under `deploy/` or `charts/` (CRDs, manifests, NetworkPolicies,+PVC/storage definitions, the Minikube overlay) require a full reconcile when+the marker does not already match HEAD. Harness, documentation, Makefile, and+`scripts/e2e` diffs do not force a full reconcile. The runner refuses to+downgrade a `deploy/` or `charts/` change to a service-only restart.## Ownership and concurrency@@ -83,7 +106,12 @@ Never remove a lock with a live owner, and never remove the whole lock root.The runner checks required namespaces, Services, Secret names, ConfigMap names,the `control-postgres` PVC/deployment, all required deployment readiness, the-image manifest/source, and profile-owned port-forward processes. Secret values+image manifest/source, and real `kubectl port-forward` processes for this+profile. Allowed port-forward PIDs live in+`$HOME/.cache/clerum/minikube-profiles/<profile>/pids/*.pid` (and the+legacy `/tmp/pf-<profile>-*.pid` files written by `pf-all-stack.sh`).+`make minikube-t2` invokes `pre-gate-sync` with `--skip-port-forwards` so the+orchestrator does not plant forwards that fail its own T2 check. Secret valuesare never printed. The local Real PostgreSQL lane resolves the`control-postgres` Secret using the explicit context, constructs its admin DSNonly in process memory, and passes it only to the shared-server suites. Suites@@ -101,12 +129,19 @@ never share live `control-postgres` (#412). CI continues to usePostgres 16; the lane reports `PASS`, `FAIL`, `SKIPPED`, and `NOT_RUN`separately and fails on an unavailable DSN, an isolated server that did notstart, or zero executed tests.-* **T2** — the exact worktree/`HEAD` is deployed to the owned profile, the- cluster is healthy, readiness and health checks pass, and applicable- Control UI/Desktop journeys are run through their user-visible paths.--CI, static tests, T1, T2, and Playwright are separate evidence lanes. A green-CI job or unit suite is not proof of T2 runtime behavior.+* **T2** — the final exact-head preflight inside `make minikube-t2` (or+ `make minikube-t2-runtime`): the marker matches this worktree/`HEAD`, the+ image manifest is current, PostgreSQL and required namespaces/Services are+ present, deployments are Ready, and no foreign `kubectl port-forward` owns+ this profile. User-facing health and Control UI/Desktop Playwright journeys+ are opt-in via `T2_HEALTHCHECK_COMMAND` / `T2_PLAYWRIGHT_COMMAND` and are+ recorded as separate evidence statuses (`NOT_RUN` by default;+ `T2_REQUIRE_PLAYWRIGHT=true` refuses a missing journey). Product E2E scripts+ such as `scripts/e2e/e2e-hcc-rollout-readiness.sh` are not T2.++CI, static tests, T1, T2, Playwright, and product E2E scripts are separate+evidence lanes. A green CI job or unit suite is not proof of T2 runtime+behavior. A `T2_PREFLIGHT_PASS` line from the planner is not a T2 verdict.## NP-08 security evidence gatesdiff --git a/scripts/minikube/pf-all-stack.sh b/scripts/minikube/pf-all-stack.shindex 492e8c46f..abcec6931 100755--- a/scripts/minikube/pf-all-stack.sh+++ b/scripts/minikube/pf-all-stack.sh@@ -123,14 +123,22 @@ start_pf() {local health_url="${5:-}"local log="/tmp/pf-${SAFE_PROFILE}-${name}.log"local pidfile="/tmp/pf-${SAFE_PROFILE}-${name}.pid"+ local profile_pids_dir="${CLERUM_PROFILE_CACHE_ROOT:-${HOME}/.cache/clerum/minikube-profiles}/${PROFILE}/pids"+ local profile_pidfile="${profile_pids_dir}/${name}.pid"+ mkdir -p "${profile_pids_dir}"if [[ -f "${pidfile}" ]]; thenkill "$(cat "${pidfile}")" 2>/dev/null || truerm -f "${pidfile}"fi+ if [[ -f "${profile_pidfile}" ]]; then+ kill "$(cat "${profile_pidfile}")" 2>/dev/null || true+ rm -f "${profile_pidfile}"+ finohup "${KC[@]}" -n "${namespace}" port-forward --address=127.0.0.1 "svc/${service}" "${ports}" >"${log}" 2>&1 </dev/null &echo $! >"${pidfile}"+ echo $! >"${profile_pidfile}"PIDS+=("$!")echo " ${name}: pid=$(cat "${pidfile}") ns=${namespace} svc=${service} ports=${ports}"sleep 0.2diff --git a/scripts/minikube/t2-common.sh b/scripts/minikube/t2-common.shindex fa13d1541..1b766d737 100755--- a/scripts/minikube/t2-common.sh+++ b/scripts/minikube/t2-common.sh@@ -43,8 +43,11 @@ T2_ERROR_CODE=""T2_NEXT_COMMAND='re-run the canonical command with the verified profile'T2_PLAN_STATE=""T2_PLAN_REASON=""+T2_PLAN_MODE="$T2_PLAN_MODE"+if [ -z "$T2_PLAN_MODE" ]; then T2_PLAN_MODE=false; fiT2_BOOTSTRAP_REQUIRED=falseT2_PROFILE_HEALTHY=false+T2_MARKER_MATCHES_HEAD=falseT2_MARKER_JSON=""T2_IMAGE_SOURCE=""T2_IMAGE_TAG=""@@ -294,10 +297,22 @@ PY)"; thencase "$marker_values" in*ownership*) T2_NEXT_COMMAND='run pre-gate-sync for this worktree/profile, then retry'; t2_fail PROFILE_OWNERSHIP_MISMATCH 'pre-gate marker belongs to another worktree' ;;- *head*) T2_NEXT_COMMAND="MINIKUBE_PROFILE=$T2_PROFILE make minikube-pre-gate-sync GATE=minikube-t2"; t2_fail HEAD_MARKER_MISMATCH 'pre-gate marker does not match current HEAD' ;;+ *head*)+ # Standalone preflight is fail-loud. The orchestrator planner+ # (T2_PLAN_MODE=true) must keep going so it can select targeted-sync+ # or full-reconcile and update the marker.+ if [ "$T2_PLAN_MODE" = true ]; then+ T2_MARKER_MATCHES_HEAD=false+ T2_PLAN_REASON='pre-gate marker does not match current HEAD'+ return 0+ fi+ T2_NEXT_COMMAND="MINIKUBE_PROFILE=$T2_PROFILE make minikube-t2"+ t2_fail HEAD_MARKER_MISMATCH 'pre-gate marker does not match current HEAD'+ ;;*) T2_NEXT_COMMAND="MINIKUBE_PROFILE=$T2_PROFILE make minikube-setup-local"; t2_fail BOOTSTRAP_REQUIRED 'pre-gate marker is incomplete' ;;esacfi+ T2_MARKER_MATCHES_HEAD=trueIFS=$'\t' read -r T2_CLUSTER_FINGERPRINT T2_IMAGE_SOURCE T2_IMAGE_TAG <<< "$marker_values"}@@ -493,18 +508,27 @@ PY}t2_process_check() {- local process_lines allowed pid command_line pid_file profile_safe- process_lines="$(ps -ef 2>/dev/null | awk '/[p]ort-forward/ && /kubectl/ {print}' || true)"- [ -z "$process_lines" ] && return 0- profile_safe="${T2_PROFILE//[^A-Za-z0-9_.-]/_}"- while IFS= read -r command_line; do- [ -z "$command_line" ] && continue+ local uid pid ppid rest command_line comm allowed pid_file recorded_pid+ local safe_profile+ safe_profile="$(printf '%s' "$T2_PROFILE" | tr -c 'A-Za-z0-9_.-' '_')"+ # Only real kubectl port-forward processes. A wrapper whose argv merely+ # mentions those words is not a port-forward.+ while IFS= read -r uid pid ppid rest; do+ [ -n "$pid" ] || continue+ command_line="$uid $pid $ppid $rest"[[ "$command_line" == *"$T2_PROFILE"* || "$command_line" == *"$T2_CONTEXT"* ]] || continue+ comm="$(ps -p "$pid" -o comm= 2>/dev/null || true)"+ case "$comm" in+ *kubectl*) ;;+ *) continue ;;+ esacallowed=false- for pid_file in "$T2_PROFILE_ROOT/$T2_PROFILE"/pids/*.pid; do+ for pid_file in \+ "$T2_PROFILE_ROOT/$T2_PROFILE"/pids/*.pid \+ /tmp/pf-"$safe_profile"-*.pid; do[ -f "$pid_file" ] || continue- pid="$(sed -n '1p' "$pid_file" 2>/dev/null || true)"- [[ -n "$pid" && "$command_line" == *" $pid "* ]] && allowed=true+ recorded_pid="$(sed -n '1p' "$pid_file" 2>/dev/null || true)"+ [ "$recorded_pid" = "$pid" ] && allowed=truedone# pf-all-stack.sh is the canonical gate forwarder and records its child# PIDs in /tmp/pf-<profile>-*.pid. Accept those PIDs as profile-owned too;@@ -518,7 +542,7 @@ t2_process_check() {T2_NEXT_COMMAND='stop the unrelated profile port-forward or select the owner worktree; do not share it't2_fail PORT_FORWARD_CONFLICT 'a port-forward for this profile is owned by another process'fi- done <<< "$process_lines"+ done < <(ps -ef 2>/dev/null | awk '/(^|\/)kubectl([[:space:]]|$)/ && /[[:space:]]port-forward([[:space:]]|$)/ {print}' || true)}t2_classify_transition() {@@ -527,6 +551,11 @@ t2_classify_transition() {[ -n "$T2_PLAN_REASON" ] || T2_PLAN_REASON='profile is not bootstrapped'return 0fi+ if [ "$T2_MARKER_MATCHES_HEAD" = true ]; then+ T2_PLAN_STATE=already-synced+ T2_PLAN_REASON='pre-gate marker already matches HEAD'+ return 0+ filocal changed infra=false pathchanged="$(git -C "$T2_PROJECT_DIR" diff --name-only "$T2_ORIGIN_DEV...$T2_HEAD")"if [ -z "$changed" ]; then@@ -537,7 +566,7 @@ t2_classify_transition() {while IFS= read -r path; do[ -z "$path" ] && continuecase "$path" in- deploy/*|charts/*|scripts/minikube/*|scripts/e2e/*|Makefile|AGENTS.md|.github/workflows/*)+ deploy/*|charts/*)infra=truebreak;;@@ -545,10 +574,10 @@ t2_classify_transition() {done <<< "$changed"if [ "$infra" = true ]; thenT2_PLAN_STATE=full-reconcile- T2_PLAN_REASON='infrastructure, manifest, CRD, policy, storage, or orchestration input changed'+ T2_PLAN_REASON='infrastructure, manifest, CRD, policy, storage, or overlay input changed'elseT2_PLAN_STATE=targeted-sync- T2_PLAN_REASON='changes are limited to service/package source inputs'+ T2_PLAN_REASON='changes are limited to service, package, harness, or documentation inputs'fi}diff --git a/scripts/minikube/t2-preflight.sh b/scripts/minikube/t2-preflight.shindex 6f74c53a8..18ee423b0 100755--- a/scripts/minikube/t2-preflight.sh+++ b/scripts/minikube/t2-preflight.sh@@ -1,5 +1,8 @@#!/usr/bin/env bash# Read-only validation and state-transition planner for local Evenfire Minikube.+# This is not T0, T1, or T2. T2_PLAN_MODE=false (default, make minikube-t2-preflight+# and the final T2 check) is fail-loud on full-bootstrap or a stale marker.+# T2_PLAN_MODE=true is only the orchestrator planner so full-bootstrap is reachable.# shellcheck disable=SC2269set -euo pipefailset +xdiff --git a/scripts/minikube/t2.sh b/scripts/minikube/t2.shindex d66477f5a..2e8b9ae24 100755--- a/scripts/minikube/t2.sh+++ b/scripts/minikube/t2.sh@@ -39,8 +39,17 @@ cleanup_plan() {}trap cleanup_plan EXIT+t2_lane_completed() {+ local status="$1"+ [ "$status" = PASS ] || [ "$status" = SKIPPED ]+}+run_t0() {- [ "$T2_RUN_T0" = true ] || return 0+ if [ "$T2_RUN_T0" != true ]; then+ T2_T0_STATUS=SKIPPED+ t2_evidence_write T0 SKIPPED 'T2_RUN_T0=false; static lane already certified on this HEAD'+ return 0+ fiprintf '[minikube-t2] T0: shell syntax and contract checks\n'git -C "$T2_PROJECT_DIR" diff --check "$T2_ORIGIN_DEV...$T2_HEAD"bash -n "$SCRIPT_DIR/t2-common.sh" "$SCRIPT_DIR/t2-preflight.sh" "$SCRIPT_DIR/t2.sh"@@ -128,8 +137,11 @@ run_bootstrap_or_reconcile() {printf '[minikube-t2] targeted sync: service-only source input changed\n'run_targeted_sync;;+ already-synced)+ printf '[minikube-t2] already synced: marker matches HEAD; skipping setup\n'+ ;;*)- T2_NEXT_COMMAND='re-run make minikube-t2-preflight to select bootstrap, targeted sync, or full reconcile'+ T2_NEXT_COMMAND='re-run make minikube-t2-preflight to select bootstrap, targeted sync, full reconcile, or already-synced't2_fail BOOTSTRAP_REQUIRED "unknown transition: $T2_PLAN_STATE";;esac@@ -171,12 +183,20 @@ run_targeted_sync() {}run_pre_gate() {+ if [ "$T2_PLAN_STATE" = already-synced ]; then+ printf '[minikube-t2] skipping pre-gate-sync; marker already matches HEAD\n'+ return 0+ fiprintf '[minikube-t2] pre-gate-sync after bootstrap/reconcile\n'- MINIKUBE_PROFILE="$T2_PROFILE" make minikube-pre-gate-sync GATE=minikube-t2+ MINIKUBE_PROFILE="$T2_PROFILE" make minikube-pre-gate-sync GATE=minikube-t2 ARGS='--skip-port-forwards'}run_t1() {- [ "$T2_RUN_T1" = true ] || return 0+ if [ "$T2_RUN_T1" != true ]; then+ T2_T1_STATUS=SKIPPED+ t2_evidence_write T1 SKIPPED 'T2_RUN_T1=false; Real PostgreSQL lane already certified on this HEAD'+ return 0+ fiprintf '[minikube-t2] T1: Real PostgreSQL suites\n'if T2_SKIP_LOCK=true CONTROL_API_REAL_PG_CONTEXT="$T2_CONTEXT" MINIKUBE_PROFILE="$T2_PROFILE" \bash "$T2_PROJECT_DIR/scripts/e2e/minikube-real-postgres.sh" >"$T2_T1_OUTPUT" 2>&1; then@@ -194,7 +214,8 @@ run_t1() {run_final_preflight() {printf '[minikube-t2] final exact-head readiness preflight\n'- if ! T2_SKIP_LOCK=true T2_PLAN_MODE=true T2_PLAN_FILE="$T2_PLAN_TMP" \+ # Fail-loud: a stale marker or missing bootstrap must not count as T2.+ if ! T2_SKIP_LOCK=true T2_PLAN_MODE=false T2_PLAN_FILE="$T2_PLAN_TMP" \T2_PROJECT_DIR="$T2_PROJECT_DIR" MINIKUBE_PROFILE="$T2_PROFILE" \CONTROL_API_REAL_PG_CONTEXT="$T2_CONTEXT" T2_PROFILE_ROOT="$T2_PROFILE_ROOT" \T2_PROFILE_ENV="$T2_PROFILE_ENV" T2_PORTS_ENV="$T2_PORTS_ENV" \@@ -204,6 +225,16 @@ run_final_preflight() {T2_NEXT_COMMAND='repair the first reported final preflight condition, then re-run T2 on the same HEAD't2_fail DEVELOPMENT_SCOPE_REQUIRED 'final exact-head readiness preflight failed'fi+ T2_PLAN_STATE="$(python3 - "$T2_PLAN_TMP" <<'PY'+import json+import sys+print(json.loads(open(sys.argv[1]).read()).get("state", ""))+PY+ )"+ if [ "$T2_PLAN_STATE" != already-synced ]; then+ T2_NEXT_COMMAND='re-run make minikube-t2 so pre-gate-sync updates the marker to this HEAD'+ t2_fail HEAD_MARKER_MISMATCH "final T2 preflight selected $T2_PLAN_STATE instead of already-synced"+ fiT2_T2_STATUS=PASSt2_evidence_write T2 PASS 'exact marker, image, PostgreSQL, namespace, Service, and deployment readiness passed'}@@ -273,15 +304,19 @@ main() {t2_evidence_initrun_t0- if [ "$T2_T0_STATUS" != PASS ]; then+ if ! t2_lane_completed "$T2_T0_STATUS"; thenT2_NEXT_COMMAND='re-run make minikube-t2 with T2_RUN_T0=true so the static lane is executed't2_fail ZERO_TESTS_EXECUTED 'T0 was not executed'firun_preflight_plan+ if { [ "$T2_RUN_T0" != true ] || [ "$T2_RUN_T1" != true ]; } && [ "$T2_PLAN_STATE" != already-synced ]; then+ T2_NEXT_COMMAND='run make minikube-t2 so bootstrap/reconcile and T0/T1 execute on this HEAD'+ t2_fail DEVELOPMENT_SCOPE_REQUIRED 'T2-only mode requires an already-synced exact-head profile'+ firun_bootstrap_or_reconcilerun_pre_gaterun_t1- if [ "$T2_T1_STATUS" != PASS ]; then+ if ! t2_lane_completed "$T2_T1_STATUS"; thenT2_NEXT_COMMAND='re-run make minikube-t2 with T2_RUN_T1=true so the Real PostgreSQL lane is executed't2_fail ZERO_TESTS_EXECUTED 'T1 was not executed'fidiff --git a/scripts/tests/test-minikube-t2-contract.sh b/scripts/tests/test-minikube-t2-contract.shindex 327649124..9eac0ae2d 100755--- a/scripts/tests/test-minikube-t2-contract.sh+++ b/scripts/tests/test-minikube-t2-contract.sh@@ -80,6 +80,27 @@ grep -Fq 'run_np08_hcc_authorization' "$T2"grep -Fq "CLERUM_PROFILE_PORTS_ENV=\"\$T2_PORTS_ENV\"" "$T2"grep -Fq 'NP08_HCC_AUTHORIZATION PASS' "$T2"grep -Fq "NP08_HCC_AUTHORIZATION=\$T2_NP08_HCC_AUTHORIZATION_STATUS" "$T2"+grep -Fq 'already-synced' "$T2" "$COMMON"+grep -Fq 'T2_SKIP_LOCK=true T2_PLAN_MODE=true T2_PLAN_FILE' "$T2"+grep -Fq 'T2_SKIP_LOCK=true T2_PLAN_MODE=false T2_PLAN_FILE' "$T2"+grep -Fq 'T2_PLAN_MODE=false' "$PREFLIGHT"+grep -Fq -- '--skip-port-forwards' "$T2"+grep -Fq 't2_lane_completed' "$T2"+grep -Fq 'T2_T0_STATUS=SKIPPED' "$T2"+grep -Fq 'T2_T1_STATUS=SKIPPED' "$T2"+grep -Fq 'REUSE_DB=true' "$T2"+grep -Fq 'T2_T0_STATUS=NOT_RUN' "$T2"+grep -Fq 'T2_T1_STATUS=NOT_RUN' "$T2"+grep -Fq 'T2_HEALTHCHECK_COMMAND' "$T2"+grep -Fq 'minikube-t2-runtime' "$ROOT/Makefile"+if ! grep -Fq 'instead of already-synced' "$T2"; then+ echo 'FAIL: final T2 preflight does not require already-synced' >&2+ exit 1+fi+if grep -Eq 'make minikube-pre-gate-sync GATE=minikube-t2$' "$T2"; then+ echo 'FAIL: orchestrator pre-gate-sync still starts port-forwards' >&2+ exit 1+figrep -Fq 'trap t2_lock_release EXIT INT TERM' "$COMMON"grep -Fq 'T2_LOCK_ROOT' "$COMMON"diff --git a/scripts/tests/test-minikube-t2-scenarios.sh b/scripts/tests/test-minikube-t2-scenarios.shindex 79b70d53f..22eb3ae98 100755--- a/scripts/tests/test-minikube-t2-scenarios.sh+++ b/scripts/tests/test-minikube-t2-scenarios.sh@@ -208,6 +208,17 @@ targeted_state="$(env "${repo_env[@]}" T2_PROJECT_DIR="$repo" T2_BOOTSTRAP_REQUIbash -c 'source "$1"; T2_ORIGIN_DEV="$2"; T2_HEAD="$3"; T2_BOOTSTRAP_REQUIRED=false; t2_classify_transition; printf "%s" "$T2_PLAN_STATE"' bash "$COMMON" "$base_sha" "$feature_sha")"[ "$targeted_state" = targeted-sync ] || fail "service change selected $targeted_state instead of targeted-sync"+printf 'agents\n' >"$repo/AGENTS.md"+mkdir -p "$repo/scripts/e2e"+printf 'harness\n' >"$repo/scripts/e2e/gate.sh"+git -C "$repo" add AGENTS.md scripts/e2e/gate.sh+git -C "$repo" commit -q -m harness-docs+docs_sha="$(git -C "$repo" rev-parse HEAD)"+docs_state="$(env "${repo_env[@]}" T2_PROJECT_DIR="$repo" T2_BOOTSTRAP_REQUIRED=false \+ T2_ORIGIN_DEV="$base_sha" T2_HEAD="$docs_sha" \+ bash -c 'source "$1"; T2_ORIGIN_DEV="$2"; T2_HEAD="$3"; T2_BOOTSTRAP_REQUIRED=false; t2_classify_transition; printf "%s" "$T2_PLAN_STATE"' bash "$COMMON" "$base_sha" "$docs_sha")"+[ "$docs_state" = targeted-sync ] || fail "harness/docs change selected $docs_state instead of targeted-sync"+mkdir -p "$repo/deploy"printf 'infrastructure\n' >"$repo/deploy/change.txt"git -C "$repo" add deploy/change.txt@@ -218,6 +229,15 @@ full_state="$(env "${repo_env[@]}" T2_PROJECT_DIR="$repo" T2_BOOTSTRAP_REQUIRED=bash -c 'source "$1"; T2_ORIGIN_DEV="$2"; T2_HEAD="$3"; T2_BOOTSTRAP_REQUIRED=false; t2_classify_transition; printf "%s" "$T2_PLAN_STATE"' bash "$COMMON" "$base_sha" "$infra_sha")"[ "$full_state" = full-reconcile ] || fail "infrastructure change selected $full_state instead of full-reconcile"+already_state="$(env "${repo_env[@]}" T2_PROJECT_DIR="$repo" T2_BOOTSTRAP_REQUIRED=false \+ T2_ORIGIN_DEV="$base_sha" T2_HEAD="$infra_sha" \+ bash -c 'source "$1"; T2_ORIGIN_DEV="$2"; T2_HEAD="$3"; T2_BOOTSTRAP_REQUIRED=false; T2_MARKER_MATCHES_HEAD=true; t2_classify_transition; printf "%s" "$T2_PLAN_STATE"' bash "$COMMON" "$base_sha" "$infra_sha")"+[ "$already_state" = already-synced ] || fail "matching marker selected $already_state instead of already-synced"++plan_mode_head="$(env "${marker_env[@]}" T2_PLAN_MODE=true FAKE_MARKER='{"data":{"clusterFingerprint":"fp","gitHead":"old","worktreeId":"worktree-a","imageSource":"local","imageTag":"test"}}' \+ bash -c 'source "$1"; T2_WORKTREE_ID=worktree-a; T2_HEAD=feature; T2_PLAN_MODE=true; t2_kc(){ printf "%s" "$FAKE_MARKER"; }; t2_marker_check; printf "%s" "$T2_MARKER_MATCHES_HEAD"' bash "$COMMON")"+[ "$plan_mode_head" = false ] || fail "planner mode still treated a stale marker as matching HEAD"+evidence="$tmp/evidence.json"detail_value="$(printf '%s://%s:%s@%s' postgresql user marker local-db)"env "${repo_env[@]}" T2_EVIDENCE_FILE="$evidence" T2_EVIDENCE_DIR="$tmp/evidence-dir" \