diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 8651ebb62..7821d66f9 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -6,13 +6,13 @@ Three jobs run independently: | Job | Coverage | | --- | --- | -| Tests and static checks | `make ci-tests`: naming, lint, the complete Python suite, Node UI/native-adapter tests and the fixture smoke test | +| Tests and static checks | `make ci-tests`: review guidance, naming, lint, the complete Python suite, Node UI/native-adapter tests and the fixture smoke test | | Installation and packaging | Base installation and CLI language checks, sdist/pip installation, wheel smoke checks and all existing optional installation profiles | | Rendered reference and report checks | Chromium reference capture, report interactions and Web Search visual checks | The Python suite uses two workers with `--dist loadfile`, keeping each test file in one process. Slow-test durations appear in the job log. Local `make ci` remains serial by default; use `make ci PYTEST_ARGS='-n 2 --dist loadfile --durations=20'` for the same test scheduling. -The checks job also verifies the pinned shared review guide and synchronization tool against `review-guidelines.lock.json`, and confirms that OCR loads the shared guide alongside its built-in rules. This offline integrity check needs no cross-repository credentials. Use `uv run --frozen python scripts/review_guidelines.py check --source ` to also compare the files with their recorded source commit. Shared requirements are maintained in `lexmount/ai-template-py`; Browser Eval's review supplement remains in `.opencodereview/review-rules.md`. +`make review-check`, part of both `make ci-tests` and local `make ci`, verifies the pinned shared review guide and synchronization tool against `review-guidelines.lock.json`, and confirms that OCR loads the guide alongside its built-in rules. This offline integrity check needs no cross-repository credentials. Use `uv run --frozen python scripts/review_guidelines.py check --source ` to also compare the files with their recorded source commit. Shared requirements are maintained in `lexmount/ai-template-py`; Browser Eval's review supplement is the section after the repository supplement marker at the end of `docs/references/review-guidelines.md`; the lock covers only the text before it, and synchronization preserves it. The existing `Python 3.11` status succeeds only when all three jobs succeed. A failed, cancelled or skipped job fails that status. New commits cancel obsolete CI runs for the same pull request. Main and tag runs each have a unique concurrency group, so a newer run cannot replace an earlier pending run. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a9f94279..6af3ab95f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,6 @@ jobs: node-version: "22" cache: npm - run: make setup-test - - name: Verify shared review guidance - run: uv run --frozen --no-sync python scripts/review_guidelines.py check - run: make ci-tests PYTEST_ARGS='-n 2 --dist loadfile --durations=20' package: diff --git a/.opencodereview/review-rules.md b/.opencodereview/review-rules.md deleted file mode 100644 index a87ea6377..000000000 --- a/.opencodereview/review-rules.md +++ /dev/null @@ -1,7 +0,0 @@ -# Browser Eval review supplement - -Read `docs/references/review-guidelines.md` for shared review criteria. The following requirements belong to Browser Eval and supplement the pinned common standard and OCR's built-in rules. - -## Repository checks - -Keep provider execution and reporting in the harness; use benchmark-owned definitions and scoring. Trace scored answers to native evidence. Verify populations, timing and certification against the selected track contract. Preserve frozen evidence and report targets, keep private run data outside Git, and check report views agree with their evidence. diff --git a/AGENTS.md b/AGENTS.md index 0f385c0ba..52a9cd095 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,9 +1,10 @@ # Code review -Use [Shared Review Guidelines](docs/references/review-guidelines.md) and the -[repository supplement](.opencodereview/review-rules.md). The shared guide is -generated from the commit recorded in `review-guidelines.lock.json`; change -common requirements in `lexmount/ai-template-py` and synchronize the copy. +Use [Review Guidelines](docs/references/review-guidelines.md). Its shared text and +`scripts/review_guidelines.py` are synchronized from the commit recorded in +`review-guidelines.lock.json`; change them in `lexmount/ai-template-py`. Browser +Eval's own requirements follow the repository supplement marker at the end of the +guide and are edited here. # Benchmark ownership diff --git a/Makefile b/Makefile index bc99107c6..c49310c50 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,11 @@ fixture-smoke: runtime-check test: test-python test-ui test-native-adapters -.PHONY: ci-tests -ci-tests: naming-check lint-check test fixture-smoke +.PHONY: review-check ci-tests +review-check: runtime-check + $(PY) scripts/review_guidelines.py check + +ci-tests: review-check naming-check lint-check test fixture-smoke ci: ci-tests package-check diff --git a/docs/references/review-guidelines.md b/docs/references/review-guidelines.md index 8dfe288b9..a12f5affe 100644 --- a/docs/references/review-guidelines.md +++ b/docs/references/review-guidelines.md @@ -4,11 +4,13 @@ The canonical version of this document lives in `lexmount/ai-template-py` at `docs/references/review-guidelines.md`. Consumer repositories synchronize their copies with `scripts/review_guidelines.py` and pin the source revision in `review-guidelines.lock.json`. Change the canonical document rather than editing -a synchronized copy. +a synchronized copy. A consumer adds its own requirements only after the +repository review supplement marker at the end of its copy; synchronization +preserves that section. OCR's official rules remain the foundation. This document adds shared review, -scope, and feedback requirements. Read the repository's local review supplement -for its domain requirements. Use the review language required by the user or +scope, and feedback requirements. The repository supplement at the end of this +document, when present, adds the consumer's domain requirements and entry points. Use the review language required by the user or repository; preserve code identifiers, commands, schema values, and product names. ## Establish the review basis @@ -231,3 +233,13 @@ Touching more files during a fix does not require cleaning up every old problem in those files. The work can close when valid in-scope findings are resolved and necessary verification passes. Add task requirements only when the user or repository maintainer explicitly changes the goal. + + + +## Browser Eval review supplement + +Follow the repository review constraints in `AGENTS.md` and `CONTRIBUTING.md`. The following requirements belong to Browser Eval and supplement the shared criteria above and OCR's built-in rules. + +### Repository checks + +Keep provider execution and reporting in the harness; use benchmark-owned definitions and scoring. Trace scored answers to native evidence. Verify populations, timing and certification against the selected track contract. Preserve frozen evidence and report targets, keep private run data outside Git, and check report views agree with their evidence. diff --git a/review-guidelines.lock.json b/review-guidelines.lock.json index 740ee2263..295f3c790 100644 --- a/review-guidelines.lock.json +++ b/review-guidelines.lock.json @@ -1,9 +1,9 @@ { "version": 1, "repository": "lexmount/ai-template-py", - "revision": "6188715448dfc3f54e721715fd5147daac5b400e", + "revision": "984b8d5319ab3f87b13c2aae38ea9a7c795a3adf", "files": { - "docs/references/review-guidelines.md": "8eb5da2e3a6a7ea9766bb4131b1d1cc9e6191a49fde8f745bd6148196ced51e1", - "scripts/review_guidelines.py": "c38b6d5d229d875393ed7514d00e11365b98c0c58c4279115c49bd18ace0eaf7" + "docs/references/review-guidelines.md": "98f93a11aefd1e003a778d889a77d9283b49ea786d7db3c38ed04005561cba06", + "scripts/review_guidelines.py": "6732c01ba592f098f32f76bad3ad5bde7d23002fc70a9acde2b16a48f6c0f96c" } } diff --git a/scripts/review_guidelines.py b/scripts/review_guidelines.py index d9a27a47f..a0c9e0de5 100644 --- a/scripts/review_guidelines.py +++ b/scripts/review_guidelines.py @@ -15,6 +15,9 @@ REPOSITORY = "lexmount/ai-template-py" FILES = ("docs/references/review-guidelines.md", "scripts/review_guidelines.py") LOCK = "review-guidelines.lock.json" +# A consumer's copy of the guide may end with its own requirements after this +# line. The lock and source comparison cover only the shared text above it. +SUPPLEMENT = b"" def git(root: Path, *args: str) -> bytes: @@ -23,14 +26,32 @@ def git(root: Path, *args: str) -> bytes: ).stdout +def repository_root(path: Path) -> Path: + return Path(git(path, "rev-parse", "--show-toplevel").decode().strip()).resolve() + + def is_source(root: Path) -> bool: - remote = git(root, "remote", "get-url", "origin").decode().strip() - return remote.removesuffix(".git") in ( + remote = git(root, "remote", "get-url", "origin").decode().strip().rstrip("/") + remote = remote.removesuffix(".git").replace("ssh://git@github.com/", "git@github.com:") + return remote in ( f"git@github.com:{REPOSITORY}", f"https://github.com/{REPOSITORY}", ) +def shared_part(path: str, content: bytes) -> bytes: + if path != FILES[0]: + return content + shared, marker, _ = content.partition(SUPPLEMENT) + # Blank lines before the marker separate the sections and are not shared text. + return shared.rstrip(b"\n") + b"\n" if marker else shared + + +def local_part(path: str, content: bytes) -> bytes: + index = content.find(SUPPLEMENT) if path == FILES[0] else -1 + return b"" if index < 0 else b"\n" + content[index:] + + def managed_path(root: Path, relative: str) -> Path: path = root / relative if path.exists() and not path.is_file(): @@ -56,7 +77,10 @@ def source_files(source: Path, revision: str) -> dict[str, bytes]: raise ValueError(f"Source origin must be {REPOSITORY}") if git(source, "cat-file", "-t", revision).strip() != b"commit": raise ValueError("The source revision must identify a commit") - return {path: git(source, "show", f"{revision}:{path}") for path in FILES} + contents = {path: git(source, "show", f"{revision}:{path}") for path in FILES} + if local_part(FILES[0], contents[FILES[0]]): + raise ValueError("The canonical guide must not contain a repository supplement") + return contents def check_routing(root: Path) -> None: @@ -74,8 +98,11 @@ def check(root: Path, source: Path | None = None) -> None: if not is_source(root): raise ValueError(f"Missing {LOCK}; synchronize from {REPOSITORY}") for path in FILES: - if not managed_path(root, path).read_bytes().strip(): + content = managed_path(root, path).read_bytes() + if not content.strip(): raise ValueError(f"Empty source file: {path}") + if local_part(path, content): + raise ValueError("The canonical guide must not contain a repository supplement") else: lock = json.loads(lock_path.read_text()) if lock.get("repository") != REPOSITORY or lock.get("version") != 1: @@ -87,7 +114,7 @@ def check(root: Path, source: Path | None = None) -> None: raise ValueError("The lock must cover the guide and synchronization tool") upstream = source_files(source, revision) if source is not None else None for path in FILES: - local = managed_path(root, path).read_bytes() + local = shared_part(path, managed_path(root, path).read_bytes()) if digest(local) != lock["files"][path]: raise ValueError(f"Local drift: {path}; synchronize, do not edit the copy") if upstream is not None and local != upstream[path]: @@ -104,15 +131,20 @@ def sync(source: Path, revision: str, targets: list[Path]) -> None: "revision": revision, "files": {path: digest(data) for path, data in contents.items()}, } - payloads = {**contents, LOCK: (json.dumps(lock, indent=2) + "\n").encode()} - # Validate every destination before changing any of them. + prepared = [] + # Validate every destination before writing; repositories are then updated in turn. for root in targets: if is_source(root): raise ValueError("Edit the canonical source directly; do not sync over it") + payloads = {**contents, LOCK: (json.dumps(lock, indent=2) + "\n").encode()} for path in payloads: managed_path(root, path) + guide = root / FILES[0] + if guide.exists(): + payloads[FILES[0]] += local_part(FILES[0], guide.read_bytes()) check_routing(root) - for root in targets: + prepared.append((root, payloads)) + for root, payloads in prepared: with TemporaryDirectory(prefix=".review-guidelines-", dir=root) as directory: staged = Path(directory) for path, data in payloads.items(): @@ -137,9 +169,10 @@ def main() -> int: args = parser.parse_args() try: if args.command == "check": - check(Path.cwd().resolve(), args.source.resolve() if args.source else None) + source = repository_root(args.source) if args.source else None + check(repository_root(Path.cwd()), source) else: - sync(args.source.resolve(), args.ref, [p.resolve() for p in args.targets]) + sync(repository_root(args.source), args.ref, [repository_root(p) for p in args.targets]) except (OSError, ValueError, KeyError, TypeError, subprocess.CalledProcessError) as exc: print(f"Review guidance error: {exc}", file=sys.stderr) return 1