Skip to content

feat(skills): past-mistake-gate (P-MAG) in proceed-with-the-recommendation#39

Merged
naimkatiman merged 5 commits intomainfrom
feat/past-mistake-gate
Apr 28, 2026
Merged

feat(skills): past-mistake-gate (P-MAG) in proceed-with-the-recommendation#39
naimkatiman merged 5 commits intomainfrom
feat/past-mistake-gate

Conversation

@naimkatiman
Copy link
Copy Markdown
Owner

Summary

Adds Phase 0 (Past Mistake Acknowledgment Gate / P-MAG) to proceed-with-the-recommendation. Three rules in order: acknowledge before context, clearance gate, negative prompt. Forces the instinct system's prior corrections to be read at the moment they actually matter — before a new recommendation list is touched.

  • Phase 0 sectionRule 1 quotes literal evidence from ~/.claude/instincts/<project-hash>/observations.jsonl and the project CLAUDE.md "Past Mistakes" section; Rule 2 is a hard halt if residue lives in the working tree or operator queue; Rule 3 carries one named past failure into Phase 2 as Will NOT repeat: <pattern>
  • Stop Conditions gain a new bullet enumerating Rule 2's clearance gate alongside needs-approval halts
  • Phase 2 plan template gains a fifth field (Will NOT repeat:) so every per-item plan ships a declared negative prompt; the worked example demonstrates the shape on items 1 and 3
  • CI lock mirrors the wild-risa-floor pattern from cb9cbdf: 6 docs-substring assertions (3 literals × source + plugin mirror) plus a new past-mistake-gate.test.mts with 8 assertions

Why now: prior-session corrections were being logged to the instinct system but never read at the start of the next session. Lists kept walking past unfinished verification steps because the framework had no gate that forced acknowledgment + clearance + negative prompt.

Commits

  1. cafc198 feat(skills): add Phase 0 Acknowledge (Past Mistake Gate / P-MAG)
  2. 003fbe5 feat(skills): add P-MAG Rule 2 clearance bullet to Stop Conditions
  3. c63de36 feat(skills): add 'Will NOT repeat' negative prompt to Phase 2 plan template
  4. bcf971b feat(ci): lock P-MAG literals via docs-substring assertion + test

One concern per commit; source skill + plugin mirror always edited together.

Test plan

  • npm run build clean
  • node bin/check-docs-substrings.mjsOK docs-substrings: all 78 substring assertion(s) match
  • node --test test/past-mistake-gate.test.mjs — 8/8 pass
  • npm test — full suite 246/246 pass
  • Reviewer: confirm Phase 0 lands above Phase 1 in both source skill and plugin mirror
  • Reviewer: confirm Will NOT repeat: reads as the fifth template field, not a sixth (count: WILL build, Will NOT build, Verification, Fallback, Will NOT repeat)
  • Reviewer: confirm CI lock catches drift by temporarily deleting one of the three literals locally and seeing the test fail

Out of scope (deferred)

  • Standalone past-mistake-gate.md skill — only promote after the inline gate has been used for a session or two and assumption-breakages surface
  • Promoting acknowledgment to an 8th Law in SKILL.md core — bigger leverage, bigger blast radius; revisit after this lands

Three rules in order: acknowledge before context, clearance gate,
negative prompt. Forces the instinct system's prior corrections to be
read at the moment they actually matter — before a new recommendation
list is touched. Source skill + plugin mirror updated together so the
bundled README install path picks it up unchanged.
Lifts P-MAG Rule 2 into the Stop Conditions list so the gate is
enumerated alongside needs-approval halts and verification failures.
Prevents Phase 1 from starting while a prior mistake still has live
residue in the working tree or operator queue.
…emplate

P-MAG Rule 3 promotes a named past failure into the per-item plan as a
fifth field alongside WILL build / Will NOT build / Verification /
Fallback. Worked example updated for item 1 and item 3 so the shape is
visible. Phase 6 reflection now has a declared target to score against.
Adds a past-mistake-gate test asserting that both the source skill and
the plugin mirror contain three structural literals: the Phase 0
heading, the negative-prompt field marker, and the Stop Conditions
clearance bullet. Plus six matching entries in the docs-substring
inventory so the standalone lint catches drift before the full suite
runs.

- src/test/past-mistake-gate.test.mts: new test, 8 assertions
- src/bin/check-docs-substrings.mts: 6 inventory entries appended
- bin/, test/: regenerated build outputs (npm run build)

Guards against future edits silently dropping any of the three rules
(acknowledge / clearance / negative prompt) the way the WILD/RISA floor
was almost dropped before commit cb9cbdf locked it.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Past Mistake Acknowledgment Gate (P-MAG) into the recommendation workflow, adding a mandatory Phase 0 that requires reviewing past failures and ensuring their resolution before proceeding. The changes include updates to the skill documentation, new assertions in the documentation checker, and a new test suite to verify the presence of these gates. A critical issue was identified in the new test file where the repository root path calculation is incorrect, which will cause tests to fail when attempting to read the markdown files.

import { fileURLToPath } from "node:url";

const __dirname = fileURLToPath(new URL(".", import.meta.url));
const REPO_ROOT = join(__dirname, "..");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The REPO_ROOT calculation is incorrect for a file located in src/test/. It currently points to src/, but it needs to point to the repository root (two levels up) to correctly locate the skills/ directory used in the MIRRORS array. This will cause the readFileSync call on line 42 to fail.

const REPO_ROOT = join(__dirname, "..", "..");

Resolves conflicts in bin/check-docs-substrings.mjs and
src/bin/check-docs-substrings.mts by keeping both the P-MAG
literal-lock block (this branch) and the WILD/RISA floor
literal-lock block (#37, just merged to main).

Verified locally:
- node bin/check-docs-substrings.mjs: 80/80 pass
- node bin/check-skill-tiers.mjs: 13 tiered skills
- node bin/check-skill-mirror.mjs: 13 pairs match
- node --test test/past-mistake-gate.test.mjs: 8/8 pass
- node --test test/wild-risa-floor.test.mjs: 4/4 pass
- node --test test/skill-tiers.test.mjs: 17/17 pass
@naimkatiman naimkatiman merged commit f1e6440 into main Apr 28, 2026
4 checks passed
@naimkatiman naimkatiman deleted the feat/past-mistake-gate branch April 28, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant