jig-harness/jig
M8 Learning loop · in your tools

M8 mappings — per-ecosystem implementations

The module invariant — classify, file with a durable id, reconstruct as a pre-fix fixture, answer with an additive lens, validate before gating, then measure — is tool-independent. This file maps its mechanisms onto concrete issue trackers, eval runners, telemetry, and agent runtimes. Replace <placeholders> with your values.

The gates, per rung

GateWhen it runsRung
corpus-linton any change to the corpus / taxonomyCI (authority); cheap enough to pre-commit too
parity reporton a schedule (a weekly parity snapshot)CI on a cron; its failure reopens a lever + feeds M7 promotion
reflection triggerat the end of a review loop, once it convergesnot a gate — a loop step whose exit code says whether to prompt (see § Reflection below)

The recipes run the gates from a pinned Jig checkout: each gate imports the shared implementation in lib/module-gates.ts, so keep the module and lib/ together and set M8 to the module’s path inside that checkout. The reflection trigger also uses plugin/shared/cleanup.ts from that checkout to release its lock through the shared process registry.

GitHub Actions

yaml
# .github/workflows/learning-loop.yml
on:
  pull_request:
    paths: ['corpus.yaml', 'miss-taxonomy.yaml']
  schedule:
    - cron: '0 9 * * 1'        # weekly parity snapshot
jobs:
  corpus:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    env:
      M8: <jig-checkout>/modules/M8-learning-loop
    steps:
      - uses: actions/checkout@<full-commit-sha> # v4
      - run: bun test "$M8"/reference/corpus-lint/check-corpus.test.ts
      - run: CORPUS=corpus.yaml bun "$M8"/reference/corpus-lint/check-corpus.ts
  parity:
    if: github.event_name == 'schedule'
    runs-on: ubuntu-latest
    env:
      M8: <jig-checkout>/modules/M8-learning-loop
    steps:
      - uses: actions/checkout@<full-commit-sha> # v4
      - run: ./scripts/parity-snapshot > parity.tsv      # from your telemetry
      - run: MIN_PRECISION=0.90 bun "$M8"/reference/parity-report/check-parity.ts parity.tsv

GitLab CI

yaml
variables:
  M8: <jig-checkout>/modules/M8-learning-loop
corpus-lint:
  rules: [{ changes: ['corpus.yaml', 'miss-taxonomy.yaml'] }]
  script:
    - bun test "$M8"/reference/corpus-lint/check-corpus.test.ts
    - CORPUS=corpus.yaml bun "$M8"/reference/corpus-lint/check-corpus.ts
parity:
  rules: [{ if: '$CI_PIPELINE_SOURCE == "schedule"' }]
  script:
    - ./scripts/parity-snapshot > parity.tsv
    - MIN_PRECISION=0.90 bun "$M8"/reference/parity-report/check-parity.ts parity.tsv

Issue trackers (durable lever ids)

The lever id (L-NNNN) is the spine — a lens, a fixture, and a metric all point at it. It needs a home that outlives a PR.

TrackerWiring
Linear / Jiraone issue per lever with a stable key; a learning-loop label; the corpus lever: is the issue key. Uniqueness is free (the tracker assigns keys)
GitHub issuesone issue per lever; the issue number is the L-NNNN; a lever label. Guard next-number races the same way as ADR numbering
Flat filea levers.md ledger if you have no tracker; corpus-lint enforces uniqueness within the corpus regardless

Eval runners (replaying the corpus)

The corpus is data; running a fixture — replay the pinned commit through the reviewer and diff its findings against the expected — is a job in your own stack, not shipped here (see the README).

RuntimeReplay shape
Claude Code / Codex / Cursora skill/command that checks out pinned_commit, runs the reviewer with the current lens set, and asserts the expected finding appears
A test harnesseach required: true fixture becomes a case in your normal test runner; the corpus is the case list

Only a fixture whose live replay passes flips to required: true — corpus-lint enforces that a required fixture carries the validation record, but the running is the runner’s job.

Telemetry (the measure step)

The parity report consumes tallies; producing them is a telemetry job.

ToolRole
An event or product-analytics store (PostHog, Amplitude, a warehouse table; M11 maps the options)per-review events (was a finding real? was it acted on?) aggregate into the <reviewer> tp fp missed rows
Weekly snapshota scheduled query emits parity.tsv; the parity gate turns it into keep/promote/kill + missed_blockers

Wire the actual metric events under M11 (process observability) — M8 only defines what the numbers mean for the loop.

Reflection & memory-promotion commands

The two companion cycles are runtime commands with a human-approval checkpoint.

RuntimeReflectionMemory promotion
Claude CodeJig’s /jig:reflect records a session’s findings in the shared reflection store; /jig:review-reflections proposes scaffolding changes for human approvalJig’s /jig:promote-memory lifts private memory into the git-tracked docs, after checking it still holds
Codexthe same two skills, from the Jig pluginthe same promote-memory skill, from the Jig plugin
Cursor / otheran end-of-session hook writing to the inbox (or, through the plugin’s scripts, to the store); a periodic review stepa scripted promote step over the agent’s memory store

Reflection stores

Where the reflection records live. Every store answers the same contract (check, append, list, diagnose; see the reflect skill), and its conformance suite checks any of them.

Storereflection.storeFits
A folder of JSONL files, one file per writefilesystem (the default)One person’s machine, or a team folder synced by a cloud drive or committed to a git repository
A Notion database, one page per change, with each event kept on its pagenotionA team that triages in Notion and wants the findings filterable and sortable there
Any command that answers the contractcommandA store a repository or a person already runs: a database, an internal service
Without the plugin: the markdown inbox the reflection trigger appends ton/aA repository that does not use Jig’s plugin

Reflection: firing it on the round count

Whether to reflect is the part that decays. The reflection trigger reads M7’s convergence decision — which already carries the round count — and fires only at convergence, only at or above the threshold. Its exit 3 (“nothing to do”) is not a failure, so wire it as a condition rather than a bare step:

sh
# last step of the review loop, after check-round-converged.ts wrote decision.txt
CHANGE="$PR" INBOX=docs/reflection-inbox.md ARCHIVE=docs/reflection-archive.md \
  ROUND_THRESHOLD=3 bun "$M8"/reference/reflection-trigger/reflection-trigger.ts decision.txt \
  && trigger_rc=0 || trigger_rc=$?

case "$trigger_rc" in
  0) <your runtime's reflect command> ;;   # /reflect, an end-of-session hook, …
  3) : ;;                                  # SKIP — ordinary review, nothing to do
  *) echo "reflection trigger failed (exit $trigger_rc)" >&2; exit "$trigger_rc" ;;
esac

Only 3 means “nothing to do”. A bare if …; then reflect; fi treats exit 2 — a malformed or self-contradictory decision.txt — as an ordinary skip, so a broken producer silently stops reflection from ever firing and nothing reports it. Re-raise every status except 3.

RuntimeWhere the trigger sits
Claude Code / Codex / Cursorinside the skill or command that drives the review loop, as its final step — the same place that decided the loop was done
A CI-driven loopa step after the convergence check; on PROMPT, open an issue or post the record so the prompt survives the job ending
A session hookpass the decision file through; a hook that fires on every session end is the under-firing problem again, just inverted

CHANGE is the source-change key — a PR number, branch, or ticket key. It is not a lever id, and conflating the two breaks the join rather than making it: levers are L-NNNN in the lever ledger, one change can produce several levers or none, and the lever does not exist yet at the moment the trigger fires. Keep change as the source-change key and record the lever separately, in the record’s disposition: field — that field is the foreign key from a reflection to the lever it became, and it is what lets you ask both “which changes fought the scaffolding hardest” and “which levers came from them”.

ARCHIVE is optional but wanted in practice: the inbox is worked down as entries become levers, and the trigger’s duplicate guard reads the archive too. Move processed entries there rather than deleting them, or a later re-run of the same change re-appends a record that was already handled.

On isolated runners the lock is not the guard. The trigger’s $INBOX.lock serializes processes sharing a filesystem; two CI jobs on separate runners each have their own checkout and their own lock, so both will append and both will prompt. What actually deduplicates across runners is that the inbox is git-tracked: the second job’s push loses the race, has to rebase, and on the retry the trigger finds the marker and skips. So commit the inbox as part of the job, and key anything the prompt causes — an issue, a post, a notification — on change+rounds, because the trigger can promise one record per change and round but not one side effect.

The human-approval step on reflection-proposed scaffolding changes is HITL (see M7’s registry) — a system editing its own rules must stop for a person, whatever the runtime.

Audit cadence reminders

The audit catalog records when an audit is due; something still has to say so. Pick the reminder by cadence, and put the catalog’s own file under the same review as any document (an M4 owner and freshness date).

CadenceWhere the reminder lives
continuousNowhere: a gate or a schedule runs the audit, and its failure is the reminder. A continuous row with no such check is mislabelled.
per releaseA step in the release procedure (M10): the release is not cut until the area’s Last audited names the previous release as the one its audit followed.
monthly, quarterlyA scheduled job that reads the table and opens or updates one issue per overdue area, assigned to the row’s owner: GitHub Actions on: schedule (cron), a GitLab CI pipeline schedule, or a recurring item in your tracker or calendar. One open issue per area, never a new one each run.
ad hocThe named trigger: a path filter on the change that should prompt the audit, or the checklist of the process that changes the area.

A manual row’s gap in tooling is an ordinary tracker issue (label it as you label other tooling work); the catalog row links to it, and closing the issue is the moment the row’s Tooling cell changes.

Source: modules/M8-learning-loop/mappings.md