repopact 3.0.1__tar.gz → 3.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of repopact might be problematic. Click here for more details.

Files changed (56) hide show
  1. {repopact-3.0.1/repopact.egg-info → repopact-3.0.2}/PKG-INFO +2 -2
  2. {repopact-3.0.1 → repopact-3.0.2}/README.md +1 -1
  3. repopact-3.0.2/VERSION +1 -0
  4. {repopact-3.0.1 → repopact-3.0.2}/repopact/doctor.py +7 -3
  5. repopact-3.0.2/repopact/repo_model.py +220 -0
  6. {repopact-3.0.1 → repopact-3.0.2/repopact.egg-info}/PKG-INFO +2 -2
  7. {repopact-3.0.1 → repopact-3.0.2}/tests/test_validate_repo.py +163 -6
  8. repopact-3.0.1/VERSION +0 -1
  9. repopact-3.0.1/repopact/repo_model.py +0 -74
  10. {repopact-3.0.1 → repopact-3.0.2}/LICENSE +0 -0
  11. {repopact-3.0.1 → repopact-3.0.2}/MANIFEST.in +0 -0
  12. {repopact-3.0.1 → repopact-3.0.2}/pyproject.toml +0 -0
  13. {repopact-3.0.1 → repopact-3.0.2}/repopact/__init__.py +0 -0
  14. {repopact-3.0.1 → repopact-3.0.2}/repopact/adopt_repo.py +0 -0
  15. {repopact-3.0.1 → repopact-3.0.2}/repopact/check_frozen_surface.py +0 -0
  16. {repopact-3.0.1 → repopact-3.0.2}/repopact/cli.py +0 -0
  17. {repopact-3.0.1 → repopact-3.0.2}/repopact/fleet_verify.py +0 -0
  18. {repopact-3.0.1 → repopact-3.0.2}/repopact/frontmatter.py +0 -0
  19. {repopact-3.0.1 → repopact-3.0.2}/repopact/generate_dashboard.py +0 -0
  20. {repopact-3.0.1 → repopact-3.0.2}/repopact/generate_spec.py +0 -0
  21. {repopact-3.0.1 → repopact-3.0.2}/repopact/init_repo.py +0 -0
  22. {repopact-3.0.1 → repopact-3.0.2}/repopact/new.py +0 -0
  23. {repopact-3.0.1 → repopact-3.0.2}/repopact/package_version.py +0 -0
  24. {repopact-3.0.1 → repopact-3.0.2}/repopact/plan_import.py +0 -0
  25. {repopact-3.0.1 → repopact-3.0.2}/repopact/release_build.py +0 -0
  26. {repopact-3.0.1 → repopact-3.0.2}/repopact/run_conformance.py +0 -0
  27. {repopact-3.0.1 → repopact-3.0.2}/repopact/schemas/adopter-fleet.schema.json +0 -0
  28. {repopact-3.0.1 → repopact-3.0.2}/repopact/schemas/audit-finding.schema.json +0 -0
  29. {repopact-3.0.1 → repopact-3.0.2}/repopact/schemas/conformance-manifest.schema.json +0 -0
  30. {repopact-3.0.1 → repopact-3.0.2}/repopact/schemas/evidence-run.schema.json +0 -0
  31. {repopact-3.0.1 → repopact-3.0.2}/repopact/schemas/frozen-surface.schema.json +0 -0
  32. {repopact-3.0.1 → repopact-3.0.2}/repopact/schemas/invariants.schema.json +0 -0
  33. {repopact-3.0.1 → repopact-3.0.2}/repopact/schemas/record-frontmatter.schema.json +0 -0
  34. {repopact-3.0.1 → repopact-3.0.2}/repopact/schemas/work-item.schema.json +0 -0
  35. {repopact-3.0.1 → repopact-3.0.2}/repopact/takeover.py +0 -0
  36. {repopact-3.0.1 → repopact-3.0.2}/repopact/templates/README.md +0 -0
  37. {repopact-3.0.1 → repopact-3.0.2}/repopact/templates/decision.md +0 -0
  38. {repopact-3.0.1 → repopact-3.0.2}/repopact/templates/evidence-run.json +0 -0
  39. {repopact-3.0.1 → repopact-3.0.2}/repopact/templates/policy.md +0 -0
  40. {repopact-3.0.1 → repopact-3.0.2}/repopact/templates/work-item.README.md +0 -0
  41. {repopact-3.0.1 → repopact-3.0.2}/repopact/templates/work-item.json +0 -0
  42. {repopact-3.0.1 → repopact-3.0.2}/repopact/track_import.py +0 -0
  43. {repopact-3.0.1 → repopact-3.0.2}/repopact/validate_repo.py +0 -0
  44. {repopact-3.0.1 → repopact-3.0.2}/repopact/validate_research.py +0 -0
  45. {repopact-3.0.1 → repopact-3.0.2}/repopact.egg-info/SOURCES.txt +0 -0
  46. {repopact-3.0.1 → repopact-3.0.2}/repopact.egg-info/dependency_links.txt +0 -0
  47. {repopact-3.0.1 → repopact-3.0.2}/repopact.egg-info/entry_points.txt +0 -0
  48. {repopact-3.0.1 → repopact-3.0.2}/repopact.egg-info/requires.txt +0 -0
  49. {repopact-3.0.1 → repopact-3.0.2}/repopact.egg-info/top_level.txt +0 -0
  50. {repopact-3.0.1 → repopact-3.0.2}/setup.cfg +0 -0
  51. {repopact-3.0.1 → repopact-3.0.2}/tests/test_conformance.py +0 -0
  52. {repopact-3.0.1 → repopact-3.0.2}/tests/test_fleet_verify.py +0 -0
  53. {repopact-3.0.1 → repopact-3.0.2}/tests/test_plan_import_links.py +0 -0
  54. {repopact-3.0.1 → repopact-3.0.2}/tests/test_release_build.py +0 -0
  55. {repopact-3.0.1 → repopact-3.0.2}/tests/test_research_metadata.py +0 -0
  56. {repopact-3.0.1 → repopact-3.0.2}/tests/test_takeover_refs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repopact
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Summary: A repository-native standard for durable agent work: binding invariants, evidence-gated work items, and drift audits.
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Homepage, https://github.com/ForgeWireLabs/repopact
@@ -26,7 +26,7 @@ cannot be silently weakened.
26
26
  > The repository is the pact: authority, intent, evidence, and history that survive every
