Repository navigation
feat(ci): add a change-scope action so a light-only PR skips the full lane - #314
Conversation
A PR that touches only markdown, docs/, .claude/ or .vscode/ still runs every product repo's full CI: SahajCloud#1265, one line of .claude/workflow.json, waited 12-16 minutes on lint, typecheck, the Postgres suites and the Railway smoke lane, then again in the queue. A trigger filter cannot fix it, because the job is a required check and paths-ignore stops it reporting. The action decides inside the run and outputs `full`; callers gate steps, or jobs through `needs`. Every doubt (push, unreadable base, empty diff) is full. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The shape is right and the diff is the size of the problem: a required check cannot be filtered by path, so deciding inside the run and gating steps is the only lane that keeps the merge queue working.
The base derivation is not. On actions/checkout's default depth-1 checkout the merge ref has no parents, so the head^2 guard fires before the deepening fetch below it and every PR takes the full lane. The light lane fires only in the merge queue, where line 18 fetches its base first. This repo already derives a base twice, in contract-check/action.yml and ci.yml, from base.sha on the event — two lines, and the case block goes.
Two body claims do not hold. ## Safety says the base is "fetched at depth 2 if the checkout was shallow"; that fetch is unreachable. ## Tested reports a docs-only merge commit giving false, from a scratch repo that cannot have been shallow. The body also weighs no alternative but paths-ignore: say no to dorny/paths-filter explicitly.
Findings
- blocker —
scope.sh:14: thehead^2guard precedes the fetch that would make it pass. - should-fix —
scope.sh:30: an invalidlightreads asfull=false. Fail-open. - should-fix —
action.yml:21: SahajCloud's unit tests read.mdanddocs/.
What was checked
Both new files whole, the AGENTS.md and why.md edits, and contract-check/{action.yml,check.sh} plus this repo's ci.yml as the siblings that already solve the base. Added prose checked against documentation.md and code-comments.md: the ⚠ block is protected, so not flagged. Consumer side: SahajCloud's ci.yml checkout depth, and git ls-tree for the two unit tests that read markdown. Both failure modes reproduced in a scratch repo. new-pieces.mjs says NONE, so no streamliner ran; the ladder was walked by hand for both pieces.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`actions/checkout` defaults to `fetch-depth: 1`, where the merge commit is grafted and lists no parents. `HEAD^2` therefore exited 1 on every pull request, the guard fired, and every PR took the full lane — the light lane only ever fired in the merge queue, which fetched its base first. The deepening fetch on the next line was unreachable. The base now comes off the event, `pull_request.base.sha || merge_group.base_sha`, as `contract-check/action.yml` and this repo's `ci.yml` already read it, and the `case` block goes with it. An event with neither, a push among them, has no base and takes the full lane. Verified in a scratch depth-1 clone of a `refs/pull/N/merge` ref: a docs-only PR now gives `full=false`, a PR touching code gives `true`, and a missing or unreachable base gives `true`. Addresses #314 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXjFzrdjq6zUmC44CZ
`grep -vE` exits 2 with no output on an invalid pattern, and exits 1 with no output when every file is light. Both left `heavy` empty, so a typo in a caller's `light` input reported `full=false` and skipped the full lane on every PR — the one thing the file's second line promises cannot happen. The status is now read, and anything above 1 takes the full lane. Verified against the scratch depth-1 harness: `light` of `\.md$|^docs/|[` on a docs-only PR gave `full=false` before and gives `full=true` now, with a warning naming the input. Addresses #314 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXjFzrdjq6zUmC44CZ
The default `light` included `\.md$|^docs/`, yet markdown is exactly what a repo is most likely to read from a test. SahajCloud's `tests/unit/perf-figures-pinned.spec.ts` asserts `tests/PERF.md`'s figures against four consumer docs, and `tests/unit/docs-auth.spec.ts` reads docs too, so a prose-only PR there would have skipped the one suite written to catch that edit. The default is now `^\.claude/|^\.vscode/` — editor and agent config, which no build reads by construction. A repo that knows its prose is unread widens `light` itself, which is why the input exists. Narrowed rather than dropped so the five consumer PRs stay valid as written; a required input would have each of them edited before they could pass. `light: ''` is now the full lane too: an empty regex matches every line, so it would otherwise have read as all-light. Verified against the scratch depth-1 harness: with the new default a README-and-docs PR gives `full=true`, a `.claude/`-only PR gives `false`, and an empty `light` gives `true`. Addresses #314 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXjFzrdjq6zUmC44CZ
`ci.yml:77` diffs the same two commits with three dots, and the two files now sit a screen apart, so unifying them looks like a tidy-up. It is not: there is no merge base to find in a depth-1 checkout, and three dots would fail there. Docs sync for this branch: `docs/why.md` and this header carry the new default and the new failure paths; `AGENTS.md`'s change-scope paragraph needed no edit, and nothing else in the tree describes the input. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXjFzrdjq6zUmC44CZ
|
Three findings from the adversarial review, all adopted. Pushed 85fdce2.
The body's Lean gate green: plugin validate, 162 lib tests. No path matches 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
There was a problem hiding this comment.
Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. 🤖 Written by the sydevs autonomous loop — see what this is
What
A new composite action,
.github/actions/change-scope/, which each product repo's CI calls as the first step after checkout. It outputsfull=falsewhen every changed file matches thelightregex. The default is^\.claude/|^\.vscode/, editor and agent config alone. Each caller then gates its expensive steps on that output, or gates whole jobs throughneeds.Markdown and
docs/are deliberately not in the default: a repo's tests may read its prose. SahajCloud pinstests/PERF.md's figures against four consumer docs, so a prose-only PR there must still take the full lane. A repo that knows its prose is unread passes a widerlightitself.The failure it prevents
SahajCloud#1265 changes one line of
.claude/workflow.json, yet it runs 12–16 minutes of CI: lint, both typechecks, the unit and Postgres integration suites, the Railway preview wait and the smoke specs. The merge queue then runs all of that again. Nothing in that lane reads the file. The same happens on every guide, docs and agent-config PR the loop opens.Why not
paths-ignoreThe jobs are required checks. With
paths-ignore, a required check never reports, so the PR can never merge. A job skipped byifreports SKIPPED, and the ruleset accepts that.dorny/paths-filteris the same shape as this action and would do the job, but it is a third-party dependency on every CI run in four repos, and it still would not decide the base: it readsbasefrom the event exactly as this does. Forty lines of bash besidecontract-check, which already derives that base, costs less to audit than a pinned action to keep updated.Safety
Any doubt sends the PR to the full lane. That covers an event carrying no base (a push among them), a base commit that can't be fetched, a diff that fails, an empty diff, and a
lightthat is empty or not a valid extended regex.The base is
pull_request.base.sha || merge_group.base_sha, read off the event ascontract-check/action.ymland this repo'sci.ymlalready read it, then fetched at depth 1. It is never read off the checkout:actions/checkoutdefaults tofetch-depth: 1, where the merge commit is grafted and has no parents at all.This repo's own CI doesn't call the action, because here the markdown is the product.
Rollout
This PR merges first. Consumer PRs in SahajCloud, WeMeditateWeb, SahajAtlasWeb, SahajAtlasWordpress and WeMeditateApp reference
@main, so their CI fails until this lands.Each of those PRs inherits the narrowed default, so a repo that wants its markdown or
docs/in the light lane now passes its ownlightand says which suites read neither. None of them needs an edit to stay correct — only to stay as fast as the first draft implied.Tested
scope.shran against a scratch origin carrying a realrefs/pull/N/mergeref, cloned at--depth=1and checked out the way a runner does — the shallow case the first draft of this action could not survive. With alightof\.md$|^docs/: a prose-only PR givesfalse, a PR touching code givestrue. With the shipped default: aREADME.md-and-docs/PR givestrue, a.claude/-only PR givesfalse. An emptylight, an invalidlight, an absent base and an unreachable base sha each givetrue.claude plugin validate ./workflow --strictnode --test workflow/lib/*.test.mjsSecurity review: skipped. No changed path matches
securityReview.triggerPattern.🤖 Generated with Claude Code