repopact 3.0.0__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.2/MANIFEST.in +2 -0
  2. {repopact-3.0.0 → repopact-3.0.2}/PKG-INFO +2 -3
  3. {repopact-3.0.0 → repopact-3.0.2}/README.md +1 -2
  4. repopact-3.0.2/VERSION +1 -0
  5. {repopact-3.0.0 → repopact-3.0.2}/pyproject.toml +1 -1
  6. {repopact-3.0.0 → repopact-3.0.2}/repopact/__init__.py +4 -2
  7. {repopact-3.0.0 → repopact-3.0.2}/repopact/doctor.py +7 -3
  8. repopact-3.0.2/repopact/package_version.py +68 -0
  9. {repopact-3.0.0 → repopact-3.0.2}/repopact/release_build.py +7 -2
  10. repopact-3.0.2/repopact/repo_model.py +220 -0
  11. {repopact-3.0.0 → repopact-3.0.2}/repopact/validate_repo.py +74 -9
  12. {repopact-3.0.0 → repopact-3.0.2}/repopact.egg-info/PKG-INFO +2 -3
  13. {repopact-3.0.0 → repopact-3.0.2}/repopact.egg-info/SOURCES.txt +2 -0
  14. {repopact-3.0.0 → repopact-3.0.2}/tests/test_release_build.py +12 -6
  15. {repopact-3.0.0 → repopact-3.0.2}/tests/test_research_metadata.py +4 -4
  16. {repopact-3.0.0 → repopact-3.0.2}/tests/test_validate_repo.py +252 -8
  17. repopact-3.0.0/VERSION +0 -1
  18. repopact-3.0.0/repopact/repo_model.py +0 -66
  19. {repopact-3.0.0 → repopact-3.0.2}/LICENSE +0 -0
  20. {repopact-3.0.0 → repopact-3.0.2}/repopact/adopt_repo.py +0 -0
  21. {repopact-3.0.0 → repopact-3.0.2}/repopact/check_frozen_surface.py +0 -0
  22. {repopact-3.0.0 → repopact-3.0.2}/repopact/cli.py +0 -0
  23. {repopact-3.0.0 → repopact-3.0.2}/repopact/fleet_verify.py +0 -0
  24. {repopact-3.0.0 → repopact-3.0.2}/repopact/frontmatter.py +0 -0
  25. {repopact-3.0.0 → repopact-3.0.2}/repopact/generate_dashboard.py +0 -0
  26. {repopact-3.0.0 → repopact-3.0.2}/repopact/generate_spec.py +0 -0
  27. {repopact-3.0.0 → repopact-3.0.2}/repopact/init_repo.py +0 -0
  28. {repopact-3.0.0 → repopact-3.0.2}/repopact/new.py +0 -0
  29. {repopact-3.0.0 → repopact-3.0.2}/repopact/plan_import.py +0 -0
  30. {repopact-3.0.0 → repopact-3.0.2}/repopact/run_conformance.py +0 -0
  31. {repopact-3.0.0 → repopact-3.0.2}/repopact/schemas/adopter-fleet.schema.json +0 -0
  32. {repopact-3.0.0 → repopact-3.0.2}/repopact/schemas/audit-finding.schema.json +0 -0
  33. {repopact-3.0.0 → repopact-3.0.2}/repopact/schemas/conformance-manifest.schema.json +0 -0
  34. {repopact-3.0.0 → repopact-3.0.2}/repopact/schemas/evidence-run.schema.json +0 -0
  35. {repopact-3.0.0 → repopact-3.0.2}/repopact/schemas/frozen-surface.schema.json +0 -0
  36. {repopact-3.0.0 → repopact-3.0.2}/repopact/schemas/invariants.schema.json +0 -0
  37. {repopact-3.0.0 → repopact-3.0.2}/repopact/schemas/record-frontmatter.schema.json +0 -0
  38. {repopact-3.0.0 → repopact-3.0.2}/repopact/schemas/work-item.schema.json +0 -0
  39. {repopact-3.0.0 → repopact-3.0.2}/repopact/takeover.py +0 -0
  40. {repopact-3.0.0 → repopact-3.0.2}/repopact/templates/README.md +0 -0
  41. {repopact-3.0.0 → repopact-3.0.2}/repopact/templates/decision.md +0 -0
  42. {repopact-3.0.0 → repopact-3.0.2}/repopact/templates/evidence-run.json +0 -0
  43. {repopact-3.0.0 → repopact-3.0.2}/repopact/templates/policy.md +0 -0
  44. {repopact-3.0.0 → repopact-3.0.2}/repopact/templates/work-item.README.md +0 -0
  45. {repopact-3.0.0 → repopact-3.0.2}/repopact/templates/work-item.json +0 -0
  46. {repopact-3.0.0 → repopact-3.0.2}/repopact/track_import.py +0 -0
  47. {repopact-3.0.0 → repopact-3.0.2}/repopact/validate_research.py +0 -0
  48. {repopact-3.0.0 → repopact-3.0.2}/repopact.egg-info/dependency_links.txt +0 -0
  49. {repopact-3.0.0 → repopact-3.0.2}/repopact.egg-info/entry_points.txt +0 -0
  50. {repopact-3.0.0 → repopact-3.0.2}/repopact.egg-info/requires.txt +0 -0
  51. {repopact-3.0.0 → repopact-3.0.2}/repopact.egg-info/top_level.txt +0 -0
  52. {repopact-3.0.0 → repopact-3.0.2}/setup.cfg +0 -0
  53. {repopact-3.0.0 → repopact-3.0.2}/tests/test_conformance.py +0 -0
  54. {repopact-3.0.0 → repopact-3.0.2}/tests/test_fleet_verify.py +0 -0
  55. {repopact-3.0.0 → repopact-3.0.2}/tests/test_plan_import_links.py +0 -0
  56. {repopact-3.0.0 → repopact-3.0.2}/tests/test_takeover_refs.py +0 -0
@@ -0,0 +1,2 @@
1
+ include VERSION
2
+ include RELEASE_LABEL
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repopact
3
- Version: 3.0.0
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,8 +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.0**
30
- ([changelog](decisions/0030-release-repopact-3-0-0-package-boundary.md)).
29
+ `pip install repopact` · Apache-2.0 · current release **3.0.2** ([changelog](decisions/0036-release-repopact-3-0-2.md)).
31
30
 
32
31
  ## How it relates to `AGENTS.md`
33
32
 
@@ -9,8 +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.0**
13
- ([changelog](decisions/0030-release-repopact-3-0-0-package-boundary.md)).
12
+ `pip install repopact` · Apache-2.0 · current release **3.0.2** ([changelog](decisions/0036-release-repopact-3-0-2.md)).
14
13
 
15
14
  ## How it relates to `AGENTS.md`
16
15
 
repopact-3.0.2/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.0.2
@@ -33,4 +33,4 @@ include-package-data = false
33
33
  repopact = ["schemas/*.json", "templates/*"]
34
34
 
35
35
  [tool.setuptools.dynamic]
36
- version = { file = "VERSION" }
36
+ version = { attr = "repopact.package_version.__version__" }
@@ -21,9 +21,11 @@ def _version() -> str:
21
21
  distribution metadata.
22
22
  """
23
23
  from pathlib import Path
24
- candidate = Path(__file__).resolve().parent.parent / "VERSION"
24
+ root = Path(__file__).resolve().parent.parent
25
+ candidate = root / "VERSION"
25
26
  if candidate.is_file():
26
- return candidate.read_text(encoding="utf-8").strip()
27
+ from .package_version import package_version
28
+ return package_version(root)
27
29
  from importlib.metadata import PackageNotFoundError, version
28
30
  try:
29
31
  return version("repopact")
@@ -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,68 @@
1
+ """Derive distribution identity without weakening the VERSION compatibility core."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from pathlib import Path
7
+
8
+
9
+ SEMVER_IDENT = r"(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)"
10
+ RELEASE_LABEL_RE = re.compile(
11
+ rf"(?P<base>[0-9]+\.[0-9]+\.[0-9]+)"
12
+ rf"-(?P<prerelease>{SEMVER_IDENT}(?:\.{SEMVER_IDENT})*)"
13
+ rf"(?:\+(?P<build>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?"
14
+ )
15
+
16
+
17
+ class PackageVersionError(ValueError):
18
+ """Raised when governed source identity cannot form package metadata."""
19
+
20
+
21
+ def semver_label_to_pep440(label: str) -> str:
22
+ """Map a valid RepoPact SemVer pre-release identity deterministically to PEP 440.
23
+
24
+ Conventional alpha/beta/rc/dev labels stay readable. Other legal SemVer
25
+ pre-releases use a lossless hexadecimal local segment so setuptools never gets
26
+ to apply an incidental, potentially ambiguous normalization.
27
+ """
28
+ match = RELEASE_LABEL_RE.fullmatch(label)
29
+ if not match:
30
+ raise PackageVersionError(f"invalid SemVer RELEASE_LABEL: {label!r}")
31
+ base = match.group("base")
32
+ prerelease = match.group("prerelease")
33
+ build = match.group("build")
34
+ conventional = re.fullmatch(r"(?P<kind>alpha|a|beta|b|rc|dev)\.(?P<num>0|[1-9][0-9]*)", prerelease)
35
+ if conventional:
36
+ kind = {"alpha": "a", "a": "a", "beta": "b", "b": "b", "rc": "rc", "dev": "dev"}[
37
+ conventional.group("kind")
38
+ ]
39
+ rendered = f"{base}{kind}{conventional.group('num')}"
40
+ if build:
41
+ rendered += "+" + build.replace("-", ".")
42
+ return rendered
43
+ encoded = label[len(base) + 1 :].encode("utf-8").hex()
44
+ return f"{base}.dev0+semver.{encoded}"
45
+
46
+
47
+ def package_version(root: Path) -> str:
48
+ """Return stable VERSION or the explicit development distribution identity."""
49
+ version_path = root / "VERSION"
50
+ if not version_path.is_file():
51
+ from importlib.metadata import PackageNotFoundError, version as distribution_version
52
+ try:
53
+ return distribution_version("repopact")
54
+ except PackageNotFoundError:
55
+ return "unknown"
56
+ version = version_path.read_text(encoding="utf-8").strip()
57
+ label_path = root / "RELEASE_LABEL"
58
+ if not label_path.is_file():
59
+ return version
60
+ label = label_path.read_text(encoding="utf-8").strip()
61
+ match = RELEASE_LABEL_RE.fullmatch(label)
62
+ if not match or match.group("base") != version:
63
+ raise PackageVersionError("RELEASE_LABEL must be a SemVer pre-release whose core equals VERSION")
64
+ return semver_label_to_pep440(label)
65
+
66
+
67
+ # setuptools' dynamic attr reader obtains this value while building from the source tree.
68
+ __version__ = package_version(Path(__file__).resolve().parent.parent)
@@ -24,6 +24,8 @@ import zipfile
24
24
  from pathlib import Path
