You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since PR #101 (Apr 6) the user has been editing ~/.pai/PAI/Algorithm/v3.7.0.md and ~/.claude/CLAUDE.md directly in the runtime as part of normal learning-cycle iteration. Those edits have never been backported to the release source Releases/v4.0.3+/.claude/. The runtime Algorithm is now ~14KB larger than the repo copy and contains seven net-new gates / sections born from reflection mining.
This issue tracks the content sync of the net-new material — the parts of the runtime delta that are not path/two-root cleanup (which is tracked in #108) and not Learning-skill bug fixes (#109).
Files
Runtime (source for sync)
Repo target
~/.pai/PAI/Algorithm/v3.7.0.md
Releases/v4.0.3+/.claude/PAI/Algorithm/v3.7.0.md
~/.claude/CLAUDE.md
Releases/v4.0.3+/.claude/CLAUDE.md
~/.pai/PAI/Algorithm/LATEST (symlink → v3.7.0.md)
Releases/v4.0.3+/.claude/PAI/Algorithm/LATEST (currently a 7-byte marker file)
Each is mined from real failure data — the runtime Algorithm cites specific session IDs and failure counts as justification, which a fix-PR should preserve verbatim.
A. Voice mechanism rewrite — inline curl → Notify.ts CLI
Replaces the inline POST-to-localhost block with bun ${PAI_DIR}/PAI/Tools/Notify.ts \"MESSAGE\". Notify.ts is self-gating (reads `notifications.voice.enabled` from settings.json) and self-isolating (detects `CLAUDE_CODE_AGENT_TASK_ID` so subagents stay silent automatically). Eliminates the prior "Only the primary agent may execute voice curls" prose rule by moving enforcement into the binary.
⚠️ The runtime version writes the path as `/.claude/PAI/Tools/Notify.ts` which is wrong (file is at `/.pai/PAI/Tools/Notify.ts`). Fix on backport. Tracked in #108 as one of the two new regressions.
B. Directive Compliance Gate (NEW section, inserted before OBSERVE)
Four pre-OBSERVE checks: branch verification, target directory verification, user-system directives (CLAUDE.md / loaded context), sticky constraints from prior turns. Cites the avg-1.3 rating failure class for sticky-constraint violations. Gate rule: do not enter OBSERVE until all four pass.
C. OBSERVE phase additions
Request Comprehension Check — restate the user's request in one sentence; if the restatement changes meaning, you misunderstood.
Context Disambiguation (TARGET DECLARATION) — when file ops have multiple plausible targets (repo source / installed copy at `/.claude/` / runtime at `/.pai/` / fork vs upstream), enumerate all candidates with absolute paths, then declare the chosen one with a one-line "TARGET:" reason. Cites: "wrong-target pattern grew from 5 to 9 occurrences across the last review cycle despite a prior fix being applied."
Scope Gate (HARD BLOCK) — atomic / simple / complex classification. Atomic = single discrete action → skip ceremony, execute, done. "The phrase 'while I'm there' is forbidden." Cites: "session 42908b3f (2026-04-12) scored 1.71 avg — the worst session on record."
D. FAST-PATH Classifier table (Standard tier only)
Decision table at OBSERVE entry, before mode classification commits to full ceremony. Five rows: atomic action / mechanical substitution / pure content extraction / ≤5-line single-file edit / anything else. Cites: "full ceremony on trivial work is the failure mode (12 reflection occurrences). Prior FAST-PATH guidance was prose-only."
E. Agent Prompt Requirements (added to CAPABILITY SELECTION)
When delegating to agents, every prompt must include: explicit boundaries (files in/out of scope), exemplar excerpt (10-20 lines of existing output to anchor style), schema/format constraints.
F. OBSERVE Exit Gate — External Assumption Verification
Five hard-block checks before THINK: file paths exist (Read or `ls`), repos/targets verified (`git remote -v` / `pwd`), external endpoints probed (`curl -I` / `dig`), product specifics from official docs not memory, existing tooling grep'd before improvising. Cites: "prior verification rules were applied at the steering-rule level but the underlying pattern still produced 32 failure events across the dataset."
G. Dependency Analysis Micro-Phase (in PLAN)
Mandatory at all tiers. Enumerate every action into a flat list, identify dependencies, partition into parallel tracks. Default disposition: "if two actions share no input, launch them concurrently" is the rule, not the exception. Exit gate: no action may be serialized if it has no dependency. Cites: "the underlying signal grew from 11 to 14 occurrences over 21 days, demonstrating that disposition without mechanism is insufficient."
H. Pre-Read Sweep Gate (BUILD, MANDATORY HARD BLOCK before EXECUTE)
Enumerate every file that EXECUTE will Read/Edit/Write. Issue a SINGLE batched Read call with all of them as parallel tool invocations. Edit and Write blocked until pre-read sweep completes. Drift handling: if file list grows mid-EXECUTE, pause, batch-read new files, resume. Cites: "the mechanical pattern persisted at 8 occurrences unchanged."
I. VERIFY phase additions
Phantom-capability anti-criterion (`ISC-A`): if a capability was selected but never invoked via tool, this is a CRITICAL FAILURE. Either invoke it now or remove it from the selected list with a reason. "Leaving a phantom selection is dishonest."
OUTCOME VERIFICATION: "I wrote the file" is not done. "I wrote the file, read it back, and confirmed it contains X" is done. Code changes → run code or tests. Framework choices → minimal proof before scaling.
DOCUMENT LINT GATES: for any task touching Markdown/MDX/etc., run programmatic checks before exiting VERIFY — link checker, heading hierarchy, frontmatter validation, cross-doc consistency. Proposes building reusable micro-tools (`Tools/lint-links.ts`, `Tools/lint-headings.ts`, `Tools/lint-frontmatter.ts`) so document tasks trigger them automatically. Cites: "Manual multi-file reading missed these in 4 prior reflections."
This last item (`Tools/lint-*.ts`) is the only delta that implies new code, not just docs.
Net-new CLAUDE.md changes to backport
J. Title de-versioned
`# PAI 4.0.3 — Personal AI Infrastructure` → `# PAI — Personal AI Infrastructure`. The old title hardcodes a version into the user-facing config file every release; the new title is version-agnostic.
The whole `## MINIMAL — pure acknowledgments, ratings` block is deleted
Critical Rules block reference still says `(ALGORITHM, NATIVE, or MINIMAL)` — needs update if MINIMAL truly gone
The Algorithm file's Critical Rules still references `MINIMAL` as one of four format options ("ALGORITHM, NATIVE, ITERATION, or MINIMAL"). One of the two needs to win. Suggest: keep MINIMAL out of CLAUDE.md but add a note or remove it from Algorithm's Critical Rules too.
L. Inline curl voice command removed from NATIVE MODE header
The curl block was redundant once Notify.ts exists (delta A). Just delete.
M. Speaker rename: `Assistant:` → `Viki:`
Two occurrences in the NATIVE / iteration formats. Personalization rename.
N. Awkward inline header
The runtime CLAUDE.md has a sentence-collision artifact:
```
... follow that file's instructions exactly. Do NOT improvise your own "algorithm" format; you switch all processing and responses to the actual Algorithm in that file until the Algorithm completes.Critical Rules (Zero Exceptions)
```
The `Critical Rules (Zero Exceptions)` text is welded onto the end of the previous paragraph with no space. Looks like an editing accident — the original `### Critical Rules (Zero Exceptions)` header was deleted but its text leaked into the prior paragraph. Fix on backport by removing the orphan text or restoring it as a header.
Summary
Since PR #101 (Apr 6) the user has been editing
~/.pai/PAI/Algorithm/v3.7.0.mdand~/.claude/CLAUDE.mddirectly in the runtime as part of normal learning-cycle iteration. Those edits have never been backported to the release sourceReleases/v4.0.3+/.claude/. The runtime Algorithm is now ~14KB larger than the repo copy and contains seven net-new gates / sections born from reflection mining.This issue tracks the content sync of the net-new material — the parts of the runtime delta that are not path/two-root cleanup (which is tracked in #108) and not Learning-skill bug fixes (#109).
Files
~/.pai/PAI/Algorithm/v3.7.0.mdReleases/v4.0.3+/.claude/PAI/Algorithm/v3.7.0.md~/.claude/CLAUDE.mdReleases/v4.0.3+/.claude/CLAUDE.md~/.pai/PAI/Algorithm/LATEST(symlink → v3.7.0.md)Releases/v4.0.3+/.claude/PAI/Algorithm/LATEST(currently a 7-byte marker file)Generate the working diff with:
```bash
diff -u Releases/v4.0.3+/.claude/PAI/Algorithm/v3.7.0.md ~/.pai/PAI/Algorithm/v3.7.0.md
diff -u Releases/v4.0.3+/.claude/CLAUDE.md ~/.claude/CLAUDE.md
```
Net-new Algorithm v3.7.0.md sections to backport
Each is mined from real failure data — the runtime Algorithm cites specific session IDs and failure counts as justification, which a fix-PR should preserve verbatim.
A. Voice mechanism rewrite — inline curl → Notify.ts CLI
Replaces the inline POST-to-localhost block with
bun ${PAI_DIR}/PAI/Tools/Notify.ts \"MESSAGE\". Notify.ts is self-gating (reads `notifications.voice.enabled` from settings.json) and self-isolating (detects `CLAUDE_CODE_AGENT_TASK_ID` so subagents stay silent automatically). Eliminates the prior "Only the primary agent may execute voice curls" prose rule by moving enforcement into the binary./.claude/PAI/Tools/Notify.ts` which is wrong (file is at `/.pai/PAI/Tools/Notify.ts`). Fix on backport. Tracked in #108 as one of the two new regressions.B. Directive Compliance Gate (NEW section, inserted before OBSERVE)
Four pre-OBSERVE checks: branch verification, target directory verification, user-system directives (CLAUDE.md / loaded context), sticky constraints from prior turns. Cites the avg-1.3 rating failure class for sticky-constraint violations. Gate rule: do not enter OBSERVE until all four pass.
C. OBSERVE phase additions
/.claude/` / runtime at `/.pai/` / fork vs upstream), enumerate all candidates with absolute paths, then declare the chosen one with a one-line "TARGET:" reason. Cites: "wrong-target pattern grew from 5 to 9 occurrences across the last review cycle despite a prior fix being applied."D. FAST-PATH Classifier table (Standard tier only)
Decision table at OBSERVE entry, before mode classification commits to full ceremony. Five rows: atomic action / mechanical substitution / pure content extraction / ≤5-line single-file edit / anything else. Cites: "full ceremony on trivial work is the failure mode (12 reflection occurrences). Prior FAST-PATH guidance was prose-only."
E. Agent Prompt Requirements (added to CAPABILITY SELECTION)
When delegating to agents, every prompt must include: explicit boundaries (files in/out of scope), exemplar excerpt (10-20 lines of existing output to anchor style), schema/format constraints.
F. OBSERVE Exit Gate — External Assumption Verification
Five hard-block checks before THINK: file paths exist (Read or `ls`), repos/targets verified (`git remote -v` / `pwd`), external endpoints probed (`curl -I` / `dig`), product specifics from official docs not memory, existing tooling grep'd before improvising. Cites: "prior verification rules were applied at the steering-rule level but the underlying pattern still produced 32 failure events across the dataset."
G. Dependency Analysis Micro-Phase (in PLAN)
Mandatory at all tiers. Enumerate every action into a flat list, identify dependencies, partition into parallel tracks. Default disposition: "if two actions share no input, launch them concurrently" is the rule, not the exception. Exit gate: no action may be serialized if it has no dependency. Cites: "the underlying signal grew from 11 to 14 occurrences over 21 days, demonstrating that disposition without mechanism is insufficient."
H. Pre-Read Sweep Gate (BUILD, MANDATORY HARD BLOCK before EXECUTE)
Enumerate every file that EXECUTE will Read/Edit/Write. Issue a SINGLE batched Read call with all of them as parallel tool invocations. Edit and Write blocked until pre-read sweep completes. Drift handling: if file list grows mid-EXECUTE, pause, batch-read new files, resume. Cites: "the mechanical pattern persisted at 8 occurrences unchanged."
I. VERIFY phase additions
This last item (`Tools/lint-*.ts`) is the only delta that implies new code, not just docs.
Net-new CLAUDE.md changes to backport
J. Title de-versioned
`# PAI 4.0.3 — Personal AI Infrastructure` → `# PAI — Personal AI Infrastructure`. The old title hardcodes a version into the user-facing config file every release; the new title is version-agnostic.
K. MINIMAL output format removed entirely
Both occurrences:
The Algorithm file's Critical Rules still references `MINIMAL` as one of four format options ("ALGORITHM, NATIVE, ITERATION, or MINIMAL"). One of the two needs to win. Suggest: keep MINIMAL out of CLAUDE.md but add a note or remove it from Algorithm's Critical Rules too.
L. Inline curl voice command removed from NATIVE MODE header
The curl block was redundant once Notify.ts exists (delta A). Just delete.
M. Speaker rename: `Assistant:` → `Viki:`
Two occurrences in the NATIVE / iteration formats. Personalization rename.
N. Awkward inline header
The runtime CLAUDE.md has a sentence-collision artifact:
```
... follow that file's instructions exactly. Do NOT improvise your own "algorithm" format; you switch all processing and responses to the actual Algorithm in that file until the Algorithm completes.Critical Rules (Zero Exceptions)
```
The `Critical Rules (Zero Exceptions)` text is welded onto the end of the previous paragraph with no space. Looks like an editing accident — the original `### Critical Rules (Zero Exceptions)` header was deleted but its text leaked into the prior paragraph. Fix on backport by removing the orphan text or restoring it as a header.
Out of scope (tracked elsewhere)
Suggested fix-PR shape
Single PR that:
Related