Keep Knowledge Graph synchronized with live repo state. Scan code (AST), scan experiments (DuckDB), propagate belief changes, detect staleness, generate downstream artifacts, export to sci-llm-writer.
A reproducible Skill for keeping the Knowledge Graph synchronized with the live repo state and exporting a snapshot to sci-llm-writer for manuscript generation.
This skill operates at Layer 3 (Evidence) and generates Layer 5 artifacts.
See docs/planning/prd-kg-openspec-architecture.md for the full architecture.
scripts/check_projection_staleness.py reports stale downstream files/kg-sync or /kg-sync --export-to sci-llm-writerThis Skill is designed for any repo following the pattern:
knowledge-graph/
code-structure/ ← from AST (any Python repo)
experiments/ ← from experiment tracker (MLflow, W&B, etc.)
manuscript/ ← from human narrative + projections.yaml
Future repos (foundation-PLR, any research repo) can use the same Skill with their own scanner + experiment tracker.
1. SCAN-CODE → ast.parse() scan of src/ → code-structure/*.yaml
2. SCAN-EXP → DuckDB query over mlruns/ → experiments/*.yaml
2b. PROPAGATE → Check _network.yaml propagation: for modified nodes → requires_review flags
3. STAMP → Write _generated_at.yaml (git commit hash + timestamp)
4. STALENESS → check_projection_staleness.py → stale file report
5. GENERATE → Render stale projections via Jinja2 templates/*.j2 → .tex files
6. VALIDATE → (a) Schema check (b) Idempotency (c) pdflatex compile
7. EXPORT → If --export-to: atomic copy to sci-llm-writer kg-snapshot/
uv run python scripts/scan_code_structure.py \
--source-dir src/minivess/ \
--output-dir knowledge-graph/code-structure/
What it does:
ast.parse() all .py files in src/minivess/ (CLAUDE.md Rule #16 — no regex)flows.yaml, adapters.yaml, config-schema.yaml, test-coverage.yamluv run python scripts/scan_experiments.py \
--mlruns-dir mlruns/ \
--output-dir knowledge-graph/experiments/
What it does:
current_best.yaml{status: "PENDING", reason: "GPU runs not complete"}knowledge-graph/_network.yaml propagation: section_generated_at.yaml commit hash):
requires_review: true + review_reason: "parent changed: <id>"scripts/review_prd_integrity.py to validate _network.yaml consistencyWrites knowledge-graph/code-structure/_generated_at.yaml and knowledge-graph/experiments/_generated_at.yaml:
generated_at: "2026-03-15T10:00:00Z"
git_commit: "<sha>"
git_dirty: false