27
27
  > session.
28
28
 
29
- `pip install repopact` · Apache-2.0 · current release **3.0.1** ([changelog](decisions/0033-release-repopact-3-0-1.md)).
29
+ `pip install repopact` · Apache-2.0 · current release **3.0.2** ([changelog](decisions/0036-release-repopact-3-0-2.md)).
30
30
 
31
31
  ## How it relates to `AGENTS.md`
32
32
 
@@ -9,7 +9,7 @@ cannot be silently weakened.
9
9
  > The repository is the pact: authority, intent, evidence, and history that survive every
10
10
  > session.
11
11
 
12
- `pip install repopact` · Apache-2.0 · current release **3.0.1** ([changelog](decisions/0033-release-repopact-3-0-1.md)).
12
+ `pip install repopact` · Apache-2.0 · current release **3.0.2** ([changelog](decisions/0036-release-repopact-3-0-2.md)).
13
13
 
14
14
  ## How it relates to `AGENTS.md`
15
15
 
repopact-3.0.2/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.0.2
@@ -129,8 +129,8 @@ def _dead_source_of_truth(root: Path) -> list[Finding]:
129
129
  positives. Not auto-fixed: the correct target needs judgment.
130
130
  """
131
131
  out: list[Finding] = []
132
- patterns = ("work/**/*.md", "decisions/*.md", "governance/**/*.md",
133
- "audits/**/*.md", "*.md")
132
+ patterns = ("work/**/*.md", "decisions/**/*.md", "governance/**/*.md",
133
+ "audits/**/*.md", "research/**/*.md", "docs/**/*.md", "*.md")
134
134
  seen: set[Path] = set()
135
135
  for pattern in patterns:
136
136
  for path in sorted(root.glob(pattern)):
@@ -152,7 +152,11 @@ def _dead_source_of_truth(root: Path) -> list[Finding]:
152
152
  value = stripped.split(":", 1)[1].strip()
153
153
  for token in (t.strip() for t in value.split(";")):
154
154
  looks_like_path = "/" in token or token.endswith((".md", ".json"))
155
- if token and " " not in token and looks_like_path and not (root / token).exists():
155
+ # Front-matter paths follow the same rule as Markdown links:
156
+ # resolve every token from the declaring record's directory.
157
+ # In particular, a bare name is not implicitly root-relative.
158
+ target = path.parent / token
159
+ if token and " " not in token and looks_like_path and not target.resolve().exists():
156
160
  rel = str(path.relative_to(root)).replace("\\", "/")
157
161
  out.append(Finding("warn", "source-of-truth-stale",
158
162
  f"{rel}: source_of_truth points at missing path '{token}'", False))
@@ -0,0 +1,220 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ import subprocess
6
+ from dataclasses import dataclass
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+
11
+ STATUSES = ("proposed", "active", "blocked", "deferred", "completed")
12
+
13
+ # Directories that are not part of the governed tree: tooling caches, test
14
+ # fixtures (self-contained sub-repositories validated on their own), and
15
+ # `worktrees` -- the conventional directory name agent tooling uses for a
16
+ # scratch checkout. The name remains a compatibility/performance fallback for
17
+ # stale or orphaned scratch trees whose Git metadata is gone; live linked
18
+ # worktrees are identified structurally by discover_embedded_worktree_roots.
19
+ IGNORED_PARTS = {
20
+ ".git", "__pycache__", "node_modules", ".venv", ".pytest_cache",
21
+ "build", "dist", "fixtures", "worktrees",
22
+ }
23
+
24
+
25
+ def _resolved(path: Path) -> Path:
26
+ """Resolve a path without requiring it to exist, with a safe fallback."""
27
+ try:
28
+ return path.resolve()
29
+ except (OSError, RuntimeError):
30
+ return Path(os.path.abspath(path))
31
+
32
+
33
+ def _is_descendant(path: Path, ancestor: Path) -> bool:
34
+ """Return whether ``path`` is strictly below ``ancestor``."""
35
+ try:
36
+ path.relative_to(ancestor)
37
+ except ValueError:
38
+ return False
39
+ return path != ancestor
40
+
41
+
42
+ def _gitdir_from_entry(entry: Path) -> Path | None:
43
+ """Read a Git directory from either a normal directory or linked-worktree file."""
44
+ if entry.is_dir():
45
+ return _resolved(entry)
46
+ if not entry.is_file():
47
+ return None
48
+ try:
49
+ first = entry.read_text(encoding="utf-8").splitlines()[0].strip()
50
+ except (OSError, IndexError, UnicodeDecodeError):
51
+ return None
52
+ if not first.lower().startswith("gitdir:"):
53
+ return None
54
+ target = Path(first.split(":", 1)[1].strip())
55
+ if not target.is_absolute():
56
+ target = entry.parent / target
57
+ return _resolved(target)
58
+
59
+
60
+ def _git_common_dir(root: Path) -> Path | None:
61
+ """Find the primary repository's common Git directory when metadata permits."""
62
+ entry = root / ".git"
63
+ direct = _gitdir_from_entry(entry)
64
+ if direct is not None:
65
+ # A linked checkout's .git file points at <common>/.git/worktrees/<name>.
66
+ if direct.parent.name.lower() == "worktrees":
67
+ return direct.parent.parent
68
+ return direct
69
+ if not entry.exists():
70
+ return None
71
+ try:
72
+ result = subprocess.run(
73
+ ["git", "-C", str(root), "rev-parse", "--git-common-dir"],
74
+ capture_output=True,
75
+ text=True,
76
+ check=False,
77
+ )
78
+ except OSError:
79
+ return None
80
+ if result.returncode != 0 or not result.stdout.strip():
81
+ return None
82
+ common = Path(result.stdout.strip())
83
+ if not common.is_absolute():
84
+ common = root / common
85
+ return _resolved(common)
86
+
87
+
88
+ def _registered_worktree_roots(root: Path) -> set[Path]:
89
+ """Return registered same-repository worktrees below ``root`` when Git is usable."""
90
+ if not (root / ".git").exists():
91
+ return set()
92
+ try:
93
+ result = subprocess.run(
94
+ ["git", "-C", str(root), "worktree", "list", "--porcelain"],
95
+ capture_output=True,
96
+ text=True,
97
+ check=False,
98
+ )
99
+ except OSError:
100
+ return set()
101
+ if result.returncode != 0:
102
+ return set()
103
+ roots: set[Path] = set()
104
+ root_abs = _resolved(root)
105
+ for line in result.stdout.splitlines():
106
+ if not line.startswith("worktree "):
107
+ continue
108
+ candidate = Path(line[len("worktree "):])
109
+ if not candidate.is_absolute():
110
+ candidate = root_abs / candidate
111
+ candidate = _resolved(candidate)
112
+ if _is_descendant(candidate, root_abs):
113
+ roots.add(candidate)
114
+ return roots
115
+
116
+
117
+ def discover_embedded_worktree_roots(root: Path) -> set[Path]:
118
+ """Find linked worktree checkout roots nested below a RepoPact scan root.
119
+
120
+ Git's porcelain registry catches live worktrees even when their embedded
121
+ metadata is unusual. The filesystem pass catches stale-but-identifiable
122
+ linked checkouts whose ``.git`` file still points into the primary
123
+ ``.git/worktrees`` directory. Independent nested repositories have a
124
+ ``.git`` directory and are intentionally not returned.
125
+ """
126
+ root_abs = _resolved(root)
127
+ if not (root_abs / ".git").exists():
128
+ return set()
129
+ linked = _registered_worktree_roots(root_abs)
130
+ common = _git_common_dir(root_abs)
131
+ worktrees_dir = common / "worktrees" if common is not None else None
132
+
133
+ if worktrees_dir is not None:
134
+ for current, directories, files in os.walk(root_abs, topdown=True, followlinks=False):
135
+ current_path = _resolved(Path(current))
136
+ if current_path != root_abs and any(
137
+ current_path == known or _is_descendant(current_path, known) for known in linked
138
+ ):
139
+ directories[:] = []
140
+ continue
141
+ directories[:] = sorted(
142
+ name for name in directories if name not in IGNORED_PARTS
143
+ )
144
+ if ".git" not in files or current_path == root_abs:
145
+ continue
146
+ git_dir = _gitdir_from_entry(Path(current) / ".git")
147
+ if git_dir is not None and (
148
+ git_dir == worktrees_dir or _is_descendant(git_dir, worktrees_dir)
149
+ ):
150
+ linked.add(current_path)
151
+ directories[:] = []
152
+ return linked
153
+
154
+
155
+ def iter_contracts(root: Path) -> list[Path]:
156
+ """All AGENTS.md under root, excluding ignored and linked-worktree subtrees."""
157
+ root_abs = _resolved(root)
158
+ linked = discover_embedded_worktree_roots(root_abs)
159
+ result: list[Path] = []
160
+ for current, directories, files in os.walk(root_abs, topdown=True, followlinks=False):
161
+ current_abs = _resolved(Path(current))
162
+ if current_abs != root_abs and any(
163
+ current_abs == known or _is_descendant(current_abs, known) for known in linked
164
+ ):
165
+ directories[:] = []
166
+ continue
167
+ directories[:] = sorted(
168
+ name for name in directories
169
+ if name not in IGNORED_PARTS
170
+ and not any(
171
+ _resolved(Path(current) / name) == known
172
+ or _is_descendant(_resolved(Path(current) / name), known)
173
+ for known in linked
174
+ )
175
+ )
176
+ if "AGENTS.md" not in files:
177
+ continue
178
+ relative = current_abs.relative_to(root_abs)
179
+ result.append(root / relative / "AGENTS.md")
180
+ return sorted(result)
181
+
182
+
183
+ @dataclass(frozen=True)
184
+ class WorkItem:
185
+ directory: Path
186
+ data: dict[str, Any]
187
+
188
+ @property
189
+ def item_id(self) -> str:
190
+ return str(self.data.get("id", ""))
191
+
192
+ @property
193
+ def status(self) -> str:
194
+ return str(self.data.get("status", ""))
195
+
196
+
197
+ def load_json(path: Path) -> dict[str, Any]:
198
+ with path.open(encoding="utf-8") as handle:
199
+ value = json.load(handle)
200
+ if not isinstance(value, dict):
201
+ raise ValueError(f"expected a JSON object: {path}")
202
+ return value
203
+
204
+
205
+ def discover_work_items(root: Path) -> list[WorkItem]:
206
+ items: list[WorkItem] = []
207
+ for status in STATUSES:
208
+ status_dir = root / "work" / status
209
+ if not status_dir.exists():
210
+ continue
211
+ for manifest in sorted(status_dir.glob("*/work-item.json")):
212
+ items.append(WorkItem(manifest.parent, load_json(manifest)))
213
+ return items
214
+
215
+
216
+ def discover_evidence_ids(root: Path) -> set[str]:
217
+ result: set[str] = set()
218
+ for path in sorted((root / "evidence" / "runs").glob("*.json")):
219
+ result.add(str(load_json(path).get("id", "")))
220
+ return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repopact
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Summary: A repository-native standard for durable agent work: binding invariants, evidence-gated work items, and drift audits.
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Homepage, https://github.com/ForgeWireLabs/repopact
@@ -26,7 +26,7 @@ cannot be silently weakened.
26
26
  > The repository is the pact: authority, intent, evidence, and history that survive every
27
27
  > session.
28
28
 
29
- `pip install repopact` · Apache-2.0 · current release **3.0.1** ([changelog](decisions/0033-release-repopact-3-0-1.md)).
29
+ `pip install repopact` · Apache-2.0 · current release **3.0.2** ([changelog](decisions/0036-release-repopact-3-0-2.md)).
30
30
 
31
31
  ## How it relates to `AGENTS.md`
32
32
 
@@ -22,6 +22,7 @@ from repopact import ( # noqa: E402
22
22
  generate_spec,
23
23
  init_repo,
24
24
  plan_import,
25
+ repo_model,
25
26
  takeover,
26
27
  validate_repo,
27
28
  )
@@ -266,6 +267,108 @@ class RepositoryValidationTests(unittest.TestCase):
266
267
  (worktree / "AGENTS.md").write_text("# from a scratch worktree checkout\n", encoding="utf-8")
267
268
  self.assertFalse(any("not registered in audits/registry.json" in v for v in self.problems()))
268
269
 
270
+ def _seed_git_repo(self, name: str = "git-root") -> Path:
271
+ repo = Path(self.temp.name) / name
272
+ init_repo.bootstrap(repo)
273
+ run = lambda *args: subprocess.run(
274
+ ["git", *args], cwd=repo, check=True, capture_output=True, text=True
275
+ )
276
+ run("init", "--initial-branch=main")
277
+ run("config", "user.email", "test@example.invalid")
278
+ run("config", "user.name", "RepoPact Test")
279
+ run("add", "-A")
280
+ run("commit", "-m", "seed")
281
+ return repo
282
+
283
+ def test_nonconventional_linked_worktree_is_structurally_excluded(self) -> None:
284
+ repo = self._seed_git_repo("linked-worktree")
285
+ worktree = repo / "scratch agent" / "feature x"
286
+ try:
287
+ subprocess.run(
288
+ ["git", "worktree", "add", "--detach", str(worktree), "HEAD"],
289
+ cwd=repo, check=True, capture_output=True, text=True,
290
+ )
291
+ contract = worktree / "AGENTS.md"
292
+ self.assertTrue((worktree / ".git").is_file())
293
+ self.assertIn(worktree.resolve(), repo_model.discover_embedded_worktree_roots(repo))
294
+ self.assertNotIn(contract, repo_model.iter_contracts(repo))
295
+ self.assertEqual([], [p.message for p in validate(repo)])
296
+ finally:
297
+ subprocess.run(
298
+ ["git", "worktree", "remove", "--force", str(worktree)],
299
+ cwd=repo, check=True, capture_output=True, text=True,
300
+ )
301
+ subprocess.run(["git", "worktree", "prune"], cwd=repo, check=True,
302
+ capture_output=True, text=True)
303
+
304
+ def test_conventional_forgewire_worktree_is_excluded(self) -> None:
305
+ repo = self._seed_git_repo("conventional-worktree")
306
+ worktree = repo / ".claude" / "worktrees" / "wi238-regression-test"
307
+ try:
308
+ subprocess.run(
309
+ ["git", "worktree", "add", "--detach", str(worktree), "HEAD"],
310
+ cwd=repo, check=True, capture_output=True, text=True,
311
+ )
312
+ self.assertNotIn(worktree / "AGENTS.md", repo_model.iter_contracts(repo))
313
+ self.assertEqual([], [p.message for p in validate(repo)])
314
+ finally:
315
+ subprocess.run(
316
+ ["git", "worktree", "remove", "--force", str(worktree)],
317
+ cwd=repo, check=True, capture_output=True, text=True,
318
+ )
319
+ subprocess.run(["git", "worktree", "prune"], cwd=repo, check=True,
320
+ capture_output=True, text=True)
321
+
322
+ def test_stale_linked_worktree_git_file_is_excluded_without_git_registry(self) -> None:
323
+ repo = self._seed_git_repo("stale-linked-worktree")
324
+ orphan = repo / "scratch-agent" / "orphan"
325
+ orphan.mkdir(parents=True)
326
+ (orphan / ".git").write_text(
327
+ f"gitdir: {repo / '.git' / 'worktrees' / 'orphan'}\n", encoding="utf-8"
328
+ )
329
+ (orphan / "AGENTS.md").write_text("# stale linked checkout\n", encoding="utf-8")
330
+ self.assertNotIn(orphan / "AGENTS.md", repo_model.iter_contracts(repo))
331
+
332
+ def test_independent_nested_repository_contract_remains_discoverable(self) -> None:
333
+ repo = self._seed_git_repo("nested-repository")
334
+ nested = repo / "vendor" / "component"
335
+ nested.mkdir(parents=True)
336
+ (nested / "AGENTS.md").write_text("# independent component\n", encoding="utf-8")
337
+ subprocess.run(["git", "init", "-q", str(nested)], check=True,
338
+ capture_output=True, text=True)
339
+ registry = json.loads((repo / "audits" / "registry.json").read_text(encoding="utf-8"))
340
+ registry["scopes"].append({
341
+ "path": "vendor/component", "owner": "governance-owner",
342
+ "contract": "vendor/component/AGENTS.md", "last_reviewed": "2026-09-02",
343
+ "next_review": "2026-12-01", "alignment": "current",
344
+ "notes": "Independent nested repository contract.",
345
+ })
346
+ (repo / "audits" / "registry.json").write_text(
347
+ json.dumps(registry, indent=2) + "\n", encoding="utf-8"
348
+ )
349
+ (nested / "_audit").mkdir()
350
+ for name in ("README.md", "inventory.md", "alignment-report.md"):
351
+ (nested / "_audit" / name).write_text(f"# {name}\n", encoding="utf-8")
352
+ generate_dashboard.write_dashboard(repo)
353
+ self.assertNotIn(nested.resolve(), repo_model.discover_embedded_worktree_roots(repo))
354
+ self.assertIn(nested / "AGENTS.md", repo_model.iter_contracts(repo))
355
+ self.assertEqual([], [p.message for p in validate(repo)])
356
+
357
+ def test_exported_tree_discovery_has_no_git_dependency(self) -> None:
358
+ repo = Path(self.temp.name) / "exported-tree"
359
+ init_repo.bootstrap(repo)
360
+ nested = repo / "governed" / "component"
361
+ nested.mkdir(parents=True)
362
+ (nested / "AGENTS.md").write_text("# governed component\n", encoding="utf-8")
363
+ fake = repo / "worktree" / "name"
364
+ fake.mkdir(parents=True)
365
+ (fake / "AGENTS.md").write_text("# ordinary governed path\n", encoding="utf-8")
366
+ first = repo_model.iter_contracts(repo)
367
+ second = repo_model.iter_contracts(repo)
368
+ self.assertEqual(first, second)
369
+ self.assertIn(nested / "AGENTS.md", first)
370
+ self.assertIn(fake / "AGENTS.md", first)
371
+
269
372
  def test_existing_audit_companion_must_be_complete(self) -> None:
