memory-alignment-check

$npx mdskill add Fr-e-d/GAAI-framework/memory-alignment-check

Extract implementation footprint from report

  • Identify changes in the codebase since last delivery.
  • Retrieve relevant details about implemented features and logic.
  • Compile a concise summary of the differences between current and previous implementations.
  • Prepare data for comparison with long-term memory entries.

SKILL.md

.github/skills/memory-alignment-checkView on GitHub ↗
---
name: memory-alignment-check
description: After QA PASS, compare the Story's implementation footprint against relevant memory entries. Reports confirmed entries, contradictions, and new knowledge candidates. Never writes to memory — produces a delta report for Discovery to action.
license: ELv2
compatibility: Works with any filesystem-based AI coding agent
metadata:
  author: gaai-framework
  version: "1.0"
  category: cross
  track: cross-cutting
  id: SKILL-MEMORY-ALIGNMENT-CHECK-001
  updated_at: 2026-02-26
  status: stable
inputs:
  - contexts/artefacts/impl-reports/{id}.impl-report.md
  - contexts/artefacts/stories/{id}.story.md
  - contexts/memory/index.md
  - [selective memory entries by scope tags]
outputs:
  - contexts/artefacts/memory-deltas/{id}.memory-delta.md
---

# Memory Alignment Check

## Purpose / When to Activate

Activate after QA verdict is PASS — never before (avoids analysis on code that will change).

This skill checks that long-term memory (decisions, patterns, project context) remains accurate after a Story is delivered. It compares only the Story's implementation footprint against relevant memory entries — not the full codebase.

The codebase is the source of truth for implementation.
Memory is the source of truth for decisions and patterns.
This skill checks that both remain consistent after each delivery.

**This skill reports. It never writes to memory.**

---

## Process

### 1. Extract Implementation Footprint

From `{id}.impl-report.md`:
- Files modified or created
- New modules or services introduced
- Patterns applied during implementation
- Technical decisions made during implementation
- New integrations or external dependencies introduced

### 2. Retrieve Relevant Memory (Selective)

Using `contexts/memory/index.md`:
- Identify memory entries whose tags intersect the Story's scope and touched modules
- Load only those entries — do not load all memory
- Scope: project context, patterns, decisions relevant to the implementation footprint

### 3. Compare Footprint Against Memory

For each relevant memory entry, assign one verdict:

- **CONFIRMED** — implementation is consistent with what memory states
  → Record entry ID, suggest `last_verified_at` update to today, `verified_against_story` to Story ID

- **CONTRADICTED** — implementation contradicts or obsoletes what memory states
  → Record exact contradiction, affected memory entry ID, severity (high / medium / low)

- **UNADDRESSED** — memory entry is not touched by this Story
  → Skip — no verdict needed

### 4. Identify New Knowledge Not Yet in Memory

From the implementation footprint, extract candidates not present in memory:
- New patterns introduced not in `contexts/memory/patterns/`
- New architectural or technical decisions not in `contexts/memory/decisions/`
- New constraints or conventions applied for the first time

These are **ingestion candidates** — flagged for Discovery to validate and ingest.

---

## Outputs

Written to: `contexts/artefacts/memory-deltas/{id}.memory-delta.md`

```yaml
---
artefact_type: memory-delta
skill: memory-alignment-check
story_id: E01S01
generated_at: YYYY-MM-DD
verdict: ALIGNED | DRIFT_DETECTED | NEW_KNOWLEDGE_FOUND | DRIFT_AND_NEW_KNOWLEDGE
---

## Confirmed Entries

- memory_id: PATTERNS-001
  status: CONFIRMED
  suggested_last_verified_at: YYYY-MM-DD
  suggested_verified_against_story: E01S01
  note: Implementation of X is consistent with stated convention.

## Contradicted Entries

- memory_id: DEC-{N}
  status: CONTRADICTED
  severity: high | medium | low
  description: Memory states [X]. Implementation did [Y]. These are incompatible.
  action_required: Update or invalidate memory entry.

## New Knowledge Candidates

- candidate_id: CANDIDATE-001
  category: architecture | decisions | patterns | project | strategy | domains
  description: New retry pattern introduced in services/api/client.ts — not yet in memory.
  suggested_tags: [api, resilience, patterns]
  ingestion_priority: high | medium | low
```
Downstream consumer: `memory-delta-triage` (`.gaai/core/skills/cross/memory-delta-triage/SKILL.md`) processes these delta files to produce a governed triage verdict before Discovery invokes `memory-ingest`.

---

## Verdict Logic

| Verdict | Condition |
|---|---|
| `ALIGNED` | No contradictions, no new knowledge candidates |
| `DRIFT_DETECTED` | One or more memory entries contradicted by the implementation |
| `NEW_KNOWLEDGE_FOUND` | New knowledge candidates identified, no contradictions |
| `DRIFT_AND_NEW_KNOWLEDGE` | Both contradictions and new knowledge candidates present |

---

## Quality Checks

- Only memory entries intersecting the Story scope are loaded — never full memory
- Confirmed entries include specific evidence from impl-report (not assertions)
- Contradictions describe the exact mismatch — no vague statements
- New knowledge candidates are concrete and grounded in impl-report — not speculative
- No memory is written — this skill produces a report only

---

## Non-Goals

This skill must NOT:
- Write or update any memory file
- Trigger `memory-ingest` directly (only Discovery may do so)
- Scan the full codebase
- Analyse code outside the Story's implementation footprint
- Make product or architectural decisions
- Block or modify the QA verdict

---

## Closed Grandfather List (one-time legacy exemption)

The CI validator (`validate-memory-deltas.sh`, `LEGACY_GRANDFATHERED` array) exempts exactly 21 pre-canonical-schema delta files from the canonical-section-header check. These files predate the three canonical headers and use heterogeneous legacy formats with no single rename rule.

**Policy (non-negotiable):**
- The allowlist **MUST NOT grow** — every new delta produced by this skill MUST include at least one canonical section header (`## Confirmed Entries`, `## Contradicted Entries`, `## New Knowledge Candidates`).
- Allowlist entries **MAY be removed** after the corresponding delta file is triaged by Discovery and moved to `processed/` (which the validator already excludes).

*Authority: see project audit-intake for the originating finding and grandfathered basenames.*

More from Fr-e-d/GAAI-framework

SkillDescription
abort-safe-handlerOrchestrator-level Stage 4 entry gate for /gaai:bootstrap. Presents a pre-loop "Skip Q&A entirely" option, delegates to qa-loop-ui when the user proceeds, and returns a unified abort_safe_result with telemetry on every path. Guarantees no partial state on skip or abort.
ambiguity-detectorTakes surface scan results, optional LLM synthesis open-question entries, and optional tree-sitter AST signals to score project ambiguities (1-10). Outputs structured ambiguity_feed for smart-question-generator. Pure heuristic — no LLM calls. Designed for Stage 3.5 of the /gaai:bootstrap pipeline (between LLM synthesis and Q&A).
approach-evaluationResearch industry standards and best practices, identify viable approaches for a given technical or architectural problem, and produce a structured factual comparison against project-specific constraints. Reports options — does not decide.
architecture-extractConvert raw project structure into clear architectural understanding — module boundaries, data flows, service relationships, and architectural patterns. Activate after codebase-scan during Bootstrap.
bootstrap-llm-synthesisConstruct the LLM synthesis prompt from project surface scan + optional tree-sitter context + optional Q&A answers. Call the LLM. Parse and validate the response into 6-8 structured memory entries with clarity tags and source traceability. Used as Stage 3 of the /gaai:bootstrap pipeline.
bootstrap-memory-ingest-cloudWrite structured memory entries to the Cloud workspace via gaai_memory.store MCP tool with source='bootstrap'. Loops over entries from bootstrap-llm-synthesis, calls the tool per entry, collects success/fail counts. Used as Stage 5 of the /gaai:bootstrap pipeline (Cloud path only).
browser-journey-testValidate user stories by simulating real user journeys in a live browser against deployed application. Activate after implementation to verify actual user experience against acceptance criteria, not just code logic.
build-agents-indexScan all agent and sub-agent definition files in .gaai/core/agents/, extract YAML frontmatter, merge with specialists.registry.yaml, and generate a derived agents-index.yaml at .gaai/core/agents/agents-index.yaml. Activate after adding, modifying, or removing any agent, sub-agent, or specialist entry.
build-skills-indexScan SKILL.md files in .gaai/core/skills/ and .gaai/project/skills/, extract YAML frontmatter, and regenerate separate skills indices for each layer. Core index ships with the OSS framework; project index is project-specific.
ci-watch-and-fixWatch GitHub Actions CI after PR creation, detect failures, extract logs, apply minimal fixes, and re-push — keeping the delivery session alive until CI resolves or escalating after 3 cycles. Activate immediately after gh pr create and before marking the story done.