25
25
  from typing import Any
26
26
 
27
+ from .package_version import package_version
28
+
27
29
 
28
30
  EXPECTED_SCHEMAS = 8
29
31
  EXPECTED_TEMPLATES = 6
@@ -160,6 +162,7 @@ def _build_once(root: Path, revision: str, destination: Path) -> dict[str, Any]:
160
162
  _export(root, revision, source)
161
163
  output.mkdir()
162
164
  version = (source / "VERSION").read_text(encoding="utf-8").strip()
165
+ artifact_version = package_version(source)
163
166
  epoch = _run(["git", "show", "-s", "--format=%ct", revision], cwd=root)
164
167
  env = os.environ.copy()
165
168
  env["SOURCE_DATE_EPOCH"] = epoch
@@ -178,8 +181,9 @@ def _build_once(root: Path, revision: str, destination: Path) -> dict[str, Any]:
178
181
  _normalize_sdist(sdists[0], int(epoch))
179
182
  return {
180
183
  "version": version,
181
- "wheel": inspect_wheel(wheels[0], version),
182
- "sdist": inspect_sdist(sdists[0], version),
184
+ "artifact_version": artifact_version,
185
+ "wheel": inspect_wheel(wheels[0], artifact_version),
186
+ "sdist": inspect_sdist(sdists[0], artifact_version),
183
187
  "wheel_path": wheels[0],
184
188
  "sdist_path": sdists[0],
185
189
  }
@@ -212,6 +216,7 @@ def build_release(root: Path, outdir: Path, revision: str = "HEAD") -> dict[str,
212
216
  return {
213
217
  "commit": commit,
214
218
  "version": first["version"],
219
+ "artifact_version": first["artifact_version"],
215
220
  "reproducible": True,
216
221
  "wheel": first["wheel"],
217
222
  "sdist": first["sdist"],
@@ -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
@@ -17,6 +17,7 @@ import jsonschema
17
17
  from .frontmatter import FrontMatterError, parse_file
18
18
  from . import generate_dashboard
19
19
  from . import validate_research
20
+ from .package_version import RELEASE_LABEL_RE, PackageVersionError, package_version
20
21
  from .repo_model import STATUSES, discover_evidence_ids, discover_work_items, iter_contracts, load_json
21
22
 
22
23
 
@@ -121,14 +122,6 @@ def validate_version(root: Path, problems: list[Problem]) -> None:
121
122
  # is captured so it can be pinned to VERSION, then the SemVer pre-release grammar
122
123
  # (dot-separated identifiers, numeric identifiers with no leading zeros) and the
123
124
  # optional build metadata (decision 0026).
124
- _SEMVER_IDENT = r"(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)"
125
- _RELEASE_LABEL_RE = re.compile(
126
- rf"(?P<base>[0-9]+\.[0-9]+\.[0-9]+)"
127
- rf"-{_SEMVER_IDENT}(?:\.{_SEMVER_IDENT})*"
128
- rf"(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?"
129
- )
130
-
131
-
132
125
  def validate_release_label(root: Path, problems: list[Problem]) -> None:
133
126
  """Validate the optional ``RELEASE_LABEL`` product/maturity identity (decision 0026).
134
127
 
@@ -142,7 +135,7 @@ def validate_release_label(root: Path, problems: list[Problem]) -> None:
142
135
  if not path.is_file():
143
136
  return
144
137
  label = path.read_text(encoding="utf-8").strip()
145
- match = _RELEASE_LABEL_RE.fullmatch(label)
138
+ match = RELEASE_LABEL_RE.fullmatch(label)
146
139
  if not match:
147
140
  problems.append(Problem(
148
141
  path,
@@ -159,6 +152,76 @@ def validate_release_label(root: Path, problems: list[Problem]) -> None:
159
152
  ))
160
153
 
161
154
 
155
+ _PACKAGE_IDENTITY_PATHS = (
156
+ "pyproject.toml",
157
+ "README.md",
158
+ "VERSION",
159
+ "RELEASE_LABEL",
160
+ "repopact/*.py",
161
+ "repopact/schemas",
162
+ "repopact/templates",
163
+ )
164
+
165
+
166
+ def _git(root: Path, *args: str) -> subprocess.CompletedProcess[str]:
167
+ return subprocess.run(
168
+ ["git", "-C", str(root), *args],
169
+ text=True,
170
+ capture_output=True,
171
+ check=False,
172
+ )
173
+
174
+
175
+ def validate_source_artifact_identity(root: Path, problems: list[Problem]) -> None:
176
+ """Distinguish post-tag package source from an already released artifact.
177
+
178
+ Repositories without Git metadata, including portable conformance fixtures and
179
+ exported source archives, remain valid. When the stable ``vVERSION`` tag exists,
180
+ its exact package/runtime tree may remain unlabeled. Materially later source at
181
+ the same compatibility core requires RELEASE_LABEL, whose package identity is
182
+ independently derived and checked above (decision 0032).
183
+ """
184
+ version_path = root / "VERSION"
185
+ label_path = root / "RELEASE_LABEL"
186
+ if not version_path.is_file() or label_path.is_file():
187
+ return
188
+ version = version_path.read_text(encoding="utf-8").strip()
189
+ tag = f"v{version}"
190
+ resolved = _git(root, "rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
191
+ if resolved.returncode != 0:
192
+ return
193
+ changed = _git(root, "diff", "--name-only", tag, "--", *_PACKAGE_IDENTITY_PATHS)
194
+ untracked = _git(root, "ls-files", "--others", "--exclude-standard", "--", *_PACKAGE_IDENTITY_PATHS)
195
+ if changed.returncode != 0 or untracked.returncode != 0:
196
+ return
197
+ paths = sorted({line for line in (changed.stdout + untracked.stdout).splitlines() if line})
198
+ if paths:
199
+ problems.append(Problem(
200
+ label_path,
201
+ f"package/runtime source differs from released {tag} but has no RELEASE_LABEL; "
202
+ f"add a VERSION-pinned development identity (changed: {', '.join(paths)})",
203
+ ))
204
+
205
+
206
+ def validate_package_version(root: Path, problems: list[Problem]) -> None:
207
+ """Prove the governed identity can be rendered as deterministic PEP 440 metadata."""
208
+ if not (root / "VERSION").is_file():
209
+ return
210
+ label_path = root / "RELEASE_LABEL"
211
+ if label_path.is_file():
212
+ label = label_path.read_text(encoding="utf-8").strip()
213
+ version = (root / "VERSION").read_text(encoding="utf-8").strip()
214
+ match = RELEASE_LABEL_RE.fullmatch(label)
215
+ # The structural/core diagnostics belong to validate_release_label; do
216
+ # not emit a second, less actionable error for the same malformed record.
217
+ if not match or match.group("base") != version:
218
+ return
219
+ try:
220
+ package_version(root)
221
+ except (OSError, PackageVersionError) as exc:
222
+ problems.append(Problem(root / "RELEASE_LABEL", f"invalid package identity: {exc}"))
223
+
224
+
162
225
  # The README convention this rule is gated on: a release line naming the current
163
226
  # version, optionally carrying a changelog link. Both groups are optional-friendly
164
227
  # so a README that omits the line (any adopter's, typically) is simply unaffected.
@@ -883,6 +946,8 @@ def validate(root: Path) -> list[Problem]:
883
946
  problems: list[Problem] = []
884
947
  validate_version(root, problems)
885
948
  validate_release_label(root, problems)
949
+ validate_package_version(root, problems)
950
+ validate_source_artifact_identity(root, problems)
886
951
  validate_release_surface(root, problems)
887
952
  validate_contracts(root, problems)
888
953
  validate_invariants(root, problems)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repopact
3
- Version: 3.0.0
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,8 +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.0**
30
- ([changelog](decisions/0030-release-repopact-3-0-0-package-boundary.md)).
29
+ `pip install repopact` · Apache-2.0 · current release **3.0.2** ([changelog](decisions/0036-release-repopact-3-0-2.md)).
31
30
 
32
31
  ## How it relates to `AGENTS.md`
33
32
 
@@ -1,4 +1,5 @@
1
1
  LICENSE
2
+ MANIFEST.in
2
3
  README.md
3
4
  VERSION
4
5
  pyproject.toml
@@ -13,6 +14,7 @@ repopact/generate_dashboard.py
13
14
  repopact/generate_spec.py
14
15
  repopact/init_repo.py
15
16
  repopact/new.py
17
+ repopact/package_version.py
16
18
  repopact/plan_import.py
17
19
  repopact/release_build.py
18
20
  repopact/repo_model.py
@@ -10,22 +10,28 @@ import zipfile
10
10
  from pathlib import Path
11
11
 
12
12
  from repopact import release_build
13
+ from repopact.package_version import semver_label_to_pep440
13
14
 
14
15
 
15
16
  ROOT = Path(__file__).resolve().parents[1]
16
17
 
17
18
 
18
19
  class ReleaseBuildTests(unittest.TestCase):
20
+ def test_release_label_maps_deterministically_to_pep440(self) -> None:
21
+ self.assertEqual("3.0.1rc1", semver_label_to_pep440("3.0.1-rc.1"))
22
+ first = semver_label_to_pep440("3.0.1-preview.1+windows")
23
+ self.assertEqual(first, semver_label_to_pep440("3.0.1-preview.1+windows"))
24
+ self.assertNotEqual("3.0.1", first)
19
25
  def _wheel(self, root: Path, *, flat_module: bool = False) -> Path:
20
- path = root / "repopact-3.0.0-py3-none-any.whl"
26
+ path = root / "repopact-3.0.1-py3-none-any.whl"
21
27
  with zipfile.ZipFile(path, "w") as archive:
22
28
  archive.writestr("repopact/__init__.py", "")
23
29
  for index in range(release_build.EXPECTED_SCHEMAS):
24
30
  archive.writestr(f"repopact/schemas/{index}.json", "{}")
25
31
  for index in range(release_build.EXPECTED_TEMPLATES):
26
32
  archive.writestr(f"repopact/templates/{index}.txt", "")
27
- archive.writestr("repopact-3.0.0.dist-info/top_level.txt", "repopact\n")
28
- archive.writestr("repopact-3.0.0.dist-info/METADATA", "Version: 3.0.0\n")
33
+ archive.writestr("repopact-3.0.1.dist-info/top_level.txt", "repopact\n")
34
+ archive.writestr("repopact-3.0.1.dist-info/METADATA", "Version: 3.0.1\n")
29
35
  if flat_module:
30
36
  archive.writestr("frontmatter.py", "")
31
37
  return path
@@ -34,7 +40,7 @@ class ReleaseBuildTests(unittest.TestCase):
34
40
  with tempfile.TemporaryDirectory() as temporary:
35
41
  report = release_build.inspect_wheel(
36
42
  self._wheel(Path(temporary)),
37
- "3.0.0",
43
+ "3.0.1",
38
44
  )
39
45
  self.assertEqual(["repopact"], report["import_roots"])
40
46
  self.assertEqual(0, report["data_files"])
@@ -46,7 +52,7 @@ class ReleaseBuildTests(unittest.TestCase):
46
52
  release_build.ReleaseBuildError,
47
53
  "import roots.*frontmatter.py",
48
54
  ):
49
- release_build.inspect_wheel(path, "3.0.0")
55
+ release_build.inspect_wheel(path, "3.0.1")
50
56
 
51
57
  def test_export_creates_nested_temporary_parent(self) -> None:
52
58
  with tempfile.TemporaryDirectory() as temporary:
@@ -59,7 +65,7 @@ class ReleaseBuildTests(unittest.TestCase):
59
65
  with path.open("wb") as raw:
60
66
  with gzip.GzipFile(filename="", mode="wb", fileobj=raw, mtime=timestamp) as compressed:
61
67
  with tarfile.open(fileobj=compressed, mode="w") as archive:
62
- member = tarfile.TarInfo("repopact-3.0.0/README.md")
68
+ member = tarfile.TarInfo("repopact-3.0.1/README.md")
63
69
  member.size = 5
64
70
  member.mtime = timestamp
65
71
  archive.addfile(member, io.BytesIO(b"hello"))
@@ -41,8 +41,8 @@ class ResearchMetadataTests(unittest.TestCase):
41
41
  self.assertEqual([], self.messages())
42
42
 
43
43
  def test_expired_research_claim_contract_is_rejected(self) -> None:
44
- problems = validate_research.validate(self.root, today=date(2026, 8, 10))
45
- self.assertTrue(any("freshness expired on 2026-08-09" in p.message for p in problems))
44
+ problems = validate_research.validate(self.root, today=date(2026, 9, 19))
45
+ self.assertTrue(any("freshness expired on 2026-09-18" in p.message for p in problems))
46
46
 
47
47
  def test_unregistered_research_claim_document_is_rejected(self) -> None:
48
48
  (self.root / "research" / "new-claim.md").write_text(
@@ -66,8 +66,8 @@ class ResearchMetadataTests(unittest.TestCase):
66
66
  self.assertTrue(any("expected 24; observed 21" in message for message in self.messages()))
67
67
 
68
68
  def test_stale_hypothesis_range_is_rejected(self) -> None:
69
- self.replace("research/benchmark-protocol.md", "H8–H13", "H8–H10")
70
- self.assertTrue(any("expected H8–H13; observed H8–H10" in message for message in self.messages()))
69
+ self.replace("research/benchmark-protocol.md", "H8–H14", "H8–H10")
70
+ self.assertTrue(any("expected H8–H14; observed H8–H10" in message for message in self.messages()))
71
71
 
72
72
  def test_future_provenance_wording_is_rejected(self) -> None:
73
73
  self.replace(
@@ -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
  )
@@ -29,19 +30,55 @@ from repopact.validate_repo import validate # noqa: E402
29
30
 
30
31
 
31
32
  class RepositoryValidationTests(unittest.TestCase):
33
+ READ_ONLY_TESTS = {
34
+ "test_repository_is_valid",
35
+ "test_dashboard_generation_is_stable_between_audit_transitions",
36
+ "test_readme_without_checkboxes_is_unaffected",
37
+ "test_symbol_hits_detects_protected_symbol",
38
+ "test_symbol_hits_ignores_context_lines",
39
+ "test_seed_data_uses_package_resources_not_data_files",
40
+ "test_spec_generation_is_idempotent",
41
+ "test_cli_validate_returns_zero_on_valid_repo",
42
+ "test_split_num_strips_tracker_prefix",
43
+ "test_section_lifecycle_keywords",
44
+ }
45
+ TEMP_ONLY_TESTS = {
46
+ "test_bootstrap_produces_valid_repo",
47
+ "test_bootstrap_uses_installed_tooling_instead_of_vendoring_modules",
48
+ "test_adopt_existing_repo_validates",
49
+ "test_adopt_is_non_destructive",
50
+ "test_adopt_maps_workflows_and_codeowners",
51
+ "test_adopt_dry_run_writes_nothing",
52
+ "test_adopt_warns_on_gitignored_records",
53
+ "test_import_plan_populates_and_validates",
54
+ "test_import_plan_completed_items_are_waived_not_fabricated",
55
+ "test_import_plan_is_idempotent",
56
+ "test_import_plan_dry_run_writes_nothing",
57
+ "test_tracking_import_maps_to_record_types_and_validates",
58
+ "test_tracking_import_is_idempotent",
59
+ "test_import_plan_section_roadmap_without_checkboxes",
60
+ }
61
+
32
62
  def setUp(self) -> None:
63
+ self.temp: tempfile.TemporaryDirectory[str] | None = None
64
+ if self._testMethodName in self.READ_ONLY_TESTS:
65
+ self.root = ROOT
66
+ return
33
67
  self.temp = tempfile.TemporaryDirectory()
34
68
  self.root = Path(self.temp.name) / "repo"
69
+ if self._testMethodName in self.TEMP_ONLY_TESTS:
70
+ return
35
71
  shutil.copytree(
36
72
  ROOT,
37
73
  self.root,
38
74
  ignore=shutil.ignore_patterns(
39
- ".git", ".venv", ".pytest_cache", "__pycache__", "build", "dist", "*.egg-info"
75
+ ".git", ".venv", ".pytest_cache", "__pycache__", "build", "dist", "dist-*", "*.egg-info"
40
76
  ),
41
77
  )
42
78
 
43
79
  def tearDown(self) -> None:
44
- self.temp.cleanup()
80
+ if self.temp is not None:
81
+ self.temp.cleanup()
45
82
 
46
83
  def problems(self) -> list[str]:
47
84
  return [problem.message for problem in validate(self.root)]
@@ -217,6 +254,121 @@ class RepositoryValidationTests(unittest.TestCase):
217
254
  (extra / "AGENTS.md").write_text("# unregistered\n", encoding="utf-8")
218
255
  self.assertTrue(any("not registered in audits/registry.json" in v for v in self.problems()))
219
256
 
257
+ def test_worktree_scratch_checkouts_are_not_scanned_as_nested_contracts(self) -> None:
258
+ # A `worktrees/<name>/` directory is a second, independent working
259
+ # copy of this same repository (the convention agent tooling uses for
260
+ # a scratch `git worktree` checkout) -- its own AGENTS.md belongs to
261
+ # that checkout, not this one, and must not be flagged as an
262
+ # unregistered nested contract just because it happens to be reachable
263
+ # on disk under this root, including several levels deep and left
264
+ # behind after the session that created it ended.
265
+ worktree = self.root / "worktrees" / "some-agent-session" / "crates" / "example"
266
+ worktree.mkdir(parents=True)
267
+ (worktree / "AGENTS.md").write_text("# from a scratch worktree checkout\n", encoding="utf-8")
268
+ self.assertFalse(any("not registered in audits/registry.json" in v for v in self.problems()))
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
+
220
372
  def test_existing_audit_companion_must_be_complete(self) -> None:
221
373
  (self.root / "repopact" / "_audit" / "inventory.md").unlink()
222
374
  self.assertTrue(any("incomplete _audit companion" in v for v in self.problems()))
@@ -454,6 +606,50 @@ class RepositoryValidationTests(unittest.TestCase):
454
606
  (self.root / "VERSION").write_text("v1\n", encoding="utf-8")
455
607
  self.assertTrue(any("must be semantic" in v for v in self.problems()))
456
608
 
609
+ def _tag_identity_fixture(self) -> None:
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()
617
+ readme = self.root / "README.md"
618
+ text = readme.read_text(encoding="utf-8")
619
+ start = text.index("`pip install repopact`")
620
+ end = text.index("\n\n", start)
621
+ readme.write_text(text[:start] + "current release **9.9.9**." + text[end:], encoding="utf-8")
622
+ generate_dashboard.write_dashboard(self.root)
623
+ subprocess.run(["git", "init", "--initial-branch=main"], cwd=self.root, check=True,
624
+ capture_output=True, text=True)
625
+ subprocess.run(["git", "config", "user.email", "test@example.invalid"], cwd=self.root, check=True)
626
+ subprocess.run(["git", "config", "user.name", "RepoPact Test"], cwd=self.root, check=True)
627
+ subprocess.run(["git", "add", "-A"], cwd=self.root, check=True)
628
+ subprocess.run(["git", "commit", "-m", "stable"], cwd=self.root, check=True,
629
+ capture_output=True, text=True)
630
+ subprocess.run(["git", "tag", "-a", "v9.9.9", "-m", "9.9.9"], cwd=self.root, check=True)
631
+
632
+ def test_exact_tagged_release_tree_is_accepted(self) -> None:
633
+ self._tag_identity_fixture()
634
+ self.assertEqual([], self.problems())
635
+
636
+ def test_later_package_source_requires_development_identity(self) -> None:
637
+ self._tag_identity_fixture()
638
+ (self.root / "repopact" / "repo_model.py").write_text(
639
+ (self.root / "repopact" / "repo_model.py").read_text(encoding="utf-8") + "\n# later runtime change\n",
640
+ encoding="utf-8",
641
+ )
642
+ self.assertTrue(any("differs from released v9.9.9" in v for v in self.problems()))
643
+
644
+ def test_later_package_source_with_label_is_accepted(self) -> None:
645
+ self._tag_identity_fixture()
646
+ (self.root / "repopact" / "repo_model.py").write_text(
647
+ (self.root / "repopact" / "repo_model.py").read_text(encoding="utf-8") + "\n# later runtime change\n",
648
+ encoding="utf-8",
649
+ )
650
+ (self.root / "RELEASE_LABEL").write_text("9.9.9-dev.1\n", encoding="utf-8")
651
+ self.assertFalse(any("differs from released" in v for v in self.problems()))
652
+
457
653
  # --- release surface (decision 0028) ------------------------------------
458
654
 
459
655
  def set_readme_release(self, line: str) -> None:
@@ -472,19 +668,19 @@ class RepositoryValidationTests(unittest.TestCase):
472
668
 
473
669
  def test_readme_release_changelog_link_must_name_current_release(self) -> None:
474
670
  self.set_readme_release(
475
- "current release **3.0.0** "
671
+ "current release **3.0.2** "
476
672
  "([changelog](decisions/0025-release-2.2.0-dashboard-integrity.md))."
477
673
  )
478
674
  self.assertTrue(any("does not name the current release" in v for v in self.problems()))
479
675
 
480
676
  def test_readme_release_changelog_link_must_resolve(self) -> None:
481
677
  self.set_readme_release(
482
- "current release **3.0.0** ([changelog](decisions/9999-nonexistent.md))."
678
+ "current release **3.0.2** ([changelog](decisions/9999-nonexistent.md))."
483
679
  )
484
680
  self.assertTrue(any("does not resolve" in v for v in self.problems()))
485
681
 
486
682
  def test_readme_release_line_without_link_is_accepted(self) -> None:
487
- self.set_readme_release("current release **3.0.0**.")
683
+ self.set_readme_release("current release **3.0.2**.")
488
684
  self.assertEqual([], self.problems())
489
685
 
490
686
  def test_readme_without_release_line_is_unaffected(self) -> None:
@@ -495,13 +691,13 @@ class RepositoryValidationTests(unittest.TestCase):
495
691
 
496
692
  def test_readme_release_link_may_be_an_external_url(self) -> None:
497
693
  self.set_readme_release(
498
- "current release **3.0.0** ([changelog](https://example.invalid/changelog))."
694
+ "current release **3.0.2** ([changelog](https://example.invalid/changelog))."
499
695
  )
500
696
  self.assertEqual([], self.problems())
501
697
 
502
698
  def test_readme_release_link_outside_decisions_is_existence_checked_only(self) -> None:
503
699
  (self.root / "CHANGELOG.md").write_text("# Changelog\n", encoding="utf-8")
504
- self.set_readme_release("current release **3.0.0** ([changelog](CHANGELOG.md)).")
700
+ self.set_readme_release("current release **3.0.2** ([changelog](CHANGELOG.md)).")
505
701
  self.assertEqual([], self.problems())
506
702
 
507
703
  # --- dependency cycles --------------------------------------------------
@@ -986,7 +1182,55 @@ class RepositoryValidationTests(unittest.TestCase):
986
1182
  findings = doctor._dead_source_of_truth(self.root)
987
1183
  msgs = [f.message for f in findings]
988
1184
  self.assertTrue(any("docs/gone.md" in m for m in msgs))
989
- 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)))
990
1234
 
991
1235
  def test_import_plan_section_roadmap_without_checkboxes(self) -> None:
992
1236
  repo = Path(self.temp.name) / "roadmapped"
repopact-3.0.0/VERSION DELETED
@@ -1 +0,0 @@
1
- 3.0.0
@@ -1,66 +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 and, notably,
12
- # test fixtures, which are self-contained sub-repositories validated on their own.
13
- IGNORED_PARTS = {
14
- ".git", "__pycache__", "node_modules", ".venv", ".pytest_cache",
15
- "build", "dist", "fixtures",
16
- }
17
-
18
-
19
- def iter_contracts(root: Path) -> list[Path]:
20
- """All AGENTS.md under root, excluding ignored subtrees (relative to root)."""
21
- result: list[Path] = []
22
- for path in sorted(root.rglob("AGENTS.md")):
23
- if any(part in IGNORED_PARTS for part in path.relative_to(root).parts):
24
- continue
25
- result.append(path)
26
- return result
27
-
28
-
29
- @dataclass(frozen=True)
30
- class WorkItem:
31
- directory: Path
32
- data: dict[str, Any]
33
-
34
- @property
35
- def item_id(self) -> str:
36
- return str(self.data.get("id", ""))
37
-
38
- @property
39
- def status(self) -> str:
40
- return str(self.data.get("status", ""))
41
-
42
-
43
- def load_json(path: Path) -> dict[str, Any]:
44
- with path.open(encoding="utf-8") as handle:
45
- value = json.load(handle)
46
- if not isinstance(value, dict):
47
- raise ValueError(f"expected a JSON object: {path}")
48
- return value
49
-
50
-
51
- def discover_work_items(root: Path) -> list[WorkItem]:
52
- items: list[WorkItem] = []
53
- for status in STATUSES:
54
- status_dir = root / "work" / status
55
- if not status_dir.exists():
56
- continue
57
- for manifest in sorted(status_dir.glob("*/work-item.json")):
58
- items.append(WorkItem(manifest.parent, load_json(manifest)))
59
- return items
60
-
61
-
62
- def discover_evidence_ids(root: Path) -> set[str]:
63
- result: set[str] = set()
64
- for path in sorted((root / "evidence" / "runs").glob("*.json")):
65
- result.add(str(load_json(path).get("id", "")))
66
- return result
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes