Skip to content

MR-14: ci-scope in shadow mode - #784

Merged
michaeljgrimm merged 1 commit into
mainfrom
codex/mr-14-ci-scope
Oct 21, 2026
Merged

michaeljgrimm merged 1 commit into
mainfrom
codex/mr-14-ci-scope

Conversation

@michaeljgrimm

Copy link
Copy Markdown
Contributor

MR-14 of the monorepo program (docs/programs/monorepo/README.md, section 4 "verify contents", step 1 scope, and Phase 1). Additive: one new script, one test, one check:ci-scope script. No package behavior, workflow or ruleset changes.

What it does

node scripts/ci-scope.mjs --base <base> --head <head> (or --files a b c) answers three questions for a change:

  1. Which packages are affected: the directly changed packages, plus their dependents through the workspace graph (the same edges as pnpm --filter "...[base]").
  2. Which tier each runs: full for a changed package, contract for a dependent, skip otherwise. A forced run (any scripts/, .github/, pnpm-lock.yaml, root configuration, unclassified path, the full-ci label, an empty or unreadable diff, any event other than pull_request) runs every package at full. Overall class: docs, leaf, engine, core, all (the rows of the plan's target table).
  3. Which jobs verify must run: lint (always), the package jobs (gallery, core, render, pptx, editor, cli, integration) with their tier, goldens (render src/fonts/golden, examples, core src, gallery, spec/reference), gallery-gates (check:previews and check:stability, which run in packages/integration; runs when gallery, core or render changed: the one edge the manifests cannot express, S7) and pack-shape. Output is JSON, --format text|markdown, --github-output (tier, changed, affected, jobs, matrix, required, ...) and --summary (step summary).

Path map (first match; fails closed): packages/<x>/ to its package (packages/javascript is core; evidence logs under packages/<x>/docs/evidence are docs, decks *.opf.json are not); spec/, examples/, skills/, README.md, top-level docs/*.md (core embeds them), docs/fixtures/, docs/quickstart/, docs/first-deck/ and every deck under docs/ outside docs/programs/ to core; docs/programs/, docs/evidence/ (no decks), other docs/, root documents, changes/, .claude/ to docs (no package; lint gates it); scripts/, .github/, test/, pnpm-lock.yaml, pnpm-workspace.yaml, package.json, biome.json, .nvmrc, .gitattributes, .npmrc, .gitignore, ecosystem.lock.json, release-plan.json and anything unknown to all.

The graph source is swappable (--graph manifests|target|union|<file.json>): manifests reads the package manifests as pnpm does (dependencies, devDependencies, optionalDependencies using workspace:, link: or file:; peers and registry ranges are not edges); target is the plan's graph (TARGET_GRAPH: gallery has no edge, core depends on gallery, render on core and gallery, pptx on core, gallery and render, editor and cli on those, integration on all); union (default) is both, so before MR-10/MR-23 wire the manifests, and for packages not imported yet, the dependents are still right. It does not import check:workspace-graph (MR-10), so it works before that merges.

Tests (pnpm check:ci-scope, 23 tests, also part of pnpm test)

  • The six S5 scenarios (editor-only, CLI-only, renderer, PPTX, core, cross-cutting) plus gallery-only and integration-only, each in a scratch git repo with the target manifests, compared with the real pnpm --filter "...[origin/main]" (and "[origin/main]" for the cross-cutting case); skipped only if pnpm is not installed. The plan's S5 table is also spelled out, so a graph change has to be deliberate.
  • The root-owned paths (spec/, docs/programs, scripts/, lockfile, workflows): pnpm selects only the root project for every one of them; ci-scope decides by the path map (the reason the script exists).
  • Edge cases: lockfile only, root configuration, scripts, workflows, gallery records only (all six affected at contract, goldens and gallery gates run), docs only (lint only), docs/*.md and evidence decks as core inputs, spec and examples, unclassified paths and unknown package directories (fail closed, reported), package evidence logs, a manifest-only change, non-PR events, full-ci, an empty diff, an unreadable diff, a file moved out of a package (both sides listed), file names with spaces, the three-dot merge-base semantics, the graph sources (a registry range of gallery is not an edge; the union keeps the target edge), the command line and its GitHub outputs.

Shadow validation on the last 30 merged PRs

Method: one GraphQL query (cost 1 point: pullRequests(states: MERGED, first: 50, orderBy: UPDATED_AT) with mergeCommit, baseRefOid, headRefOid, changedFiles, files(first: 100)), sorted by mergedAt, the first 30 (#777 down to #746; equal to the 30 newest first-parent commits of main). For each, the changed paths come from the local git diff --name-only -z --no-renames <merge commit>^1 <merge commit> (exactly what landed), cross-checked against the API file list (* = the API list is truncated at 100 files, so the local diff is the reference). scope() runs on that list with the union graph of this checkout; "packages/ dirs touched" is computed independently from the path prefix and must equal the directory-derived part of changed. changed can additionally contain core for core inputs outside packages/javascript (docs/*.md, spec, examples, README).

PR Title Files packages/ dirs touched ci-scope changed Class Jobs besides lint Dirs match
#777 MR-01: plan decisions D16–D18 and the S7 gallery move 3 - core core core render pptx editor cli integration gallery-gates pack-shape yes
#775 FA-33: release CLI 0.25.0 5 cli cli leaf cli integration pack-shape yes
#776 RR-101: release plan on the 0.25.0 set 19 cli, core core, cli all all 11 (forced) yes
#774 MR-00: plan v2: gallery in, one shared version, no merge que 2 - - docs none yes
#773 RR-101: published control accepts newer patch releases (plan 7 - core all all 11 (forced) yes
#772 FA-33: release core 0.25.0 10 cli, core core, cli core core render pptx editor cli integration goldens gallery-gates pack-shape yes
#771 RR-50: roll ecosystem.lock.json to the four main branches 1 - - all all 11 (forced) yes
#770 FA-33: adopt gallery 5.0.0 21 cli, core core, cli all all 11 (forced) yes
#756 FA-33: layouts as one list of regions 182* cli, core core, cli all all 11 (forced) yes
#769 RR-101: release plan on editor 0.24.2 10 - core all all 11 (forced) yes
#768 RR-101: control job runs the Playwright 1.64 image 2 - - all all 11 (forced) yes
#766 docs: add timeless slide design principles 3 - core core core render pptx editor cli integration gallery-gates pack-shape yes
#765 RR-50: roll ecosystem.lock.json to the four main branches 1 - - all all 11 (forced) yes
#764 MR-00: monorepo program plan (approved; starts after 0.25.0) 2 - - docs none yes
#763 RR-97: release plan and published matrix on the 0.24 set 13 - core all all 11 (forced) yes
#762 RR-100: publish and tag trust green CI of the exact commit 18 - core all all 11 (forced) yes
#761 RR-97: release CLI 0.24.1 5 cli, core core, cli all all 11 (forced) yes
#760 RR-97: release core 0.24.2 3 core core core core render pptx editor cli integration gallery-gates pack-shape yes
#759 RR-97: changelog note for core 0.24.2 1 - - docs none yes
#758 RR-97: check:examples-convert runs in-process (publish job u 5 - - all all 11 (forced) yes
#757 RR-97: release core 0.24.1 4 core core core core render pptx editor cli integration gallery-gates pack-shape yes
#753 RR-97: opf convert reports an unreadable image as a warning 4 cli, core core, cli core core render pptx editor cli integration goldens gallery-gates pack-shape yes
#755 RR-50: roll ecosystem.lock.json to the four main branches 1 - - all all 11 (forced) yes
#752 RR-97: every example converts: embedded supporting photos 120* - core all all 11 (forced) yes
#754 RR-96: release CLI 0.24.0 7 cli, core core, cli all all 11 (forced) yes
#751 RR-96: release core 0.24.0 7 cli, core core, cli core core render pptx editor cli integration goldens gallery-gates pack-shape yes
#750 RR-50: roll ecosystem.lock.json to the four main branches 1 - - all all 11 (forced) yes
#749 RR-96: adopt gallery 4.0.0 and theme variants 122* cli, core core, cli all all 11 (forced) yes
#748 RR-96: release CLI 0.23.0 5 cli, core core, cli all all 11 (forced) yes
#746 RR-96: release core 0.23.0 6 cli, core core, cli core core render pptx editor cli integration goldens gallery-gates pack-shape yes

Results (2026-10-21):

  • Packages: no mismatch. In all 30 PRs the packages whose directory the PR touched equal the directory-derived changed set; none was missed, none invented. 27 local diffs equal the API file list; 3 PRs have more than 100 files (FA-33: layouts as one list of regions #756, RR-97: every example converts: embedded supporting photos #752, RR-96: adopt gallery 4.0.0 and theme variants #749).
  • No path was unclassified (0 of the changed paths of the 30 PRs); the fail-closed branch was reached only through the documented forced rules.
  • Class counts: all 18, core 8, docs 3 (MR-00: plan v2: gallery in, one shared version, no merge queue #774, MR-00: monorepo program plan (approved; starts after 0.25.0) #764, RR-97: changelog note for core 0.24.2 #759), leaf 1 (FA-33: release CLI 0.25.0 #775), engine 0. The 18 forced runs all touch scripts/, .github/workflows/, pnpm-lock.yaml, release-plan.json or ecosystem.lock.json (the release and roller PRs, which the plan retires or turns into the one release commit), so they run everything at full, as section 4 says. Engine is 0 because render and PPTX are not in this repository yet.
  • Old CI for comparison: ecosystem-scope.mjs skipped 0 of the 30 (it only skips docs/programs and docs/evidence), so the current CI ran everything on all 30. ci-scope would have run lint only on 3, and the 12 non-forced PRs would have run 71 of 120 possible non-lint jobs.
  • Narrowing to review: the three docs-class PRs touched only CHANGELOG.md, changes/*, AGENTS.md, llms.txt and docs/programs/*; lint (Biome, check:text, check:changes, the rest of the root check:* suite) is what gates them. No PR in the sample was narrowed past a path a gating test reads (llms.txt is read only by test:agent-site, which no workflow runs).
  • Not covered by the sample: render, PPTX, editor and gallery paths (they are not in opf yet); the fixture tests above cover them.

Shadow mode in CI: workflow patch (not applied; .github/workflows is not edited by this PR)

A non-required job next to the current CI in .github/workflows/opf-ci.yml. It is not in the needs of Verify OPF packages, has continue-on-error: true, needs no install, and prints the ci-scope decision (log plus step summary) followed by the current ecosystem-scope.mjs decision. It applies cleanly with git apply on current main (checked) and is skipped for merge_group and manual runs.

diff --git a/.github/workflows/opf-ci.yml b/.github/workflows/opf-ci.yml
index afdec479..6194edec 100644
--- a/.github/workflows/opf-ci.yml
+++ b/.github/workflows/opf-ci.yml
@@ -228,6 +228,33 @@ jobs:
       pptx-ref: ${{ needs.gallery.outputs.published_opf_pptx }}
       editor-ref: ${{ needs.gallery.outputs.published_opf_editor }}
       cli-ref: ${{ needs.gallery.outputs.published_cli }}
+  # MR-14: scripts/ci-scope.mjs in shadow mode. Not a required check and not in the needs of `verify`: it only prints what the
+  # monorepo `verify` would run for this change (affected packages, tiers, jobs) next to the real CI, so MR-32 can compare the two.
+  # It reads the diff and the package manifests only (no install), and it never fails the run.
+  ci-scope-shadow:
+    name: ci-scope (shadow)
+    if: github.event_name == 'pull_request'
+    runs-on: ubuntu-24.04
+    timeout-minutes: 5
+    continue-on-error: true
+    permissions:
+      contents: read
+    steps:
+      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+        with:
+          # A pull_request checkout is the merge commit of the head into the base: HEAD^1 is the base.
+          fetch-depth: 2
+          persist-credentials: false
+      - name: Setup Node.js
+        uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
+        with:
+          node-version: 24
+      - name: Scope this change (ci-scope)
+        env:
+          PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}
+        run: node scripts/ci-scope.mjs --event "$GITHUB_EVENT_NAME" --base HEAD^1 --head HEAD --labels "$PR_LABELS" --github-output --summary --format text
+      - name: Current scope for comparison (ecosystem-scope)
+        run: node scripts/ecosystem-scope.mjs
   verify:
     name: Verify OPF packages
     needs: [gallery, normal, release-prep, candidate, control]

Notes and what is not verified

  • No changes/ fragment: tooling only, no package or user-facing change.
  • Not verified: the job in a real GitHub Actions run (it needs the workflow edit; the commands were run locally with GITHUB_OUTPUT and GITHUB_STEP_SUMMARY set on HEAD^1/HEAD, and the patch was checked with git apply --check and parsed as YAML); the pnpm cross-check on Windows (the nightly will show it; the test spawns pnpm through a shell there); the verify p50 targets (MR-32).
  • Choices the plan left open, all conservative: integration runs at full only when its own directory changes (the plan says contract for dependents; MR-23 and MR-30 define what its contract tier contains); the golden "core geometry sources" are all of packages/javascript/src/ plus spec/reference/ (core's source is flat and cannot be separated by directory); every event other than pull_request, including the push run on main, runs everything.
  • scripts/ci-scope.mjs stays decoupled from check:workspace-graph (MR-10); once that lands and the manifests are wired, --graph manifests is the pure pnpm view and the union default can be retired.

Part of MR-14 (Phase 1). The shadow-validation script and raw data were scratch files and are not committed.

🤖 Generated with Claude Code

scripts/ci-scope.mjs maps a change to affected packages, the tier each runs and
the jobs verify must run (plan section 4), with a swappable workspace graph and
a test that cross-checks it against pnpm --filter on the six S5 scenarios.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@michaeljgrimm
michaeljgrimm added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 21, 2026
@michaeljgrimm
michaeljgrimm added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 52cde77 Oct 21, 2026
26 checks passed
@michaeljgrimm
michaeljgrimm deleted the codex/mr-14-ci-scope branch October 26, 2026 07:56
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