Repository navigation
feat: run only the CI suites a change reaches, gated by one CI Gate and a pre-push hook (DOTGH-1) - #10
Conversation
…nd a pre-push hook (DOTGH-1) Every repository set up CI its own way, and none shared the changed-suites routing Talaria built. CI.md is now the contract: a suites file of ordered rules, a router action that selects suites from a pull request's merge-base diff or a push's diff from the last commit CI passed on, a gate action that fails naming the job that did not pass, and a maudecode-ci command that prints the selection and runs the selected suites' lint and typecheck before a push.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (2)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31420f17e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 31420f17e4
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| run(async () => { | ||
| const env = process.env; | ||
| const workspace = env.GITHUB_WORKSPACE ?? process.cwd(); | ||
| const config = readConfig(resolve(workspace, env.INPUT_CONFIG)); |
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Security: Load routing policy from the trusted base
Condition: in a consumer using the documented pull-request checkout and CI Gate as its required check, a PR author controls the checked-out .github/ci-suites.json. This line loads that head copy before routing, so the PR can add a valid first rule mapping both the policy and malicious source paths to []. The router emits suites=[]; all suite jobs skip; and ci-gate accepts the empty selection and reports success. Load routing policy from the trusted base revision, or force policy/workflow changes to select every suite.
Useful? React with 👍 / 👎.
| git: gitIn(process.cwd()), | ||
| // One stream, so a failure's output reads in the order it was written. | ||
| exec: (command, cwd) => { | ||
| const ran = spawnSync("sh", ["-c", `exec 2>&1\n${command}`], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "inherit"], maxBuffer: 256 * 1024 * 1024 }); |
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Security: Stop executing worktree-controlled hook commands
Condition: a developer has enabled the documented pre-push hook, checks out an untrusted PR head, and pushes it. prePush strings come from the PR's working-tree config and reach this sh -c unchanged; a PR can route its own config change to a suite whose command runs as the developer before the push. The HEAD check only confirms that the attacker head is checked out. Load commands from a trusted revision and install an immutable hook outside PR-controlled paths, or replace shell strings with an allowlisted command model.
Useful? React with 👍 / 👎.
Ticket
DOTGH-1
Problem
Each MaudeCode repository sets up CI its own way. Talaria routes changed paths to suites with a 557-line script and gates them with a
CI Gatejob. Cowtail runs five workflows with separatepathsfilters.RELEASES.mdtells a repository to name its gate job, but nothing shared provides one.Solution
This follows the repository's existing layout: logic in
lib/, thin actions,node --test, and no dependencies.lib/suites.js:select(config, paths)reads.github/ci-suites.jsonrules in order, and the first matching glob decides each path."*"selects every suite and[]selects none. An unmatched path, or a path with an empty,.or..segment, selects every suite. The result is the union over all paths, and each path records the index of the rule that decided it. Config errors name the offending key. The suite namessuitesandbaseare refused because they would collide with outputs.git diff --name-only --no-renames. A rename therefore counts under both paths, and ablob:noneclone never fetches contents. I checked this on a blobless clone withGIT_NO_LAZY_FETCH=1.actions/ci-suites: sets one output per suite, plussuitesandbase, and writes a job summary that shows the first path and rule behind each selected suite. Base selection by event:pull_request: the merge base.pushto the default branch: the head of the newest earlier push run that succeeded, among the last 50. Failed and cancelled runs are skipped.actions/ci-gate: inputs areneeds,selected, and an optionaljobsmap. A job is required when any suite it runs is selected. Each failure prints its own::error::naming the job. If the router fails, the emptyselectedis reported as well.package.json(@maudecode/ci) andbin/maudecode-ci.js:suites --base … [--head] [--merge-base] [--config] [--explain]andpre-push. The pre-push command skips tags and deletions and refuses a pushed branch that is notHEAD. It selects onorigin/<default>...HEAD, runs the selectedprePushcommands in order, running a command shared by two suites only once, and stops at the first failure. If selection fails, it runs every suite's commands. The package has no install or build script.hooks/pre-push: the stub a repository copies to.githooks/pre-push.CI.md: the numbered contract (items 1–10) and aci.ymlto copy, which passes actionlint 1.7.12.RELEASES.mdlinks to it from its intro and item 4.Decisions to review
jobsmap. The gate cannot tell an unselected suite's job from any other needed job, so any needed job other than a selected suite's may succeed or be skipped. A router that fails is still caught: it endsfailure, and its empty selection is reported.CI.mdsays to passjobswhen a workflow has jobs besides the router and the suites. Withjobs, every unlisted needed job must succeed.ci.yml: CI Gate. A push compares with the last commit on which CI passed. So a gate that passed on a push means every suite passes on that commit.CI.mditem 8 says so.engines.nodeis>=22.5.0, the first 22.x withpath.matchesGlob. Node 20 is end-of-life.*and**do not match dot-names inpath.matchesGlob.CI.mdsays to write such paths literally (.github/**). An unmatched dot-path falls back to every suite.Validation
node --test: 33 pass, 0 fail (the existing release and iOS tests plus 13 new tests intest/suites.test.jsandtest/cli.test.js).actionlinton theci.ymlextracted fromCI.md: exit 0. The repository's ownci.yml: exit 0.ci-suiteson apull_requestevent against this branch: outputslib=true docs=true,suites=["lib","docs"],base=20b180b…, and a summary table.ci-gate: a failed required job exits 1 and names the job, a failed router exits 1, and a passing run exits 0.CI.md's suites example passescheck(), and its documented routing holds:web/README.mdselects no suite, andprotocol/a.tsselectswebandcli.node --test, which picks up the new test files.Regression proof
This change adds a feature, so there is no pre-fix commit to test against. Each behavior was instead removed by a mutation in a scratch copy of baseline
31420f1, and the same command,node --test, went red at the owning test's assertion:AssertionError: web/convex/a/b.test.ts(selectedweb, docs, expectedweb)--no-renamesmaudecode-ci suites… counting a rename under both paths…+ 'web=false\ncli=true…' - 'web=true\n'./..segment checkAssertionError: web//a.tsExpected values to be strictly equal(basefailed, expectedpassed)skippedAssertionError: {"web":{"result":"skipped"}}Expected values to be strictly equal(ran more thanlint web)AssertionError: refs/tags/v1.0.0 …Green:
node --teston31420f1passes 33 of 33.Codex finding (gate accepted a selected suite when only one of its mapped jobs was in
needs): the test was added first, andnode --test test/suites.test.json31420f1went red atwith a jobs map, a job is required…withactual: '': the gate passed withweb_e2emissing. The fix is in1aa6b67, where the same command and the fullnode --testpass 33 of 33.Device / screenshots
None. There is no user-visible UI.
Risk
Low for existing users: the release and iOS actions are unchanged apart from the
RELEASES.mdlinks. No repository adopts the contract in this PR. Cowtail and Talaria adopt it in their own tickets.Rollback
Revert this PR. Nothing consumes it yet.