Skip to content

feat(ratchet): enforce R3 'no learning without a constraint' as a script gate (ag-maaa #r3-constraint-gate)#768

Open
boshu2 wants to merge 1 commit into
mainfrom
feature/ag-maaa-r3-constraint-gate
Open

feat(ratchet): enforce R3 'no learning without a constraint' as a script gate (ag-maaa #r3-constraint-gate)#768
boshu2 wants to merge 1 commit into
mainfrom
feature/ag-maaa-r3-constraint-gate

Conversation

@boshu2
Copy link
Copy Markdown
Owner

@boshu2 boshu2 commented Jun 6, 2026

What

Makes the Brownian-Ratchet rule R3 — "no learning without a constraint" self-enforcing. Previously it was prose only (docs/architecture/operating-loop.md promotion table: "Must never regress → add a validation gate"): a learning could be promoted to a durable maturity tier without ever compiling into a gate/test/rule. The mechanism existed (cli/internal/ratchet/) but R3 was a manual operator decision with no check.

How

scripts/check-ratchet-r3-constraint.sh scans the learnings corpus and flags any durable-tier learning (candidate/established/canonical/stable/promoted) that cites no constraint — a scripts//.github/workflows/ gate, a _test.go/tests/ reference, a skills/**/SKILL.md step, or a constraint:/enforced_by: frontmatter field. Provisional learnings are exempt (still forming).

  • Warn-first → blocking, mirroring the ratchet's own warn-then-fail ladder: warn-only by default (exit 0); --strict or RATCHET_R3_BLOCKING=true makes the same gaps blocking (exit 1).

Why a script, not a CI path-filter gate

.agents/learnings/** is gitignored (0 tracked). A CI path-filter gate on it would be dead-by-design — the exact reason the learning-coherence CI job was retired (2026-05-19). So R3 runs at ratchet/flywheel time against the live local corpus; the script's own correctness is gated in CI by the committed bats test (tests/scripts/*.bats runs in validate.yml).

Verification

  • tests/scripts/check-ratchet-r3-constraint.bats — 11 hermetic tests on a synthetic fixture (warn-first, --strict, env-var parity, provisional exemption, empty-field rejection, gate/test/SKILL citation forms, count accuracy). All pass.
  • shellcheck clean.
  • Dry-run against the real local corpus: 639 scanned, 7 durable-tier, 5 flagged — warn-only, exit 0 (honest; does not break on existing corpus).

Closes-scenario: ag-maaa#r3-constraint-gate
Bounded-context: BC1-Corpus
Evidence: tests/scripts/check-ratchet-r3-constraint.bats

…ipt gate (ag-maaa #r3-constraint-gate)

The promotion-ratchet rung "Must never regress -> add a validation gate"
(docs/architecture/operating-loop.md) was prose only: a learning could be
promoted to a durable maturity tier without ever compiling into a
gate/test/rule. R3 itself was never enforced.

Add scripts/check-ratchet-r3-constraint.sh: scans the learnings corpus and
flags any durable-tier learning (candidate/established/canonical/stable/
promoted) that cites no constraint -- a scripts//.github/workflows/ gate, a
_test.go/tests/ reference, a skills/**/SKILL.md step, or a
constraint:/enforced_by: frontmatter field. Warn-only by default; --strict
(or RATCHET_R3_BLOCKING=true) makes it blocking, mirroring the ratchet's own
warn-then-fail promotion ladder.

A CI path-filter gate is intentionally NOT used: .agents/learnings/** is
gitignored, so such a gate would be dead-by-design (the same reason the
learning-coherence CI job was retired). The script runs at ratchet/flywheel
time against the live local corpus; its own correctness is gated in CI by
the committed bats test.

- scripts/check-ratchet-r3-constraint.sh: the gate (shellcheck-clean)
- tests/scripts/check-ratchet-r3-constraint.bats: 11 hermetic tests on a
  synthetic fixture (CI runs tests/scripts/*.bats)
- docs/architecture/operating-loop.md: enforcement pointer under the
  promotion-ratchet table (prose -> referenced gate)

Closes-scenario: ag-maaa#r3-constraint-gate
Bounded-context: BC1-Corpus
Evidence: tests/scripts/check-ratchet-r3-constraint.bats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant