Skip to content

feat: run only the CI suites a change reaches, gated by one CI Gate and a pre-push hook (DOTGH-1) - #10

Merged
kiliantyler merged 2 commits into
mainfrom
ci/DOTGH-1-factory-e635aad7
Nov 24, 2026
Merged

kiliantyler merged 2 commits into
mainfrom
ci/DOTGH-1-factory-e635aad7

Conversation

@kiliantyler

@kiliantyler kiliantyler commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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 Gate job. Cowtail runs five workflows with separate paths filters. RELEASES.md tells 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.json rules 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 names suites and base are refused because they would collide with outputs.
    • The diff runs git diff --name-only --no-renames. A rename therefore counts under both paths, and a blob:none clone never fetches contents. I checked this on a blobless clone with GIT_NO_LAZY_FETCH=1.
  • actions/ci-suites: sets one output per suite, plus suites and base, 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.
    • push to the default branch: the head of the newest earlier push run that succeeded, among the last 50. Failed and cancelled runs are skipped.
    • Every other event, an unreadable diff, or an API failure: every suite.
  • actions/ci-gate: inputs are needs, selected, and an optional jobs map. 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 empty selected is reported as well.
  • package.json (@maudecode/ci) and bin/maudecode-ci.js: suites --base … [--head] [--merge-base] [--config] [--explain] and pre-push. The pre-push command skips tags and deletions and refuses a pushed branch that is not HEAD. It selects on origin/<default>...HEAD, runs the selected prePush commands 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 a ci.yml to copy, which passes actionlint 1.7.12. RELEASES.md links to it from its intro and item 4.

Decisions to review

  • Gate without a jobs map. 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 ends failure, and its empty selection is reported. CI.md says to pass jobs when a workflow has jobs besides the router and the suites. With jobs, every unlisted needed job must succeed.
  • Releases can name 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.md item 8 says so.
  • engines.node is >=22.5.0, the first 22.x with path.matchesGlob. Node 20 is end-of-life.
  • * and ** do not match dot-names in path.matchesGlob. CI.md says 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 in test/suites.test.js and test/cli.test.js).
  • actionlint on the ci.yml extracted from CI.md: exit 0. The repository's own ci.yml: exit 0.
  • I ran both action entrypoints by hand the way the runner calls them:
    • ci-suites on a pull_request event against this branch: outputs lib=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 passes check(), and its documented routing holds: web/README.md selects no suite, and protocol/a.ts selects web and cli.
  • The repository's CI job already runs 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:

Mutation Red test Assertion excerpt
last matching rule wins instead of first the first rule that matches a path decides its suites… AssertionError: web/convex/a/b.test.ts (selected web, docs, expected web)
drop --no-renames maudecode-ci suites … counting a rename under both paths… + 'web=false\ncli=true…' - 'web=true\n'
drop the empty/./.. segment check a path no rule may decide selects every suite AssertionError: web//a.ts
accept any earlier run as a push base a push tests its diff from the newest earlier run that passed… Expected values to be strictly equal (base failed, expected passed)
let a required job be skipped the CI gate passes when every required job succeeded… AssertionError: {"web":{"result":"skipped"}}
keep going after a failing pre-push command the pre-push hook stops at the first failure… Expected values to be strictly equal (ran more than lint web)
run checks for tag pushes the pre-push hook skips tags and deletions AssertionError: refs/tags/v1.0.0 …

Green: node --test on 31420f1 passes 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, and node --test test/suites.test.js on 31420f1 went red at with a jobs map, a job is required… with actual: '': the gate passed with web_e2e missing. The fix is in 1aa6b67, where the same command and the full node --test pass 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.md links. 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.

…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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T04:34:58.771781Z 31420f1 Manual request
🔒 Security Review ✅ Completed 2026-11-24T04:44:04.032011Z 31420f1 Manual request

Security findings

Advisory findings (2)

ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kiliantyler

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread lib/suites.js Resolved
@kiliantyler
kiliantyler merged commit c22c421 into main Nov 24, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector 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.

🛡️ 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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

P2 Badge 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 👍 / 👎.

Comment thread bin/maudecode-ci.js
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 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

P2 Badge 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 👍 / 👎.

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.

1 participant