Skip to content

#611 Nightly doc-accuracy reviewer opens a draft PR with its fixes - #612

Merged
nockawa merged 1 commit into
mainfrom
feature/doc-drift-auto-pr
Jul 31, 2026
Merged

nockawa merged 1 commit into
mainfrom
feature/doc-drift-auto-pr

Conversation

@nockawa

@nockawa nockawa commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Fixes #611

Extends the Layer-2 nightly reviewer (#490) so it applies the fixes it finds and opens a draft PR, instead of only filing issues.

Why

Filing an issue throws the verification away. The job already reads the source and confirms file:line on both sides — serialising that to prose means the next human re-derives all of it before they dare trust it. The #604–#608 batch (PR #610) is the measurement: the bot had verified every claim, and the fix still cost a full session of re-reading DagScheduler.cs to confirm what the bot already knew.

The job split is the security boundary

Job Permissions Contains
review contents: **read**, issues: write the LLM + author-controlled input. Files issues as today, then edits doc/. Output: a patch artifact.
open-pr contents: write, pull-requests: write no LLM. Applies the patch, commits, pushes doc-drift/nightly, opens/updates the draft PR.

The existing workflow header documents prompt injection as expected and pins the worst case at "one stray issue". Granting the LLM step contents: write would move that to "arbitrary commit on main" — and main's protection currently requires neither reviews nor status checks. Actions permissions: has no path or branch scope, so "may commit to doc/ on a non-main branch" is not expressible as a token grant. Narrowing it has to be structural.

A path guard between the jobs fails the run if any tracked file outside doc/ was touched.

Two decisions worth reviewing

Claude edits files; it does not author diff text. Unified-diff hunk headers encode exact line numbers and context counts, git apply rejects the whole patch on any mismatch, and models miscount context lines. git diff derives the patch mechanically.

git merge origin/main, not rebase. A rebase rewrites the branch and could only be pushed with --force — which would clobber commits pushed to that branch by hand. Merge keeps every push a fast-forward, so plain git push always suffices. Conflict → abort, comment on the PR, fail the run; never auto-resolved. The merge commits never reach main because the repo squash-merges.

Verified, not just written

  • YAML parses; every run: block passes bash -n.
  • Path guard against a real repo: doc edit + untracked scope scratch → passes; tracked src/ edit → fails. The first case was a bug I introduced — scope leaves merged.json/prs.txt/aff_*.json untracked in the workspace, so a git status-based guard would have failed every single run. It now checks tracked paths only; untracked files are never staged, so they cannot reach the patch anyway.
  • Fixes dedup: #601 suppressed as already-present, #60 kept despite being a substring (grep -vxF).
  • Full open-pr rehearsal against a sandbox with a diverged branch, a hand-pushed maintainer commit on it, and an advanced main: merge OK → git apply --3way clean → push with no --force → the maintainer's edit survived intact in both the file and the history.

The one acceptance criterion still open is a real nightly run on the runner — can be forced early with workflow_dispatch.

Not in scope

🤖 Generated with Claude Code

https://claude.ai/code/session_01SVvtTh6p1AJoSX85AGcAhF

…fixes, not just issues [no-ut]

Filing an issue throws the verification away. The job already reads the source and confirms file:line on both sides; serialising that to prose means the next human re-derives all of it before they dare trust it. The #604-#608 batch cost a full session re-reading DagScheduler.cs to confirm what the bot already knew. A diff carries the verification in a form you can check by looking at it.

Split into two jobs, and the split is the security boundary rather than organisation. `review` keeps contents:read and holds the LLM plus the author-controlled input; its only output is a patch. `open-pr` holds the write token, contains no LLM, and sees nothing but a patch that already passed a doc/-only path allowlist. Actions permissions have no path or branch scope, so "may commit to doc/ on a non-main branch" cannot be expressed as a token grant — narrowing it has to be structural, and main's protection currently requires neither reviews nor checks.

Claude edits files; it does not author diff text. Hunk headers encode exact line numbers and context counts, git apply rejects the whole patch on any mismatch, and models miscount context lines — so git diff derives the patch mechanically from edits the model is actually good at making.

Merge main into the branch rather than rebase: a rebase rewrites it and could only be pushed with --force, which would clobber whatever was committed there by hand. Merge keeps every push a fast-forward. A conflict aborts, comments on the PR and fails the run; nothing is ever auto-resolved. The extra merge commits never reach main because the repo squash-merges.

Issues are still filed unchanged — they are this layer's dedup ledger, and Fixes #N in the PR body means merging closes them so the ledger self-cleans.

The path guard checks tracked paths only. Matching on git status would have failed every single run, because the scope step leaves merged.json, prs.txt and aff_*.json untracked in the workspace; untracked files are never staged, so they cannot reach the patch anyway.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVvtTh6p1AJoSX85AGcAhF
@nockawa
nockawa merged commit e4c2bcd into main Jul 31, 2026
13 checks passed
@nockawa
nockawa deleted the feature/doc-drift-auto-pr branch July 31, 2026 12:51
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.

CI: nightly doc-accuracy reviewer opens a draft PR with the fixes, not just issues

1 participant