jig-harness/jig
M13

Pipeline economy

CI spent only where it changes a merge decision: honest signal, selection, superseding, bounds, ordering, placement, the CI hold, caches
1 · The idearead this first

CI costs money and, worse, time: every pull request waits for it, and so does every agent driving one. Left alone, a pipeline grows by addition. Every new check runs on every push, whether or not the change could affect it. Five quick pushes run the full pipeline five times, though only the last head will ever merge. A hung job holds a runner until the provider’s default limit, which can be hours away. A half-hour end-to-end sweep runs per change although no one waits for its answer. A build cache whose key leaves out an input answers a change with a result computed for another one, and the usual cure, switching the cache off, pays the full price on every run. The other usual cure makes things worse: a team that filters a slow workflow by changed paths, or skips a job “when it is not needed”, has quietly turned some failures into passes: a skipped required job counts as success, and a workflow that never started leaves its check waiting until the team stops requiring it. This module makes CI cheap and fast without weakening it: spend where the answer changes a merge decision, and make every saving fail toward running more, never toward a green check nobody earned.

Invariantthe rule, independent of any tool

Spend CI only where it changes a merge decision, and never let a saving turn a failure into a pass.

Boundary. M1 decides what is checked and on which rung; M13 decides how cheaply and how fast it runs, without weakening it. M13 never removes a check M1 requires; it decides where and when that check runs, and makes sure the result still reaches the merge.

2 · The practicewhat each level asks of your repository

M13 Lite — minimum useful

a new push to a pull request cancels the runs for its older head; every job has its own timeout, below the provider’s default; no workflow behind a required check is filtered by changed paths at its trigger.

