jig-harness/jig
M2 Generated-artifact freshness · in your tools

M2 mappings — per-ecosystem implementations

The module’s invariant and its drop > check > commit ladder (see README.md) are tool-independent. This file maps each rung’s checks onto concrete CI providers, git hook managers, and container/database stacks. Replace <placeholders> with your repo’s values.

Every command below is a TypeScript script run with Bun: bun <script>.ts. The runner (CI job, hook or container) needs Bun installed at a pinned version first — see the toolchain note in M1’s mappings.

Run the schema replay script from a pinned Jig checkout: it shares the plugin’s retry, clock and trace helpers as well as lib/. A standalone copy must retain those relative dependencies.

CI providers, per rung

RungCheckReference script
2 — CI-check, commit nothingstated-counts drift; referenced-path-existsreference/prose-facts/
2 — registered factseach fact re-derived from its source, every registered phrasing of a stated copy checkedreference/prose-facts/check-registered-facts.ts
2 — unchecked tallies (advisory)a number that reads as a tally with no check behind it; <!-- measured --> exempts a linereference/prose-facts/lint-derivable-counts.ts
3 — commit + triadregenerate-to-temp-and-diff drift gatereference/triad/check-index-fresh.ts
3 (Strict, schema-like)ephemeral replayreference/ephemeral-replay/check-schema-drift.ts
every rung-3 check, one CI stepthe generic runner over the generated-file inventoryreference/inventory/run-generated-checks.ts
3 — generator coveragethe inputs the generator reads equal the inputs that existreference/generator-coverage/check-generator-coverage.ts
3 — structured artifactscommitted copy and fresh output compared as parsed datareference/compare-as-data/compare-as-data.ts
after the mergeregeneration published through a pull request on a fixed branch, merged by a persontemplates/regenerate-after-merge.yml

GitHub Actions

yaml
# Rung 2 — commit-nothing prose checks. Land advisory, promote by deleting
# `continue-on-error` — no script change needed. Add these under any job's
# `steps:` key.
steps:
  - name: Stated-counts drift (advisory)
    run: bun reference/prose-facts/check-stated-counts.ts <instruction-file> <dir> <noun>
    continue-on-error: true
  - name: Referenced paths exist (advisory)
    run: bun reference/prose-facts/check-referenced-paths.ts <instruction-file>
    continue-on-error: true
  - name: Registered facts (advisory)
    run: bun reference/prose-facts/check-registered-facts.ts <facts.yaml> <instruction-file>
    continue-on-error: true
  - name: Unchecked tallies (advisory; stays advisory)
    run: bun reference/prose-facts/lint-derivable-counts.ts --registry <facts.yaml> <prose-file>...
    continue-on-error: true
yaml
# Rung 3 — triad drift gate. Blocking; path-filter to the artifact's inputs.
# .github/workflows/freshness.yml
on:
  pull_request:
    paths: ['<docs-dir>/**/*.md']
jobs:
  freshness:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<full-commit-sha> # v4
      - run: bun reference/triad/check-index-fresh.ts <docs-dir>
yaml
# Every declared check, one step: the runner reads the inventory (or the
# change-area catalog's `generated:` entries) and runs each entry's `check`.
# A generator added later needs an inventory entry and no change here. Put
# it in the workflow that is a required check.
steps:
  - uses: actions/checkout@<full-commit-sha> # v4
  - run: bun reference/inventory/run-generated-checks.ts <inventory.yaml>
yaml
# Rung 3 Strict — ephemeral replay. A separate workflow, path-filtered to the
# schema's own inputs, so migration/schema changes trigger it even when no
# docs changed (GitHub Actions filters `on.pull_request.paths` per workflow,
# not per job — hence the separate file rather than a second job above).
# Ubuntu runners ship docker.
# .github/workflows/schema-drift.yml
on:
  pull_request:
    paths: ['<migrations-dir>/**', '<schema.sql>']
jobs:
  schema-drift:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<full-commit-sha> # v4
      - run: bun reference/ephemeral-replay/check-schema-drift.ts <migrations-dir> <schema.sql>

GitLab CI

yaml
# Rung 2 — advisory via allow_failure; promote by deleting that line.
prose-facts:
  script:
    - bun reference/prose-facts/check-stated-counts.ts <instruction-file> <dir> <noun>
    - bun reference/prose-facts/check-referenced-paths.ts <instruction-file>
    - bun reference/prose-facts/check-registered-facts.ts <facts.yaml> <instruction-file>
  allow_failure: true

# The tally lint stays advisory: it judges by shape.
unchecked-tallies:
  script: bun reference/prose-facts/lint-derivable-counts.ts --registry <facts.yaml> <prose-file>...
  allow_failure: true

