Skip to content

Use native gh, GraphQL, and git features instead of hand-rolled ones; read every page of the repo's notifications - #1457

Merged
max-sixty merged 6 commits into
mainfrom
api-simplifications
Sep 29, 2026
Merged

max-sixty merged 6 commits into
mainfrom
api-simplifications

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Replaces hand-rolled mechanisms with features the tools and APIs tend already uses provide natively, and fixes two bugs the sweep found. Net −204 lines across 55 files.

Bugs

  • mark_notification_read only saw the first 50 threads of the bot's whole inbox. It read gh api notifications unpaginated — every repo's threads, first page only — so a bot with more than 50 unread threads never marked this repo's thread. It now reads repos/{repo}/notifications across every page and marks this event's thread only when its updated_at is strictly before the run's start. The comparison stays client-side because the API's before= filter has returned threads bumped after its cutoff.
  • review-reviewers couldn't read the verify job log or all of a PR's reviews. gh api .../jobs/<id>/logs exits 1 on gh 2.101 when the log carries terminal escapes, and pulls/<n>/reviews unpaginated drops the newest past 30. Now gh run view --log and gh pr view / gh issue view --json.

Simplifications

  • Pagination: gh api --paginate --slurp replaces four hand-written decoders of concatenated pages (github_cli, the inlined mention and notifications checks); gh's GraphQL --paginate with $endCursor replaces poll_pr_checks.fetch_rollup's cursor loop.
  • CODEOWNERS preflight: one GraphQL query reads each candidate directory's entry mode and blob text, replacing up to three Contents probes (404s detected by matching HTTP 404 in stderr), a base64 decode, and a separate mode query. Precedence (.github/, root, docs/) and the refusals — symlink, submodule, binary, truncated — are kept.
  • Codex: codex plugin add --json's installedPath replaces scraping Installed plugin root: from its text output. Codex's warnings go to stderr, which both the runner and the surface probe keep out of the parsed JSON.
  • Nightly: git diff --cached --quiet -I '<stamp line>' decides whether only the version stamp changed, instead of regexing a diff.
  • checks.py: environments are read from the listing already fetched (it carries protection_rules and deployment_branch_policy); one rulesets listing and one login lookup instead of three and two.
  • Duplicates: Cancelled / raise_on_cancel live once in _common; gist_memory uses require_env; mark_notification_read uses subject_number. The proxy pid file nothing read is gone.
  • Skills: gh api's {owner}/{repo} placeholders replace seven REPO=$(gh repo view …) round trips. The yolo merge gate is the PUT with sha alone — GitHub refuses a moved head (409) and a closed or unmergeable PR (405) itself. run-tend states the real hazard of gh run watch / gh pr checks --watch.

Left as is

A search-based count in rate_limit_preflight (the search index lags creation by seconds, weakening the burst guard); gh run watch anywhere (it treats one failed read as a finished run); token_report / list_recent_runs (#1397 edits them).

#1171 will conflict in mark_notification_read.py on rebase: its early return sat after the event-parsing line this removes. Read the event name from env and the action from _common.event_payload() instead.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 5 commits September 29, 2026 14:27
…s' logs and reviews

mark_notification_read read one unpaginated page of the bot's whole inbox (50
threads across every repo), so a busy bot never marked a thread past the first
page. It now reads the repository's notifications, every page, with GitHub
applying the run-start cutoff through before=.

review-reviewers fetched the verify job log with gh api, which gh 2.101 refuses
for a log carrying terminal escapes, and read PR reviews unpaginated, dropping
the newest past 30. It now uses gh run view --log and gh pr/issue view --json.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…cel handler

- codex plugin add --json's installedPath replaces scraping its text output.
- security_preflight reads the CODEOWNERS entry modes and blob text in one
  GraphQL query, instead of up to three Contents probes told apart by
  'HTTP 404' in stderr plus a separate mode query.
- Cancelled/raise_on_cancel live once in _common; gist_memory uses
  require_env; mark_notification_read uses subject_number.
- Drop the proxy pid file nothing reads; correct ensure_label's docstring.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…listing each

- --slurp replaces four hand-written decoders of concatenated pages
  (github_cli, the mention and notifications checks), and gh's GraphQL
  --paginate replaces fetch_rollup's cursor loop.
- nightly_workflow_update asks git diff -I whether only the version stamp
  changed, instead of regexing a diff.
- checks.py reads each environment from the listing it already fetched, and
  keeps one rulesets listing and one login lookup.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… preconditions

- gh api fills {owner}/{repo}; drop the gh repo view round-trips.
- The yolo merge PUT carries sha, and GitHub refuses a moved head (409) or a
  closed/unmergeable PR (405) itself, so the pre-read of state and head goes.
- run-tend states the real hazard of gh run watch / gh pr checks --watch.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

test-codex-surface is red because of this PR. The installed path is in the output, but json.loads fails on the line in front of it. Details are inline, along with a question about whether the notification guard still needs its client-side cutoff.

Comment thread shared/steps/codex_surface.py Resolved
Comment thread shared/steps/mark_notification_read.py Resolved
…off client-side

- The surface probe merged stderr into stdout, so codex's PATH-alias warning
  (printed when CODEX_HOME sits under /tmp) landed in front of the JSON. The
  plugin probe now leaves stderr to the log, as the runner does; the fake
  codex now warns the same way.
- The notifications API's before= filter has returned threads bumped after its
  cutoff, so it can't be the guard against marking mid-run activity read. The
  comparison is made on each thread's updated_at again, strictly before the
  run's start, and the read drops before=.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 511d587 into main Sep 29, 2026
14 checks passed
@max-sixty
max-sixty deleted the api-simplifications branch September 29, 2026 21:51
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Sep 30, 2026
Upgrades the generated Tend workflows from 0.3.4 to 0.3.5
([compare](max-sixty/tend@0.3.4...0.3.5)).
The regenerated YAML changes little on its own: the action pin moves to
`max-sixty/tend/[email protected]`, and most of the behavior change arrives
through the new action's bundled skills and scripts.

What maintainers will notice:

- **Bot PRs get their review findings applied.** The review workflow now
decides whether to apply its own findings by who authored the PR, so a
review on a bot-authored PR follows through with a fix instead of
stopping at the comment (max-sixty/tend#1433).
- **Relayed PR-review mentions are named after the PR.** `tend-mention`
runs triggered through `tend-mention-relay` now get the PR title as
their run name rather than the event type, and the notifications poll
uses that name to tell which PR a live run is handling
(max-sixty/tend#1450). The relay job also skips when `TEND_ENABLED` is
`false`, instead of dispatching a run that does nothing
(max-sixty/tend#1452).
- **CI waits run to completion instead of a fixed cap.** CI polling and
integration-test waits now wait for checks to settle instead of timing
out at about 9 minutes, so a slow matrix reports its real result rather
than "unverified" (max-sixty/tend#1448, max-sixty/tend#1451).
- **Fewer truncated listings.** Pagination now reads every page of
notifications, failed-run jobs, and workflow listings
(max-sixty/tend#1435, max-sixty/tend#1442, max-sixty/tend#1457). The
inline pagination helpers in `tend-mention` and `tend-notifications` now
use `gh api --paginate --slurp`.
- **Weekly dependency review matches Dependabot and Renovate PRs
again.** It now matches on the `app/…` author login that `gh` reports
(max-sixty/tend#1441).
- **Nightly and review behavior.** Repo overlays can now skip advisory
checks, review findings are ranked by severity, and the nightly issue
sweep rotates across issues (max-sixty/tend#1450). `ci-fix` recurrence
comments now lead with what changed (max-sixty/tend#1446).

Also bumps the pinned `uv` from 0.12.17 to 0.12.19 in the pre-check
steps. `.config/tend.yaml` has no model pin, so there was no model to
update.

Co-authored-by: worktrunk-bot <[email protected]>
max-sixty added a commit to max-sixty/leaf that referenced this pull request Oct 1, 2026
#1162)

Update the generated Tend workflows from 0.3.2 to 0.3.5. The 0.3.3
refresh workflow moves credential rotation into a dedicated
`tend-codex-refresh` environment, separate from agent jobs. The 0.3.4
action update makes feature-request triage replies more useful and marks
notifications read after answered relayed PR reviews. It also improves
repository-specific refresh PAT setup and handles shells that force
colored `gh` output. The obsolete `control_plane_owner` generator
setting is removed; the existing CODEOWNERS rule still requires a fresh
owner approval.

0.3.5's CI poll waits for checks to settle rather than giving up after 9
minutes, which [#1441](#1441)
depends on; it also names relayed mention runs for their PR and stops
the relay while Tend is paused.

The refresh credentials are already provisioned: `tend-codex-refresh`
admits only `main` and holds `CODEX_REFRESH_AUTH_JSON` and
`CODEX_REFRESH_PAT`, and `tend` no longer holds copies. Fresh
control-plane owner approval is required.

[Upstream
changes](max-sixty/tend@0.3.2...0.3.5),
including
[max-sixty/tend#1418](max-sixty/tend#1418),
[max-sixty/tend#1448](max-sixty/tend#1448),
[max-sixty/tend#1450](max-sixty/tend#1450), and
[max-sixty/tend#1457](max-sixty/tend#1457).

---------

Co-authored-by: leaf-agent <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.

2 participants