Skip to content

ci: add pre-commit lint job - #73

Merged
max-sixty merged 3 commits into
mainfrom
sweep/add-lint-ci-23581131535
Mar 28, 2026
Merged

max-sixty merged 3 commits into
mainfrom
sweep/add-lint-ci-23581131535

Conversation

@tend-agent

@tend-agent tend-agent commented Mar 26, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a lint job to the CI workflow that runs pre-commit checks (ruff, typos, actionlint, uv-lock) on every push and PR. Also fixes ruff formatting in a test file that was flagged.

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

tend-agent and others added 2 commits March 26, 2026 06:44
The `.pre-commit-config.yaml` added in #68 (ruff, typos, actionlint,
uv-lock) only runs locally. PRs can pass CI with linting violations.
Add a `lint` job using `pre-commit/action` so CI enforces the same checks.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@max-sixty
max-sixty merged commit 2f3aedc into main Mar 28, 2026
3 checks passed
@max-sixty
max-sixty deleted the sweep/add-lint-ci-23581131535 branch March 28, 2026 06:18
max-sixty pushed a commit that referenced this pull request Aug 7, 2026
#875)

The `review-runs` evidence log lives in one rolling comment on the
monthly tracking issue, and the skill finds it with "newest comment
authored by the bot". That selector is wrong whenever another skill has
posted on the same issue more recently — which is now the steady state
on `max-sixty/cargo-affected`, where `tend-nightly` posted its own
below-threshold finding as a second comment on the
`review-runs-tracking` issue.

Run the current recipe verbatim against that issue today:

```console
$ gh api "repos/max-sixty/cargo-affected/issues/73/comments" \
    --jq '[.[] | select(.user.login == "cargo-affected-bot")] | last | .id'
5188771252     # tend-nightly's comment, "## Nightly run 30984146563 — 2026-08-05"
```

The evidence log is `5150650688` ("## Run 30691987081 —
2026-08-01T08:37:18Z", 42 KB, six daily entries). A run that follows the
recipe literally appends its findings under the nightly's heading and
leaves the log orphaned — with no error, because both comments are valid
PATCH targets. The size guard a few lines down then measures the wrong
body too (2.5 KB instead of 42 KB), so it would keep appending there
indefinitely.

## Why it hasn't broken yet

Both `tend-review-runs` runs since the nightly comment appeared noticed
and silently deviated, hard-coding the right comment ID instead of
running the selector. From each run's session JSONL:

| Run | Date | What it executed |
|---|---|---|
|
[30989981741](https://github.com/max-sixty/cargo-affected/actions/runs/30989981741)
| 2026-08-05 | `TARGET=5150650688` then `gh api
.../issues/comments/$TARGET -X PATCH` |
|
[31085867626](https://github.com/max-sixty/cargo-affected/actions/runs/31085867626)
| 2026-08-06 | listed the comments, then `TARGET=5150650688` and the
same PATCH |

The 2026-08-05 run also wrote down why, in its own summary: *"Nightly
posted its finding as a second tracker comment, so the skill's `| last`
append target now resolves to it. I appended to the review-runs comment
(`5150650688`) instead to keep the log contiguous — cosmetic, no
evidence lost, and the cross-skill convention would be bundled guidance
rather than a repo overlay."* It classified the fix as bundled guidance
and recorded it below-threshold on the tracker, which is as far as it
could take it from the adopter side.

So correctness currently depends on the model spotting a broken
instruction and ignoring it, two runs in a row. That's the part worth
removing.

## Fix

Match the evidence log by the `## Run <id>` heading the finding format
already mandates, rather than by recency. Verified against both tracking
issues:

```console
$ # max-sixty/cargo-affected #73 (nightly comment present)
$ gh api ".../issues/73/comments" --jq '[.[] | select(.user.login == "cargo-affected-bot" and (.body | test("^## Run [0-9]")))] | last | .id'
5150650688     # the evidence log

$ # max-sixty/tend #801 (no interloping comment)
$ gh api ".../issues/801/comments" --jq '[.[] | select(.user.login == "tend-agent" and (.body | test("^## Run [0-9]")))] | last | .id'
5150655987     # unchanged from the old selector
```

`// empty` still falls through to the create-new branch on a fresh
monthly issue, and `| last` is kept so a rollover comment (started when
the previous one passes 50 KB) still wins over the one it replaced.

## Gate assessment

- **Gate 1 — confidence**: High. Structural and deterministic, not
stochastic: the selector's result is fixed by what's on the issue, and
the wrong answer is reproducible on demand (above). 2 occurrences of a
run having to deviate (2026-08-05, 2026-08-06), both confirmed from the
posting call in each session log rather than inferred from timing. High
needs 2–3.
- **Gate 2 — magnitude**: Targeted fix (one jq predicate, one comment,
one clause of prose), Normal bar. No new section, no restructuring.
- **Failure mode is invisible**: a literal-following run produces a
successful PATCH to the wrong comment. Nothing fails, no CI turns red,
and the fork would only surface when someone reads the tracker.

Not proposed here: migrating `review-runs` to the gist-backed store
`review-reviewers` uses (there's a `TODO` in the file for it). That's a
structural change against a very high evidence bar, and this selector is
wrong regardless of where the log ends up.

Evidence log: https://gist.github.com/dca23a6e6a0d8cae2665944ba31676fb

---------

Co-authored-by: tend-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Aug 7, 2026
…nst tend before filing upstream (#891)

## Problem

Two dedup blocks were blind in two different ways, and the cited
duplicate needed both fixed.

**State filter.** `review-runs` Step 5 and `review-reviewers` Step 4
both deduped against PRs with `gh pr list --state open`. A merged PR is
never returned by that query, so a finding whose fix already landed
reads as undeduped and gets filed again. `running-in-ci`'s PR-creation
dedup recheck already gets this right ("with `--state all` so closed and
merged siblings show up"); these two recipes contradicted it.

**Repo scope.** `review-runs` is a generated workflow
([`generator/src/tend/config.py:24`](https://github.com/max-sixty/tend/blob/f65f49f/generator/src/tend/config.py#L24)
lists it in the enabled set), so it runs in each adopter's checkout and
an unqualified `gh pr list` returns *the adopter's* PRs. Step 6 routes
bundled-skill defects upstream to tend, but neither Step 5 nor any of
`running-in-ci`'s dedup recipes — all local-repo — told the agent to
dedup in the target repo before filing there. `--state all` alone does
not close this: the adopter's PR list never contained the upstream fix
at any state.

`review-reviewers` is unaffected by the second half. It runs in
`max-sixty/tend` and files onto tend, so its unqualified `gh pr list`
already resolves to the right repo; only the state filter was wrong
there.

This bites hardest on tend specifically, because of the pinning model:
adopters call `max-sixty/tend/<harness>@X.Y.Z`, so a merged skill fix
stays dormant on their repos until the next release tags. The bug keeps
reproducing after the fix merges — which is exactly the window in which
the analysis legs are looking at it, and exactly when the dedup queries
are blind to the fix.

## What happened

`max-sixty/cargo-affected`'s `tend-review-runs` run
[31160677649](https://github.com/max-sixty/cargo-affected/actions/runs/31160677649)
(08:11:33Z → 08:21:41Z) hit the `| last` evidence-log mis-selection: it
appended ~12 KB of run evidence into the nightly's unrelated comment on
target [#73](max-sixty/cargo-affected#73),
noticed on its post-verify read, restored comment `5188771252`, and
re-appended to the real log `5150650688`. Good recovery. It then filed
[#883](#883) upstream, whose
"Proposed fix" is a `## Run ` heading predicate on the comment selector.

[#875](#875) merged that exact fix
at 07:34:40Z — 46 minutes before the issue was filed — as `test("^## Run
[0-9]")` on the same selector, in the same file. #883 is a duplicate of
a merged PR.

The run made three dedup queries before filing (`gh issue list --state
all --search "tracking issue comment append"`, a broader `gh issue list
--state all` title regex, and a final `gh issue list --state open`
recheck). All three were `gh issue list`, which never returns PRs — and
all three ran against `max-sixty/cargo-affected`. Even had it run Step
5's PR line verbatim, it would not have returned #875, for both reasons:
the state filter excluded merged PRs, and the query's repo was the
adopter's, not tend's.

## The fix

- Both skills: `gh pr list --state open` → `--state all`, projecting
`state,mergedAt` so a merged hit is legible.
- `review-runs` only: add the cross-repo pair (`gh pr list`/`gh issue
list --repo max-sixty/tend --state all`) so a finding heading upstream
under Step 6 is deduped against tend first.
- `review-runs` only: the pinning note is scoped to the upstream repo,
since in that skill the reader is the adopter and the local `gh pr list`
above it has nothing to do with pinned refs. `review-reviewers` keeps
the original wording, where tend is the reader and "on adopters" is the
correct direction.

Both added commands were run against this repo to confirm they parse and
return the expected shape.

## Gate assessment

- **Evidence level**: High. **Occurrences: 1** direct, verified end to
end (session log, both dedup query sets, #875's merge time and diff,
#883's body).
- **Structural, not stochastic.** `gh pr list --state open`
deterministically cannot return a merged PR, and a query scoped to the
adopter's repo deterministically cannot return a tend PR; replayed ten
times it misses #875 ten times. There is no decision point.
- **Change type**: targeted fix — query lines plus one sentence naming
the pinning consequence. It brings both recipes into line with a rule
the same plugin already states in `running-in-ci`, rather than
introducing new policy.
- **Why act at one occurrence**: the six-PR batch merged at 07:34:40Z
([#875](#875),
[#834](#834),
[#868](#868),
[#818](#818),
[#877](#877),
[#858](#858)) is all unreleased,
so six distinct bugs remain observable on every adopter until the next
release. The first analysis leg after that batch produced the first
duplicate. The exposure is six-wide and standing, not one-off.

## Not covered by

No open PR touches either dedup block.
[#845](https://github.com/max-sixty/tend/pull/845)/[#850](https://github.com/max-sixty/tend/pull/850)/[#838](https://github.com/max-sixty/tend/pull/838)
are the run-window cluster;
[#849](#849),
[#856](#856),
[#857](#857),
[#864](#864),
[#869](#869),
[#876](#876),
[#809](#809),
[#837](#837),
[#821](#821),
[#836](#836) are elsewhere.

#883 stays open as a maintainer call — it is redundant with #875 but the
option-2 half of its body (finish the gist migration for `review-runs`)
is not.

Evidence: https://gist.github.com/dca23a6e6a0d8cae2665944ba31676fb

---------

Co-authored-by: tend-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Aug 11, 2026
…omment (#945)

`review-runs` appends each leg's findings to a single evidence comment
on the monthly tracking issue, and guards the 65,536-character comment
limit by checking the size of the comment **before** appending
([`review-runs/SKILL.md#L111-L112`](https://github.com/max-sixty/tend/blob/3222d4ce823b3ae10ebc2c76ee3825fd9eb6acbc/plugins/tend-ci-runner/skills/review-runs/SKILL.md#L111-L112)
— `EXISTING_SIZE=$(wc -c < /tmp/existing.md)`, `-lt 50000`). That
threshold implies a maximum append of 15,536 characters. Appends are
larger than that.

Measured on `max-sixty/cargo-affected`'s tracking issue
[#73](max-sixty/cargo-affected#73), splitting
both evidence comments on their `## Run` headings (character counts, not
bytes):

| Comment | Appends | Largest | Final size |
|---|---|---|---|
| `5150650688` (Aug 1–7) | 4,570 / 3,980 / 7,985 / 8,661 / 8,202 / 9,215
/ 14,559 | 14,559 | 57,172 |
| `5225265385` (Aug 8–11) | 11,481 / 12,938 / **16,947** / 14,467 |
**16,947** | 55,833 |

The Aug 10 append (run
[31369370104](https://github.com/max-sixty/cargo-affected/actions/runs/31369370104))
was 16,947 characters — 1,411 more than the headroom the guard leaves.
Had it landed on a comment sized in `[48,590, 50,000)`, the guard would
have taken the append branch and the PATCH would have exceeded 65,536.
Appends have also grown steadily: ~4 KB on Aug 1, 12–17 KB since Aug 8.
`max-sixty/tend`'s own tracking issue
[#801](#801) shows the same
distribution (largest append 14,695).

The failure mode is invisible. `gh api ... -X PATCH` returns 422 on an
over-length body, the recipe has no fallback branch, and the surrounding
step is not `set -e` — so the leg's findings are dropped and the run
still reports `success`. The next leg then reads a log missing its
predecessor and counts occurrences against incomplete history.

The fix sizes the body it is about to POST rather than a proxy for it,
which removes the assumption entirely: build `/tmp/combined.md` first,
branch on its size, spill to a new comment when it wouldn't fit. `wc -c`
counts bytes and bytes ≥ characters in UTF-8, so 60,000 is a
conservative bound under the 65,536-character limit with room for the
multi-byte overhead these bodies carry (~0.6%).

No behavior changes when the append fits, which is the common case; the
spill branch it already had is simply reached on the correct condition.

<details><summary>Gate assessment</summary>

- **Evidence level**: structural, not stochastic — the guard's
arithmetic is fixed, so whether it overflows depends only on sizes, and
the premise (`append < 15,536`) is falsified by measurement rather than
inferred from behavior. **Occurrences of a realized overflow: 0** — all
11 daily legs of August are present in the log on both repos, so no
evidence has been lost yet. Occurrences of an append exceeding the
guard's headroom: 1 of 11 on the target this month, with 5 more within 1
KB of it.
- **Gate 1**: this is below the table's bar read literally (a plausible
problem seen once is Medium, needing 5+). Filing anyway because the
finding is a provable defect in shipped recipe text rather than a
judgment call about model behavior, and because the first realized
occurrence costs a silently lost day of evidence. Close it as premature
if you'd rather wait for the overflow.
- **Gate 2**: targeted fix — 7 lines changed in one recipe, strictly
more accurate than the check it replaces, no new guidance or structure.
- Distinct from [#883](#883)
(append *target* selected with `| last`) and
[#938](#938) (window anchor),
which touch the same recipe but not the size check.

Window analyzed: 2026-08-11T08:11:35Z → 09:11:35Z on
`max-sixty/cargo-affected`, run
[31476466100](https://github.com/max-sixty/tend/actions/runs/31476466100).
Evidence log: https://gist.github.com/dca23a6e6a0d8cae2665944ba31676fb

</details>

---------

Co-authored-by: tend-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Aug 13, 2026
`review-runs` picks its evidence-log append target with `test("^## Run
[0-9]")`
([`review-runs/SKILL.md#L96-L97`](https://github.com/max-sixty/tend/blob/c9e44e2266881538ce3ff6e55e497e790e067248/plugins/tend-ci-runner/skills/review-runs/SKILL.md#L96-L97)).
jq's `^` anchors to the start of the **string**, not the start of a
line, so the predicate only matches a log comment whose body begins at
offset 0 with the heading. The rollover comment that the create-new
branch three lines below posts routinely does not: the appended entry
carries its own leading blank line or `---` separator, so the body opens
with `\n## Run …` or `\n\n---\n\n## Run …`.

When that happens the selector skips the live log and resolves to an
older one — in practice the comment that was rolled over precisely
because it had grown near GitHub's 65536-byte body limit. From there the
run either appends its entry into a superseded comment out of
chronological order, or (once `existing + findings ≥ 60000`) takes the
rollover branch again and posts a fresh comment, repeating every run.
Both are wrong outward actions on a public issue, and both return 200,
so nothing surfaces the fault: the only symptom is that a later run's
"read historical evidence" step gets a fragmented, out-of-order log and
evaluates its gates on it.

The fix anchors the heading to a line start with `(^|\n)`. One character
class; no new state, no new step.

## Evidence

The shape is the ordinary output of the recipe's own rollover branch,
not an edge case. Measured live against `max-sixty/cargo-affected`'s two
`review-runs` trackers, projecting each bot comment's opening bytes and
both predicates:

```
tracker #62                                        ^## Run [0-9]   (^|\n)## Run [0-9]
  4852429465  "## Run 28505825777 — 202"  50513B       true              true
  4933725185  "\n## Run 29081041973 — 20" 49882B       false             true
  5020367025  "\n\n---\n\n## Run 2972877" 53815B       false             true
  5115269072  "\n\n---\n\n## Run 3043648" 14314B       false             true    <- the live log
```

Three of the four log comments are invisible to the current predicate,
and the one it does match is the 50 KB comment that was superseded
first. On `cargo-affected`'s current tracker `#73` all three log
comments happen to open at offset 0, so the predicate resolves correctly
there today.

It does not resolve correctly on **this** repo's own trackers, which
have the same rollover shape:

```
tracker #801 (2026-08, live)                       ^## Run [0-9]   (^|\n)## Run [0-9]
  5150655987  "## Run 30691978877 (revie" 51624B       true              true
  5225291682  "\n\n## Run 31247464586 (re" 49817B      false             true    <- the live log

tracker #752 (2026-07)
  4852508712  "## Run 28505815799 (revie" 51431B       true              true
  4967003130  "\n\n## Run 29318247045 (re" 51451B      false             true
  5089350899  "\n\n## Run 30251718970 (re" 18327B      false             true    <- that month's live log
```

On `#801` the predicate skips the live log and resolves to the
51,624-byte comment — 8,376 bytes under the recipe's own 60,000-byte
append bound, so the next run either appends out of chronological order
or forks a third comment.

The fault has not fired yet, and the append history shows why:
`5150655987` carries runs `30691978877`…`31160618137` (last updated
2026-08-07) and `5225291682` carries `31247464586`…`31577212332` (last
updated 2026-08-12), in order and without interleaving. Every one of
those runs predates the predicate — they executed the bare `| last`
path. `0.1.15` was tagged and this repo's workflows were pinned to it in
#958 at 2026-08-12 21:38 UTC, after that day's `review-runs` run
(`31577212332`, 08:11 UTC). The next daily cron here is the first
execution of the mis-anchored predicate anywhere, and `#801` is already
in the shape that mis-resolves.

Replayed against a fixture of the four `cargo-affected` shapes plus a
`tend-nightly` comment and a non-bot comment, using the recipe's exact
`--jq` string:

```
OLD selector picks:  1        # the oldest, superseded, near-limit log
NEW selector picks:  3        # the live log
NEW selector, full matched set: [1, 2, 3]   # nightly and non-bot comments correctly excluded
```

jq's `m` flag is not an alternative — in jq it means "`.` matches
newline", not multi-line anchors:

```
$ jq -n '"\n## Run 123" | test("^## Run [0-9]")'        # false
$ jq -n '"\n## Run 123" | test("^## Run [0-9]"; "m")'   # false
$ jq -n '"\n## Run 123" | test("(^|\n)## Run [0-9]")'   # true
```

(jq-1.7, the version on the runner.)

## Relation to prior work

The predicate arrived in #875 as the fix for #883, replacing a bare `|
last` that any other bot comment on the tracker could hijack. That
change is right and this doesn't undo it — it only corrects the anchor.
A [comment on
#883](#883 (comment))
reasoned that the rollover branch was covered because
"`/tmp/findings.md` always opens with `## Run <RUN_ID>`"; the bodies
above are the counterexample. #883 stays open on its remaining half (the
gist migration), which this doesn't touch.

## Gate assessment

- **Gate 1 — confidence**: High. Structural: jq's `^` has no decision
point, and the selector depends on a property (`findings.md` starting at
offset 0) that the recipe never establishes anywhere. Occurrences: 6 log
comments across three trackers that the predicate fails to match,
measured live and independently of the observation that raised it —
including this repo's own live tracker `#801`. It has not fired yet only
because every run so far executed `0.1.14`'s bare `| last`; the `0.1.15`
pin bump lands the mis-anchored predicate in service on the next cron.
- **Gate 2 — magnitude**: targeted fix to a specific incorrect
instruction, at the normal threshold. One line changed plus the comment
explaining why `^` isn't enough, so a later session doesn't simplify it
back.
- **Gate 3 — cost**: wrong outward action. Each occurrence posts to the
wrong comment on a public issue or adds another comment to the tracker
the recipe exists to avoid spamming, and permanently forks the evidence
log the gates are evaluated against. The fix is a character class, well
below what that class justifies.

Observed on `max-sixty/cargo-affected` during [review-reviewers run
31676935131](https://github.com/max-sixty/tend/actions/runs/31676935131).
Accumulated evidence:
https://gist.github.com/dca23a6e6a0d8cae2665944ba31676fb

Co-authored-by: tend-agent <[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