270
373
  (self.root / "repopact" / "_audit" / "inventory.md").unlink()
271
374
  self.assertTrue(any("incomplete _audit companion" in v for v in self.problems()))
@@ -505,6 +608,12 @@ class RepositoryValidationTests(unittest.TestCase):
505
608
 
506
609
  def _tag_identity_fixture(self) -> None:
507
610
  self.root.joinpath("VERSION").write_text("9.9.9\n", encoding="utf-8")
611
+ # The source checkout carries the post-release development label for
612
+ # 3.0.2. A synthetic stable v9.9.9 fixture must model an unlabeled
613
+ # release tree before testing later source identity changes.
614
+ label = self.root / "RELEASE_LABEL"
615
+ if label.exists():
616
+ label.unlink()
508
617
  readme = self.root / "README.md"
509
618
  text = readme.read_text(encoding="utf-8")
510
619
  start = text.index("`pip install repopact`")
@@ -559,19 +668,19 @@ class RepositoryValidationTests(unittest.TestCase):
559
668
 
560
669
  def test_readme_release_changelog_link_must_name_current_release(self) -> None:
561
670
  self.set_readme_release(
562
- "current release **3.0.1** "
671
+ "current release **3.0.2** "
563
672
  "([changelog](decisions/0025-release-2.2.0-dashboard-integrity.md))."
564
673
  )
