Repository navigation
operator-issue-diff: Diff the last two edits of an issue body - #7
Conversation
Port the controller's one-off operator-issue diff check into the toolbox, as specified for cgwalters-forge#3, so operators can see what changed in an issue body between its last two revisions without a bespoke script. It only reads, using gh's authentication or GH_TOKEN, and exits 0 for no change, 1 for a change and 2 on errors. GitHub documents UserContentEdit.diff as a change summary, but it holds the whole body at that revision; the command checks this against the current body on every run and refuses to diff otherwise. Issue text is untrusted, so control and bidi characters are printed escaped. Verified with just check and live runs against public cli/cli and rust-lang/rust issues. Generated-by: https://github.com/cgwalters/#llms
There was a problem hiding this comment.
VERDICT: CHANGES
Reviewed admitted head ecdcfc09ec703b975e2d16839018f77801412b75 against merge base 5e5eae2a9fb8646c2cefeaf6745aab2af0f39b5a.
-
[blocker]
crates/misctool/src/operator_issue_diff.rs:62,84-91— Edit summaries are not body snapshots. GitHub documentsUserContentEdit.diffas ‘A summary of the changes for this edit’ (schema reference). Assigning that field tobodyand passing two such values toTextDiffproduces a diff of change summaries, not the promised diff between body revisions. The equality check likewise compares summaries rather than bodies. The tests at lines 142-144 andcrates/misctool/tests/cli.rs:75conceal this by supplying complete bodies indiff; they do not establish that actual GitHub responses work. Use a source or reconstruction that yields the two actual body revisions, or explicitly redesign the command around the API's edit summaries. Add a regression using a representative, sanitized real response and assert the resulting body diff. -
[important]
crates/misctool/src/operator_issue_diff.rs:60-62— An irrelevant deleted edit prevents comparison of available recent edits. Both ends of the history are fetched, but every fetcheddiffmust be non-null before the latest two are selected. With four chronologically ordered edits where only the oldest is deleted, the latest two are available, yet the command exits 2 without comparing them. Select the required revisions before requiring their content; retain an error when one of the revisions actually needed for comparison is unavailable. Add a test with a deleted old edit and two intact recent edits. -
[important]
crates/misctool/src/operator_issue_diff.rs:70-71— Timestamp ties can select the wrong pair and reverse the diff. The comparator treats distinct edits in the same timestamp second as equal. Because the sort is stable and the two connection ends are concatenated and deduplicated first, their input order becomes the implicit chronology. For example, three same-timestamp edits A, B, C returned newest-first yield[C, B, A]; the selected pair is then B → A rather than B → C. Use a proven chronological connection/cursor order to resolve ties, or report ambiguity rather than silently guessing. Cover three same-timestamp revisions and histories longer than four in tests. -
[important]
crates/misctool/src/operator_issue_diff.rs:128— Untrusted issue content is emitted as terminal control sequences. The diff preserves issue-supplied escape and carriage-return characters and prints them directly. An issue author can therefore erase or overwrite displayed diff lines, misleading the operator about the change; supported OSC sequences can also affect terminal state. Render control characters visibly for terminal output (preserving ordinary line breaks), with any raw machine-readable mode explicit, and add a regression containing escaped control characters.
No workflow, merge-policy, or CODEOWNERS changes are present. A person must still approve the merge under this repository's merge policy.
ecdcfc0 to
274971c
Compare
There was a problem hiding this comment.
VERDICT: APPROVE
Reviewed the entire admitted diff at 274971c. No actionable correctness or security defects found.
The command passes validated repository arguments as GraphQL variables, performs a read-only query limited to two revisions, rejects deleted revisions and a current-body mismatch, and escapes terminal controls in the displayed diff. The added tests cover revision ordering, same-second edits, an initially empty body, unchanged content, error handling, and CLI exit codes. No workflow or ownership-policy files change.
A person must still approve the merge under the repository's merge policy.
Port the controller's one-off operator-issue diff check into the toolbox, as specified for #3.
operator-issue-diff OWNER/REPO#Nreads the issue body'suserContentEditsthroughgh api graphqland prints a unified diff between the two most recent edits. It exits 0 when there is no change or fewer than two edits, 1 when the body changed and 2 on errors. It only reads, using gh's authentication orGH_TOKEN.It adds
serde_jsonandsimilaras the crate's first dependencies.parse_targetis now shared withgh-pr-checks.Verified with
cargo fmtandjust check; the new tests replay recorded GraphQL responses through a fakegh, with no network. There is nojust fmtrecipe.Review: one pass, no blockers. Follow-ups it left open: a deleted edit (null
diff) anywhere in the up to four fetched edits fails the command even when it isn't one of the last two; edits with the sameeditedAthave no deterministic tie-break; issue text goes to stdout raw, control characters included;parse_targetcould move to a shared module instead of being imported fromgh_pr_checks; the CLI test covers the "no change" path only as a unit test.Closes #3