What the audit checks at Lite convention-only is enough must be mechanically enforced
  1. A new push to a pull request cancels that pull request's runs for the older head, so CI is not spent on a head no one will merge.
    superseded-pr-runs-cancelledWhat the audit looks for (2)
    • every pull-request workflow declares a concurrency group keyed by the pull request (or its ref) with cancel-in-progress, or the provider's equivalent (GitLab: interruptible jobs with auto-cancel)
    • the group is not shared with runs that check something the surviving run does not
  2. Every CI job declares its own timeout, below the provider's default limit, so a hung job fails at a bound the team chose instead of holding a runner until that limit.
    every-job-has-timeoutWhat the audit looks for (2)
    • each job carries timeout-minutes (GitHub Actions), timeout (GitLab CI) or the provider's equivalent
    • each value is below the provider's default job limit (360 minutes on GitHub-hosted runners)
  3. No workflow that reports a required check is filtered by changed paths at its trigger; selection happens inside the run, so every head gets a verdict.
    no-required-pipeline-path-filteredWhat the audit looks for (2)
    • the workflows behind the required checks have no on.pull_request.paths / paths-ignore (or the provider's trigger-level equivalent)
    • path-dependent work is selected by jobs inside the workflow instead

M13 Standard — production teams

a resolver reading the change-area catalog drives job selection, failing closed; one aggregator job is the required check; slow suites no merge waits for run on a schedule, with a cheap per-change proxy; where a CI hold is used, a required check does not pass on any held head from the instant the hold is applied, the pipeline runs on both label transitions, and only the hold’s own label skips work; every cache has a written key scheme covering the inputs that change its output, environment values included, pipelines that share a cache produce one key-affecting environment and a job with an empty cache credential fails, and each run reports its hit rate; each job’s runner class is written with the measurement behind it, the jobs that only decide or report run on the smallest class, and a machine’s parallelism is set once as a product at or below its cores; CI is the written authority for every check, each leg before it selects no more than CI does for the same change, and a leg that holds a machine beyond CI is an opt-in recorded with what it catches and what reopens it.

What the audit checks at Standard convention-only is enough must be mechanically enforced
  1. One resolver job per run reads the change-area catalog and decides which jobs the change needs; every other job reads its answer, and a changed file no area matches selects every job or fails the change.
    resolver-drives-selectionWhat the audit looks for (3)
    • one small job runs the catalog resolver and publishes its result (job outputs on GitHub Actions), or the jobs' change rules are generated from the catalog, or the resolver writes a child pipeline that the parent waits for (GitLab CI)
    • the other jobs' conditions come from the resolver's answer or the catalog, not from path patterns written by hand per job
    • an unmatched file selects every job, or a gate fails the change until the file belongs to an area (fail closed)
  2. One verdict is the required check (an aggregator job, or the provider's own verdict on the whole pipeline): it is given whenever the run was not cancelled, fails when a selected job failed, was cancelled or was skipped because a job it needs failed, and passes a job skipped only because the change did not need it.
    aggregate-required-checkWhat the audit looks for (3)
    • where each job reports its own check (GitHub Actions), an aggregator job needs every selected job, runs on !cancelled() (not always()), and compares each needed job's result with whether the resolver selected it
    • where the provider judges the whole pipeline (GitLab CI's "Pipelines must succeed"), that built-in verdict is the required check, no job that must block is allowed to fail, and a child pipeline mirrors its status to its trigger job
    • the merge rule requires that one verdict, not the individual jobs
  3. A slow suite that no merge and no verified pointer waits for runs on a schedule or on demand, and a cheap per-change proxy runs in its place.
    heavy-non-gating-suites-scheduledWhat the audit looks for (5)
    • the slow suite's workflow triggers on a schedule, on manual dispatch, or both, not on every pull request
    • a per-change job checks a cheap proxy of it (the suite still compiles, its images still build)
    • a suite is waited for when it is a required check on the default branch, the required aggregator needs it, or the verified pointer advances only after it succeeds; a branch with no required check still waits for what its verified pointer needs
    • a suite is fast only when the repository's written record classifies its speed so: the record names it fast, or states a duration threshold its recorded CI durations stay below; where a suite runs (a placement table such as PIPELINE-ECONOMY.md's) classifies nothing; a suite the record names slow, or whose recorded durations exceed the stated threshold, is slow even when the record also names it fast; durations without a stated threshold classify nothing, the auditor never estimates, and an unclassified suite counts as slow
    • the criterion covers each suite nothing waits for that is not classified fast; expected-absent when no such suite exists
  4. Where a hold label suppresses CI on intermediate heads, a required check does not pass on any held head from the instant the label is applied, every workflow that honours the label runs on its application and its removal, and only the pull request's own hold label, never the kind of label event, skips work, except in a mirror run, whose required check repeats the newest real run's result.
    ci-hold-fails-held-headsWhat the audit looks for (5)
    • a step in a required job, or in a job the required job needs directly while itself running on !cancelled(), fails while the hold label is present (cancelling its own run first counts only in the required job itself, and only when it fails where the cancellation does not happen), does not continue on error, and its message names the label to remove
    • every pull-request workflow with a job the hold skips, or reporting a required check, triggers on labeled and unlabeled beside opened, synchronize and reopened
    • each skipped job's condition tests the pull request's label set for the exact hold label, not the event's action, so an unrelated label event still runs real CI, or, where the workflow answers it with a mirror run, that run skips the heavy jobs in a concurrency group of its own and its required job repeats the newest real run's result on the head, passing only when that result passed and failing when it cannot read one
    • the driver that removes the label accepts only check runs that started after the removal
    • expected-absent when no hold label is configured (no ci.hold_label or equivalent)
  5. Every cache the pipeline uses has a written key scheme naming every input that changes its output, the values of the environment variables the task reads included, and no workflow carries a standing cache bypass in place of a complete key.
    cache-keys-completeWhat the audit looks for (4)
    • a document (the pipeline-economy policy page or the cache's own) names each cache and what its key covers: sources, lockfile, toolchain version, environment values
    • the task runner or cache step is configured to hash those inputs (declared environment lists, a hash over the lockfiles, no input list that leaves a read file out)
    • no workflow step forces a rerun or disables the cache as a standing fix (--force, --skip-cache or the equivalent); a bypass, where present, is a one-off with its reason beside it
    • expected-absent when the pipeline uses no cache
  6. Pipelines that share a cache produce an identical key-affecting environment, checked by a lint, and a job whose cache credential is empty fails before its first task rather than running apart from the shared cache.
    cache-one-namespaceWhat the audit looks for (4)
    • the jobs that share a cache are declared as a group and a lint (the cache-env-parity rule of M13's workflow-convention lint, or equivalent) fails when their key-affecting environment differs
    • a step at the top of each such job fails when a cache credential is empty, since the provider substitutes an empty string for an absent secret
    • where the tool shares its cache across working copies by itself, nothing in the configuration switches that off, and a test pins the setting that would
    • expected-absent when the cache takes no key-affecting environment variable and no credential, so there is nothing to compare or require
  7. Every run that uses a cache reports its hit rate (hits and misses) in the run's summary, and the rate is a registered process metric.
    cache-hit-rate-reportedWhat the audit looks for (3)
    • a step reads the task runner's run summary or the cache step's outputs and writes hits, misses and the rate to the run's summary or outputs
    • the metric registry (M11) carries the cache hit rate with a wired source
    • expected-absent when the pipeline uses no cache
  8. Each CI job's runner class is written down with the measurement behind it, the jobs that only decide or report (the resolver, the aggregator, an echo job) run on the smallest class, and a machine's parallelism is set once as a product, the task runner's package concurrency times the workers per package, at or below its cores.
    runner-class-follows-workWhat the audit looks for (4)
    • the pipeline-economy policy page, or a comment at the job, names each job's runner class, and a class above the smallest carries the wall time, processor use or runner-minutes that earned it
    • the resolver, the aggregator and other jobs that only decide or report run on the smallest class the pool offers
    • where a task runner runs packages in parallel and the test runner forks workers per package, a per-package worker cap is set in every package that invokes the test runner, and its product with the package concurrency is at or below the cores of the class
    • expected-absent when the provider offers one runner class and no job runs a worker-forking test runner under a task runner
  9. CI is the single authority for every check: the written record says so and that skipping a hook never changes what merges, each leg before CI (a hook, a remote sandbox) selects no more work than CI does for the same change, and a leg that holds a machine beyond CI is an opt-in recorded with the failure class it catches that CI cannot and a checkable reopen condition in each direction.
    one-authoritative-legWhat the audit looks for (5)
    • the hooks' configuration or the contributor guide states that CI is the authority and that skipping a hook never changes what merges
    • the pre-push hook's and any sandbox's commands select by the same resolver (the change-area catalog) or the same changed-since filter CI uses, not by an unscoped whole-repository run
    • a sandbox without the repository's history receives the resolved package list from the leg that dispatches it
    • an extra leg that holds a machine per push is opt-in per change area or per change, and its record (the cost ledger) names the failure class it catches that CI cannot and a reopen condition in each direction
    • expected-absent when no leg runs before CI (no hooks and no sandbox)

M13 Strict — regulated / compliance posture

the workflow conventions are checked by a lint that fails closed on input it cannot parse and accepts only reasoned exceptions, which fail once they suppress nothing, and it fails a job timeout above an hour; where a CI hold is used, the lint checks its label events, its guard, its held-head check and, where other labels’ events run a mirror, the mirror’s shape; every cache has a retention bound that a prune or the store’s eviction enforces, a declared cache that stores nothing is detected, a container build’s cache mounts are checked on every step that reads the store, and only trusted contexts write to a shared cache whose entries are verified; CI cost is measured on a cadence as runner-minutes per pipeline and job, cost per change, queue wait and hit rate, each a registered metric; every decision that changed what the pipeline spends is in a ledger with its measurement before and after and a reopen condition over a registered metric, and a gate fails an entry without them; a queue-stall watchdog runs.

What the audit checks at Strict convention-only is enough must be mechanically enforced
  1. A lint over the parsed CI configuration fails a job without a timeout, a pull-request workflow without a cancelling concurrency group, a required workflow filtered at its trigger, and an aggregator that runs on always(); it fails closed on a file it cannot parse, every exception it accepts carries a reason, and an exception that suppresses nothing fails it.
    workflow-conventions-lintedWhat the audit looks for (4)
    • a script or rule set reads the parsed workflow files and checks these conventions
    • a file that does not parse (a repeated key included) makes it fail, not pass
    • its exceptions are checked in, each with a reason; an entry without one, or one that suppresses no finding, fails the lint
    • it runs in CI on changes to the workflow files, with its own self-test
  2. The CI-configuration lint fails a job whose timeout, written as a number, is above an hour, unless a reasoned exception covers that job, so a timeout stays a generous backstop against a hang rather than drifting toward the provider's default.
    job-timeout-ceiling-lintedWhat the audit looks for (3)
    • the lint fails a literal job timeout above 60 minutes, and passes one of exactly 60
    • a job above the ceiling passes only through a checked-in exception that gives a reason
    • a timeout written as an expression is outside this criterion: its value is known only at run time, and review checks it
  3. CI time or cost is measured per workflow and job from the provider's records, so a decision about what to run where cites a number.
    ci-cost-measuredWhat the audit looks for (3)
    • a job or script collects run durations or billable minutes per workflow and job
    • the result is published on a cadence (a report, a dashboard, an issue)
    • the measures are runner-minutes per pipeline and job, cost per change (runner-minutes per merged change), queue wait and cache hit rate, each a registered metric (M11's registry) with a wired source
  4. A watchdog fails loudly when runs wait for a runner longer than a set bound, because job timeouts do not count time spent in the queue.
    queue-stall-watchdogWhat the audit looks for (2)
    • a scheduled job reads queued runs or jobs and their wait time from the provider
    • a wait over the bound fails the job or opens an alert someone sees
  5. Where a hold label is configured, the CI-configuration lint fails a workflow of the hold that misses a label event, a skipped job whose condition is not a negated test of the pull request's labels for the exact hold label, and a hold with no step that fails a required check while the label is present.
    ci-hold-shape-lintedWhat the audit looks for (6)
    • the lint reads the hold label from the repository's configuration and reports its hold rules as not applicable without one
    • it fails a pull-request trigger of a workflow in the hold that lists fewer than opened, synchronize, reopened, labeled and unlabeled
    • it accepts a guard only as a negated contains over the pull request's label names with the exact label, and a held-head check only as the positive test, in a job whose failure reaches the required check
    • where a workflow skips work on another label's events, it fails one whose concurrency group is not that run's own, whose run-name does not name mirror and real runs apart, whose required job skips or has no step that runs only on those events, or whose heavy job still runs on them, and it fails any job condition that reads the event other than through the pull request's own state, the mirror's skip term aside
    • it runs in CI on changes to the workflow files, with its own self-test
    • expected-absent when no hold label is configured
  6. Every cache has a retention bound that a scheduled prune or the store's own eviction enforces, with the window written beside its key scheme, and a declared cache that stores nothing is detected.
    cache-retention-boundedWhat the audit looks for (4)
    • each cache's bound is written beside its key scheme, naming what enforces it: the provider's eviction, a retention rule on the store, or a scheduled prune over a local or persistent cache directory
    • a shared local cache (a task runner's cache directory on a shared machine) is pruned on a schedule, with the window recorded
    • a check reads the provider's cache usage, or the hit-rate report alarms on zero over a window, so a cache that is declared but stores nothing is seen
    • expected-absent when the pipeline uses no cache
  7. A gate fails a cache wired on some steps and not on others: in a container build, every step that invokes the package manager in a stage whose store is on a cache mount carries the mount, and no step pins the store with a per-command flag.
    cache-wiring-checkedWhat the audit looks for (3)
    • a check over the Dockerfiles (M13's cache-mount coverage gate or equivalent) runs in CI on changes to them, with its own self-test
    • it fails closed on a Dockerfile it cannot read (a heredoc body, a dynamic command, a pin set to an expansion)
    • expected-absent when no container build keeps a store on a cache mount
  8. Only trusted contexts write to a shared cache, its entries are signed or verified on read, and an untrusted run (a pull request from a fork) gets no cache credentials and runs uncached rather than under a namespace of its own.
    cache-trust-boundaryWhat the audit looks for (4)
    • the shared cache's signature or verification is on (the task runner's remote-cache signature with its key, or the store's own integrity check) and an entry that does not verify is recomputed
    • cache credentials reach only trusted triggers: no pull_request_target or equivalent gives a fork's run secrets, and the fork run's cache steps are skipped or read-only
    • the provider's own cache scoping is kept, not widened: a pull request's cache is readable from its branch alone, and only the default branch's caches are read by every pull request
    • expected-absent when no cache is shared through credentials
  9. Every decision that changed what the pipeline spends (a runner resized, a leg narrowed or added, a suite moved, a cache turned on) is in a cost ledger with its measurement before and after in one unit, or a due date for the after, and a reopen condition naming a registered metric, a comparator, a threshold and a window; a gate fails an entry without them.
    cost-decisions-reopenableWhat the audit looks for (4)
    • a ledger (M13's ci-cost-ledger.yaml or equivalent) holds one entry per such decision with its unit, its before and its after, or a measure_by date while the after is pending
    • each entry's reopen condition names a metric id the metrics registry carries, a comparator, a numeric threshold and a window
    • a check (M13's cost-ledger gate or equivalent) fails an entry without its measurements, past its due date or with a reopen condition that is not checkable, and runs in CI on changes to the ledger, with its own self-test
    • a repository whose pipeline has had no such decision yet has an empty ledger, which the check reports as nothing to check; the criterion is absent, not expected-absent, until the first decision is recorded

The criteria are in M13-pipeline-economy.yaml. A repository without CI scores the module absent, not expected-absent: its criteria presuppose M1’s CI, which the repository can still add, and adopting M1 comes first.

Adoption steps

  1. Make every required check honest first: remove trigger-level path filters from the workflows behind required checks, put one aggregator in front of them, and require only the aggregator (M1’s skeleton has the shape). Give every job a generous timeout and every pull-request workflow a cancelling concurrency group. This is Lite.
  2. Write a change-area catalog (M3) if there is none, and select jobs from one resolver job; gate the toolchain setup on selected work. Copy templates/PIPELINE-ECONOMY.md, fill in the placement table, and move each slow suite nothing waits for to a schedule with a per-change proxy. Where the merge waits for a heavy suite and review takes rounds, add the CI hold in the shape of piece 7 (the opt-in block in M1’s skeleton), and only in that shape. For each cache the pipeline uses (the dependency store, the task runner’s cache, a container build’s layers), write its key scheme in the policy page, declare the jobs that share it as a cache group for the lint, fail the job on an empty cache credential, and write the hit rate into the run’s summary (piece 8; the opt-in block in M1’s skeleton). Put the resolver and the aggregator on the smallest runner class, write each job’s class in the policy page’s table with the measurement behind any larger one, and cap the test runner’s workers per package so the product with the task runner’s concurrency stays at or below the cores (piece 9). Scope the pre-push hook and any sandbox by the same resolver or filter CI uses, and write that CI is the authority (piece 10). This is Standard.
  3. Check the conventions with a lint over the workflow files (reference/workflow-conventions/), bound each cache’s retention with a prune or the store’s eviction and record the window, sign the shared cache and keep its credentials from untrusted runs, run the cache-mount check over the container builds (reference/cache-mount-coverage/), collect runner-minutes per pipeline and job, cost per change, queue wait and hit rate on a schedule into M11’s registry, start the cost ledger (templates/ci-cost-ledger.yaml) with the decisions already taken and run its check (reference/cost-ledger/) on changes to it, and run the queue-stall watchdog. This is Strict.
3 · The mechanicsopen what you need
Core piecesThe sub-invariants below. The first is the precondition for the rest: a pipeline may only economize once it reports honestly.Open

The sub-invariants below. The first is the precondition for the rest: a pipeline may only economize once it reports honestly.

1. Honest signal first

Every required check reports a verdict on every head.

  • Select inside the pipeline, never at its trigger. A workflow behind a required check is never filtered by changed paths at trigger level. A filtered-out workflow never starts, so it never reports: its required check waits forever, and the team learns to stop requiring it. Jobs are selected inside the workflow instead.
  • One always-running aggregator job is the required check. Where each job reports its own check, a job skipped by its condition reports success to the merge rule, so the individual, sometimes-skipped jobs are never required directly. One aggregator job waits for all of them and turns their results into one verdict: a job the change selected must succeed; a job the change did not select must be skipped; a failed, cancelled or missing answer fails the verdict, and so does a selection the resolver could not make. A provider that judges the whole pipeline has this verdict built in.
  • The aggregator runs whenever its run was not cancelled, not unconditionally. An unconditional aggregator also runs when a newer push cancelled the run, and then reports a failure for a head that is already superseded.
  • The aggregator’s exit code is the verdict. A summary that only prints the failures, from a step allowed to fail, blocks nothing.

M1’s pull-request workflow skeleton has the resolver and aggregator in this shape; mappings.md maps them per CI provider. A held head (the CI hold, piece 7) applies the same rule: it fails a required check rather than skipping it.

2. Select

Run what the change needs, decided once, failing toward running more.

  • One resolver per run, in the smallest job, reads the change-area catalog (M3) and publishes which areas the change touches. Every other job reads its answer; no job re-derives “what changed” with its own path pattern, because copies of a pattern drift apart.
  • Each gate is selected by its own subject, and selection fails closed. A gate whose subject is one area keys off that area, not off a broader “code changed” flag that someone may later narrow for another reason. Gates use the resolved closure of areas, not only the areas a file matched directly; M3’s resolver defines the closure. A changed file that matches no area selects every job, or a gate fails the change until the file belongs to an area.
  • A job pays for toolchain setup only when selected work exists. The resolver job installs only what the resolver needs; a job whose steps are all deselected skips the install too, rather than installing a toolchain to learn there is nothing to do.
  • Consolidate one-command satellite workflows. Each separate workflow pays its own checkout, toolchain and install to run one command. Fold them into one workflow behind the same resolver, and delete a check that a required gate already runs: it costs a second time and enforces less.
  • Scoped checks need an unscoped backstop on the integration branch. A check scoped to the changed areas never runs for a change elsewhere, so the integration branch can go red without any pull request going red. A run on the integration branch checks everything (or the whole unverified range, below).
  • Attribute a failure to a change only after reproducing it on a freshly fetched base. A failure that also occurs on the base belongs to the base: fix or report it there, rather than working around it in an unrelated change. M14 gives the triage: how to reproduce it, and what a stale test owes.

3. Supersede

Cancel a run only when another run covers it.

  • Two runs share a concurrency group only if the surviving run covers everything the displaced run would have checked. A newer push to a pull request covers the older head, so pull-request runs cancel in progress. A manual run with different inputs, or a run from another branch, covers nothing of another: it gets its own slot.
  • A concurrency key includes the ref or commit, the event, and every dispatch input. A manually dispatched run is keyed by its own run id, not by its inputs interpolated into the key.
  • A queue may keep only the newest waiting run per key. On some providers a newer run cancels the older waiting one even where running ones are never cancelled, and nothing reports it as an error. A key that collides drops a requested run silently, which is why the run id keys a dispatch.
  • Serialized post-merge verification checks the whole unverified range. A queue that keeps only the newest pending run is safe only when that run checks every commit since the last verified one (M10’s verified pointer), never just the newest commit. A run that cannot cover the range (a dispatch from another branch) gets a slot of its own, so it cannot displace one that does.

4. Bound

  • Every job has a timeout, without exception. A job with none runs until the provider’s default limit, often hours, so one hung test or stuck download holds a runner, and its cost, for that long before anything fails. Where a job only hands its work to another pipeline, the jobs that do the work carry the timeout (mappings has each provider’s default and syntax).
  • The timeout is generous, never the default. Size it to about two to three times the slowest healthy run, rounded up, and at most an hour. Its work is to stop a hang, not to police a slow day: a tight limit fails healthy runs on a busy runner, and the re-run costs more than the headroom saved. A suite with a tight time budget (M14) enforces it at its own step, and the job timeout stays the backstop around it. When two jobs merge into one, the new timeout is the sum of theirs, not a round number. A suite that outgrows its timeout is sharded, not given a longer one: a job that needs more than an hour is the sign, and one that truly cannot be split carries a reasoned exception in the workflow-convention lint. The lint checks that every job has a timeout and that none exceeds the hour; it cannot see run durations, so the two-to-three-times sizing stays the author’s to apply.
  • A watchdog bounds queue stalls and fails loudly. A job timeout counts only time the job runs, not time it waits for a runner. A job waiting for a runner that never comes holds its concurrency slot, and every newer run queues behind it, for hours, while nothing fails. A scheduled watchdog fails when a job has been queued longer than a set bound: reference/queue-watchdog/ with the workflow templates/queue-watchdog.yml. For serialized post-merge verification, M10’s watchdog applies the same bound and cancels the stalled run, which is safe because every verification run covers the whole unverified range.

5. Order and parallelize

  • Cheapest checks first: the gates that fail in seconds run before any dependency install is paid for (M1’s gate order).
  • The critical path in parallel: independent jobs need only the resolver, not each other, so the run takes about as long as its slowest job.
  • Long suites sharded across parallel jobs, each shard with its own timeout (test shard).
  • Every independent failure reported in one run: a matrix does not stop its other legs when one fails, so one push shows the author every problem instead of one per round trip.

6. Place

Each suite runs where its answer is needed. The question is: does a merge, or the verified pointer, wait for this answer?

PlacementWhat runs thereExample
Every pull requestthe gates the merge waits for, selected by what changed, and a cheap proxy for each heavy suite placed elsewhereformat, lint, types, unit tests, build; “the end-to-end images still build”
Every push to the integration branchwhat the verified pointer waits for, over the whole unverified range, and the unscoped backstopintegration tests against real services, migration replay, artifact build, end-to-end tests of journeys nothing else checks
On a scheduleslow suites nothing waits for, and trendsthe full end-to-end sweep against a deployed environment, nightly; coverage, weekly
On demandthe scheduled suites, run by hand when a change needs them nowa manual dispatch naming the suite
  • A cheap per-change proxy stands in for each heavy suite moved off the per-change path: it catches the breakage a change can cause cheaply (the suite no longer compiles, its images no longer build) and leaves the expensive question to the schedule. A trend measured over a suite that already gates every change, such as coverage over the unit tests, has that suite as its proxy.
  • The placement is enforced, not remembered. A heavy suite that gains a per-change trigger drifts back into everyone’s wait; a check on the workflow files rejects it (the workflow-convention lint). A scheduled suite reports its failures where someone will see them, and a schedule that stopped running counts as failing.
  • A run executes the pipeline definition of one ref, and it is the ref whose gates are wanted. A run started by hand executes the definition of the ref it was started from, so starting it from a branch that lags the integration branch runs an old definition and skips the gates added since, and nothing says so. A run started by another run’s completion executes the default branch’s definition whatever branch the triggering run was on, so a condition on the run’s own ref checks nothing about the triggering run (mappings has each provider’s behaviour).

The copyable policy page, templates/PIPELINE-ECONOMY.md, carries this table with the other rules, for a team to fill in with its own suites. M14 (Testing strategy) gives each suite the tier and time budget that decide its row.

7. Hold

A pull request under review takes several rounds (M7), and each push between rounds is an intermediate head no one will merge; yet each runs the whole pipeline, heavy suites included, while the reviewer only needs the cheap signal. The first instinct, skipping the heavy jobs on those pushes, is the saving piece 1 forbids: a skipped required job counts as a pass, so an intermediate head with a broken suite looks mergeable. The CI hold is the one shape in which that saving is safe: a label on the pull request that the pipeline honours, applied by the review driver once the opening head’s full run has completed and removed when review converges.

A pipeline may suppress expensive work on an intermediate head only while a required check does not pass on that head, and only until a release that runs everything again.

Every one of these holds, or the saving turns a failure into a pass:

  • A required check does not pass, and never skips, on every held head, from the instant the hold is applied. One step in the required job, or in a job it needs directly while itself running on !cancelled(), fails while the label is present: the held-head check. The pipeline runs on the label’s application, so the opening head’s green is replaced at once rather than at the next push, which may never come. A held head is visibly not mergeable from the first second to the release. A step in the required job itself may instead cancel its own run, failing only where the cancellation is refused or does not arrive: a cancelled required check blocks the merge as a failed one does, and the difference shows after the release (below). A step in a job the required one needs must fail: a cancelled run can leave the required job unstarted and skipped, and a skipped required job passes.
  • Only the hold’s own label skips work. Each heavy job skips by testing whether the pull request carries the hold label, never by the kind of event that started the run. The pipeline now runs on every label event, and a run’s result replaces the head’s previous one, so a job that skipped on any labeled event would let an unrelated label turn a failing head into a passing skip. An unrelated label event on an unheld pull request therefore runs real CI, the price of a run whose result counts, unless the pipeline answers it with a mirror (below).
  • Releasing the hold reruns every required check on the same head. Every workflow that honours the label, and every one reporting a required check, runs on the label’s removal, in full: the released head is the one the merge waits for, and a check that does not run again leaves the driver waiting for a result that never comes.
  • The driver certifies only results that started after the release. The held runs reported on the same head under the same check names, so the driver reads when the label was removed and accepts only check runs that started after it; one that started in the same second is rerun.

The held-head check’s message says why the head failed and how to release it: the label’s name, and that removing it runs everything again.

Other labels’ events: the mirror. Paying for a full run on every label event is cheap where labels rarely change. A repository whose labels change often pays it many times over: a tool that shows a pull request’s state as labels, such as Jig’s dispatcher, changes them at each step, and one change removes one label and adds another, each its own event. Each event’s run cancels the one before it on the same head, so the minutes are wasted, a run cancelled that early can leave a cancelled check that no later run replaces, and a label added just after a release cancels the run the driver is waiting for. Such a pipeline answers an event for any label but the hold’s with a mirror run:

A label event other than the hold’s may skip work only when its run cancels nothing and its required check repeats the newest real run’s result on the same head; otherwise it runs real CI.

  • It skips every heavy job and cancels nothing. The run takes a concurrency slot of its own, since it covers nothing a real run checks (piece 3).
  • Its required check repeats the real result, and fails closed. It does not simply skip. A provider may judge the required check by the newest run alone: a run that skips the required job under its name passes the check, and a run that reports no such check leaves it unreported, blocking a passing head. So the required job runs, waits for the newest real run on the same head to finish, and passes only when that run’s required check passed. It fails on any other result, when it finds no real run, when the provider’s interface does not answer, and at a deadline that outlasts the longest real run.
  • A mirror run is marked as one, and a real run is named so it cannot be taken for one, so a mirror repeats a real run only, and only one of its own pull request; where the provider cannot say which pull request a run belongs to, the mirror fails.
  • The hold still wins. On a held pull request the required job fails, or cancels itself, as in any held run.

A mirror waits as long as the real run it repeats, holding a runner, and the head reads as pending meanwhile. Its skipped heavy jobs may show under their own names as skipped; their real results stay with the real run.

The drive’s last push is usually a held one, since no one knows a push is the last until review passes it, so the head the merge waits for carries the held run beside the release’s run. Where the provider still shows the held run once the release has passed, a held run that failed reads as a failure on a mergeable head; one that was cancelled reads as superseded (mappings.md says how each provider shows it). A driver that dies mid-round leaves the label on, and the pull request stays unmergeable until someone removes it; removing it by hand is the release and reruns everything. Never rerun the old run instead: a rerun replays the event that carried the label and fails on the same step.

Open question: merge queues. A merge-queue run carries no pull-request labels, so it neither skips nor fails on the hold; what a hold means once a pull request is queued, and whether the queue’s own run is the release, has no evidence yet. A repository with a merge queue records its answer in its policy page.

The driver side is the drive-pr skill (ci.hold_label); the workflow side is an opt-in block in M1’s skeleton; mappings.md gives the trigger, guard, held-head check and mirror per provider; the workflow-convention lint checks each in the one shape it can prove safe.

8. Cache

A build cache is the saving that hides best. A stale entry fails no check: it answers the change with a result computed for other inputs, and the run is green. A cache that misses on every run fails nothing either: the run is slow, and everyone believes the cache is on. One pipeline can write entries that no other pipeline ever reads, for months, with the only symptom a hit rate no one looks at. So a cache earns its place with a key that covers everything, one namespace for everyone meant to share it, a bound on its size with its hit rate in view, and a line around who may write to it.

A cache answers only for the inputs its key names, every pipeline that shares it keys it the same way, its size is bounded and its hit rate is seen, and only a trusted run writes to it.

  • Complete keys. The cache key covers every input that changes the output: the sources, the lockfile, the toolchain, and the values of the environment variables the task reads, not only their names. A task runner that hashes a package’s whole file set needs no input list that can leave a file out; a tool that hides undeclared variables from a task hides them from the key as well, so a variable the task reads is declared where both see it. A result that went stale is fixed by completing the key, never by disabling the cache or forcing a rerun: a standing force pays the full price on every run and leaves the hole open for the next task to fall into.
  • One namespace. Every pipeline meant to share a cache produces an identical key-affecting environment: the same declared variables with the same values, the same credentials. A provider substitutes an empty string for a secret that is absent or rotated out rather than failing, and a cache tool rarely fails on it either, so a job with an empty credential splits off without a word: depending on the tool, it runs without the shared cache (every task a miss, nothing it computes shared), or, where the credential’s value selects the store or enters the key, it reads and writes a cache namespace of its own that no other pipeline reads. A missing credential therefore fails the job before its first task; what each tool does without one is in mappings.md. The declared environment of the jobs that share a cache is compared by a lint (the workflow-convention lint’s cache groups); the run-time value is the job’s own check. Where a tool shares its cache across working copies by itself, nothing in the configuration may switch that off: the feature is invisible when it works, so a test pins the setting that would.
  • Bounded and measured. Every cache has written down its key scheme, with the naming convention that keeps two jobs’ entries apart; a retention bound, enforced by the store’s own eviction or by a scheduled prune; and its hit rate, reported on every run in the run’s summary as hits and misses. A cache nobody bounds grows without limit, a shared one fastest of all, and the bound is set short on purpose: evicting early costs one recomputed miss; keeping too long costs disk no one reclaims. The hit rate is what detects what nothing else does: a cache that is declared but stores nothing (an exporter configured for a builder that never writes it) and a split namespace (one pipeline at zero hits while another is at every hit). A cache wired on some steps and not on others fails outright instead: a build step reading a store that another step mounted sees an empty directory, and the error names a missing package, not a missing mount. reference/cache-mount-coverage/ checks a container build’s cache mounts on every step that reads the store.
  • Trust boundary. Only a trusted context writes to a shared cache, and a run verifies what it reads: entries are signed with a key the trusted contexts hold, and an entry that does not verify is recomputed, so a tampered or cross-context artifact is never served as a result. An untrusted run (a pull request from a fork) gets no cache credentials; a context that cannot carry credentials runs uncached rather than under a namespace of its own, so its results are honest and its misses visible, not written to a cache no one reads.

The policy page (templates/PIPELINE-ECONOMY.md) carries the table of caches with their key schemes, bounds and reports; mappings.md maps these rules onto the task runners, build tools and CI providers; M1’s skeleton has the credential check and the hit-rate report as an opt-in block; the hit rate is an M11 metric (ci-cache-hit-rate in its registry template); and the /jig:github-actions skill checks them on a workflow change.

9. Size

A runner is bought by the minute, in classes, and the class a job runs on is a decision with a number behind it, like its timeout. Without the number, two shapes recur. A job that only decides or reports (the resolver, the aggregator, an echo job) runs for seconds on the largest class, because the workflow was given one class throughout, and pays that class’s rate for work a smaller one would not notice. And a test runner that forks a worker per core, run by a task runner that runs several packages at once, puts packages times workers processes on the machine’s cores: load spikes, every suite slower, timeouts that fail healthy runs. The second one does not look like a sizing problem; it looks like flaky tests.

A job’s runner class follows its measured work, the smallest class serves the jobs that only decide or report, every resize carries the measurement behind it, and a machine’s parallelism is set once, as a product bounded by its cores.

  • The class follows the work. Measure before sizing: the job’s wall time, its processor use and its memory at the class it runs on. A job that is processor-bound and parallel gains from a larger class; a job that waits on the network, or runs one thing at a time, does not, and a larger class costs it the same minutes at a higher rate. The resolver, the aggregator and every other job that only decides or reports run on the smallest runner class the pool offers.
  • Every resize carries its measurement. A change of class is written where the job’s timeout is (the policy page’s table), with the wall time and the runner-minutes before and after and the condition that reopens it (piece 11). A resize without a number is a guess, and the next person guesses again.
  • Parallelism is one product per machine. The task runner’s package concurrency times each package’s worker count is at most the machine’s cores. A test runner’s default is a worker per core per package, and a task runner’s default runs several packages at once, so the two defaults multiply. The per-package cap is set in the configuration of every package that invokes the test runner (the set is derived from the packages’ test scripts; a glob over configuration file names both over- and under-counts), and the package concurrency in the one script that runs the suite. mappings.md has each tool’s setting.

10. One authoritative leg

A check can run in several places for one change: in the editor, in a pre-commit or pre-push hook, in a remote sandbox before the push, and in CI. Each place is a verification leg, and only one is the authority: CI, on the head that merges. The others give earlier feedback. Left alone, the legs before CI grow wider than CI: the hook runs the whole repository’s tests while CI selects the changed packages and their dependents, so for a change inside one package the hook selects every suite where CI selects one, and pays for answers the authority will not use. A remote sandbox that mirrors CI on every push holds a machine for about what a CI run costs, while CI runs on the push regardless, so its only payback is a push CI would have failed.

CI is the single authority for each check; every leg before it selects no more work than CI does for the same change; and a leg that holds a machine beyond CI runs only where it is measured to catch what CI cannot, under reopen conditions that can be checked.

  • One authority. The verdict a merge waits for is CI’s on the head that merges (M1). A hook that passed changes nothing about what merges, and one that failed saved a round trip; so hooks and sandboxes are feedback, and skipping one never changes what merges.
  • No wider than CI. A leg before CI selects its work the way CI does for the same change: the same resolver over the change-area catalog, or the same changed-since filter of the task runner. A leg that selects more pays for answers the authority will not use; one that selects less is still safe, because CI is behind it. Where a wider run is wanted because CI’s selection may miss a coupling it cannot see (an undeclared dependency, a file outside every package), the run is widened in CI, where it is authoritative, not in a hook. A remote sandbox without the repository’s history cannot resolve a changed-since filter, so the leg that dispatches it resolves the selection first and sends the package list.
  • A costly extra leg is an opt-in with reopen conditions. A leg that holds a machine per push (a sandbox on a machine like CI’s) runs only where the record shows a class of failure CI alone would miss or a hook cannot reproduce: an opt-in per change area, never a default. The decision writes a reopen condition in each direction: what turns the leg on for an area (a CI-only failure class recurring on its changes after the hook passed them), and what turns it off again (the leg’s share of the period’s runner-minutes). What such a leg still offers is a place to reproduce a CI-only failure by hand on a machine like CI’s: an escalation, not a step every change pays.

11. Measure

Every piece above trades something, and a trade without a number is re-argued at each round. The measurement is cheap: the provider records when each job started and finished and on which class; the cost is in not reading it.

Pipeline cost is measured on a cadence, per pipeline and per job, and every optimization records its measurement before and after with the threshold that reopens it.

  • On a cadence. Runner-minutes per pipeline and per job (where the time goes: two jobs are usually most of it); the cost per change, runner-minutes per merged change, the number that makes a per-push leg comparable with CI; queue wait, the time between a job’s creation and its start, which piece 4’s watchdog bounds and whose trend says whether the pool is sized right; and the cache hit rate (piece 8). A scheduled job collects them from the provider’s records and publishes a report; each is a registered M11 metric.
  • Before and after, in one unit. Every optimization, a resize, a leg narrowed or added, a suite moved to a schedule, a cache turned on, records the measurement that motivated it and the measurement after it, in the same unit over comparable windows: a median against a mean is not a comparison, and two windows that overlap are not a before and an after. A decision whose after is not yet measured says by when it will be, and the ledger fails once that date passes.
  • With the threshold that reopens it. Each decision names what would make the team revisit it: a registered metric, a comparator, a threshold and a window, so the next person checks it instead of re-arguing it. “Reopen when the sandbox holds more than a tenth of the month’s runner-minutes” is checkable; “reopen if it gets expensive” is not, and a condition over a metric nobody collects is dark. The decisions live in a cost ledger (templates/ci-cost-ledger.yaml), and reference/cost-ledger/ fails an entry without its measurements, with a reopen condition that is not checkable, or whose metric the registry does not carry.
In your toolsThe same rule, wired into a specific CI provider, hook manager or tracker. Shows only your stack.Open

The module’s sub-invariants are tool-independent; this page maps each onto the two CI providers Jig’s other modules map, GitHub Actions and GitLab CI. Terms of art: see the glossary.

The two providers differ most in one place. On GitHub Actions each workflow and each job reports its own check, so honest signal is something a team builds (an aggregator job). On GitLab CI the pipeline as a whole is the verdict a merge request waits for, so the aggregator is built in, and the risk moves to pipelines that are never created.

Honest signal

RuleGitHub ActionsGitLab CI
No trigger-level path filter on a required pipelineNo paths: or paths-ignore: under on.pull_request or on.push in a workflow behind a required check. A workflow skipped by a path filter leaves its required checks pending, so the pull request cannot mergeNo changes: in workflow:rules for merge-request pipelines; select jobs instead. Keep the project setting “Skipped pipelines are considered successful” off
A skipped job is judged, not trustedA job skipped by its if: reports success to branch protection; require the aggregator, never the jobA job that rules: leave out is not created and not counted; the pipeline status covers the jobs that ran
One aggregated verdictAn aggregator job with needs: on every selected job and if: ${{ !cancelled() }}, comparing each needs.<job>.result (success, failure, cancelled, skipped) with the resolver’s selection; it is the only required checkBuilt in: “Pipelines must succeed” in the merge-request settings judges the whole pipeline
Runs when not cancelled!cancelled(); always() also runs, and fails, on a run a newer push cancelledNot needed: an interrupted pipeline is superseded by the newer one
The exit code is the verdictNo continue-on-error: true on the aggregator or its verdict stepNo allow_failure: true on a job whose failure must block

Select

RuleGitHub ActionsGitLab CI
One resolver per runOne small job runs the change-area resolver and publishes job outputs:; other jobs read needs.<resolver>.outputs.<name> in their if:rules: are evaluated when the pipeline is created, before any job runs, so a resolver job cannot deselect jobs of its own pipeline. Either generate each job’s rules: changes: from the catalog, or let the resolver job write a child pipeline and start it with trigger: include: - artifact: and strategy: mirror (depend before GitLab 18.2), a dynamic child pipeline whose verdict becomes the trigger job’s. Without a strategy the trigger job succeeds as soon as the child pipeline is created, whatever the child’s checks then report
Fail closedThe resolver sets the “everything” output when a changed file matches no area, or a gate fails the change until every file belongs to an areaThe generated changes: lists include a catch-all for unmatched paths, or the resolver’s child pipeline includes every job
Toolchain setup only for selected workThe setup step carries the same if: as the work it serves, or the job is skipped as a wholeThe job is not created when its rules: do not match; a resolver job installs only the resolver’s runtime
Consolidate satellitesSeveral one-command workflows become steps or jobs of one workflow behind one resolverSeveral small pipelines’ jobs move into the main .gitlab-ci.yml under the same rules
Unscoped backstopA push to the integration branch resolves to every area (or the whole unverified range)A branch pipeline on the default branch runs every job: rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
Reproduce on a fresh basegit fetch origin <base> then run the failing command on origin/<base> before blaming the changeThe same, with $CI_MERGE_REQUEST_TARGET_BRANCH_NAME

Supersede

RuleGitHub ActionsGitLab CI
Cancel a pull request’s superseded runsconcurrency: { group: <workflow>-<pull request number or ref>, cancel-in-progress: true }interruptible: true on the jobs, plus “Auto-cancel redundant pipelines” (on by default) or workflow: auto_cancel: on_new_commit: interruptible
A key per non-interchangeable runThe group names the ref or commit and github.event_name; a workflow_dispatch run is keyed by github.run_id, never by an interpolated inputPipelines of different refs never cancel each other; with the default auto_cancel: on_new_commit: conservative, a newer pipeline on the same ref cancels an older one unless a job with interruptible: false has already started
What happens to a third runOne pending run per group survives: a newer run cancels the older pending one, also with cancel-in-progress: false, and nothing reports it as an error; group names compare case-insensitivelyA job in a resource_group waits its turn; nothing is dropped. The process_mode (unordered, oldest_first, newest_first, newest_ready_first) picks the order
Serialized post-merge verificationA fixed group for the integration branch with cancel-in-progress: false, and the run checks the range from the verified pointer to its headA resource_group on the verification job. Waiting jobs are not dropped: with newest_first the older ones still run afterwards, so the step that advances the verified pointer must only move it forward (or enable “Prevent outdated deployment jobs”), and each run checks the range from the verified pointer, as on GitHub

Bound

RuleGitHub ActionsGitLab CI
A timeout on every jobtimeout-minutes: on each job (default 360), about two to three times the slowest healthy run and at most an hour; there is no workflow-level default, so each job needs its own, and the lint checks it; a job that calls a reusable workflow cannot carry one, so the called workflow’s jobs do; steps may carry their owntimeout: on each job, about two to three times the slowest healthy run and at most an hour; default: does not accept it, so share one value through extends: or a YAML anchor; the project’s default (60 minutes unless changed) and each runner’s maximum also apply
Queue time is not run timetimeout-minutes does not count time a job waits for a runner; the jobs API shows a waiting job as status: queued with its created_atA job waiting for a runner is pending; the jobs API reports queued_duration
Queue-stall watchdogA scheduled workflow feeding the jobs API to reference/queue-watchdog/ (templates/queue-watchdog.yml)A pipeline schedule running a job that reads pending jobs’ queued_duration from the jobs API and fails over the bound

Order and parallelize

RuleGitHub ActionsGitLab CI
Cheapest firstCheap steps first in the first job, before the toolchain installAn early stage of small jobs, or the cheap commands first in one job
Critical path in parallelJobs that needs: only the resolver run side by sideneeds: makes jobs start as soon as their dependencies finish, regardless of stage
Shard long suitesA strategy.matrix of shard indexes, each leg with its own timeout-minutesparallel: <n>, with CI_NODE_INDEX and CI_NODE_TOTAL telling each job its shard
Report every independent failurestrategy.fail-fast: false on matricesJobs of a stage all run; jobs connected only by needs: run unless a job they need failed

Place

PlacementGitHub ActionsGitLab CI
Every pull requeston: pull_requestrules: - if: $CI_PIPELINE_SOURCE == "merge_request_event"
Every push to the integration branchon: push: branches: [<integration branch>]rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
On a scheduleon: schedule: - cron:; in a public repository GitHub disables a scheduled workflow after 60 days without repository activity, so watch that it still runsA pipeline schedule; rules: - if: $CI_PIPELINE_SOURCE == "schedule"
On demandon: workflow_dispatch with inputs: naming the suiteA manual job (when: manual) or a pipeline run from the web ($CI_PIPELINE_SOURCE == "web")
Which definition a run executesA workflow_dispatch run executes the workflow file of the ref it is dispatched from (--ref on the command line, the branch picker in the web), so a run that operates on another ref takes it as an input; a workflow_run run executes the default branch’s file with github.ref set to the default branch, and the triggering run’s identity is in github.event.workflow_runA manual pipeline runs the .gitlab-ci.yml of the ref it is started on; a downstream pipeline started by a trigger job or the API runs the configuration of the ref it is started for
The placement checkedA lint over .github/workflows/ rejecting a per-change trigger on a workflow marked as a scheduled suite: reference/workflow-conventions/A lint over .gitlab-ci.yml rejecting a merge-request rule on such a job

Hold

GitLab CI has no known equivalent: a label change creates no merge-request pipeline, so applying or removing a label starts no run, and a job whose rules: skip it on CI_MERGE_REQUEST_LABELS is not created and not counted, so nothing fails for it. Until a shape is validated there, run full CI on every push. The rows below are GitHub Actions only.

RuleGitHub Actions
The pipeline runs on both label transitionson.pull_request.types: [opened, synchronize, reopened, labeled, unlabeled] on every workflow that honours the label or reports a required check. Applying the label fires only labeled and removing it only unlabeled; listing any type replaces the three defaults, so they stay listed. The same for a pull_request_target trigger
Only the hold’s own label skips workOn each heavy job, !contains(github.event.pull_request.labels.*.name, '<label>') as an &&-joined term of its if:. It reads the pull request’s label set at the time of the run, never github.event.action or github.event.label.name, so an unrelated label event on an unheld pull request runs real CI, unless the workflow answers it with a mirror (the rows below), and the same guard serves synchronize, labeled and unlabeled runs alike
Other labels’ events: why a run cannot simply skipMeasured on GitHub Actions with a ruleset requiring the check: a pull request that read clean stayed blocked, with every required check passing in its list, after one other-label event’s run reported no check under the required name. A skipped required job passes the check, as a skipped check counts as passing. Renaming the skipped job does not help: GitHub does not evaluate a skipped job’s name: when it reads a context (github, matrix), and the check takes the expression’s text instead; a constant expression, such as ${{ 'gates' }}, is evaluated, so it keeps the real name
Other labels’ events: the mirror runThe other-label test is github.event.label.name && github.event.label.name != '<label>': an opened, synchronize or reopened event, and a push, carry no label, so it is false there. Each heavy job adds !(<the test>) as an &&-joined term of its if:. The workflow’s concurrency group starts with the test and a key of the run’s own: group: <workflow>-${{ <the test> && format('mirror-{0}', github.run_id) || github.ref }}, so the run cancels nothing and nothing cancels it. run-name: ${{ <the test> && format('<workflow> mirror ({0} label)', github.event.label.name) || github.event_name == 'pull_request' && format('<workflow> - {0}', github.event.pull_request.title) || '' }} (with pull_request_target for a workflow on that trigger, or startsWith(github.event_name, 'pull_request') for one on both) marks it, and gives a real pull-request run a name that starts otherwise: left to its default, a real run’s name is the pull request’s title, which can start like a mirror’s. A run-name that comes to nothing but whitespace keeps the default name, so a push keeps its commit message. A run’s display_title in the API is that name, and so is its name field. The required job keeps its static name and its if: ${{ !cancelled() }}, keeps the held-head check first, runs a step with if: ${{ <the test> }} that repeats the real result, and keeps the steps that judge the skipped jobs off that event with if: ${{ !(<the test>) }}. Its timeout-minutes is an expression, ${{ <the test> && <minutes> || 5 }}, long enough to outlast the step’s deadline, and so is its runs-on: the one-processor runner (ubuntu-slim) ends every job at 15 minutes, so a mirror that waits longer runs on a standard one
The mirror stepWith actions: read (the held-head check’s actions: write includes it), it lists every page of GET /repos/{owner}/{repo}/actions/workflows/<file>/runs?head_sha=<head>&event=pull_request (gh api --paginate: label events add runs, and the real one can fall past the first page), with the head from github.event.pull_request.head.sha (not github.sha, which is the merge commit). It leaves out its own github.run_id, every run whose display_title starts with the mirror’s mark, and every run whose pull_requests is not exactly this pull request, then takes the one with the highest id. While that run is not completed it polls; once it is, GET /repos/{owner}/{repo}/actions/runs/<id>/jobs?filter=latest gives the required job’s conclusion, and the step exits 0 only on success. It exits 1 on any other conclusion, on a run with no such job, when no real run appears within a grace period (the push’s run can be created a moment after the label’s), when three reads in a row fail, each read bounded by its own timeout, and at its deadline. Jig’s own .github/workflows/gates.yml has this shape, and scripts/gates-mirror.test.ts runs its step against a fake gh
What a mirror costsA runner for as long as the real run it waits on. The head’s required check reads as pending meanwhile, and a mirror that fails closed reads as failing until the next push or label event runs again. The skipped heavy jobs show under their names as skipped in the mirror run, while their real results stay with the real run on the same commit. A run of a fork’s pull request lists no pull request in the API, and one on a commit that heads several pull requests lists them all, so there the mirror finds no run of its own and fails: a push runs CI
A required check fails while heldA run: step with if: contains(github.event.pull_request.labels.*.name, '<label>') that exits 1, with no continue-on-error, in the required job (on !cancelled()) or in a job it needs directly; its message names the label. The required job is never guarded: a skipped required job passes. Branch protection judges a check by its newest run, yet the head’s check list keeps every run, so after the release a failed held run still shows red beside the passing one. To have it listed as cancelled instead, a step in the required job itself (never in a job it needs: cancelling the run there can leave the required job skipped, which passes) first cancels its own run (POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel, which needs permissions: actions: write on that job), waits with a deadline for the cancellation to end it, and exits 1 when the call is refused or the wait runs out; Jig’s own .github/workflows/gates.yml has this shape
Release reruns every required checkRemoving the label (gh pr edit <PR> --remove-label '<label>') fires unlabeled on every workflow listing it, and the guard reads the label as absent; the other-label test is false on the hold’s own events, so the release runs in full in the pull request’s shared concurrency group. Never gh run rerun the held run: a rerun replays the event payload that carried the label and fails on the held-head check again
Only results after the release countThe unlabeled timeline event’s time, compared with each check run’s started_at; a run started in the same second is rerun. drive-pr’s ci-hold.ts final-ready does this
Merge queuesA merge_group run carries no pull-request labels, so the hold neither skips nor fails there; an open question of the module
The shape checkedThe lint’s ci-hold-events, ci-hold-guard, ci-hold-sentinel and ci-hold-mirror rules (reference/workflow-conventions/), each accepting the one form above; ci-hold-mirror applies only to a workflow that answers other labels’ events with a mirror

Cache

The cache rules (piece 8) live mostly in the task runner or build tool, whichever computes the key; the CI provider adds the dependency cache, the credentials and the trust boundary. A pnpm triple for the cache-mount check is its default; the other package managers’ are in the last row.

By task runner and build tool

ToolComplete keysOne namespace, measuredBounded, trusted
TurborepoglobalEnv and each task’s env name the variables whose values enter every hash; a task with no inputs hashes every tracked file of its package, so no list can leave a read file out; globalDependencies adds files outside packages; with the strict environment mode (the default), a variable the task reads is declared or neither the task nor the hash sees it. --force is the bypass to avoid as a standing fixRemote cache: the same token (TURBO_TOKEN), team (TURBO_TEAM, sent with every remote-cache call to select whose cache is read and written) and signature key in every job’s environment; none of them enters a task’s hash, and a job whose token is empty runs on its local cache alone without failing, so every task the shared cache would have served is a miss; --summarize writes .turbo/runs/<run>.json, whose tasks[].cache.status (HIT or MISS) gives the run’s hit rate; the worktrees of one clone share the main worktree’s .turbo/cache by themselves, and an explicit cacheDir switches that offThe local cache is unbounded by default: cacheMaxAge and cacheMaxSize in turbo.json (or TURBO_CACHE_MAX_AGE, TURBO_CACHE_MAX_SIZE) turn on eviction at the start of each turbo run, oldest first; on a version without them, a scheduled prune over .turbo/cache by modification time (find … -mtime +<days> -delete), with the window recorded. remoteCache.signature: true with TURBO_REMOTE_CACHE_SIGNATURE_KEY signs artifacts, and one that does not verify is rerun
NxnamedInputs with file sets, env inputs (the variable’s value) and runtime inputs (a command’s output, such as the toolchain version); a production set that leaves test files out of a build’s key. --skip-nx-cache is the bypass to avoidThe remote cache’s access token in every job; a run’s output marks each task read from the local or remote cache, and the final line counts them; nx reset empties the local cachecacheDirectory (or NX_CACHE_DIRECTORY) is pruned on a schedule; the remote cache’s read-only tokens for untrusted runs, read-write only on trusted ones
BazelAn action’s key hashes its inputs and command line; --action_env=NAME passes a variable and puts its value into the key, and an undeclared one reaches no action--remote_cache= with the same --remote_header= credentials in every job; the build’s final INFO: <n> processes: line counts remote cache hit--disk_cache= grows without bound: a scheduled prune of the directory, or the garbage-collection size flag where the version has one; --remote_upload_local_results=false on untrusted runs, so they read but never write
GradleA task’s key hashes the inputs it declares (@Input, @InputFiles); a variable read with System.getenv inside the action is invisible to the key, so it is declared as an input. --rerun-tasks is the bypass to avoidorg.gradle.caching=true everywhere that shares; a remote build cache’s credentials in every job; the console marks each task FROM-CACHE, and a build scan tallies themThe local build cache removes entries unused for 7 days (removeUnusedEntriesAfterDays); the remote cache has push = true only on the trusted branch’s jobs, and pull elsewhere
BuildKit (container builds)A layer’s key hashes the instruction and the files it copies; RUN --mount=type=cache,target=<path> keeps a directory across builds for that RUN alone, and the store is pointed at it by a stage-level ENV the later processes inherit--cache-to/--cache-from with type=registry or the provider’s cache exporter, mode=max; the default docker driver exports no cache but the inline one unless the containerd image store is enabled, so on the classic image store type=gha is declared and inert (the provider’s cache usage stays at zero bytes) and the docker-container driver, or the containerd image store, is needed; --progress=plain logs CACHED per stepdocker builder prune --filter until=<duration> bounds the builder’s cache; every step that reads the store mounts it, which reference/cache-mount-coverage/ checks
Package managers (the triple for the cache-mount check)pnpm: npm_config_store_dir pins the store, --store-dir is the flag to avoid. npm: npm_config_cache, --cache. Yarn: YARN_CACHE_FOLDER, --cache-folder. pip: PIP_CACHE_DIR, --cache-dir. uv: UV_CACHE_DIR, --cache-dir. cargo: CARGO_HOME (no flag). go: GOMODCACHE (no flag)A per-command flag binds one process; the variable is inherited by every child, which is why the check fails the flag—

By CI provider

RuleGitHub ActionsGitLab CI
Complete keysactions/cache (and the cache: input of the setup actions) keyed by hashFiles() over every lockfile with runner.os and the toolchain version; restore-keys only as prefixes of the same scheme, since a fallback hit is a partial restore the task then completescache:key:files (up to two files, hashed) with cache:key:prefix, and cache:paths for what is kept
One namespaceThe same env: on every job of a cache group (the lint’s cache-env-parity rule); a first step that fails on an empty credential ([ -n "$TOKEN" ]), because an absent or rotated-out secret reads as an empty string; the secrets context is unavailable in if:, so a composite action takes each value as an inputThe same variables: on every job of the group; a before_script that fails on an empty variable. Caches of protected branches are kept apart from unprotected ones by the provider, so a job on an unprotected branch never shares a protected branch’s cache
BoundedThe repository’s caches are capped (10 gigabytes) and an entry unused for 7 days is evicted, the oldest first beyond the cap; gh cache list and gh cache delete; a persistent runner volume keeps exact keys only, with no fallback, and evicts after days idle, so its key convention (<workflow>-<purpose>) is written down; a self-hosted runner’s volume is pruned by the team’s own scheduleThe runner’s local cache directory, or the lifecycle rule of the object store behind a distributed cache; “Clear runner caches” resets
MeasuredThe restore step’s cache-hit output, and the task runner’s summary, written to $GITHUB_STEP_SUMMARY; a declared cache that stores nothing shows in gh api repos/<owner>/<repo>/actions/cache/usage as zero bytesThe job log’s cache lines (extracted, or not found) and the project’s cache listing
Trust boundaryA pull_request run from a fork gets no secrets, so no remote-cache credentials: it runs uncached, and never under pull_request_target to get them; a cache written on a pull-request branch is readable from that branch alone, and the default branch’s caches are readable by every pull request, which is the provider’s own line; the task runner’s remote cache is signedcache:policy: pull on jobs of merge requests from forks; protected-branch caches as above

Size

The runner classes are vendor-bound: each provider and each runner vendor names its own, and the README names none. The rule maps onto them like this.

RuleGitHub ActionsGitLab CI
The class follows the workruns-on: names the class: a hosted label (ubuntu-slim is the smallest hosted Linux class: one processor in an unprivileged container, with a minimal tool set, no Docker and a 15-minute job limit, so it suits the jobs that only decide or report; ubuntu-latest is the smallest full virtual machine; larger hosted runners carry labels the organization defines), a runner vendor’s label (the vendor’s label usually carries the core count), or a self-hosted pool’s labels; a matrix may set runs-on per leg, and an expression may pick the class from the resolver’s outputstags: select a runner: the hosted sizes are tags (saas-linux-small-amd64 is the smallest; medium, large and up follow), and a self-hosted runner’s tags are the pool’s
The smallest class for the jobs that only decide or reportthe resolver, the aggregator and an echo job on the smallest label the pool offers, whatever the other jobs usethe same, by tag
The measurement behind a classthe jobs API’s started_at and completed_at per job, and the billing usage report’s minutes per runner type; gh run view <run> --json jobs for one runthe jobs API’s duration, and the Usage Quotas page per runner size

Parallelism, by task runner and test runner

The product of the two columns on one machine is at most its cores. The core count is per machine (nproc, os.availableParallelism()), never per package.

ToolPackage concurrencyWorkers per package
Turborepo--concurrency on turbo run (default 10)—
Nx--parallel=<n> (default 3)—
pnpm -r / Lerna--workspace-concurrency / --concurrency—
Vitest—top-level maxWorkers (default: the machine’s available parallelism), set in the configuration of every package whose test script invokes it
Jest—maxWorkers or --maxWorkers (default: the cores less one)
pytest-xdist—-n <n> (auto is the cores)
Gogo test -p <n>: test binaries (packages) run at once (default: GOMAXPROCS, normally the cores)-parallel <n>: t.Parallel tests at once within one binary (default: GOMAXPROCS)
Gradleorg.gradle.workers.maxmaxParallelForks on each test task
Bazel--jobs--local_cpu_resources

Legs

RuleGitHub ActionsGitLab CI
CI is the authoritythe required check on the merged head (M1’s aggregator)the pipeline’s verdict on the merge request
A leg before CI selects as CI doesthe pre-push hook (M1’s hook managers) runs the resolver over the change-area catalog, or the task runner’s changed-since filter the CI job runs (turbo run test --filter='...[origin/<base>]', nx affected --base=origin/<base>), not the unscoped root scriptthe same; the merge request pipeline’s changes: rules give the base
A remote sandbox has no historya changed-since filter cannot resolve on a machine without the repository’s git history, so the dispatching leg resolves the package list first and sends it; a dispatched sandbox job receives no secret of the CI job (so secret-dependent checks never need one) and cannot run the workflow files themselvesthe same
A costly extra lega workflow_dispatch run on a CI-like machine, opt-in through the change-area catalog per area, with its reopen conditions in the cost ledgera manual pipeline (when: manual) on the same terms

Measuring cost

The measures of the README’s piece 11, read from the provider’s records by a scheduled job into M11’s registry (ci-runner-minutes, ci-sandbox-minutes-share, ci-cost-per-change, ci-queue-wait, ci-cache-hit-rate).

MeasureGitHub ActionsGitLab CI
Time per jobThe jobs API’s started_at and completed_at; gh run view <run> --json jobsThe jobs API’s duration and queued_duration
Runner-minutes per pipeline and jobthe jobs API’s completed_at less started_at, summed per job and per workflow over the window; gh run list --json gives the runs of a workflowthe jobs API’s duration summed per job and per pipeline
Billed minutesThe account’s billing usage report (per workflow and runner type)Compute minutes on the group’s or project’s Usage Quotas page
Cost per changethe runner-minutes of every run on a pull request’s heads, and of its post-merge run, over the merged pull requests of the window; the billing report’s rate per runner type turns minutes into moneythe same over merged merge requests
Queue waitthe jobs API’s started_at less created_at per job; the watchdog bounds the worst case, the trend sizes the poolthe jobs API’s queued_duration
Cache hit ratethe line each run writes to its summary (cache)the same
The ledgertemplates/ci-cost-ledger.yaml, checked by reference/cost-ledger/ on changes to itthe same

Source: modules/M13-pipeline-economy/mappings.md

4 · Statuswhat is built, and what is left out on purpose

What the module provides

PieceWhat it is
templates/PIPELINE-ECONOMY.mdThe copyable policy page: the rules, the placement table to fill in, the hold’s label and jobs, the caches with their key schemes, bounds and reports, the runner class and parallelism of each job, the legs before CI and their scope, the cost measures and their cadence, and a checklist for a new or changed workflow
templates/ci-cost-ledger.yamlThe copyable cost ledger: one entry per decision that changed what the pipeline spends, with its measurement before and after and the reopen condition over a registered metric
templates/queue-watchdog.ymlA scheduled GitHub Actions workflow that runs the queue-stall check
reference/queue-watchdog/The queue-stall check: fails when a job has waited for a runner longer than a bound; with its self-test
reference/cost-ledger/The cost-ledger check: fails a decision without its measurement before and after, with an after-measurement past its due date, with a reopen condition that names no metric, comparator, threshold and window, or whose metric the registry does not carry; fails closed on a ledger it cannot read or that has no decisions list, and passes an empty list (no cost decision yet); with its self-test
reference/cache-mount-coverage/The cache-mount check: fails a container build whose dependency store is on a cache mount that a step reading the store does not carry, or that is pinned by a per-command flag; fails closed on a Dockerfile it cannot read; with its self-test
reference/workflow-conventions/The workflow-convention lint behind the Strict level: job timeouts, cancelling pull-request concurrency, unfiltered required workflows and !cancelled() aggregators, the CI hold’s label events, guard and held-head check, heavy suites off the per-change path, cache-environment parity, commit-pinned actions (M1’s piece 7 says why), and path filters that match each other and the change-area catalog; reasoned, self-pruning exceptions; with its self-test. Jig runs it over its own workflows
mappings.mdEach sub-invariant on GitHub Actions and GitLab CI, the cache rules on the task runners and build tools, the runner classes and parallelism settings by vendor and tool, and the cost measures by provider, with the syntax and provider behaviour this page leaves out
maturity criteriaThe criteria the audit skill scores

The resolver and the aggregator are not repeated here: the aggregator’s shape is in M1’s skeleton, and so is the CI hold’s wiring, as an opt-in block; the catalog and resolver are M3’s, and the verified pointer and its post-merge range are M10’s. The /jig:github-actions skill reviews workflow changes, and Jig’s own gates workflow is a worked example of sub-invariants 1, 2 and 4, and of sharding a long suite. The CI hold’s driver side and the cost metrics are not repeated here either: the former is drive-pr’s, the latter M11’s (ci-runner-minutes, ci-sandbox-minutes-share, ci-cost-per-change, ci-queue-wait and ci-cache-hit-rate in its registry template). The hooks that run the leg before CI are M1’s, and their scope comes from M3’s catalog.

Left out by design

  • What is checked. Which gates exist and on which rung they sit is M1’s; M13 never trades a gate away for speed.
  • Repositories without CI. Nothing to economize yet; the module scores absent until M1 brings CI in.

Future

Not in the module yet; each lands as its own work:

  • The lint on GitLab CI: the workflow-convention lint reads GitHub Actions files only.
  • A collector for the cost measures: the measures of piece 11 are read from the provider’s records by each repository’s own scheduled job (the mappings name the fields); a reference collector waits until one has run long enough somewhere to show which fields and windows hold up.