# Rung 3 — triad drift gate, run only when the inputs changed.
index-freshness:
  script: bun reference/triad/check-index-fresh.ts <docs-dir>
  rules:
    - changes: ['<docs-dir>/**/*.md']

# Every declared check in one job, whatever changed; blocking.
generated-files:
  script: bun reference/inventory/run-generated-checks.ts <inventory.yaml>

# Rung 3 Strict — ephemeral replay via docker-in-docker...
schema-drift:
  image: docker:27
  services: ['docker:27-dind']
  script: bun reference/ephemeral-replay/check-schema-drift.ts <migrations-dir> <schema.sql>

# ...or skip the container entirely with a GitLab service database: replay
# migrations into the `postgres` service with psql, dump with pg_dump, then
# compare through the reference script's normalizeSchema step.

Other providers follow the same shape: any CI that can run a shell script can run all three rungs. The only provider-specific decisions are the advisory mechanism (continue-on-error / allow_failure / equivalent) and how the runner reaches a database (local docker, docker-in-docker, or a provider-managed service container).

Regeneration after merge, through a pull request

The steps are the same on every provider: run on the push to the integration branch, filtered to the generator’s inputs and never its outputs; serialize the generator’s runs; regenerate; when something changed, commit on a fixed branch per generator, push it leased to the tip the run inspected and only while every commit on that branch is the generator’s own, open the pull request if none is open, and stop there: a person merges it. No commit, the branch commit or the merge commit, carries any of the platform’s skip instructions; the inputs-only filter and the no-change exit keep the run from starting itself again. When nothing changed, close a pull request an earlier run left open, deleting its branch under the same lease and ownership check. Where the platform evaluates a path filter against only part of a large push, a manual run is the recovery. A manual run from any ref other than the integration branch does nothing, and the pull request’s base is the integration branch as configured, never the ref the run started from. The credential that pushes and opens the pull request has write to contents and pull requests and nothing else, and its absence fails the run before any work.

ProviderWhere each step lives
GitHub Actionstemplates/regenerate-after-merge.yml: on.push.paths for the inputs; a concurrency group per generator; a GitHub App installation token minted per run (actions/create-github-app-token, pinned) or a fine-grained token in a secret; the branch’s commits checked through gh api repos/:owner/:repo/compare, then git push --force-with-lease and gh pr create on the fixed branch. The path filter sees only the first 3,000 changed files of a push; workflow_dispatch is the recovery
GitLab CIa job with rules: [{ if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH, changes: [<inputs>] }] and resource_group: regenerate-<artifact> to serialize; the branch’s commits checked through the repository compare API, then git push --force-with-lease -o merge_request.create -o merge_request.target=<branch> -o merge_request.remove_source_branch origin <fixed branch> with a project access token that has write_repository; a person merges the merge request. When nothing changed, close the open merge request through the merge request API (glab mr close), which needs a token with the api scope, since write_repository alone cannot close it

Hook managers (rung 3’s auto-stage twin)

The pre-commit hook regenerates the artifact and stages it when its inputs are staged. The hook is a convenience; CI remains the authority.

ManagerAuto-stage wiring
lefthookglob on the inputs; run the generator then git add <artifact>; stage_fixed: true
huskyin .husky/pre-commit: guard with git diff --cached --name-only | grep -q '<inputs-pattern>', then generate + git add <artifact>
pre-commit frameworka local repo: local hook with files: <inputs-pattern> running the generator; it stages nothing itself, but any file the hook modifies fails the commit, and the standard workflow is git add + retry

Lefthook example (the fullest expression — glob filtering, staging, and timeout are all declarative):

yaml
pre-commit:
  commands:
    <artifact>-fresh:
      glob: "<inputs-glob>"
      timeout: 2m
      run: |
        <generate-command>
        git add <artifact-path>
      stage_fixed: true

pre-commit framework example:

yaml
repos:
  - repo: local
    hooks:
      - id: <artifact>-fresh
        name: regenerate <artifact>
        entry: <generate-command>
        language: system
        files: '<inputs-pattern>'
        pass_filenames: false

Container and database variants (ephemeral replay)

