Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

docs(lessons): align prune trigger sets and failure semantics between the SKILL and hook (#753)

06FallingLight906a3f15d514d5
diff --git a/understand-anything-plugin/hooks/auto-update-prompt.md b/understand-anything-plugin/hooks/auto-update-prompt.md
index 6ae23d81..b4bcd342 100644
--- a/understand-anything-plugin/hooks/auto-update-prompt.md
+++ b/understand-anything-plugin/hooks/auto-update-prompt.md
@@ -102,13 +102,13 @@ node "$PLUGIN_ROOT/skills/understand/finalize-incremental.mjs" "$PROJECT_ROOT"
The finalizer performs deterministic graph/layer/tour validation and independently reruns the shared symbol check on the exact graph before writing. It atomically saves `knowledge-graph.json`, patches changed fingerprints while preserving untouched entries, removes deleted fingerprints, and only then writes `meta.json`. A graph-save failure must never advance the fingerprint or commit baseline. If symbol loss is first detected here, follow the same one-retry procedure, rerun merge and any required architecture/tour phases, then finalize; an already-used or unsuccessful repair must stop with the old graph and baselines intact.
-After the finalizer exits successfully, publish lessons with the same rules as **Lesson publication** in SKILL.md's incremental save gate — only lessons staged by the current invocation: atomically move `$UA_DIR/intermediate/code-lessons.normalized.json` over `$UA_DIR/code-lessons.json` when this run staged it; when lessons were attempted but skipped or failed, delete a served `$UA_DIR/code-lessons.json` instead; when the finalizer failed, touch nothing so the previous graph and lessons stay consistent. `PARTIAL_UPDATE` never attempts lessons, but it can still delete or newly ignore files from the graph while their source-derived lessons survive — so for every action except `SKIP` (and `PARTIAL_UPDATE` in particular), after the finalizer succeeds and the publication rules above have been applied, run:
+After the finalizer exits successfully, publish lessons with the same rules as **Lesson publication** in SKILL.md's incremental save gate — only lessons staged by the current invocation: atomically move `$UA_DIR/intermediate/code-lessons.normalized.json` over `$UA_DIR/code-lessons.json` when this run staged it; when lessons were attempted but skipped or failed, delete a served `$UA_DIR/code-lessons.json` instead; when the finalizer failed, touch nothing so the previous graph and lessons stay consistent. `PARTIAL_UPDATE` never attempts lessons, but incremental updates can still delete or newly ignore files from the graph while their source-derived lessons survive — so for every action except `SKIP` (and `PARTIAL_UPDATE` in particular), after the finalizer succeeds and the publication rules above have been applied, run:
```bash
node "$PLUGIN_ROOT/skills/understand/prune-code-lessons.mjs" "$PROJECT_ROOT"
```
-The helper removes only entries whose file path has no node in the saved graph and leaves every surviving lesson byte-identical.
+The helper removes only entries whose file path has no node in the saved graph and leaves every surviving lesson's content untouched (the file is rewritten as normalized 2-space JSON). If the prune itself fails, report the warning and continue — the saved graph is already final and the idempotent helper can prune the orphans again on the next run; never roll the graph back for it.
Report:
diff --git a/understand-anything-plugin/skills/understand/SKILL.md b/understand-anything-plugin/skills/understand/SKILL.md
index 5a30c333..97fe019c 100644
--- a/understand-anything-plugin/skills/understand/SKILL.md
+++ b/understand-anything-plugin/skills/understand/SKILL.md
@@ -627,13 +627,13 @@ Required fields: `order`, `title`, `description`, `nodeIds`. Preserve optional `
### Code Lessons — per-file learning explanations
-Run this step whenever the tour is (re)built — full analysis and incremental plans with `rerunTour === true`. For `PARTIAL_UPDATE`, keep the existing `$UA_DIR/code-lessons.json` untouched (line ranges may drift slightly; the next `rerunTour` rebuild refreshes them) — but once the incremental save gate finalizes successfully, prune entries for files the saved graph no longer contains:
+Run this step whenever the tour is (re)built — full analysis and incremental plans with `rerunTour === true`. For `PARTIAL_UPDATE`, keep the existing `$UA_DIR/code-lessons.json` untouched (line ranges may drift slightly; the next `rerunTour` rebuild refreshes them). After ANY successful incremental save (every action except `SKIP` — `PARTIAL_UPDATE` in particular), prune entries for files the saved graph no longer contains:
```bash
node "<SKILL_DIR>/prune-code-lessons.mjs" "$PROJECT_ROOT"
```
-The helper removes only orphaned entries (paths with no node in the saved graph) and leaves every surviving lesson byte-identical. A `PARTIAL_UPDATE` can delete or newly ignore files while their source-derived lessons survive, and the viewer would keep serving lessons the graph no longer knows about.
+The helper removes only orphaned entries (paths with no node in the saved graph) and leaves every surviving lesson's content untouched (the file is rewritten as normalized 2-space JSON). Incremental updates can delete or newly ignore files while their source-derived lessons survive, and the viewer would keep serving lessons the graph no longer knows about. If the prune itself fails, record the failure in `$PHASE_WARNINGS` and continue — the saved graph is already final, orphaned entries are a soft inconsistency the next run can prune again (the helper is idempotent); never roll the graph back for it.
Report to the user: `[Phase 5/7] Writing code lessons...`
@@ -718,7 +718,7 @@ Assemble the full KnowledgeGraph JSON object:
"nodes": [<all nodes from assembled-graph.json after Phase 3 review>],
"edges": [<all edges from assembled-graph.json after Phase 3 review>],
"layers": [<layers from Phase 4>],
- "tour": [<steps from `$UA_DIR/intermediate/tour.normalized.json` (Phase 5)>]
+ "tour": [<steps from `$UA_DIR/intermediate/tour.normalized.json` (Phase 5 — full runs; incremental `--review` reruns skip this assembly and keep the tour embedded in the graph the save gate copied)>]
}
```