Skip to main content

Module bootstrap

Module bootstrap 

Source
Expand description

Knowledge-graph bootstrap helpers.

Why: Issue #60 — after palace_create, the knowledge graph (KG) sits at zero triples and there is no auto-discovery path. Users have no idea they’re supposed to call kg_assert manually before kg_query returns anything useful. kg_bootstrap closes this gap by scanning well-known project files (Cargo.toml, package.json, pyproject.toml, CLAUDE.md, .git/config, go.mod) and seeding structured triples that describe the project (language, version, source repo, etc.). It also seeds temporal metadata (created_at, bootstrapped_at) so even an empty project at least has something in the KG and a timestamp anchor for future queries. What: A pure-blocking scanner (scan_project) returns a flat list of (subject, predicate, object, provenance) tuples; the public async entry point bootstrap_palace resolves a palace handle, runs the scanner, and asserts each tuple through the existing KnowledgeGraph::assert path. Test: Unit tests pin each scanner against fixture directories; kg_bootstrap is exercised end-to-end from the MCP tool surface in tools.rs.

Design notes:

  • Missing files are NOT errors — every read is best-effort. The scanner returns whatever triples it could derive and skips the rest with a debug-level log.
  • All extracted facts use the user-supplied (or inferred) project name as the triple subject. When no project name can be derived from manifests, the palace ID is used as a fallback so the temporal triples still anchor to a stable subject.
  • Provenance strings are stable identifiers (bootstrap:cargo.toml, bootstrap:package.json, …) so operators can audit which scanner asserted each triple and retract by source if needed.

Structs§

BootstrapResult
Aggregate result of a bootstrap run.
BootstrapTriple
A single bootstrap discovery before it becomes a Triple.
ScannedFile
Per-file scan summary returned to the MCP caller.

Constants§

KG_EMPTY_HINT
Hint string returned by kg_query when the palace KG is empty.

Functions§

bootstrap_palace
Run the bootstrap scan against a palace.
is_kg_empty_for_subject
Convenience: count active triples across an entire palace.
result_to_json
Helper: bubble up the bootstrap result as the MCP JSON envelope expects.
scan_project
Blocking scanner: walk well-known files under root and extract triples.