|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from pathlib import Path |
| 4 | + |
| 5 | + |
| 6 | +BOUNDARY_PATH = Path("docs/plans/post-phase-67-decision-trace-eval-ownership-boundary-2026-06-08.md") |
| 7 | +REPLAY_AUDIT_PATH = Path("docs/plans/post-phase-67-decision-trace-replay-audit-2026-06-08.md") |
| 8 | +MINIMUM_LOOP = ( |
| 9 | + "corpus -> chunks -> graph -> personas -> scenarios -> deterministic runs -> " |
| 10 | + "report/claims -> eval" |
| 11 | +) |
| 12 | + |
| 13 | + |
| 14 | +def _read(path: Path) -> str: |
| 15 | + assert path.exists(), path |
| 16 | + return path.read_text(encoding="utf-8") |
| 17 | + |
| 18 | + |
| 19 | +def test_decision_trace_eval_ownership_boundary_exists_with_required_sections() -> None: |
| 20 | + boundary = _read(BOUNDARY_PATH) |
| 21 | + required_sections = [ |
| 22 | + "# Post-Phase-67 Decision Trace Eval Ownership Boundary", |
| 23 | + "## Scope", |
| 24 | + "## Current-Code Finding", |
| 25 | + "## Source Evidence", |
| 26 | + "## Blueprint Alignment Decision", |
| 27 | + "## Future Trigger Conditions", |
| 28 | + "## Boundaries", |
| 29 | + "## Validation Commands", |
| 30 | + ] |
| 31 | + for section in required_sections: |
| 32 | + assert section in boundary |
| 33 | + |
| 34 | + |
| 35 | +def test_eval_ownership_boundary_keeps_metrics_unclaimed_without_phase68() -> None: |
| 36 | + boundary = _read(BOUNDARY_PATH) |
| 37 | + replay_audit = _read(REPLAY_AUDIT_PATH) |
| 38 | + contracts = _read(Path("docs/architecture/contracts.md")) |
| 39 | + eval_service = _read(Path("backend/app/evals/service.py")) |
| 40 | + decision_kernel = _read(Path("backend/app/decision_kernel/service.py")) |
| 41 | + pipeline_tests = _read(Path("backend/tests/test_pipeline.py")) |
| 42 | + |
| 43 | + required_boundary_phrases = [ |
| 44 | + f"`{MINIMUM_LOOP}`", |
| 45 | + "Current-code audit result: eval-owned decision-trace replay metrics remain unclaimed today.", |
| 46 | + "This is not a source-backed Phase 68 blocker.", |
| 47 | + "Opening an implementation queue for eval-owned decision-trace replay metrics without a new source-backed blocker would be blueprint drift.", |
| 48 | + "Do not open Phase 68 from this boundary note.", |
| 49 | + "The current queue remains in the formal paused stop-state.", |
| 50 | + "`backend/app/evals/service.py` currently has no `decision_trace`, `replay_cache`, or `accepted_from_replay` ownership.", |
| 51 | + "`docs/architecture/contracts.md` does not require transfer eval summaries to include decision-trace replay metrics.", |
| 52 | + "kernel-level replay and runner-level same-run-directory replay remain the current proven boundary", |
| 53 | + "No ADR or `docs/architecture/contracts.md` update is made by this boundary note because this diff does not change a protected-core contract.", |
| 54 | + "`status:needs-adr` and unresolved `risk:safety` findings remain merge blockers.", |
| 55 | + "Do not present Mirror as a real-world prediction machine.", |
| 56 | + "Do not build real-person personas or digital doubles.", |
| 57 | + "Do not build political persuasion, hidden surveillance, law-enforcement scoring, hiring, credit, medical, or judicial decision systems.", |
| 58 | + ] |
| 59 | + forbidden_boundary_phrases = [ |
| 60 | + "Phase 68 is active", |
| 61 | + "Phase 68 execution queue is open", |
| 62 | + "open a Phase 68 milestone now", |
| 63 | + "eval-owned decision-trace replay metrics are implemented", |
| 64 | + "changes decision_trace.jsonl shape", |
| 65 | + "claims provider-backed replay readiness", |
| 66 | + "claims future-world readiness", |
| 67 | + ] |
| 68 | + for phrase in required_boundary_phrases: |
| 69 | + assert phrase in boundary, phrase |
| 70 | + for phrase in forbidden_boundary_phrases: |
| 71 | + assert phrase not in boundary, phrase |
| 72 | + |
| 73 | + assert "Future eval ownership for decision-trace replay metrics remains unclaimed by this audit." not in replay_audit |
| 74 | + assert "`docs/plans/post-phase-67-decision-trace-eval-ownership-boundary-2026-06-08.md`" in replay_audit |
| 75 | + |
| 76 | + for phrase in [ |
| 77 | + "`decision_trace.jsonl` is the durable v1 decision audit artifact", |
| 78 | + "`replay_cache` when the selection is copied from an existing trace entry for the same", |
| 79 | + "`accepted_from_replay` for replay-cache reuse.", |
| 80 | + ]: |
| 81 | + assert phrase in contracts |
| 82 | + |
| 83 | + for phrase in ["decision_trace", "replay_cache", "accepted_from_replay"]: |
| 84 | + assert phrase not in eval_service |
| 85 | + |
| 86 | + for phrase in [ |
| 87 | + "replay_entry = self.replay_cache.get(input_hash)", |
| 88 | + 'provider_mode="replay_cache"', |
| 89 | + 'validation_status="accepted_from_replay"', |
| 90 | + ]: |
| 91 | + assert phrase in decision_kernel |
| 92 | + assert phrase in boundary |
| 93 | + |
| 94 | + assert "test_simulation_replays_from_existing_decision_trace" in pipeline_tests |
| 95 | + assert "test_simulation_replays_from_existing_decision_trace" in boundary |
| 96 | + |
| 97 | + |
| 98 | +def test_current_docs_point_to_eval_ownership_boundary_without_opening_phase68() -> None: |
| 99 | + docs = [ |
| 100 | + Path("README.md"), |
| 101 | + Path("docs/plans/current-state-baseline.md"), |
| 102 | + Path("docs/plans/phase-execution-queue.md"), |
| 103 | + Path("docs/plans/automation-roadmap.md"), |
| 104 | + ] |
| 105 | + required_phrases = [ |
| 106 | + "`docs/plans/post-phase-67-decision-trace-eval-ownership-boundary-2026-06-08.md`", |
| 107 | + "Post-Phase-67 decision-trace eval-ownership boundary keeps the queue paused", |
| 108 | + "eval-owned decision-trace replay metrics remain unclaimed", |
| 109 | + "Do not open Phase 68 from this boundary note.", |
| 110 | + ] |
| 111 | + forbidden_phrases = [ |
| 112 | + "Phase 68 is active", |
| 113 | + "Phase 68 execution queue is open", |
| 114 | + "`audit-github-queue` reports `ready` for Phase 68", |
| 115 | + "milestone `Phase 68", |
| 116 | + ] |
| 117 | + for path in docs: |
| 118 | + text = _read(path) |
| 119 | + for phrase in required_phrases: |
| 120 | + assert phrase in text, f"{path} is missing eval-ownership boundary pointer: {phrase}" |
| 121 | + for phrase in forbidden_phrases: |
| 122 | + assert phrase not in text, f"{path} opens Phase 68 prematurely: {phrase}" |
0 commit comments