feat(skills): past-mistake-gate (P-MAG) in proceed-with-the-recommendation#39
feat(skills): past-mistake-gate (P-MAG) in proceed-with-the-recommendation#39naimkatiman merged 5 commits intomainfrom
Conversation
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.
There was a problem hiding this comment.
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, ".."); |
There was a problem hiding this comment.
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
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.Rule 1quotes literal evidence from~/.claude/instincts/<project-hash>/observations.jsonland the project CLAUDE.md "Past Mistakes" section;Rule 2is a hard halt if residue lives in the working tree or operator queue;Rule 3carries one named past failure into Phase 2 asWill NOT repeat: <pattern>needs-approvalhaltsWill NOT repeat:) so every per-item plan ships a declared negative prompt; the worked example demonstrates the shape on items 1 and 3cb9cbdf: 6 docs-substring assertions (3 literals × source + plugin mirror) plus a newpast-mistake-gate.test.mtswith 8 assertionsWhy 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
cafc198feat(skills): add Phase 0 Acknowledge (Past Mistake Gate / P-MAG)003fbe5feat(skills): add P-MAG Rule 2 clearance bullet to Stop Conditionsc63de36feat(skills): add 'Will NOT repeat' negative prompt to Phase 2 plan templatebcf971bfeat(ci): lock P-MAG literals via docs-substring assertion + testOne concern per commit; source skill + plugin mirror always edited together.
Test plan
npm run buildcleannode bin/check-docs-substrings.mjs—OK docs-substrings: all 78 substring assertion(s) matchnode --test test/past-mistake-gate.test.mjs— 8/8 passnpm test— full suite 246/246 passWill NOT repeat:reads as the fifth template field, not a sixth (count: WILL build, Will NOT build, Verification, Fallback, Will NOT repeat)Out of scope (deferred)
past-mistake-gate.mdskill — only promote after the inline gate has been used for a session or two and assumption-breakages surfaceSKILL.mdcore — bigger leverage, bigger blast radius; revisit after this lands