KeiSeiKit-1.0/_primitives/_rust
Parfii-bot a31a056f61 feat(graph): live runtime DNA viewer — kei-graph-export + lbm-graph-viz adapter
User pushback: "можно нашего Кейси подключить к обсидиан? будет в
онлайне строить граф из всех наших агентов?"

Closer-to-question architecture: don't build new Obsidian plugin —
re-use the legacy `~/Projects/lbm-graph-viz/` D3 viewer (lineage:
keicode → living-graph → lbm → lbm-graph-viz → keisei-graph). Strip
its Hebbian/co-change edges, replace with DNA-derived edges from the
kei-registry + kei-ledger. Open in any browser, file://...index.html.

NEW Rust crate `_primitives/_rust/kei-graph-export/` (~440 LOC, 5 files)

Reads:
  ~/.claude/registry.sqlite       (730 active blocks)
  ~/.claude/agents/ledger.sqlite  (6 agents post-cleanup)
  _manifests/*.toml               (38 agent manifests)

Emits 581-node, 291-edge graph. Edge types:
  block_dep        171  manifest → atom (blocks=[])
  path_ref          99  manifest → atom (path:NAME refs)
  branch_lineage    11  parent_branch → branch
  agent_uses_manifest 10  agent → manifest (slug from branch name)

Output formats:
  --format spaces-fragment  →  `window.RUNTIME_SPACE = {...}` JS file
  --format json             →  raw {nodes, links} for downstream tools

Block-name lookup is multi-resolution: each block is registered under
display name + lowercased + file-stem slug (from path basename) so
manifest references like `blocks = ["baseline"]` resolve to a registry
row whose `name` column holds "BASELINE — inherit from Main Claude".
Without this fix the graph had 0 block_dep edges; with it, 171.

NEW background updater `hooks/graph-export-watcher.sh` + launchd plist
template `_primitives/templates/io.keisei.graph-export.plist`

5-second loop:
  while true; do
      kei-graph-export --format spaces-fragment --output <viz>/data-runtime.js.tmp
      mv <viz>/data-runtime.js.tmp <viz>/data-runtime.js  # atomic
      sleep 5
  done

launchd plist substitutes `HOME_DIR` and `HOOKS_DIR` placeholders at
install time. RunAtLoad=true, KeepAlive=true. Logs to
~/.claude/memory/graph-export.log. Bypass: GRAPH_EXPORT_BYPASS=1.

Loaded into user-side launchd (PID 16474 confirmed running). File
mtime advances every 5s — live updates verified.

PATCH `~/Projects/lbm-graph-viz/index.html` (outside kit, surgical)

Three changes:
  1. Add `<script src="data-runtime.js">` BEFORE `spaces.js` (window
     global available when SPACES is defined).
  2. After spaces.js: `if (window.RUNTIME_SPACE) SPACES.runtime = window.RUNTIME_SPACE;`
  3. Auto-refresh setInterval(5s): fetch data-runtime.js, eval (re-
     assigns window.RUNTIME_SPACE), hash-compare, re-render via
     `rebuildGraph()` if currently viewing the runtime space.

window.RUNTIME_SPACE (not const RUNTIME_SPACE) avoids the
"const cannot be re-declared" error on subsequent eval() calls.

Effect: open file://~/Projects/lbm-graph-viz/index.html in any
browser, switch to "Runtime" space — full DNA graph of every agent /
atom / skill / branch / manifest / hook / primitive / rule, force-
laid-out by D3. Updates every 5 seconds without page reload.

What this does NOT do (deferred):
  - Obsidian mirror — separate work, would emit .md per node into
    ~/Projects/KeiSeiVault/. Useful for backlinks navigation but
    file-watcher latency similar to current 5s polling.
  - Skill-invocation edges — table is empty until next Skill tool
    use; will populate naturally.
  - Scoped queries (orphan finder, hot-path PageRank). Out of scope
    for v1; the JSON --format export feeds any downstream tool.
  - `agent_uses_manifest` heuristic warns on unknown subagent slugs
    (e.g. `physics-deriver` with no manifest yet). Non-fatal.

=== STATUS-TRUTH MARKER ===
shipped: functional
stubs: 0
cargo-check: PASS
behaviour-verified: yes
follow-up-required:
  - Obsidian vault mirror (Phase C, separate work)
  - Skill-edges populate from real Skill use (not blockered)
  - Hot-path PageRank highlighting in viewer (cosmetic)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 13:07:21 +08:00
..
firewall-diff KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
frustration-matrix KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-agent-runtime KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-artifact KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-atom-discovery KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-auth KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-auth-apple KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-auth-google KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-auth-magiclink KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-auth-webauthn KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-backend-daytona KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-brain-view KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-cache KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-capability KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-changelog KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-chat-store KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-compute-baremetal KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-compute-digitalocean KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-compute-linode KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-compute-vultr KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-conflict-scan KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-content-store KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-cortex KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-cron-scheduler KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-crossdomain KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-curator KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-db-contract feat(frontend-loop): kei-db-contract primitive + frontend-validator agent + auto-dev-guard hook 2026-05-01 15:34:39 +08:00
kei-decision KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-decompose KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-diff KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-discover KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-dna-index KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-entity-store KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-export-trajectories KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-forge KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-fork KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-frustration-loop KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-gateway KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-gdrive-import KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-git-bitbucket KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-git-forgejo KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-git-gitea KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-git-gitlab KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-graph-check KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-graph-export feat(graph): live runtime DNA viewer — kei-graph-export + lbm-graph-viz adapter 2026-05-02 13:07:21 +08:00
kei-hibernate KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-import-project KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-leak-matrix KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-ledger feat(tracking): close 3 last observability gaps — toolStats + skill-record + numeric-claims journal 2026-05-02 03:42:09 +08:00
kei-ledger-sign KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-llm-bridge-mlx KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-llm-llamacpp KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-llm-mlx KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-llm-ollama KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-llm-router KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-machine-probe KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-mcp KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-memory chore(kit): wire kei-db-contract into installer + drop final #[path] hack 2026-05-01 17:55:52 +08:00
kei-memory-postgres KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-memory-redis KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-memory-sled KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-memory-sqlite KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-migrate KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-model feat(secrets+catalog): orphan-detector for env vars + image/video/voice models 2026-05-02 00:06:16 +08:00
kei-model-router KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-net-ipsec KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-net-openvpn KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-net-wireguard KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-notify-discord KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-notify-slack KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-notify-sms KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-notify-telegram KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-pet KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-ping KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-pipe KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-projects-index KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-projects-watcher KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-provision KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-prune KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-refactor-engine KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-registry feat(secrets+catalog): orphan-detector for env vars + image/video/voice models 2026-05-02 00:06:16 +08:00
kei-replay KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-router KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-runtime KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-runtime-core KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-sage KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-scheduler KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-search-core KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-shared KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-skill-importer KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-skills KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-social-store KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-spawn KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-store KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-svc-systemd KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-task KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-tlog KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-token-tracker KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-tty KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
kei-watch KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
keisei KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
mock-render KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
ssh-check KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
tokens-sync KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
visual-diff KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
.gitignore KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
Cargo.lock feat(graph): live runtime DNA viewer — kei-graph-export + lbm-graph-viz adapter 2026-05-02 13:07:21 +08:00
Cargo.toml feat(graph): live runtime DNA viewer — kei-graph-export + lbm-graph-viz adapter 2026-05-02 13:07:21 +08:00