Skip to content

fix(review): preserve local requirements in shared OCR guidance - #101

Merged
lanyue-llk merged 2 commits into
mainfrom
codex/review-guidance-followup
Oct 29, 2026
Merged

lanyue-llk merged 2 commits into
mainfrom
codex/review-guidance-followup

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Note: This PR merged at 403736dc: the marker-based supplement in the synced guide, pinning ai-template-py commit 984b8d53. The single-file design described below landed after the merge and continues in #109.

Summary

After #82, OCR loaded only the shared guide and dropped Browser Eval's local review requirements. OCR loads exactly one file per rule entry, so the shared and local rules must live in one file.

This PR puts both in .opencodereview/review-rules.md and points OCR at it. The shared section is copied from lexmount/ai-template-py, with its source commit in the first line. Browser Eval's supplement follows it and points reviewers to AGENTS.md and CONTRIBUTING.md.

It also removes the sync machinery added in #82: scripts/review_guidelines.py, review-guidelines.lock.json, the separate docs/references/review-guidelines.md copy and the CI integrity step. Drift in review prompt text is low-risk and visible in ordinary PR review. To update the shared section, copy the new upstream text in a normal PR and bump the commit.

Earlier revisions of this PR forked the tool, committed a generated copy of the guide, or extended the shared tool. None of that remains.

Changes

  • .opencodereview/review-rules.md: copied shared guide, followed by the Browser Eval supplement.
  • .opencodereview/rule.json: ** → .opencodereview/review-rules.md, merge_system_rule: true.
  • Removed scripts/review_guidelines.py, review-guidelines.lock.json, docs/references/review-guidelines.md, and the "Verify shared review guidance" CI step.
  • AGENTS.md and .github/workflows/README.md describe where each part is edited.

Most of the added lines are the guide moving from docs/references/ into the rules file. The net change is −157 lines.

Dependency

The header names commit c5639aab from lexmount/ai-template-py#8, which removes the sync tool upstream and changes the guide's intro to describe this convention. After #8 merges, update that commit ID in the first line. It's a one-line change, with no lock to re-pin.

Validation

  • make lint-check ruff steps, check_track_naming.py and tests/test_source_language_policy.py (15 passed) all pass.
  • The rules file is 16 KB, under OCR's 512 KB limit, and rule.json parses.
  • Not run locally: the full make ci, because the dependency fetch failed offline.

🤖 Generated with Claude Code

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · e283808

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design review: this fixes the symptom locally and creates a larger, shared-ownership problem

#82 had one defect: OCR loads exactly one rule file per route, and the shared guide refers to "the repository's local review supplement" without naming it. This PR (+804/−155, 11 files) answers that one gap with a forked sync tool, a 246-line committed generated file, an OCR route simulator, a lock-format bump and 306 lines of tests. AGENTS.md treats a large diff as a design signal ("identify the existing owner, the smallest reusable extension"). That rule applies here.

1. Wrong owner. lexmount/ai-template-py still ships scripts/review_guidelines.py (blob d9a27a47, the same file this PR deletes from the lock) and still writes v1 locks. This PR forks that tool into harness/review_guidelines.py, drops it from the lock and introduces lock v2. After merge, the org has two incompatible sync tools and two lock formats. Every other consumer that needs a supplement will either copy these 213 lines or write its own. AGENTS.md calls this a parallel implementation: "Extend the current owner before adding a parallel implementation" and "Keep one supported current implementation of each stage." Composition of shared and local guidance is a cross-repo concern and belongs in the shared template.

2. Three copies of the same policy in Git. The shared guide now exists as docs/references/review-guidelines.md, again inside .opencodereview/review-rules.generated.md, and the supplement is also duplicated there. That duplication is why the PR needs render, a staleness check, a make review-check target and docs explaining regeneration. A derived artifact that can be recomputed should not be committed with drift guards around it.

3. Re-implementing OCR's loader. check_routing simulates OCR's first-match and inline-versus-file semantics with heuristics (no newline, no space, .md/.txt/.markdown suffix). That is a private model of a third-party tool and can silently diverge from it. With a single ** route, an exact-equality assertion on rule.json is enough.

4. Speculative scope. The PR says "Only Browser Eval is updated", yet it adds multi-target batch sync, partial-failure recovery docs, any-remote-name URL parsing and symlink hardening, all tested here. Most of the 306 test lines cover this machinery rather than the defect (that the supplement reaches OCR).

Fundamental alternatives (pick one, each is far smaller)

  • A. Fix it at the owner (preferred). In ai-template-py, standardise the supplement path (.opencodereview/review-rules.md) and have the shared sync tool emit the composed entry, or pin both files in the lock. Browser Eval then only re-syncs: lock, guide, and a supplement it already has. No local fork, no v2.
  • B. Compose at review time, not in Git. In the OCR workflow, run cat docs/references/review-guidelines.md .opencodereview/review-rules.md > "$RUNNER_TEMP/rules.md" before invoking OCR, and point the route there. Nothing generated is committed, and render and the staleness check go away.
  • C. Reverse the routing. Point rule.json at the local supplement and keep the guide verbatim under the lock. If OCR's reviewer can read repo files (this needs verification, since the PR claims it cannot), the supplement's explicit pointer is sufficient. If not, use A or B.

Under any of these, the diff in this repo is roughly rule.json, one supplement line and the lock, plus at most one behavior test proving that OCR's effective rules contain both documents.

Also missing: upstream ai-template-py rule.json has "include": ["**/test_*.py"], which this repo does not mirror. That should be either deliberate and documented, or aligned.