StackNotes
docker + PostgresThe reference script. Pin the image to a digest (PG_IMAGE); two-gate readiness (init sentinel, then pg_isready); dump with pg_dump --schema-only --no-owner --no-privileges --no-tablespaces --no-security-labels
podman + PostgresThe script runs a docker executable, so install podman’s docker-compatible command (e.g. the podman-docker package); a shell alias is not enough. Rootless mode avoids CI privilege requirements
CI service containerGitHub Actions services: / GitLab services: start the database for you — replay with a psql client and keep only the script’s normalize-and-compare step
testcontainersSame recipe inside a test framework, when the repo already uses one; readiness and teardown come for free
MySQL/MariaDBDump with mysqldump --no-data; normalize away AUTO_INCREMENT= values, /*! version comments, and the dump-date footer
SQLiteNo container at all: replay migrations into a temp file with sqlite3, dump with .schema, diff. The cheapest full-chain replay there is

Whatever the engine, the invariants hold: replay from zero, pin versions and ordering, normalize both sides identically, and always tear down, even on failure or interrupt.

Toolchain pin sites

reference/toolchain-pins/ takes a declaration of each tool’s one source and its pin sites, each with how to read it: a toml:, json: or yaml: dotted path; a step: naming a CI setup action with the input that holds its version (with:) and the one that names a version file (with-file:), read from the parsed workflow so a comment is no step and a step without its input is caught (a step reading a file agrees only for actions/setup-node and oven-sh/setup-bun, whose own readers the check mirrors, when that reader takes the source’s value from it; any other setup action, and a file the action reads in a way the check does not follow such as mise.toml or global.json, sets its version explicitly); or a pattern: whose first capture group is the version, for files that are text. The rows name the sites a repository commonly has and the reader for each; a declaration lists the sites the repository has and nothing else, because a declared glob that matches no file fails the check. A version range (engines, requires-python, a >= in a project file) is not a pin and is left out.

ToolOne sourcePin sites, with the reader
Bunmise.toml (toml: tools.bun), or .tool-versions (pattern: '^bun (\S+)$')package.json packageManager (json: packageManager with pattern: '^bun@(.+)$'); @types/bun, released with the runtime (json: devDependencies.@types/bun); oven-sh/setup-bun steps (step: oven-sh/setup-bun, with: bun-version, with-file: bun-version-file; a step with neither installs the latest); a Dockerfile (pattern: '^ARG BUN_VERSION=(\S+)$', with FROM oven/bun:${BUN_VERSION} so the image follows the argument)
Node.js.node-version or .nvmrc (pattern: '^v?(\S+)$'), or mise.toml (toml: tools.node)actions/setup-node steps (step: actions/setup-node, with: node-version, with-file: node-version-file); a Dockerfile (pattern: '^FROM node:(\d+\.\d+\.\d+)'); @types/node tracks the major only, so it is a second tool whose source and site are read with a pattern that captures the major
Python.python-version (pattern: '^(\S+)$'), or mise.tomlactions/setup-python steps (step: actions/setup-python, with: python-version, with-file: python-version-file); a Dockerfile (pattern: '^FROM python:(\d+\.\d+\.\d+)')
Gogo.mod (pattern: '^go (\S+)$', and ^toolchain go(\S+)$ where one is set)actions/setup-go steps (step: actions/setup-go, with: go-version, with-file: go-version-file); a Dockerfile (pattern: '^FROM golang:(\S+)')
Rustrust-toolchain.toml (toml: toolchain.channel)dtolnay/rust-toolchain@<channel> steps, whose channel is the action’s @ref and so is read with a pattern anchored at the step (pattern: '^\s*(?:-\s+)?uses: dtolnay/rust-toolchain@(\S+)'); a Dockerfile (pattern: '^FROM rust:(\S+)')
Ruby.ruby-version (pattern: '^(\S+)$')ruby/setup-ruby steps (step: ruby/setup-ruby, with: ruby-version); a Dockerfile (pattern: '^FROM ruby:(\S+)')
JVM.sdkmanrc (pattern: '^java=(\S+)$') or .java-versionactions/setup-java steps (step: actions/setup-java, with: java-version, with-file: java-version-file); a Dockerfile (pattern: '^FROM eclipse-temurin:(\S+)'); a language level in the build file is a different fact from the runtime, so it is its own tool entry if pinned
.NETglobal.json (json: sdk.version)actions/setup-dotnet steps (step: actions/setup-dotnet, with: dotnet-version; global.json is a structured source, so a step reading it through global-json-file is a finding); a Dockerfile (pattern: '^FROM mcr\.microsoft\.com/dotnet/sdk:(\S+)')
pnpm, Yarnpackage.json packageManager (json: packageManager with pattern: '^pnpm@(.+)$')pnpm/action-setup steps (step: pnpm/action-setup, with: version; a step without it reads packageManager, the source, so a repository whose steps all leave it out declares no such site); corepack prepare pnpm@(\S+) in scripts and a Dockerfile

Other CI providers’ files are read with a path or an anchored pattern: a GitLab CI job pins an image (pattern: '^\s*image: oven/bun:(\S+)' in .gitlab-ci.yml), a CircleCI job a docker: image. Where the version manager is mise or asdf, one file is the source for every runtime, with one tool entry per runtime in the declaration. The pin a runtime canary holds (canary, nightly, head, a release candidate) is registered as an exception with that reason.

Source: modules/M2-generated-artifact-freshness/mappings.md