565
674
  self.assertTrue(any("does not name the current release" in v for v in self.problems()))
566
675
 
567
676
  def test_readme_release_changelog_link_must_resolve(self) -> None:
568
677
  self.set_readme_release(
569
- "current release **3.0.1** ([changelog](decisions/9999-nonexistent.md))."
678
+ "current release **3.0.2** ([changelog](decisions/9999-nonexistent.md))."
570
679
  )
571
680
  self.assertTrue(any("does not resolve" in v for v in self.problems()))
572
681
 
573
682
  def test_readme_release_line_without_link_is_accepted(self) -> None:
574
- self.set_readme_release("current release **3.0.1**.")
683
+ self.set_readme_release("current release **3.0.2**.")
575
684
  self.assertEqual([], self.problems())
576
685
 
577
686
  def test_readme_without_release_line_is_unaffected(self) -> None:
@@ -582,13 +691,13 @@ class RepositoryValidationTests(unittest.TestCase):
582
691
 
583
692
  def test_readme_release_link_may_be_an_external_url(self) -> None:
584
693
  self.set_readme_release(
585
- "current release **3.0.1** ([changelog](https://example.invalid/changelog))."
694
+ "current release **3.0.2** ([changelog](https://example.invalid/changelog))."
586
695
  )
587
696
  self.assertEqual([], self.problems())
