test_workspace_cycle.py file-level

at main · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:6 fix(ISR): default require_independent_second_reviewer to require Opera… · aaronrene · Sep 2, 2026
1 """E2E acceptance stories S1–S12 for workspace lanes (§MR.9 / §MR.10 e2e)."""
2
3 from __future__ import annotations
4
5 import json
6 from pathlib import Path
7
8 from tests.fixtures.workspace import build_two_repo_constellation
9 from tests.support import run_shim
10 from tools.workspace.types import EXIT_WORKSPACE_RELAY
11
12
13 def test_s1_s2_stale_then_refresh(tmp_path: Path) -> None:
14 stale = build_two_repo_constellation(tmp_path / "s1", stale_relay=True)
15 r1 = run_shim("ok", ["workspace", "check-next"], cwd=stale["scooling"])
16 assert r1.exit_code == EXIT_WORKSPACE_RELAY
17 assert "stale_relay" in r1.stdout + r1.stderr
18
19 fresh = build_two_repo_constellation(tmp_path / "s2", stale_relay=False)
20 r2 = run_shim("ok", ["workspace", "check-next"], cwd=fresh["scooling"])
21 assert r2.exit_code == 0
22
23
24 def test_s3_archived_not_selected(tmp_path: Path) -> None:
25 fx = build_two_repo_constellation(tmp_path)
26 path = fx["scooling_handover"]
27 text = path.read_text(encoding="utf-8")
28 text += "\n<!-- overseer:next role=archived status=archived -->\n## ARCHIVED SESSION — old Thinking\n"
29 path.write_text(text, encoding="utf-8")
30 assert run_shim("ok", ["workspace", "check-next"], cwd=fx["scooling"]).exit_code == 0
31
32 # Forbidden legacy form fails
33 path.write_text(
34 path.read_text(encoding="utf-8") + "\n## NEXT SESSION — archived leftover\n",
35 encoding="utf-8",
36 )
37 assert run_shim("ok", ["workspace", "check-next"], cwd=fx["scooling"]).exit_code == EXIT_WORKSPACE_RELAY
38
39
40 def test_s4_s12_distinct_basenames_and_doctor(tmp_path: Path) -> None:
41 fx = build_two_repo_constellation(tmp_path)
42 status = json.loads(
43 run_shim("ok", ["workspace", "status", "--json"], cwd=fx["scooling"]).stdout
44 )
45 bases = {m["handover_basename"] for m in status["members"]}
46 assert "SCOOLING-OVERSEER-HANDOVER.md" in bases
47 assert "KNOWTATION-OVERSEER-HANDOVER.md" in bases
48 assert status["authoritative_handover"]
49
50 bare = build_two_repo_constellation(tmp_path / "bare", bare_names_on_relay=True)
51 doctor = json.loads(
52 run_shim("ok", ["workspace", "doctor", "--json"], cwd=bare["scooling"]).stdout
53 )
54 assert any(f["code"] == "board_name_violation" for f in doctor["findings"])
55
56
57 def test_s6_lane_tip_non_primary(tmp_path: Path) -> None:
58 fx = build_two_repo_constellation(tmp_path, with_lane_tip=True)
59 assert run_shim("ok", ["workspace", "check-next"], cwd=fx["scooling"]).exit_code == 0
60 status = json.loads(
61 run_shim("ok", ["workspace", "status", "--json"], cwd=fx["scooling"]).stdout
62 )
63 assert any(l["id"] == "security" and not l["primary"] for l in status["lanes"])
64
65
66 def test_s7_optional_brain_absent(tmp_path: Path) -> None:
67 fx = build_two_repo_constellation(tmp_path, with_brain=True)
68 status = json.loads(
69 run_shim("ok", ["workspace", "status", "--json"], cwd=fx["scooling"]).stdout
70 )
71 brain = next(m for m in status["members"] if m["id"] == "brain")
72 assert brain["member_status"] == "absent"
73 assert run_shim("ok", ["workspace", "check-next"], cwd=fx["scooling"]).exit_code == 0
74
75
76 def test_s8_external_two_repo(tmp_path: Path) -> None:
77 fx = build_two_repo_constellation(tmp_path, constellation_id="app-store")
78 assert run_shim("ok", ["workspace", "check-next"], cwd=fx["scooling"]).exit_code == 0
79 stale = build_two_repo_constellation(tmp_path / "stale", stale_relay=True)
80 assert run_shim("ok", ["workspace", "check-next"], cwd=stale["scooling"]).exit_code == 35
81
82
83 def test_s10_s11_product_relay(tmp_path: Path) -> None:
84 good = build_two_repo_constellation(tmp_path / "pr", ownership_product_relay=True)
85 assert run_shim("ok", ["workspace", "check-next"], cwd=good["scooling"]).exit_code == 0
86 status = json.loads(
87 run_shim("ok", ["workspace", "status", "--json"], cwd=good["scooling"]).stdout
88 )
89 assert status["authoritative_handover"]
90 assert "SCOOLING" in Path(status["authoritative_handover"]).name.upper()
91
92 missing = build_two_repo_constellation(tmp_path / "miss", missing_product_relay=True)
93 assert (
94 run_shim("ok", ["workspace", "check-next"], cwd=missing["scooling"]).exit_code
95 == EXIT_WORKSPACE_RELAY
96 )
97
98
99 def test_e2e_governance_sync_footer_workspace_relay(tmp_path: Path) -> None:
100 from adapters.config import load_config
101 from tools.workspace import workspace_relay_footer_state
102
103 fx = build_two_repo_constellation(tmp_path, stale_relay=True)
104 cfg = load_config(fx["scooling"] / ".overseer" / "config.yaml")
105 assert workspace_relay_footer_state(cfg, fx["scooling"]) == "stale_relay"
106
107
108 def test_e2e_init_prefixed_defaults(tmp_path: Path) -> None:
109 from tests.support import run_shim
110
111 result = run_shim(
112 "ok",
113 ["init", "--regime", "git-only", "--repo-name", "acme-app", "--non-interactive"],
114 cwd=tmp_path,
115 )
116 assert result.exit_code == 0
117 assert (tmp_path / "docs" / "ACME-APP-OVERSEER-HANDOVER.md").is_file()
118 assert (tmp_path / "docs" / "ACME-APP-ROADMAP.md").is_file()