AgentSkillsCN

Brain QA

对 Alex 的认知架构进行语义、逻辑、代码与架构层面的全面验证——不仅关注文件数量,更注重意义的连贯性。

SKILL.md
--- frontmatter
name: "Brain QA"
description: "Semantic, logic, code, and architectural validation of Alex's cognitive architecture — not just file counts, but meaning coherence"
applyTo: "**/*synapse*,**/*skill*,**/*trigger*"

Brain QA

Semantic, logic, code, and architectural validation of Alex's cognitive architecture — not just file counts, but meaning coherence

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:

ScriptContextPhasesInheritance
brain-qa.ps1Master Alex31 (full)master-only
brain-qa-heir.ps1Heir deployments23 (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.

DimensionScript CatchesAlex Catches (with this skill)
StructuralMissing files, broken paths, count mismatches✅ Automated
SemanticTerminology drift (e.g. "DK files" vs "skills"), meaning contradictions between documents
LogicProcess descriptions that conflict (e.g. dream says X, meditation says Y), impossible workflows
CodeCompile errors, lintCode behavior diverging from documented claims (e.g. documented trigger not wired in TypeScript)
ArchitecturalWorking 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

powershell
# 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

powershell
# 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

PhaseNameValidatesHeir?
1Synapse Target ValidationAll connection targets existYes
2Inheritance Field ValidationAll skills have inheritance fieldYes
3Skill Index CoverageAll skills in skill-activation indexYes
4Trigger Semantic AnalysisOverlapping keywords (warnings OK if related)Yes
5Master-Heir Skill SyncSkill directories matchNo
6Synapse Schema FormatNumeric strengths, $schema presentYes
7Synapse File Syncsynapses.json hash matchNo
8Skill-Activation Index SyncSKILL.md hash matchNo
9Catalog AccuracySKILLS-CATALOG count matches realityYes (count-only)
10Core File Token BudgetSize + ASCII art checks on core filesYes
11Boilerplate DescriptionsNo placeholder skill descriptionsYes
12Heir Reset ValidationEmpty profile, available P5-P7 slotsYes
13Instructions/Prompts SyncMemory files synced to heirNo
14Agents StructureValid agent files in bothYes
15Config FilesRequired configs present, no leaksYes
16Skill YAML Frontmattername and description in frontmatterYes
17Internal Skills Hiddenuser-invokable: false for metacognitionYes
18Agent HandoffsReturn-to-Alex handoffs presentYes
19ApplyTo PatternsInstructions have file-type patternsYes
20LLM-First ContentNo ASCII art, Mermaid OKYes
21Emoji SemanticsMeaningful emoji usage statsYes
22Episodic Archive Health.github/episodic/ session records validYes
23Assets Validation.github/assets/ contains expected filesYes
24Issue/PR TemplatesGitHub templates present and validYes
25Root File CompletenessRequired .github/ root files existYes
26alex_docs FreshnessDocumentation not stale beyond thresholdNo
27M365 Heir ValidationM365 heir structure and version alignmentNo
28Codespaces Heir ValidationCodespaces devcontainer and config validNo
29Global Knowledge SyncGK repo index and counts consistentNo
30Muscles IntegrityAll scripts referenced by trifectas existYes
31ROADMAP Version AlignmentROADMAP versions match package.jsonYes (config-only)

Mode Shortcuts

ModePhasesUse Case
all1-31Full audit before release
quick1-6Fast validation during development
sync5,7,8,13-15,27,28Master-Heir synchronization check
schema2,6,11,16,17Schema, frontmatter, and format validation
llm10,20,21LLM-first content format validation
ghfolder22-25.github/ subfolder health
full26-31External folders + cross-repo validation

Known Gaps (Future Phases)

PhaseNameValidates
22Brain HTML Count DriftHardcoded counts in docs/alex-brain-anatomy.html match actual file counts (skills, instructions, muscles, prompts)
23Motor Cortex MappingMuscle 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

IssueFix
Broken synapse targetUpdate path in synapses.json
Missing inheritanceAdd "inheritance": "inheritable" to synapses.json
Out of syncRun with -Fix or use build-extension-package.ps1
Boilerplate descriptionWrite meaningful description in SKILL.md frontmatter
Master-only leakRemove protected files from heir
Missing YAML frontmatterAdd ---\nname:\ndescription:\n--- to SKILL.md
ASCII art warningReplace with Mermaid diagrams or tables
Missing return-to-AlexAdd handoff to main Alex agent
Brain HTML count driftUpdate hardcoded numbers in docs/alex-brain-anatomy.html
Incomplete synapse pathUse full path: .github/skills/name/SKILL.md not name
Missing $schema propertyAdd "$schema": "../SYNAPSE-SCHEMA.json" to synapses.json
Master-heir ref mismatchRemove master-only files (ROADMAP-UNIFIED.md) from heir

Iterative Validation Workflow

When repairing architecture issues, use this proven pattern:

code
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:

  • Cross-document meaning: Do copilot-instructions, alex-core, and protocol-triggers describe the same processes consistently?
  • Working memory model: Does the 4+3 slot claim match the actual P1-P7 table? Are sub-slots (P4a-d) accounted for?
  • Legacy terminology: Any surviving references to deprecated concepts (DK files, domain-knowledge folders)?
  • Trigger-to-code alignment: Do synapse trigger keywords in .md files match actual activation paths in TypeScript?
  • Heir evolution logic: Does the documented 4-step heir cycle match what heir-skill-promotion.instructions.md actually describes?
  • Version source of truth: Is package.json the single source, or are versions hardcoded in prose that will drift?
  • Neuroanatomical consistency: Do brain-analog mappings in copilot-instructions match descriptions in alex-core?

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