Comment thread harness/review_guidelines.py Outdated
@@ -0,0 +1,213 @@
"""Publish pinned shared guidance through a complete repository review entry."""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fork of the canonical ai-template-py/scripts/review_guidelines.py, which upstream still maintains and which still emits v1 locks. Dropping it from the lock while keeping the same command name and sync behavior with a new lock format is the "parallel implementation" and "changed command under its old name" pattern AGENTS.md forbids. The composition feature should land upstream so every consumer gets it, not in one consumer's harness/. Also, harness/ is described as the home of a benchmark track's shared logic; repo-meta tooling does not belong there.

Comment thread harness/review_guidelines.py Outdated
rule_path = rule.get("rule")
if not isinstance(rule_path, str):
raise ValueError("Each OCR rule must name its complete review entry")
is_file = (

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_file guesses OCR's inline-versus-path semantics from whitespace and file suffix. This re-implements a third-party loader's behavior with no reference to OCR's spec or version, so if OCR's rules differ, this check gives false assurance. With one catch-all route, assert rule.json equality exactly and drop the route simulator (and the tests test_additional_rules_follow_ocr_first_match_behavior and test_inline_rules_preserve_complete_guidance).

Comment thread harness/review_guidelines.py Outdated
check(root)


def sync(source: Path, revision: str, targets: list[Path]) -> None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-target sync, staged install and partial-failure semantics are speculative for a PR scoped to "only Browser Eval". If batch sync is needed, it belongs in the shared tool owned by ai-template-py. As written, the lock this writes (v2) is incompatible with what upstream's tool writes (v1) for the same files, so whichever tool last touched a repo determines which checker accepts it.

Comment thread harness/review_guidelines.py Outdated
return Path(git(path, "rev-parse", "--show-toplevel").decode().strip()).resolve()


def has_source_remote(root: Path) -> bool:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remote-URL parsing still treats a matching remote string as provenance (anyone can git remote add x https://github.com/lexmount/ai-template-py), which the docs admit. If the trust model is "use a trusted checkout", this parsing adds complexity without adding security. Either drop it or verify the commit against GitHub (for example with gh api repos/lexmount/ai-template-py/commits/<sha>) in --source mode.

Comment thread .opencodereview/rule.json Outdated
{
"path": "**",
"rule": "docs/references/review-guidelines.md",
"rule": ".opencodereview/review-rules.generated.md",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointing OCR at a committed derived file is the root of the extra machinery (render, staleness check, make review-check, regeneration docs). Either compose at review time in the OCR workflow into $RUNNER_TEMP, or have the shared sync produce it upstream. A derived file should not need a drift guard in every PR that touches the supplement.

Comment thread review-guidelines.lock.json Outdated
@@ -1,9 +1,8 @@
{
"version": 1,
"version": 2,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lock version bump has no upstream counterpart and no migration for other consumers. ai-template-py at df122812 still produces v1 with both files. Coordinate the format change at the owner first, or keep v1.

Comment thread .github/workflows/README.md Outdated

Synchronization updates the shared guide, generated entry and source lock; it preserves local requirements and executable code. Targets must already configure the generated review entry. Standard HTTPS and SSH remote spellings are accepted under any remote name. The configured URL identifies the intended source; use a trusted checkout because offline checks do not authenticate GitHub. The ordinary check verifies local checksums and composition without network access; `--source` additionally compares bytes with the recorded Git commit.

Batch updates validate all destinations first, then process repositories sequentially. Complete files are staged on the destination filesystem and replaced atomically, with the lock last. A replacement failure can leave mixed versions in the current repository, which verification rejects; retrying the same source revision repairs it. Earlier completed repositories retain their updates. Synchronization does not commit or push changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A paragraph explaining partial batch failure, mixed versions and retry recovery for a single-repo change is a sign that the mechanism is too heavy for the problem. This documentation would disappear under alternatives A or B in the review summary.

Replace the forked review tool, generated OCR entry and v2 lock with the
shared tool from lexmount/ai-template-py, which now preserves a repository
supplement after a marker at the end of the synchronized guide. OCR loads
one file per rule, so the guide it already reads now carries both the
shared criteria and Browser Eval's requirements, with no generated copy.

The lock pins the unmerged source branch commit; re-pin to the merged
commit once the ai-template-py change lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Corrections to my earlier review, after reading OCR's source (internal/config/rules/system_rules.go):

  • The is_file heuristic was not a guess. It matches OCR's actual looksLikeFilePath: single line, no spaces, .md/.txt/.markdown. The objection to simulating OCR's loader still stands, but it no longer matters, because the route is back to the single exact entry.
  • Multi-target sync is legitimate upstream: ai-template-py batch-syncs five consumers. It was speculative only as a local fork.

I've pushed 403736dc, which replaces the approach as described in the updated PR body. The PR is blocked on the ai-template-py branch codex/review-local-supplement merging, followed by a re-pin.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Re-review complete · 403736d

No findings in this incremental review.

@lanyue-llk
lanyue-llk merged commit c967297 into main Oct 29, 2026
6 checks passed
@lanyue-llk
lanyue-llk deleted the codex/review-guidance-followup branch October 29, 2026 11:42
@lanyue-llk lanyue-llk changed the title fix(review): preserve local requirements in shared OCR guidance refactor(review): load one copied rules file instead of a synced guide Oct 29, 2026
@lanyue-llk lanyue-llk changed the title refactor(review): load one copied rules file instead of a synced guide fix(review): preserve local requirements in shared OCR guidance Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant