-
Notifications
You must be signed in to change notification settings - Fork 1
fix(sync): make sync rationale checks self-validating #3203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stranske
merged 10 commits into
main
from
codex/issue-3183-sync-rationale-self-checking
Aug 23, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fb16825
fix(sync): make sync rationale checks self-validating
codex-automation a633703
chore(autofix): formatting/lint
github-actions[bot] 9fff961
fix(sync): satisfy Gate test-quality and direct script entry points
codex-automation 3f68e88
chore(autofix): formatting/lint
github-actions[bot] 078764e
fix(sync): preserve Gate create-only evidence
codex-automation d9f9cd1
fix(sync): distinguish open manifest citations
codex-automation a70c22a
fix(sync): close manifest review gaps
codex-automation 5a2aff7
style(sync): format manifest regressions
codex-automation 306fd52
fix(gate): export GITHUB_TOKEN for manifest issue live check
codex-automation 7bd4072
fix(drift): refresh pr-00-gate allowlist fingerprint after GITHUB_TOK…
codex-automation File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import ast | ||
| from pathlib import Path | ||
|
|
||
| from scripts import cleanup_labels, langsmith_fleet | ||
| from scripts.list_registered_consumer_repos import extract_repos | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[2] | ||
| MANIFEST = ROOT / ".github/workflows/maint-68-sync-consumer-repos.yml" | ||
|
|
||
|
|
||
| def _assignment_uses_extract_repos(path: Path, target_name: str) -> bool: | ||
| tree = ast.parse(path.read_text(encoding="utf-8")) | ||
| for node in tree.body: | ||
| value: ast.expr | None = None | ||
| if ( | ||
| isinstance(node, ast.Assign) | ||
| and any( | ||
| isinstance(target, ast.Name) and target.id == target_name for target in node.targets | ||
| ) | ||
| ) or ( | ||
| isinstance(node, ast.AnnAssign) | ||
| and isinstance(node.target, ast.Name) | ||
| and node.target.id == target_name | ||
| ): | ||
| value = node.value | ||
| if value is not None and any( | ||
| isinstance(child, ast.Call) | ||
| and isinstance(child.func, ast.Name) | ||
| and child.func.id == "extract_repos" | ||
| for child in ast.walk(value) | ||
| ): | ||
| return True | ||
| return False | ||
|
|
||
|
|
||
| def test_no_second_consumer_repo_literal() -> None: | ||
| registered = extract_repos(MANIFEST) | ||
|
|
||
| assert MANIFEST.name == "maint-68-sync-consumer-repos.yml" | ||
| assert len(registered) >= 10 | ||
| assert registered == cleanup_labels.CONSUMER_REPOS | ||
| assert set(registered) == langsmith_fleet.MANAGED_CONSUMER_REPOS | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| assert _assignment_uses_extract_repos(ROOT / "scripts/cleanup_labels.py", "CONSUMER_REPOS") | ||
| assert _assignment_uses_extract_repos( | ||
| ROOT / "scripts/langsmith_fleet.py", "MANAGED_CONSUMER_REPOS" | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| import re | ||
| import subprocess | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[2] | ||
| MANIFEST = ROOT / ".github" / "sync-manifest.yml" | ||
| ISSUE_REFERENCE = re.compile(r"#(?P<number>\d+)") | ||
| ISSUE_STATE_PAIR = re.compile( | ||
| r"\b(?P<state>open|resolved):\s*(?:issue\s*)?#(?P<number>\d+)", | ||
| re.IGNORECASE, | ||
| ) | ||
|
|
||
|
|
||
| def _issue_state_pairs(line: str) -> list[tuple[str, str]]: | ||
| return [ | ||
| (match.group("state").lower(), match.group("number")) | ||
| for match in ISSUE_STATE_PAIR.finditer(line) | ||
| ] | ||
|
|
||
|
|
||
| def _unpaired_issue_references(line: str) -> list[str]: | ||
| residue = ISSUE_STATE_PAIR.sub("", line) | ||
| return [match.group(0) for match in ISSUE_REFERENCE.finditer(residue)] | ||
|
|
||
|
|
||
| def test_manifest_issue_citations_are_explicitly_stateful() -> None: | ||
| """Manifest citations name whether the referenced issue is open or resolved.""" | ||
| offenders = [ | ||
| line.strip() | ||
| for line in MANIFEST.read_text(encoding="utf-8").splitlines() | ||
| if _unpaired_issue_references(line) | ||
| ] | ||
| assert offenders == [] | ||
|
|
||
|
|
||
| def test_issue_state_parser_associates_each_citation() -> None: | ||
| line = "open: #2158; resolved: issue #2157" | ||
|
|
||
| assert _issue_state_pairs(line) == [("open", "2158"), ("resolved", "2157")] | ||
| assert _unpaired_issue_references(line) == [] | ||
| assert _unpaired_issue_references("open: #2158; also #2157") == ["#2157"] | ||
|
|
||
|
|
||
| def test_manifest_issue_references_are_open() -> None: | ||
| """Live guard for manifest citations explicitly marked as open.""" | ||
| if not (os.environ.get("GH_TOKEN") or os.environ.get("GITHUB_TOKEN")): | ||
| pytest.skip("GH_TOKEN or GITHUB_TOKEN is required to verify manifest issue references") | ||
|
stranske marked this conversation as resolved.
|
||
|
|
||
| for line in MANIFEST.read_text(encoding="utf-8").splitlines(): | ||
| for state, issue_number in _issue_state_pairs(line): | ||
| if state != "open": | ||
| continue | ||
| try: | ||
| result = subprocess.run( | ||
| [ | ||
| "gh", | ||
| "issue", | ||
| "view", | ||
| issue_number, | ||
| "--repo", | ||
| "stranske/Workflows", | ||
| "--json", | ||
| "state", | ||
| "--jq", | ||
| ".state", | ||
| ], | ||
| check=True, | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=15, | ||
| ) | ||
| except subprocess.TimeoutExpired: | ||
| pytest.fail( | ||
| f"timed out checking manifest issue #{issue_number}: {line.strip()}", | ||
| pytrace=False, | ||
| ) | ||
| assert ( | ||
| result.stdout.strip() == "OPEN" | ||
| ), f"manifest references closed issue #{issue_number}: {line.strip()}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import configparser | ||
| from pathlib import Path | ||
|
|
||
| from scripts.check_template_drift import read_allowlist | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[2] | ||
| ALLOWLIST = ROOT / "config/template-drift-allowlist.txt" | ||
|
|
||
|
|
||
| def test_every_pair_states_its_divergence() -> None: | ||
| parser = configparser.ConfigParser(interpolation=None) | ||
| parser.read(ALLOWLIST, encoding="utf-8") | ||
|
|
||
| assert ALLOWLIST.name == "template-drift-allowlist.txt" | ||
| assert len(parser.sections()) >= 1 | ||
|
|
||
| for section in parser.sections(): | ||
| divergence = parser.get(section, "divergence", fallback="").strip() | ||
| reviewed = parser.get(section, "divergence_reviewed", fallback="").strip() | ||
| refreshed = parser.get(section, "fingerprint_refreshed", fallback="").strip() | ||
| assert divergence and "Existing reviewed baseline drift" not in divergence | ||
| assert reviewed | ||
| assert refreshed | ||
|
|
||
|
|
||
| def test_read_allowlist_prefers_divergence_and_supports_legacy_reason(tmp_path: Path) -> None: | ||
| allowlist_path = tmp_path / "allowlist.txt" | ||
| allowlist_path.write_text( | ||
| """ | ||
| [pair.current] | ||
| main = root.yml | ||
| template = template.yml | ||
| main_sha256 = main-current | ||
| template_sha256 = template-current | ||
| divergence = current rationale | ||
| reason = superseded legacy rationale | ||
|
|
||
| [pair.legacy] | ||
| main = legacy-root.yml | ||
| template = legacy-template.yml | ||
| main_sha256 = main-legacy | ||
| template_sha256 = template-legacy | ||
| reason = legacy rationale | ||
| """.strip() + "\n", | ||
| encoding="utf-8", | ||
| ) | ||
|
|
||
| entries = read_allowlist(allowlist_path).entries | ||
|
|
||
| assert [entry.reason for entry in entries] == ["current rationale", "legacy rationale"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.