Brain QA
Semantic, logic, code, and architectural validation of Alex's cognitive architecture — not just file counts, but meaning coherence
Synapses
Format: See SYNAPSE-SCHEMA.md for notation reference
- [.github/instructions/semantic-audit.instructions.md] (High, Coordinates, Bidirectional) - "Procedural memory for manual semantic review that complements automated brain-qa"
- [.github/instructions/cognitive-health-validation.instructions.md] (Critical, Coordinates, Bidirectional) - "Comprehensive brain-qa integration with meditation and release workflows"
- [.github/skills/master-alex-audit/SKILL.md] (Medium, Related, Bidirectional) - "Full repository audit including brain-qa execution"
- [.github/instructions/dream-state-automation.instructions.md] (Medium, Complements, Forward) - "Dream validates synapses, brain-qa validates structure"
- [.github/instructions/release-management.instructions.md] (High, Gates, Forward) - "Pre-release validation requires brain-qa passing"
Philosophy
Brain QA is a mental exercise, not just a muscle exercise. The script validates structure, but the skill's true value is teaching Alex what to look for beyond what scripts can automate.
Two scripts serve different contexts:
| Script |
Context |
Phases |
Inheritance |
brain-qa.ps1 |
Master Alex |
31 (full) |
master-only |
brain-qa-heir.ps1 |
Heir deployments |
23 (heir-relevant) |
inheritable |
During sync, brain-qa-heir.ps1 is renamed to brain-qa.ps1 in the heir, so all contexts use the same filename. The master version includes cross-repo sync phases (5, 7, 8, 13) and master-only validations (26-29) that don't apply to heirs.
| Dimension |
Script Catches |
Alex Catches (with this skill) |
| Structural |
Missing files, broken paths, count mismatches |
✅ Automated |
| Semantic |
— |
Terminology drift (e.g. "DK files" vs "skills"), meaning contradictions between documents |
| Logic |
— |
Process descriptions that conflict (e.g. dream says X, meditation says Y), impossible workflows |
| Code |
Compile errors, lint |
Code behavior diverging from documented claims (e.g. documented trigger not wired in TypeScript) |
| Architectural |
— |
Working memory model inconsistencies, neuroanatomical mappings that contradict instruction files |
Rule: When running brain-qa, always pair the script output with a semantic review. The script is the body; this skill is the brain.
Quick Start
Master Context
# Full 31-phase audit
.github/muscles/brain-qa.ps1
# Quick validation (phases 1-6)
.github/muscles/brain-qa.ps1 -Mode quick
# Sync validation only (phases 5,7,8,13,14,15,27,28)
.github/muscles/brain-qa.ps1 -Mode sync
# Schema/frontmatter validation (phases 2,6,11,16,17)
.github/muscles/brain-qa.ps1 -Mode schema
# LLM-first content validation (phases 10,20,21)
.github/muscles/brain-qa.ps1 -Mode llm
# Specific phases
.github/muscles/brain-qa.ps1 -Phase 1,5,7
# Auto-fix sync issues
.github/muscles/brain-qa.ps1 -Mode sync -Fix
Heir Context
# Full heir audit (23 heir-relevant phases)
.github/muscles/brain-qa.ps1
# Quick validation (phases 1-4,6)
.github/muscles/brain-qa.ps1 -Mode quick
# Schema/frontmatter validation (phases 2,6,11,16,17)
.github/muscles/brain-qa.ps1 -Mode schema
# LLM content validation (phases 10,20,21)
.github/muscles/brain-qa.ps1 -Mode llm
# Note: -Mode sync is not available in heir (sync phases are master-only)
When to Use
- Before releases (structural + semantic review)
- After adding/modifying skills (do new synapses make logical sense?)
- After bulk synapse updates (are connections semantically meaningful?)
- When trigger conflicts are suspected (logic: can two triggers fire contradictory protocols?)
- To verify Master-Heir parity (architectural: does heir behavior match master docs?)
- To validate LLM-friendly content formats
- After any documentation refactor — check that meaning didn't drift when words changed
- When code and docs diverge — documented feature doesn't match TypeScript implementation
Audit Phases
| Phase |
Name |
Validates |
Heir? |
| 1 |
Synapse Target Validation |
All connection targets exist |
Yes |
| 2 |
Inheritance Field Validation |
All skills have inheritance field |
Yes |
| 3 |
Skill Index Coverage |
All skills in skill-activation index |
Yes |
| 4 |
Trigger Semantic Analysis |
Overlapping keywords (warnings OK if related) |
Yes |
| 5 |
Master-Heir Skill Sync |
Skill directories match |
No |
| 6 |
Synapse Schema Format |
Numeric strengths, $schema present |
Yes |
| 7 |
Synapse File Sync |
synapses.json hash match |
No |
| 8 |
Skill-Activation Index Sync |
SKILL.md hash match |
No |
| 9 |
Catalog Accuracy |
SKILLS-CATALOG count matches reality |
Yes (count-only) |
| 10 |
Core File Token Budget |
Size + ASCII art checks on core files |
Yes |
| 11 |
Boilerplate Descriptions |
No placeholder skill descriptions |
Yes |
| 12 |
Heir Reset Validation |
Empty profile, available P5-P7 slots |
Yes |
| 13 |
Instructions/Prompts Sync |
Memory files synced to heir |
No |
| 14 |
Agents Structure |
Valid agent files in both |
Yes |
| 15 |
Config Files |
Required configs present, no leaks |
Yes |
| 16 |
Skill YAML Frontmatter |
name and description in frontmatter |
Yes |
| 17 |
Internal Skills Hidden |
user-invokable: false for metacognition |
Yes |
| 18 |
Agent Handoffs |
Return-to-Alex handoffs present |
Yes |
| 19 |
ApplyTo Patterns |
Instructions have file-type patterns |
Yes |
| 20 |
LLM-First Content |
No ASCII art, Mermaid OK |
Yes |
| 21 |
Emoji Semantics |
Meaningful emoji usage stats |
Yes |
| 22 |
Episodic Archive Health |
.github/episodic/ session records valid |
Yes |
| 23 |
Assets Validation |
.github/assets/ contains expected files |
Yes |
| 24 |
Issue/PR Templates |
GitHub templates present and valid |
Yes |
| 25 |
Root File Completeness |
Required .github/ root files exist |
Yes |
| 26 |
alex_docs Freshness |
Documentation not stale beyond threshold |
No |
| 27 |
M365 Heir Validation |
M365 heir structure and version alignment |
No |
| 28 |
Codespaces Heir Validation |
Codespaces devcontainer and config valid |
No |
| 29 |
Global Knowledge Sync |
GK repo index and counts consistent |
No |
| 30 |
Muscles Integrity |
All scripts referenced by trifectas exist |
Yes |
| 31 |
ROADMAP Version Alignment |
ROADMAP versions match package.json |
Yes (config-only) |
Mode Shortcuts
| Mode |
Phases |
Use Case |
all |
1-31 |
Full audit before release |
quick |
1-6 |
Fast validation during development |
sync |
5,7,8,13-15,27,28 |
Master-Heir synchronization check |
schema |
2,6,11,16,17 |
Schema, frontmatter, and format validation |
llm |
10,20,21 |
LLM-first content format validation |
ghfolder |
22-25 |
.github/ subfolder health |
full |
26-31 |
External folders + cross-repo validation |
Known Gaps (Future Phases)
| Phase |
Name |
Validates |
| 22 |
Brain HTML Count Drift |
Hardcoded counts in docs/alex-brain-anatomy.html match actual file counts (skills, instructions, muscles, prompts) |
| 23 |
Motor Cortex Mapping |
Muscle inventory in brain diagrams matches .github/muscles/ |
Context: Session 2026-02-13 discovered stale counts in brain HTML (muscles 13→11, procedures 29→28, skills 100+→116). Diagrams with hardcoded numbers will drift after any architecture change.
Common Issues
| Issue |
Fix |
| Broken synapse target |
Update path in synapses.json |
| Missing inheritance |
Add "inheritance": "inheritable" to synapses.json |
| Out of sync |
Run with -Fix or use build-extension-package.ps1 |
| Boilerplate description |
Write meaningful description in SKILL.md frontmatter |
| Master-only leak |
Remove protected files from heir |
| Missing YAML frontmatter |
Add ---\nname:\ndescription:\n--- to SKILL.md |
| ASCII art warning |
Replace with Mermaid diagrams or tables |
| Missing return-to-Alex |
Add handoff to main Alex agent |
| Brain HTML count drift |
Update hardcoded numbers in docs/alex-brain-anatomy.html |
| Incomplete synapse path |
Use full path: .github/skills/name/SKILL.md not name |
| Missing $schema property |
Add "$schema": "../SYNAPSE-SCHEMA.json" to synapses.json |
| Master-heir ref mismatch |
Remove master-only files (ROADMAP-UNIFIED.md) from heir |
Iterative Validation Workflow
When repairing architecture issues, use this proven pattern:
1. Audit → Run brain-qa phase to identify errors
2. Fix Errors → Address primary issues (paths, references)
3. Re-validate → Run same phase to verify fixes
4. Fix Schema → Address structural issues ($schema, inheritance)
5. Final Check → Run quick mode to verify all phases pass
Example from 2026-02-15 session:
- Phase 1 failed → Fixed incomplete synapse paths → Phase 1 passed
- Phase 6 failed → Added $schema properties → Phase 6 passed
- Phase 7 warned about sync differences → Expected after manual edits, auto-resolves at publish
Key principle: Iterative validation catches cascading errors before they compound. Each phase builds on previous fixes.
Semantic Review Checklist (Manual — Not Scriptable)
After running the script, Alex should check:
Integration
- Dream Protocol: Run brain-qa after dream for deeper analysis
- Release Preflight: Include
-Mode quick in release checks
- LLM Content Audit: Run
-Mode llm when updating diagrams
- Skill Selection Optimization: Brain QA validates SSO data sources
- Semantic Audit: Pair script output with manual checklist above — script validates structure, Alex validates meaning
Triggers
- "brain qa", "brain audit", "validate brain"
- "synapse audit", "deep synapse check"
- "master heir sync", "heir sync validation"
- "catalog validation", "instruction sync"
- "semantic audit", "logic check", "meaning consistency"
- "code-to-docs alignment", "architectural review"
Script: .github/muscles/brain-qa.ps1
1---2name: brain-qa3description: Semantic, logic, code, and architectural validation of Alex's cognitive architecture — not just file counts, but meaning coherence4---5
6# Brain QA
7
8> Semantic, logic, code, and architectural validation of Alex's cognitive architecture — not just file counts, but meaning coherence
9
10## Synapses
11
12*Format: See `SYNAPSE-SCHEMA.md` for notation reference*
13
14- [.github/instructions/semantic-audit.instructions.md] (High, Coordinates, Bidirectional) - "Procedural memory for manual semantic review that complements automated brain-qa"
15- [.github/instructions/cognitive-health-validation.instructions.md] (Critical, Coordinates, Bidirectional) - "Comprehensive brain-qa integration with meditation and release workflows"
16- [.github/skills/master-alex-audit/SKILL.md] (Medium, Related, Bidirectional) - "Full repository audit including brain-qa execution"
17- [.github/instructions/dream-state-automation.instructions.md] (Medium, Complements, Forward) - "Dream validates synapses, brain-qa validates structure"
18- [.github/instructions/release-management.instructions.md] (High, Gates, Forward) - "Pre-release validation requires brain-qa passing"
19
20## Philosophy
21
22Brain QA is a **mental exercise**, not just a muscle exercise. The script validates structure, but the skill's true value is teaching Alex *what to look for* beyond what scripts can automate.
23
24Two scripts serve different contexts:
25
26| Script | Context | Phases | Inheritance |
27|--------|---------|--------|-------------|
28| `brain-qa.ps1` | Master Alex | 31 (full) | master-only |
29| `brain-qa-heir.ps1` | Heir deployments | 23 (heir-relevant) | inheritable |
30
31During sync, `brain-qa-heir.ps1` is **renamed** to `brain-qa.ps1` in the heir, so all contexts use the same filename. The master version includes cross-repo sync phases (5, 7, 8, 13) and master-only validations (26-29) that don't apply to heirs.
32
33| Dimension | Script Catches | Alex Catches (with this skill) |
34|-----------|---------------|-------------------------------|
35| **Structural** | Missing files, broken paths, count mismatches | ✅ Automated |
36| **Semantic** | — | Terminology drift (e.g. "DK files" vs "skills"), meaning contradictions between documents |
37| **Logic** | — | Process descriptions that conflict (e.g. dream says X, meditation says Y), impossible workflows |
38| **Code** | Compile errors, lint | Code behavior diverging from documented claims (e.g. documented trigger not wired in TypeScript) |
39| **Architectural** | — | Working memory model inconsistencies, neuroanatomical mappings that contradict instruction files |
40
41**Rule**: When running brain-qa, always pair the script output with a semantic review. The script is the body; this skill is the brain.
42
43## Quick Start
44
45### Master Context
46```powershell
47# Full 31-phase audit
48.github/muscles/brain-qa.ps1
49
50# Quick validation (phases 1-6)
51.github/muscles/brain-qa.ps1 -Mode quick
52
53# Sync validation only (phases 5,7,8,13,14,15,27,28)
54.github/muscles/brain-qa.ps1 -Mode sync
55
56# Schema/frontmatter validation (phases 2,6,11,16,17)
57.github/muscles/brain-qa.ps1 -Mode schema
58
59# LLM-first content validation (phases 10,20,21)
60.github/muscles/brain-qa.ps1 -Mode llm
61
62# Specific phases
63.github/muscles/brain-qa.ps1 -Phase 1,5,7
64
65# Auto-fix sync issues
66.github/muscles/brain-qa.ps1 -Mode sync -Fix
67```
68
69### Heir Context
70```powershell
71# Full heir audit (23 heir-relevant phases)
72.github/muscles/brain-qa.ps1
73
74# Quick validation (phases 1-4,6)
75.github/muscles/brain-qa.ps1 -Mode quick
76
77# Schema/frontmatter validation (phases 2,6,11,16,17)
78.github/muscles/brain-qa.ps1 -Mode schema
79
80# LLM content validation (phases 10,20,21)
81.github/muscles/brain-qa.ps1 -Mode llm
82
83# Note: -Mode sync is not available in heir (sync phases are master-only)
84```
85
86## When to Use
87
88- Before releases (structural + semantic review)
89- After adding/modifying skills (do new synapses make logical sense?)
90- After bulk synapse updates (are connections semantically meaningful?)
91- When trigger conflicts are suspected (logic: can two triggers fire contradictory protocols?)
92- To verify Master-Heir parity (architectural: does heir behavior match master docs?)
93- To validate LLM-friendly content formats
94- **After any documentation refactor** — check that meaning didn't drift when words changed
95- **When code and docs diverge** — documented feature doesn't match TypeScript implementation
96
97## Audit Phases
98
99| Phase | Name | Validates | Heir? |
100| ------ | ---------------------------- | --------------------------------------------- | ----- |
101| 1 | Synapse Target Validation | All connection targets exist | Yes |
102| 2 | Inheritance Field Validation | All skills have inheritance field | Yes |
103| 3 | Skill Index Coverage | All skills in skill-activation index | Yes |
104| 4 | Trigger Semantic Analysis | Overlapping keywords (warnings OK if related) | Yes |
105| 5 | Master-Heir Skill Sync | Skill directories match | No |
106| 6 | Synapse Schema Format | Numeric strengths, $schema present | Yes |
107| 7 | Synapse File Sync | synapses.json hash match | No |
108| 8 | Skill-Activation Index Sync | SKILL.md hash match | No |
109| 9 | Catalog Accuracy | SKILLS-CATALOG count matches reality | Yes (count-only) |
110| 10 | Core File Token Budget | Size + ASCII art checks on core files | Yes |
111| 11 | Boilerplate Descriptions | No placeholder skill descriptions | Yes |
112| 12 | Heir Reset Validation | Empty profile, available P5-P7 slots | Yes |
113| 13 | Instructions/Prompts Sync | Memory files synced to heir | No |
114| 14 | Agents Structure | Valid agent files in both | Yes |
115| 15 | Config Files | Required configs present, no leaks | Yes |
116| 16 | Skill YAML Frontmatter | name and description in frontmatter | Yes |
117| 17 | Internal Skills Hidden | user-invokable: false for metacognition | Yes |
118| 18 | Agent Handoffs | Return-to-Alex handoffs present | Yes |
119| 19 | ApplyTo Patterns | Instructions have file-type patterns | Yes |
120| 20 | LLM-First Content | No ASCII art, Mermaid OK | Yes |
121| 21 | Emoji Semantics | Meaningful emoji usage stats | Yes |
122| 22 | Episodic Archive Health | .github/episodic/ session records valid | Yes |
123| 23 | Assets Validation | .github/assets/ contains expected files | Yes |
124| 24 | Issue/PR Templates | GitHub templates present and valid | Yes |
125| 25 | Root File Completeness | Required .github/ root files exist | Yes |
126| 26 | alex_docs Freshness | Documentation not stale beyond threshold | No |
127| 27 | M365 Heir Validation | M365 heir structure and version alignment | No |
128| 28 | Codespaces Heir Validation | Codespaces devcontainer and config valid | No |
129| 29 | Global Knowledge Sync | GK repo index and counts consistent | No |
130| 30 | Muscles Integrity | All scripts referenced by trifectas exist | Yes |
131| 31 | ROADMAP Version Alignment | ROADMAP versions match package.json | Yes (config-only) |
132
133## Mode Shortcuts
134
135| Mode | Phases | Use Case |
136| -------- | ------------------- | ------------------------------------------ |
137| `all` | 1-31 | Full audit before release |
138| `quick` | 1-6 | Fast validation during development |
139| `sync` | 5,7,8,13-15,27,28 | Master-Heir synchronization check |
140| `schema` | 2,6,11,16,17 | Schema, frontmatter, and format validation |
141| `llm` | 10,20,21 | LLM-first content format validation |
142| `ghfolder`| 22-25 | .github/ subfolder health |
143| `full` | 26-31 | External folders + cross-repo validation |
144
145## Known Gaps (Future Phases)
146
147| Phase | Name | Validates |
148| ----- | ---------------------- | -------------------------------------------------------------------------------------------------------------------- |
149| 22 | Brain HTML Count Drift | Hardcoded counts in `docs/alex-brain-anatomy.html` match actual file counts (skills, instructions, muscles, prompts) |
150| 23 | Motor Cortex Mapping | Muscle inventory in brain diagrams matches `.github/muscles/` |
151
152> **Context**: Session 2026-02-13 discovered stale counts in brain HTML (muscles 13→11, procedures 29→28, skills 100+→116). Diagrams with hardcoded numbers will drift after any architecture change.
153
154## Common Issues
155
156| Issue | Fix |
157| ------------------------ | ---------------------------------------------------------- |
158| Broken synapse target | Update path in synapses.json |
159| Missing inheritance | Add `"inheritance": "inheritable"` to synapses.json |
160| Out of sync | Run with `-Fix` or use `build-extension-package.ps1` |
161| Boilerplate description | Write meaningful description in SKILL.md frontmatter |
162| Master-only leak | Remove protected files from heir |
163| Missing YAML frontmatter | Add `---\nname:\ndescription:\n---` to SKILL.md |
164| ASCII art warning | Replace with Mermaid diagrams or tables |
165| Missing return-to-Alex | Add handoff to main Alex agent |
166| Brain HTML count drift | Update hardcoded numbers in `docs/alex-brain-anatomy.html` |
167| Incomplete synapse path | Use full path: `.github/skills/name/SKILL.md` not `name` |
168| Missing $schema property | Add `"$schema": "../SYNAPSE-SCHEMA.json"` to synapses.json |
169| Master-heir ref mismatch | Remove master-only files (ROADMAP-UNIFIED.md) from heir |
170
171## Iterative Validation Workflow
172
173When repairing architecture issues, use this proven pattern:
174
175```
1761. Audit → Run brain-qa phase to identify errors
1772. Fix Errors → Address primary issues (paths, references)
1783. Re-validate → Run same phase to verify fixes
1794. Fix Schema → Address structural issues ($schema, inheritance)
1805. Final Check → Run quick mode to verify all phases pass
181```
182
183**Example from 2026-02-15 session:**
184- Phase 1 failed → Fixed incomplete synapse paths → Phase 1 passed
185- Phase 6 failed → Added $schema properties → Phase 6 passed
186- Phase 7 warned about sync differences → Expected after manual edits, auto-resolves at publish
187
188**Key principle:** Iterative validation catches cascading errors before they compound. Each phase builds on previous fixes.
189
190## Semantic Review Checklist (Manual — Not Scriptable)
191
192After running the script, Alex should check:
193
194- [ ] **Cross-document meaning**: Do copilot-instructions, alex-core, and protocol-triggers describe the same processes consistently?
195- [ ] **Working memory model**: Does the 4+3 slot claim match the actual P1-P7 table? Are sub-slots (P4a-d) accounted for?
196- [ ] **Legacy terminology**: Any surviving references to deprecated concepts (DK files, domain-knowledge folders)?
197- [ ] **Trigger-to-code alignment**: Do synapse trigger keywords in .md files match actual activation paths in TypeScript?
198- [ ] **Heir evolution logic**: Does the documented 4-step heir cycle match what heir-skill-promotion.instructions.md actually describes?
199- [ ] **Version source of truth**: Is `package.json` the single source, or are versions hardcoded in prose that will drift?
200- [ ] **Neuroanatomical consistency**: Do brain-analog mappings in copilot-instructions match descriptions in alex-core?
201
202## Integration
203
204- **Dream Protocol**: Run brain-qa after dream for deeper analysis
205- **Release Preflight**: Include `-Mode quick` in release checks
206- **LLM Content Audit**: Run `-Mode llm` when updating diagrams
207- **Skill Selection Optimization**: Brain QA validates SSO data sources
208- **Semantic Audit**: Pair script output with manual checklist above — script validates structure, Alex validates meaning
209
210## Triggers
211
212- "brain qa", "brain audit", "validate brain"
213- "synapse audit", "deep synapse check"
214- "master heir sync", "heir sync validation"
215- "catalog validation", "instruction sync"
216- "semantic audit", "logic check", "meaning consistency"
217- "code-to-docs alignment", "architectural review"
218
219---
220
221_Script: `.github/muscles/brain-qa.ps1`_