Skip to content

operator-issue-diff: Diff the last two edits of an issue body - #7

Merged
cgwalters-bot merged 1 commit into
cgwalters-forge:mainfrom
cgwalters-bot:dispatch/implement/agent-run-41165556147
Nov 4, 2026
Merged

cgwalters-bot merged 1 commit into
cgwalters-forge:mainfrom
cgwalters-bot:dispatch/implement/agent-run-41165556147

Conversation

@cgwalters-bot

Copy link
Copy Markdown
Collaborator

Port the controller's one-off operator-issue diff check into the toolbox, as specified for #3. operator-issue-diff OWNER/REPO#N reads the issue body's userContentEdits through gh api graphql and 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 or GH_TOKEN.

It adds serde_json and similar as the crate's first dependencies. parse_target is now shared with gh-pr-checks.

Verified with cargo fmt and just check; the new tests replay recorded GraphQL responses through a fake gh, with no network. There is no just fmt recipe.

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 same editedAt have no deterministic tie-break; issue text goes to stdout raw, control characters included; parse_target could move to a shared module instead of being imported from gh_pr_checks; the CLI test covers the "no change" path only as a unit test.

Closes #3

Generated by dispatch · ◷

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

@github-actions github-actions 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.

VERDICT: CHANGES

Reviewed admitted head ecdcfc09ec703b975e2d16839018f77801412b75 against merge base 5e5eae2a9fb8646c2cefeaf6745aab2af0f39b5a.

  1. [blocker] crates/misctool/src/operator_issue_diff.rs:62,84-91 — Edit summaries are not body snapshots. GitHub documents UserContentEdit.diff as ‘A summary of the changes for this edit’ (schema reference). Assigning that field to body and passing two such values to TextDiff produces 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 and crates/misctool/tests/cli.rs:75 conceal this by supplying complete bodies in diff; 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.

  2. [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 fetched diff must 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.

  3. [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.

  4. [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.

Generated by review for #7 at ecdcfc0

@cgwalters-bot

cgwalters-bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

✅ dispatch ended well. Result: #7

@github-actions github-actions 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.

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.

Generated by review for #7 at 274971c

@cgwalters-bot
cgwalters-bot merged commit d7b9d8e into cgwalters-forge:main Nov 4, 2026
13 checks passed
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.

Seed subcommand: the operator-issue diff check

1 participant