588
697
 
589
698
  def test_readme_release_link_outside_decisions_is_existence_checked_only(self) -> None:
590
699
  (self.root / "CHANGELOG.md").write_text("# Changelog\n", encoding="utf-8")
591
- self.set_readme_release("current release **3.0.1** ([changelog](CHANGELOG.md)).")
700
+ self.set_readme_release("current release **3.0.2** ([changelog](CHANGELOG.md)).")
592
701
  self.assertEqual([], self.problems())
593
702
 
594
703
  # --- dependency cycles --------------------------------------------------
@@ -1073,7 +1182,55 @@ class RepositoryValidationTests(unittest.TestCase):
1073
1182
  findings = doctor._dead_source_of_truth(self.root)
1074
1183
  msgs = [f.message for f in findings]
1075
1184
  self.assertTrue(any("docs/gone.md" in m for m in msgs))
1076
- self.assertFalse(any("AGENTS.md" in m for m in msgs))
1185
+ # Bare tokens are record-relative too: decisions/AGENTS.md is absent,
1186
+ # even though the bootstrap contract exists at the repository root.
1187
+ self.assertTrue(any("AGENTS.md" in m for m in msgs))
1188
+
1189
+ def test_doctor_accepts_nested_parent_relative_source_of_truth(self) -> None:
1190
+ record = self.root / "work" / "active" / "some" / "nested" / "record.md"
1191
+ target = self.root / "work" / "active" / "some" / "sibling" / "real-record.md"
1192
+ record.parent.mkdir(parents=True)
1193
+ target.parent.mkdir(parents=True)
1194
+ target.write_text("# real record\n", encoding="utf-8")
1195
+ record.write_text(
1196
+ "---\nid: nested\ntitle: Nested\nstatus: active\n"
1197
+ "source_of_truth: ../sibling/real-record.md\n---\n",
1198
+ encoding="utf-8")
1199
+ self.assertEqual([], doctor._dead_source_of_truth(self.root))
1200
+
1201
+ def test_doctor_accepts_bare_record_relative_source_of_truth(self) -> None:
1202
+ record = self.root / "decisions" / "probe.md"
1203
+ target = self.root / "decisions" / "sibling.md"
1204
+ target.write_text("# sibling\n", encoding="utf-8")
1205
+ record.write_text(
1206
+ "---\nid: probe\ntitle: Probe\nstatus: accepted\ndate: 2026-06-17\n"
1207
+ "source_of_truth: sibling.md\n---\n",
1208
+ encoding="utf-8")
1209
+ self.assertEqual([], doctor._dead_source_of_truth(self.root))
1210
+
1211
+ def test_doctor_bare_token_does_not_fall_back_to_root_coincidence(self) -> None:
1212
+ record = self.root / "decisions" / "probe.md"
1213
+ record.write_text(
1214
+ "---\nid: probe\ntitle: Probe\nstatus: accepted\ndate: 2026-06-17\n"
1215
+ "source_of_truth: sibling.md\n---\n",
1216
+ encoding="utf-8")
1217
+ (self.root / "sibling.md").write_text("# root coincidence\n", encoding="utf-8")
1218
+ findings = doctor._dead_source_of_truth(self.root)
1219
+ self.assertEqual(1, len(findings))
1220
+ self.assertIn("decisions/probe.md", findings[0].message)
1221
+ self.assertIn("sibling.md", findings[0].message)
1222
+
1223
+ def test_doctor_source_of_truth_fix_is_non_destructive(self) -> None:
1224
+ record = self.root / "decisions" / "probe.md"
1225
+ original = (
1226
+ "---\nid: probe\ntitle: Probe\nstatus: accepted\ndate: 2026-06-17\n"
1227
+ "source_of_truth: missing.md\n---\n"
1228
+ )
1229
+ record.write_text(original, encoding="utf-8")
1230
+ actions = doctor.fix(self.root)
1231
+ self.assertEqual(original, record.read_text(encoding="utf-8"))
1232
+ self.assertFalse(any("source_of_truth" in action for action in actions))
1233
+ self.assertTrue(any(f.code == "source-of-truth-stale" for f in doctor.diagnose(self.root)))
1077
1234
 
1078
1235
  def test_import_plan_section_roadmap_without_checkboxes(self) -> None:
1079
1236
  repo = Path(self.temp.name) / "roadmapped"
repopact-3.0.1/VERSION DELETED
@@ -1 +0,0 @@
1
- 3.0.1
@@ -1,74 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import json
4
- from dataclasses import dataclass
5
- from pathlib import Path
6
- from typing import Any
7
-
8
-
9
- STATUSES = ("proposed", "active", "blocked", "deferred", "completed")
10
-
11
- # Directories that are not part of the governed tree: tooling caches, test
12
- # fixtures (self-contained sub-repositories validated on their own), and
13
- # `worktrees` -- the conventional directory name agent tooling (Claude Code's
14
- # Agent isolation, Codex, etc.) uses for a scratch `git worktree` checkout.
15
- # A worktree is a second working copy of the SAME repository; its own
16
- # AGENTS.md files are already governed at their origin and must not be
17
- # re-validated as if they were a nested subtree of this checkout, and a
18
- # worktree can outlive the session that created it (left on disk after an
19
- # agent's task completes) with no reliable, portable signal other than its
20
- # name to distinguish it from a real nested contract.
21
- IGNORED_PARTS = {
22
- ".git", "__pycache__", "node_modules", ".venv", ".pytest_cache",
23
- "build", "dist", "fixtures", "worktrees",
24
- }
25
-
26
-
27
- def iter_contracts(root: Path) -> list[Path]:
28
- """All AGENTS.md under root, excluding ignored subtrees (relative to root)."""
29
- result: list[Path] = []
30
- for path in sorted(root.rglob("AGENTS.md")):
31
- if any(part in IGNORED_PARTS for part in path.relative_to(root).parts):
32
- continue
33
- result.append(path)
34
- return result
35
-
36
-
37
- @dataclass(frozen=True)
38
- class WorkItem:
39
- directory: Path
40
- data: dict[str, Any]
41
-
42
- @property
43
- def item_id(self) -> str:
44
- return str(self.data.get("id", ""))
45
-
46
- @property
47
- def status(self) -> str:
48
- return str(self.data.get("status", ""))
49
-
50
-
51
- def load_json(path: Path) -> dict[str, Any]:
52
- with path.open(encoding="utf-8") as handle:
53
- value = json.load(handle)
54
- if not isinstance(value, dict):
55
- raise ValueError(f"expected a JSON object: {path}")
56
- return value
57
-
58
-
59
- def discover_work_items(root: Path) -> list[WorkItem]:
60
- items: list[WorkItem] = []
61
- for status in STATUSES:
62
- status_dir = root / "work" / status
63
- if not status_dir.exists():
64
- continue
65
- for manifest in sorted(status_dir.glob("*/work-item.json")):
66
- items.append(WorkItem(manifest.parent, load_json(manifest)))
67
- return items
68
-
69
-
70
- def discover_evidence_ids(root: Path) -> set[str]:
71
- result: set[str] = set()
72
- for path in sorted((root / "evidence" / "runs").glob("*.json")):
73
- result.add(str(load_json(path).get("id", "")))
74
- return result
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes