Skip to content

feat(ci): add a change-scope action so a light-only PR skips the full lane - #314

Merged
Ardnived merged 5 commits into
mainfrom
claude/ci-change-scope
Nov 24, 2026
Merged

Ardnived merged 5 commits into
mainfrom
claude/ci-change-scope

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What

A new composite action, .github/actions/change-scope/, which each product repo's CI calls as the first step after checkout. It outputs full=false when every changed file matches the light regex. The default is ^\.claude/|^\.vscode/, editor and agent config alone. Each caller then gates its expensive steps on that output, or gates whole jobs through needs.

Markdown and docs/ are deliberately not in the default: a repo's tests may read its prose. SahajCloud pins tests/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 wider light itself.

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-ignore

The jobs are required checks. With paths-ignore, a required check never reports, so the PR can never merge. A job skipped by if reports SKIPPED, and the ruleset accepts that.

dorny/paths-filter is 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 reads base from the event exactly as this does. Forty lines of bash beside contract-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 light that is empty or not a valid extended regex.

The base is pull_request.base.sha || merge_group.base_sha, read off the event as contract-check/action.yml and this repo's ci.yml already read it, then fetched at depth 1. It is never read off the checkout: actions/checkout defaults to fetch-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 own light and 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.sh ran against a scratch origin carrying a real refs/pull/N/merge ref, cloned at --depth=1 and checked out the way a runner does — the shallow case the first draft of this action could not survive. With a light of \.md$|^docs/: a prose-only PR gives false, a PR touching code gives true. With the shipped default: a README.md-and-docs/ PR gives true, a .claude/-only PR gives false. An empty light, an invalid light, an absent base and an unreachable base sha each give true.

Lean gate Result
claude plugin validate ./workflow --strict ✓
node --test workflow/lib/*.test.mjs ✓ 162 passed

Security review: skipped. No changed path matches securityReview.triggerPattern.

🤖 Generated with Claude Code

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-dispatcher

sydevs-dispatcher Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🤖 no session running

recent dispatches
  • 18:37Z address-review · attempt 1 · session · done
  • 18:37Z address-review · attempt 1 · session
  • 18:29Z review-pr · attempt 1 · session · done
  • 18:29Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧐 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: the head^2 guard precedes the fetch that would make it pass.
  • should-fix — scope.sh:30: an invalid light reads as full=false. Fail-open.
  • should-fix — action.yml:21: SahajCloud's unit tests read .md and docs/.

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

Comment thread .github/actions/change-scope/scope.sh Resolved
Comment thread .github/actions/change-scope/scope.sh Resolved
Comment thread .github/actions/change-scope/action.yml Resolved
@Ardnived
Ardnived enabled auto-merge November 24, 2026 18:36
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 24, 2026
`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
@sydevs-bot sydevs-bot changed the title feat(ci): add a change-scope action so docs-only PRs skip the full lane feat(ci): add a change-scope action so a light-only PR skips the full lane Nov 24, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor

Three findings from the adversarial review, all adopted. Pushed 85fdce2.

  • scope.sh:14 — the base now comes off the event, not the merge commit. 1f115fc. This was the blocker: on actions/checkout's default depth 1 the merge commit is grafted, so HEAD^2 exited 1 and every PR took the full lane.
  • scope.sh:30 — grep's status is read, so a bad or empty light runs the full lane. 60036e0.
  • action.yml:21 — the default light is ^\.claude/|^\.vscode/; markdown and docs/ are out. b63b770.

The body's ## Safety and ## Tested are rewritten against a real depth-1 harness, ## Why not paths-ignore now rejects dorny/paths-filter, and ## Rollout says what the consumer PRs inherit. The title narrowed with the default.

Lean gate green: plugin validate, 162 lib tests. No path matches securityReview.triggerPattern.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 24, 2026

@sydevs-dispatcher sydevs-dispatcher 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.

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

@Ardnived
Ardnived added this pull request to the merge queue Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 24, 2026
Merged via the queue into main with commit 0288c17 Nov 24, 2026
60 of 64 checks passed
@Ardnived
Ardnived deleted the claude/ci-change-scope branch November 24, 2026 18:48
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants