test_gs_paste_stress.py python
115 lines 3.6 KB
Raw
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83 chore(governance): sync handover+roadmap to 84db8c8 (drift:… Human 1 day ago
1 """Stress tests for GS-PASTE NEXT regen (§GSP.10 stress)."""
2
3 from __future__ import annotations
4
5 import time
6 from pathlib import Path
7
8 from adapters.config import load_config
9 from tests.support import FIXTURES
10 from tools.governance_hygiene.next_regen import plan_next_regen, select_unambiguous_next_row
11 from tools.governance_hygiene.patch import build_handover_patches
12 from tools.governance_hygiene.types import DriftReport, VerifiedReads
13
14
15 def _reads() -> VerifiedReads:
16 return VerifiedReads(
17 regime="git-only",
18 r1_github_main_sha="cafebabe",
19 r1_command="git rev-parse origin/main",
20 r2_anchor_sha="cafebabe",
21 r2_source="origin/main",
22 r3_canonical_main_sha=None,
23 r3_command=None,
24 r4_merged_prs=(),
25 r5_branch="main",
26 r5_dirty=False,
27 r5_regime="git-only",
28 )
29
30
31 def test_200_done_plus_one_open_regenerates_quickly(tmp_path: Path) -> None:
32 config = load_config(FIXTURES / "config-git-only.yaml")
33 lines = [
34 "# Stress",
35 "",
36 "## Build queue",
37 "",
38 "| Phase | Model | Status | Deliverable |",
39 "| --- | --- | --- | --- |",
40 ]
41 for index in range(200):
42 lines.append(f"| **P{index:03d}** | Auto | **DONE** | item {index} |")
43 lines.append("| **OPEN** | Auto | **NEXT** | final |")
44 roadmap = "\n".join(lines) + "\n"
45 handover = (FIXTURES / "gs-paste-handover.md").read_text(encoding="utf-8")
46 drift = DriftReport(
47 d1_handover_vs_git="drifted",
48 d2_anchor_vs_canonical="aligned",
49 d3_queue_vs_merged="aligned",
50 )
51 start = time.perf_counter()
52 patched, sections, token = build_handover_patches(
53 handover,
54 _reads(),
55 drift,
56 realign_summary=None,
57 sync_date="2026-07-30",
58 config=config,
59 roadmap_text=roadmap,
60 repo_root=tmp_path,
61 )
62 elapsed = time.perf_counter() - start
63 assert elapsed < 2.0
64 assert "next-session" in sections
65 assert token == "next_regen: regenerated"
66 assert "| **ID** | **OPEN** |" in patched
67
68
69 def test_40_open_rows_human_authorship_no_mutation(tmp_path: Path) -> None:
70 config = load_config(FIXTURES / "config-git-only.yaml")
71 lines = [
72 "# Stress",
73 "",
74 "## Build queue",
75 "",
76 "| Phase | Model | Status | Deliverable |",
77 "| --- | --- | --- | --- |",
78 ]
79 for index in range(40):
80 lines.append(f"| **O{index:02d}** | Auto | **TODO** | open {index} |")
81 roadmap = "\n".join(lines) + "\n"
82 row, reason = select_unambiguous_next_row(roadmap)
83 assert row is None
84 assert reason == "multiple_open_rows"
85
86 handover = (FIXTURES / "gs-paste-handover.md").read_text(encoding="utf-8")
87 before_next = handover
88 drift = DriftReport(
89 d1_handover_vs_git="drifted",
90 d2_anchor_vs_canonical="aligned",
91 d3_queue_vs_merged="aligned",
92 )
93 patched, sections, token = build_handover_patches(
94 handover,
95 _reads(),
96 drift,
97 realign_summary=None,
98 sync_date="2026-07-30",
99 config=config,
100 roadmap_text=roadmap,
101 repo_root=tmp_path,
102 )
103 assert "next-session" not in sections
104 assert "paste-ready-prompt" not in sections
105 assert "human_authorship_required" in token
106 # NEXT/paste region bytes (between headings) unchanged relative to pre-run headings.
107 assert "## NEXT SESSION — prior step" in patched
108 assert "Phase GS-PASTE-b — stale prompt." in patched
109 decision = plan_next_regen(
110 roadmap_text=roadmap,
111 handover_text=before_next,
112 config=config,
113 repo_root=tmp_path,
114 )
115 assert decision.row is None
File History 1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199 fix(ISR): default require_independent_second_reviewer to require Human minor 1 day ago