GeezerVison is showing github.com — Review rules: lens_report posts a lens child's report by scuttletoby · Pull Request #1085 · scuttletoby/t3code
Conversation
Part of #888 (step T4, lens_report).
Stacked on #1079 (base branch fix/972-review-rules-minors). Retarget to main once #1079 merges.
What
- New T3 tool
lens_report {pr, body} (waits toolkit, orchestration group). Only a thread that lens_start started as a lens child may call it: the newest record in lens-children.json with that thread id. It works only for a pull request that child reads.
- T3 writes the first line,
lens: <lens> · reviewer: <model> · read at: <head>. The lens and head come from the stored child and the reviewer from the caller's model, never from the input.
- T3 posts a new issue comment through
gh api --method POST …/comments --input -. It does so only when the pull request is open and still at that head, and only when the gate would read the comment as one valid read with a findings section.
- It refuses, and says why, when the report:
- is empty;
- holds its own lens marker line (
lens: or a read at naming a sha);
- is longer than
reportMaxChars once T3's line is added;
- has characters the gate's Python reads differently (
PyTextError);
- has no findings section.
- While review rules are off, the tool is hidden and refused, like lens_start (
mcpT3ToolRule.ts).
- The lens prompt now tells children to post with
lens_report and not with gh, and to write no header line themselves.
- Pure rules are in
lensReport.ts, the post is in lensStartServer.ts (report), and the tool is in lensReportTool.ts. The docs are docs/fork/README.md and FORK_CHANGES.md. The tool list budget is re-measured at 4127 bytes.
One source for both sides
review.vectors.json has a new written section with 13 vectors. Each holds the report, the comment T3 posts or why it refuses, and what the gate reads of that comment.
- The expectations were generated with the Python gate's
replay_reads.
review_judge.test.py replays every comment through the Python gate. lensReport.test.ts runs the TS writer and the TS gate copy on the same vectors.
- Both sides' section and field lists include
written, so a vector one side skips fails.
Tests (red → green)
- Unit tests:
lensReport.test.ts.
- Server tests in
lensStartServer.test.ts, over a fake gh:
- one post with the exact args and stdin;
- a repeat posts nothing;
- two calls at once post one comment;
- a lost answer gives
failed, and the retry finds the post;
- an empty store or a foreign thread posts nothing.
- Off/on visibility:
mcpT3ToolFilter.test.ts.
- Mutation checks: I removed each of these in turn, and each removal failed a test: the marker check, the findings check, the moved-head check, the lowercase compare, the closed check, the length check, the duplicate check, the edited-post check, newest-child (
findLast), the report lock, and the off-gate entry.
vp run check:changed passes (format, lint, knip, typecheck, tests). python3 review_judge.test.py and python3 lens.test.py pass.
State question (it posts a comment that decides merges)
- Runs again: the call reads the PR's comments first. An unedited, unhidden comment with the same text (line ends and trailing space normalised) is returned as
already, and nothing is posted.
- Stops half-way: a post whose answer is lost (gh error or timeout after GitHub took it) returns
failed, which says it may or may not be posted. The retry finds the comment and returns already. Nothing else is written, so there is nothing to undo.
- Concurrent: one report posts at a time per server (a semaphore), so two calls at once give one
posted and one already.
- Existing, old or empty state:
- A missing, unreadable or empty
lens-children.json, or a thread not in it, is refused: nothing is posted.
- A head that moved since the child started is refused, so a report of an old head is never posted.
- A closed or unknown pull request is refused.
- lens_report stores nothing itself.
Not in this PR: T5 (lens_arm / C3 judge).
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
lens: state · reviewer: Opus 5.5 · read at: 9d7cecd
Diff read against the #1079 base (19 files), plus review_judge.py and lens.py (how the gate counts a comment) and the children store lensStartChildren.ts.
blocker: none
major: none
minor: the repeat check in planLensReport (lensReport.ts) does not look at the author. An identical, unedited comment by an account the gate ignores (a bot, or an author association that is not in lens_associations) is answered already, so nothing is posted and the lens has no counted read. This can only block, never pass, and the text has to be known first (for example a stranger copies a T3 post that was later deleted). Fix: match only posts with !bot and an association the gate counts.
minor: a second report from the same child at the same head with different text is posted, and the gate reads the newest. A child can quietly swap an earlier major: line for major: none. The tool's next says to post nothing more, but nothing enforces it. Consider refusing a different report when one by the same lens at the same head already exists, or name the case in the docs.
minor: reportLock is one lock for the whole server, held across up to 40 GraphQL pages plus the POST, each with a 60 s timeout. One slow PR stalls every other child's report in every project. Only speed is at risk (a per-PR lock is enough for the one-comment guarantee).
minor: when the children store write fails (lensStartChildren add only logs), the child is later refused as "no lens child lens_start started here". That is safe, but the reason is misleading: it could say the record may be missing.
State question
- Runs again: the call reads the PR's comments, reviews and inline comments first. An unedited, unhidden post with the same text (CRLF and trailing space normalised) is
already, and nothing is posted. The text carries the lens and the full head, so the match is per lens and head. Tested (pure and server).
- Stops half-way:
- T3 restarts between the check and the post: nothing was posted or stored, and the child's retry starts over.
- T3 restarts after the post, before answering: nothing local is recorded (lens_report is stateless), so the retry reads GitHub, finds the post and answers
already. Nothing needs undoing.
- gh fails or times out after GitHub took the post:
failed, and the retry finds the comment (tested).
- The one remaining window: gh is killed at the 60 s timeout while GitHub is still writing, and the retry reads before the write lands. That gives two identical comments, which the gate reads as one lens at one head (same sha, same findings). Harmless.
- Two calls at once: the semaphore orders the read and the post. The fake runner yields between steps, so the two calls interleave, and the test gets one
posted and one already. Zero comments is not reachable: a call that loses the race reads the first call's post.
- Head or open check vs a push: this is a read-then-post (TOCTOU) with no GitHub precondition. If a push lands between them, the comment names the old full sha.
lens_reads and reviewed_head then see a read of a different sha, so it cannot vouch for the new head; at worst it blocks until the next round. A PR that is closed or merged in between gets a dead comment. Both outcomes fail closed.
- Existing, old or empty state:
- A missing, corrupt or empty
lens-children.json decodes to no children: refused, nothing posted.
- The record schema is unchanged, so children stored before this PR decode and can report. A record whose
childThreadId is null can never report (fail closed).
- The newest record of the thread wins (
findLast). A moved head is refused. A closed, merged or unknown PR is refused.
- A body that starts with the override prefix cannot happen, because T3's line comes first and
override_re.match only matches at the start.
Tests run
- At this head, 5 files (lensReport, lensStartServer, mcpT3ToolFilter, lensStart, waits): 119 passed.
review_judge.test.py: 58 passed. lens.test.py: OK.
- My mutation spot-check (widening
reportLock) was not run: the machine's capacity gate refused it twice. The PR body lists its own mutation checks, and the new server tests do fail on the old code (they call report, which the base lacks).
Verdict: safe. Nothing here can make the gate count a read it should not: every gap above only blocks.
🤖 Generated with Claude Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
lens: code · reviewer: Opus 5.5 (high) · read at: 9d7cecd
Code lens of lens_report (diff against fix/972-review-rules-minors only). Read: issue #888 with comments, the PR body, the full diff, every touched file, review_judge.py and the parts of lens.py that the header, marker, override and author rules use.
blocker: none
major: none
minor: the repeat check (planLensReport, input.pull.posts.find(...)) matches a comment by any author. A copy of the report by a stranger (the repo is public) or by an account without a lens association makes the tool answer already. The gate ignores that copy, so the lens never counts. This only blocks (it can't let a change through), and only once the real post is hidden or edited. Fix: match only posts whose author is the gh account that posts, or that have a lens association.
minor: what GitHub stores can differ from what was judged. A lone surrogate is not refused (pyUnicodeCheck looks only at Cn), and GitHub turns it into U+FFFD or rejects the JSON. NUL may be stripped. The repeat check then never matches, and every retry after failed posts another copy. I found no case where the gate passes something it should not: T3's header is fixed ASCII on the first line, and a changed body only blocks. Fix: refuse lone surrogates and C0 controls other than tab, LF and CR, in the body and in the reviewer name.
minor: StoredChild has no repo. The post goes to the repo of the caller's project at the time of the call, and only the 40-hex head check ties it to the record. A child thread moved to another project whose PR of that number is at the same commit (a fork of the same repo) could post there. Fix: store the repo with the child and compare it.
minor: docs/fork/README.md says it posts "only if the gate would read it as one valid read with a findings section". A report with a blocker line and no section is posted, which is correct because it blocks (written vector 3). Wording: "with a findings section or a finding".
What I checked, in a clone of this head:
- Forged caller: the thread id comes from
loadCaller (the server's record of the thread the credential names), never from input. The lens and head come from the newest record for that thread (findLast). An empty, unreadable or evicted store (more than 500) is refused. Another PR, or an older record whose head has moved, is refused.
- Reviewer string and body: 18 probes. I ran the TS writer on each, then replayed every comment it wrote through the Python gate (
replay_reads). The probes: NEL, FS and U+2028 in the reviewer name or body, · / entities, a sha in the reviewer name, <!--, <details>, BOM, a zero-width lens, a quoted lens: line, CR-only line ends, NOT SAFE as the reviewer. Every probe was either refused by T3 or read by the gate as code at the PR head, with the same pass/fail as TS. None read another head or lens.
- Override:
override_re.match is anchored at the start of the comment, and T3's header is always first, so a report can never be read as an override.
- gh:
api --method POST repos/<repo>/issues/<n>/comments --input -, through the process runner (no shell). The body is JSON on stdin. The repo comes from the project's identity, never from input.
- Off: the tool is hidden from the list and the search, and refused, through
LENS_TOOLS in mcpT3ToolRule.ts, and again in planLensReport.
- Seams:
apps/server/src/mcp/toolkits/waits/ is in forkFiles, so handlers.ts and tools.ts need no seam entry. The budget is 3675 → 4127, and ForkAgentContextBudget.test.ts passes.
- Tests: the 10 files under
fork/reviewRules, plus mcpT3ToolFilter, waits and the budget test: 173 passed. personOnlySettings and mcpProfile: 106 passed. review_judge.test.py (58) and lens.test.py pass.
- Outside this PR: the gate still trusts the author association, so an agent with the owner's token can post a lens-looking comment with gh directly.
lens_report doesn't close that, and doesn't claim to.
State question:
- Runs again: the same unedited, unhidden text gives
already, and nothing is posted.
- Stops between the check and the post (T3 restarts): nothing was stored, and the in-memory lock is gone. The retry reads GitHub again.
- Stops after the post, before the answer: the call returns
failed, and the retry finds the comment (except for the changed-text case in the second minor).
- A push between the check and the post: the comment names the old head, and the gate doesn't count it for the new head.
- Existing, old or empty state: an empty or broken
lens-children.json is refused. So is a closed, merged or unknown PR, and so is a moved head. A head force-pushed back to the sha a child read lets that child post again, which is a real read of that commit.
🤖 Generated with Claude Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Merged main 106c78f: conflicts in FORK_CHANGES.md, resolved by keeping main's rows plus this PR's edited row (table re-formatted with vp fmt).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 27, 2026
One commit with this pull request's whole change, so the replay keeps what its merge commits held (old head f833ebb).
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|