| name | kb-reingest |
| description | Re-process an already-ingested source when its content has been updated. Finds and updates all downstream wiki pages. Use when the user wants to reingest, reprocess, refresh, or update a source. Also triggers on "kb-reingest" or "/kb-reingest". |
kb-reingest
Re-process a previously ingested raw source when its content has changed. Finds all downstream wiki pages linked to that source and updates them.
Arguments
<raw-file> — Path to the raw source file (relative to KB root, e.g., raw/some-source.md).
--force — Override human_reviewed: true protection (use with extreme caution).
Step 1: Resolve KB
python3 ~/.config/kb/scripts/kb_resolve.py --mode mutating
Capture the KB root path. Abort if resolution fails.
Step 2: Validate Source
- Confirm the raw source file exists at
{{KB_ROOT}}/{{RAW_FILE}}.
- If it does not exist, list available raw sources and let the user pick.
Step 3: Find Downstream Pages
Search all wiki pages for those whose source_ids frontmatter includes the target raw file:
python3 ~/.config/kb/scripts/kb_find_related.py "{{KB_ROOT}}" --source "{{RAW_FILE}}"
Also scan wiki pages by reading frontmatter and checking source_ids arrays. Collect the full list of downstream pages (summaries, entities, concepts, synthesis).
Step 4: Classify Downstream Pages
Separate downstream pages into three groups:
- Updatable —
human_reviewed: false pages that can be auto-updated.
- Protected —
human_reviewed: true pages. Warn the user these will be skipped unless --force is passed.
- Deprecated — Pages in
wiki/deprecated/ referencing this source (note but do not process).
Step 5: Re-read and Diff Source
- Read the current content of the raw source file.
- For each updatable downstream page, read its current content.
- Compare against the content reflected in downstream wiki pages.
- Identify:
- New information not yet captured.
- Changed claims or data.
- Removed or retracted content.
Step 6: Update Downstream Pages
For each updatable downstream page:
- Preserve the existing frontmatter structure.
- Update the page body with new/changed information from the source.
- Merge new content — never remove existing content from other sources.
- If the page has multiple
source_ids, only update the sections derived from this source.
- Update frontmatter:
last_verified: set to today's date.
confidence: adjust if warranted (increase for corroboration, decrease for retraction).
contradictions: update if the re-read reveals new or resolved contradictions.
- Preserve all existing
[[wikilinks]] and add new ones as needed.
For protected pages (human_reviewed: true):
- Default behavior: Skip the page. Print a warning:
"SKIPPED: wiki/entities/foo.md — human_reviewed is true. Use --force to override."
- With
--force: Update the page but preserve human_reviewed: true in frontmatter. Log that it was force-updated.
Step 7: Deprecate Invalidated Pages
If the updated source no longer supports a wiki page that was solely derived from it (single source_ids entry):
- Check if it has other
source_ids still supporting it. If yes, remove this source from the list but keep the page.
- If this was the only source and
human_reviewed: false:
- Move the page to
wiki/deprecated/.
- Add a tombstone header:
<!-- DEPRECATED: {{DATE}} — Source {{RAW_FILE}} no longer supports this page -->
- Update any inbound
[[wikilinks]] across the wiki to note the deprecation.
- If
human_reviewed: true, skip with a warning.
Step 8: Preserve Contradictions Record
If any downstream page had contradictions entries before reingest, preserve them unless the contradiction is explicitly resolved by the updated source content. Do not silently drop contradiction references.
Step 9: Regenerate Index
python3 ~/.config/kb/scripts/kb_index.py "{{KB_ROOT}}"
Step 10: Append Log
Add a row to log.md:
| {{DATE}} | reingest | Re-ingested {{RAW_FILE}} → {{N}} pages updated, {{M}} deprecated, {{S}} skipped (human_reviewed) |
Final Output
Print:
- Source file path
- Pages updated (list with paths and what changed)
- Pages deprecated (list)
- Pages skipped due to human_reviewed (list)
- Contradictions preserved or resolved