@mindrian_os/cli 2.0.0-beta.3 → 2.0.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +21 -0
- package/.mcp.json +14 -0
- package/CHANGELOG.md +497 -0
- package/agents/analogy-query-fetcher.md +119 -0
- package/agents/brain-query.md +91 -0
- package/agents/competitor-watch-fetcher.md +94 -0
- package/agents/framework-runner.md +258 -0
- package/agents/grading.md +216 -0
- package/agents/grant-reviewer.md +191 -0
- package/agents/investor.md +141 -0
- package/agents/larry-extended.md +215 -0
- package/agents/meeting-perspective-extractor.md +94 -0
- package/agents/opportunity-scanner.md +105 -0
- package/agents/persona-analyst.md +201 -0
- package/agents/research.md +103 -0
- package/agents/reverse-salient-agent.md +42 -0
- package/agents/vault-section-reviewer.md +107 -0
- package/assets/banner-showcase.html +537 -0
- package/assets/fonts/BebasNeue-Regular.ttf +0 -0
- package/assets/fonts/Inter-Bold.ttf +0 -0
- package/assets/fonts/Inter-Regular.ttf +0 -0
- package/assets/logo.svg +10 -0
- package/bin/local-chain-recommender.cjs +256 -0
- package/bin/mindrian-brain-mcp-client.cjs +319 -0
- package/bin/mindrian-mcp-server.cjs +445 -0
- package/bin/mindrian-mcp-shim.cjs +100 -0
- package/bin/mindrian-tools.cjs +784 -0
- package/commands/act.md +529 -0
- package/commands/admin.md +439 -0
- package/commands/agentshield.md +49 -0
- package/commands/analyze-needs.md +78 -0
- package/commands/analyze-systems.md +73 -0
- package/commands/analyze-timing.md +98 -0
- package/commands/auto-explore.md +85 -0
- package/commands/beautiful-question.md +76 -0
- package/commands/bono.md +152 -0
- package/commands/brain-derive.md +137 -0
- package/commands/build-knowledge.md +121 -0
- package/commands/build-thesis.md +94 -0
- package/commands/causal.md +269 -0
- package/commands/challenge-assumptions.md +78 -0
- package/commands/compare-ventures.md +117 -0
- package/commands/correct-reference-now.md +88 -0
- package/commands/dashboard.md +144 -0
- package/commands/deck.md +117 -0
- package/commands/deep-grade.md +214 -0
- package/commands/diagnose.md +131 -0
- package/commands/diagnostics.md +195 -0
- package/commands/dial-memory-refresh.md +113 -0
- package/commands/diffusion.md +129 -0
- package/commands/discover.md +221 -0
- package/commands/doctor.md +271 -0
- package/commands/dogfood-flush.md +130 -0
- package/commands/dominant-designs.md +76 -0
- package/commands/eureka.md +315 -0
- package/commands/explain-decision.md +135 -0
- package/commands/explore-domains.md +78 -0
- package/commands/explore-futures.md +67 -0
- package/commands/explore-opportunity.md +172 -0
- package/commands/explore-trends.md +78 -0
- package/commands/export.md +128 -0
- package/commands/feynman-timeline-refresh.md +102 -0
- package/commands/file-meeting.md +1195 -0
- package/commands/find-analogies.md +369 -0
- package/commands/find-bottlenecks.md +108 -0
- package/commands/find-connections.md +111 -0
- package/commands/funding.md +114 -0
- package/commands/futures.md +128 -0
- package/commands/grade-grant.md +297 -0
- package/commands/grade.md +257 -0
- package/commands/graph.md +218 -0
- package/commands/hat-briefing.md +163 -0
- package/commands/heal.md +72 -0
- package/commands/help.md +176 -0
- package/commands/hmi-status.md +75 -0
- package/commands/ignite.md +229 -0
- package/commands/ingest-methodology.md +128 -0
- package/commands/intel-pipeline.md +133 -0
- package/commands/jtbd.md +262 -0
- package/commands/leadership.md +113 -0
- package/commands/lean-canvas.md +74 -0
- package/commands/macro-trends.md +88 -0
- package/commands/map-unknowns.md +76 -0
- package/commands/memory-cortex-reach.md +79 -0
- package/commands/memory.md +213 -0
- package/commands/models.md +200 -0
- package/commands/mos-reason.md +489 -0
- package/commands/mos.md +162 -0
- package/commands/mullins.md +155 -0
- package/commands/mva-brief.md +86 -0
- package/commands/mva-option.md +119 -0
- package/commands/mva-report.md +76 -0
- package/commands/new-project.md +633 -0
- package/commands/new-surface.md +116 -0
- package/commands/onboard.md +489 -0
- package/commands/operator.md +168 -0
- package/commands/opportunities.md +177 -0
- package/commands/organize.md +74 -0
- package/commands/persona.md +276 -0
- package/commands/pipeline.md +167 -0
- package/commands/present.md +125 -0
- package/commands/publish.md +227 -0
- package/commands/pws-brain.md +154 -0
- package/commands/qualify-opportunity.md +113 -0
- package/commands/query.md +70 -0
- package/commands/radar.md +110 -0
- package/commands/reanalyze.md +124 -0
- package/commands/research.md +467 -0
- package/commands/room.md +385 -0
- package/commands/rooms.md +682 -0
- package/commands/root-cause.md +77 -0
- package/commands/rs-experts.md +153 -0
- package/commands/rs-explain.md +134 -0
- package/commands/rs-fetch.md +119 -0
- package/commands/rs-thesis.md +131 -0
- package/commands/scenario-plan.md +80 -0
- package/commands/scheduled-tasks.md +308 -0
- package/commands/score-innovation.md +78 -0
- package/commands/scout.md +379 -0
- package/commands/setup.md +658 -0
- package/commands/show.md +71 -0
- package/commands/skill.md +108 -0
- package/commands/snapshot.md +179 -0
- package/commands/speakers.md +118 -0
- package/commands/splash.md +55 -0
- package/commands/stance.md +91 -0
- package/commands/status.md +109 -0
- package/commands/structure-argument.md +82 -0
- package/commands/suggest-next.md +141 -0
- package/commands/systems-thinking.md +224 -0
- package/commands/think-hats.md +86 -0
- package/commands/trending-to-absurd.md +151 -0
- package/commands/update.md +256 -0
- package/commands/user-needs.md +77 -0
- package/commands/validate.md +77 -0
- package/commands/value-proposition.md +116 -0
- package/commands/vault.md +330 -0
- package/commands/visualize.md +71 -0
- package/commands/whitespace.md +541 -0
- package/commands/wiki.md +96 -0
- package/data/ROOM.md +47 -0
- package/data/brain-census.generated.json +2617 -0
- package/data/brain-orchestration-projection.json +4973 -0
- package/data/brain-packet-schema.json +545 -0
- package/data/brain-surface-contract.json +32 -0
- package/data/capability-ledger.json +391 -0
- package/data/capability-map-registry.json +23 -0
- package/data/command-registry.json +2433 -0
- package/data/connector-coverage-ledger.json +1618 -0
- package/data/connector-out-of-spine-allowlist.json +71 -0
- package/data/connector-registry.json +3637 -0
- package/data/corpus-stats-source.json +11 -0
- package/data/corpus-stats.generated.json +10 -0
- package/data/cross-domain-analogues.json +15 -0
- package/data/deck-aliases.json +6 -0
- package/data/deck-styles.json +85 -0
- package/data/deployment-surfaces.json +69 -0
- package/data/dispatch-framework-map.json +18 -0
- package/data/doctor-modules.json +206 -0
- package/data/dual-graph-health-baseline.json +12 -0
- package/data/eureka-critic-tags.json +32 -0
- package/data/first-reward-surfaces.json +66 -0
- package/data/first-touch-surfaces.json +60 -0
- package/data/flagship-floor-set.json +37 -0
- package/data/framework-names.json +121 -0
- package/data/grant-rubric-fixtures/early-stage-pre-seed.json +18 -0
- package/data/grant-rubric-fixtures/early-stage-round-a.json +18 -0
- package/data/grant-rubric-fixtures/early-stage-seed.json +18 -0
- package/data/grant-rubric-fixtures/hybrid-seed-incentive.json +18 -0
- package/data/grant-rubric-fixtures/rd-fund.json +18 -0
- package/data/grant-rubric-fixtures/regional-innovation-incubators.json +18 -0
- package/data/grant-rubric-fixtures/technology-incubators.json +18 -0
- package/data/grant-rubric-fixtures/tnufa.json +167 -0
- package/data/grant-rubric-schema.json +33 -0
- package/data/harness-fixtures/converged-room/.context/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/.intelligence/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/.snapshots/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/MINTO.md +19 -0
- package/data/harness-fixtures/converged-room/STATE.md +73 -0
- package/data/harness-fixtures/converged-room/USER.md +23 -0
- package/data/harness-fixtures/converged-room/assets/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/business-model/CONTEXT.md +32 -0
- package/data/harness-fixtures/converged-room/business-model/ROOM.md +36 -0
- package/data/harness-fixtures/converged-room/competitive-analysis/CONTEXT.md +33 -0
- package/data/harness-fixtures/converged-room/competitive-analysis/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/financial-model/CONTEXT.md +30 -0
- package/data/harness-fixtures/converged-room/financial-model/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/funding/CONTEXT.md +41 -0
- package/data/harness-fixtures/converged-room/funding/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/legal-ip/CONTEXT.md +30 -0
- package/data/harness-fixtures/converged-room/legal-ip/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/market-analysis/CONTEXT.md +32 -0
- package/data/harness-fixtures/converged-room/market-analysis/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/opportunity-bank/CONTEXT.md +39 -0
- package/data/harness-fixtures/converged-room/opportunity-bank/ROOM.md +36 -0
- package/data/harness-fixtures/converged-room/problem-definition/CONTEXT.md +32 -0
- package/data/harness-fixtures/converged-room/problem-definition/ROOM.md +36 -0
- package/data/harness-fixtures/converged-room/references/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/references/SECTION-SCHEMA.md +213 -0
- package/data/harness-fixtures/converged-room/references/SUB-SCHEMAS.md +91 -0
- package/data/harness-fixtures/converged-room/solution-design/CONTEXT.md +36 -0
- package/data/harness-fixtures/converged-room/solution-design/ROOM.md +36 -0
- package/data/harness-fixtures/converged-room/strategy/CONTEXT.md +35 -0
- package/data/harness-fixtures/converged-room/strategy/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/team/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/team-execution/CONTEXT.md +36 -0
- package/data/harness-fixtures/converged-room/team-execution/ROOM.md +35 -0
- package/data/harness-manifest.json +74 -0
- package/data/harness-policies/CONTEXT.md +55 -0
- package/data/harness-policies/_schema.json +42 -0
- package/data/harness-policies/contract-parity-larry.json +63 -0
- package/data/harness-policies/gate-card-fire.json +13 -0
- package/data/harness-policies/gate-graph-derive-health.json +13 -0
- package/data/harness-policies/gate-shape-declaration.json +13 -0
- package/data/harness-policies/gate-tool-honesty.json +13 -0
- package/data/harness-policies/gate-worktree-hygiene.json +13 -0
- package/data/harness-policies/memory-write-policy.json +28 -0
- package/data/harness-policies/registry-drift.json +13 -0
- package/data/harness-policies/release-payload-ceiling.json +13 -0
- package/data/harness-policies/voice-backend-noun-free.json +13 -0
- package/data/harness-policies/voice-fork-as-card.json +13 -0
- package/data/harness-policies/voice-glyph-present.json +13 -0
- package/data/harness-policies/voice-hyphens-only.json +13 -0
- package/data/help-groups.json +236 -0
- package/data/hitl-shape-backfill.json +777 -0
- package/data/hitl-shape-declaration-fixtures/invalid-bad-shape.json +5 -0
- package/data/hitl-shape-declaration-fixtures/invalid-missing-why.json +4 -0
- package/data/hitl-shape-declaration-fixtures/invalid-ranker-contradiction.json +6 -0
- package/data/hitl-shape-declaration-fixtures/invalid-skill-gap.json +3 -0
- package/data/hitl-shape-declaration-fixtures/valid-multi-stage.json +7 -0
- package/data/hitl-shape-declaration-fixtures/valid-single-shape.json +5 -0
- package/data/hitl-shape-declaration-fixtures/valid-skill-exempt.json +5 -0
- package/data/hitl-shape-declaration-schema.json +34 -0
- package/data/hitl-stages-fixtures/bono.json +10 -0
- package/data/hitl-stages-fixtures/pipeline-1.json +9 -0
- package/data/hitl-stages-fixtures/pipeline-2.json +9 -0
- package/data/hitl-stages-fixtures/pipeline-3.json +10 -0
- package/data/hitl-stages-fixtures/research.json +10 -0
- package/data/hitl-stages-fixtures/rs-convergence.json +10 -0
- package/data/hitl-stages-fixtures/rs-family.json +11 -0
- package/data/hitl-stages-fixtures/rs-reverse-salient.json +10 -0
- package/data/hitl-stages-fixtures/trending-to-absurd.json +11 -0
- package/data/hitl-stages-schema.json +26 -0
- package/data/mcp-tool-connectors.json +464 -0
- package/data/mva-agent-prompts.json +31 -0
- package/data/mva-deck-template.html +15 -0
- package/data/mva-heuristic-keywords.json +35 -0
- package/data/orchestration-command-ledger.json +576 -0
- package/data/orchestration-unwired-allowlist.json +6 -0
- package/data/portfolio-ahp-matrix.json +16 -0
- package/data/publish-needs.json +76 -0
- package/data/render-coverage-registry.json +1152 -0
- package/data/research-sources.json +58 -0
- package/data/roadmap-type-chains.json +28 -0
- package/data/room-blueprints.json +156 -0
- package/data/subagent-dispatch-grants.json +150 -0
- package/hooks/hooks.json +493 -0
- package/hooks/run-hook.cmd +64 -0
- package/lib/__init__.py +0 -0
- package/lib/__pycache__/__init__.cpython-312.pyc +0 -0
- package/lib/agents/auto-explore-agent.cjs +1163 -0
- package/lib/agents/mva/brain-classic-traps.cjs +55 -0
- package/lib/agents/mva/brain-cross-domain.cjs +79 -0
- package/lib/agents/mva/brain-similar-ventures.cjs +93 -0
- package/lib/agents/mva/dashboard-graph-neighborhood.cjs +72 -0
- package/lib/agents/mva/index.cjs +42 -0
- package/lib/agents/mva/six-hats-red-black.cjs +137 -0
- package/lib/agents/mva/tavily-funding-scan.cjs +147 -0
- package/lib/agents/mva/test-all-six-agents.cjs +467 -0
- package/lib/agents/reverse-salient-agent.cjs +757 -0
- package/lib/agents/tension-hook-agent.cjs +586 -0
- package/lib/brain/ROOM.md +44 -0
- package/lib/brain/chain-recommender.cjs +784 -0
- package/lib/brain/curation-batch.cjs +519 -0
- package/lib/brain/framework-chain-slice.cjs +252 -0
- package/lib/brain/hypergraph-event-schema.cjs +184 -0
- package/lib/chat/chat-context.js +185 -0
- package/lib/chat/chat-panel.js +721 -0
- package/lib/chat/fabric-chat.cjs +288 -0
- package/lib/chat/generative-tools.js +219 -0
- package/lib/conversation/ROOM.md +39 -0
- package/lib/conversation/classifier-rules.json +38 -0
- package/lib/conversation/classifier.cjs +264 -0
- package/lib/conversation/operator-epistemic-cap.test.cjs +156 -0
- package/lib/conversation/operator.cjs +492 -0
- package/lib/conversation/operator.test.cjs +160 -0
- package/lib/copy/115-spec-strings.cjs +55 -0
- package/lib/core/__init__.py +0 -0
- package/lib/core/__nav-stub.cjs +14 -0
- package/lib/core/__pycache__/__init__.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs-math.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_cache.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_corpus.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_corpus_exclude.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_hybrid.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_math.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_rooms.cpython-312.pyc +0 -0
- package/lib/core/abstraction-gate.cjs +133 -0
- package/lib/core/act-jtbd-blurb.cjs +231 -0
- package/lib/core/artifact-id.cjs +148 -0
- package/lib/core/asset-ops.cjs +151 -0
- package/lib/core/auto-commit-throttle.cjs +129 -0
- package/lib/core/bearer-token.cjs +199 -0
- package/lib/core/behavioral/observation-schema.cjs +86 -0
- package/lib/core/bono/cell-fanout.cjs +305 -0
- package/lib/core/bono/debate-composition.cjs +495 -0
- package/lib/core/bono/hat-governance.cjs +367 -0
- package/lib/core/bono/persona-research.cjs +288 -0
- package/lib/core/bono/reviewer-governance.cjs +331 -0
- package/lib/core/brain-client.cjs +2621 -0
- package/lib/core/brain-derivation-prompts.cjs +331 -0
- package/lib/core/brain-derivation-queue.cjs +535 -0
- package/lib/core/brain-derivation.cjs +740 -0
- package/lib/core/brain-md-schema.cjs +528 -0
- package/lib/core/brain-md-staleness.cjs +357 -0
- package/lib/core/brain-response-sanitize.cjs +396 -0
- package/lib/core/breakthrough/canary.cjs +134 -0
- package/lib/core/breakthrough/canary.test.cjs +136 -0
- package/lib/core/breakthrough/detectors.cjs +359 -0
- package/lib/core/breakthrough/detectors.test.cjs +333 -0
- package/lib/core/breakthrough/ethics-fence.cjs +129 -0
- package/lib/core/breakthrough/ethics-fence.test.cjs +178 -0
- package/lib/core/breakthrough/resurfacing.cjs +150 -0
- package/lib/core/breakthrough/resurfacing.test.cjs +233 -0
- package/lib/core/breakthrough/review-queue.cjs +168 -0
- package/lib/core/breakthrough/review-queue.test.cjs +160 -0
- package/lib/core/breakthrough/scanner-d17-d18.test.cjs +229 -0
- package/lib/core/breakthrough/scanner.cjs +435 -0
- package/lib/core/breakthrough/scanner.test.cjs +267 -0
- package/lib/core/breakthrough/schema.cjs +180 -0
- package/lib/core/breakthrough/schema.test.cjs +256 -0
- package/lib/core/breakthrough/scoring.cjs +293 -0
- package/lib/core/breakthrough/scoring.test.cjs +423 -0
- package/lib/core/breakthrough/verb-dispatch.cjs +230 -0
- package/lib/core/breakthrough/verb-dispatch.test.cjs +185 -0
- package/lib/core/breakthrough/voice-scaffold.cjs +249 -0
- package/lib/core/breakthrough/voice-scaffold.test.cjs +251 -0
- package/lib/core/bridge-writer.cjs +477 -0
- package/lib/core/cache-prune.cjs +314 -0
- package/lib/core/card-fire-gate.cjs +107 -0
- package/lib/core/card-fire-sidechannel.cjs +518 -0
- package/lib/core/chain-executor.cjs +939 -0
- package/lib/core/chain-retry.cjs +214 -0
- package/lib/core/chain-step-dispatcher.cjs +397 -0
- package/lib/core/chat-context-builder.cjs +253 -0
- package/lib/core/check-plugin-enabled.cjs +145 -0
- package/lib/core/close-loop-writer.cjs +492 -0
- package/lib/core/command-registration-check.cjs +246 -0
- package/lib/core/correlation-label-index.cjs +230 -0
- package/lib/core/correlation.cjs +112 -0
- package/lib/core/coverage-monitor.cjs +183 -0
- package/lib/core/coverage-rollup.cjs +232 -0
- package/lib/core/cross-room-aggregator.cjs +1127 -0
- package/lib/core/cross-room-store.cjs +292 -0
- package/lib/core/cross-room-triggers.cjs +222 -0
- package/lib/core/daily-briefing.cjs +438 -0
- package/lib/core/decision-axes.cjs +178 -0
- package/lib/core/decision-capture.cjs +618 -0
- package/lib/core/deck-design-rules.cjs +211 -0
- package/lib/core/deep-links.cjs +82 -0
- package/lib/core/directive-envelope.cjs +230 -0
- package/lib/core/directive-envelope.test.cjs +225 -0
- package/lib/core/dispatch-optimizer.cjs +354 -0
- package/lib/core/doc-text-extractor.cjs +133 -0
- package/lib/core/doctor/capability-ledger-module.cjs +170 -0
- package/lib/core/doctor/card-fire-health-module.cjs +159 -0
- package/lib/core/doctor/cascade-rooms-active-module.cjs +127 -0
- package/lib/core/doctor/cascade-rooms-module.cjs +184 -0
- package/lib/core/doctor/class-m-brain-smoke.cjs +479 -0
- package/lib/core/doctor/class-m-brain-smoke.test.cjs +448 -0
- package/lib/core/doctor/class-s-eureka-smoke.cjs +380 -0
- package/lib/core/doctor/deployment-surfaces-module.cjs +408 -0
- package/lib/core/doctor/deprecated-usage-module.cjs +155 -0
- package/lib/core/doctor/eureka-fts-health-module.cjs +236 -0
- package/lib/core/doctor/graph-derive-heal-retrofit-module.cjs +148 -0
- package/lib/core/doctor/graph-derive-health-module.cjs +486 -0
- package/lib/core/doctor/install-incomplete-module.cjs +320 -0
- package/lib/core/doctor/install-state-module.cjs +503 -0
- package/lib/core/doctor/mcp-surface-module.cjs +369 -0
- package/lib/core/doctor/mode-select-checkpoint-module.cjs +113 -0
- package/lib/core/doctor/plugin-enabled-state-module.cjs +86 -0
- package/lib/core/doctor/room-graph-density-module.cjs +181 -0
- package/lib/core/doctor/room-md-module.cjs +198 -0
- package/lib/core/doctor/shared.cjs +555 -0
- package/lib/core/doctor/stale-first-touch-copy-module.cjs +83 -0
- package/lib/core/doctor/statusline-visibility-module.cjs +295 -0
- package/lib/core/doctor/ui-compliance-module.cjs +223 -0
- package/lib/core/doctor/umbilical-module.cjs +486 -0
- package/lib/core/doctor/verify-surface-module.cjs +82 -0
- package/lib/core/doctor/voice-style-log-module.cjs +146 -0
- package/lib/core/domain-insight-sweep.cjs +224 -0
- package/lib/core/drift-baseline.cjs +362 -0
- package/lib/core/drift-runtime-reachability.cjs +283 -0
- package/lib/core/dual-path-detector.cjs +84 -0
- package/lib/core/dual-path-detector.test.cjs +334 -0
- package/lib/core/enrichment-queue.cjs +636 -0
- package/lib/core/eureka/ahp-weights.cjs +232 -0
- package/lib/core/eureka/analogy-fitness.cjs +326 -0
- package/lib/core/eureka/compression-meter.cjs +165 -0
- package/lib/core/eureka/embedding-classifier.cjs +226 -0
- package/lib/core/eureka/embedding-spine.cjs +563 -0
- package/lib/core/eureka/entity-classifier.cjs +232 -0
- package/lib/core/eureka/entity-extractor.cjs +356 -0
- package/lib/core/eureka/eureka-enable.cjs +228 -0
- package/lib/core/eureka/eureka-offer.cjs +225 -0
- package/lib/core/eureka/eureka-reach-runner.cjs +430 -0
- package/lib/core/eureka/explore-chain.cjs +834 -0
- package/lib/core/eureka/explored-artifact.cjs +456 -0
- package/lib/core/eureka/fts-index-lifecycle.cjs +265 -0
- package/lib/core/eureka/grade-grant-examine.cjs +544 -0
- package/lib/core/eureka/grade-grant.cjs +596 -0
- package/lib/core/eureka/hybrid-retrieve.cjs +256 -0
- package/lib/core/eureka/lateral-engine-adapter.cjs +118 -0
- package/lib/core/eureka/lexical-overlap.cjs +98 -0
- package/lib/core/eureka/online-pattern-query.cjs +142 -0
- package/lib/core/eureka/opportunity-harvest.cjs +752 -0
- package/lib/core/eureka/opportunity-statement.cjs +519 -0
- package/lib/core/eureka/portfolio-dimensions.cjs +255 -0
- package/lib/core/eureka/qualify-opportunity.cjs +607 -0
- package/lib/core/eureka/reasoning-mode.cjs +481 -0
- package/lib/core/eureka/report-html.cjs +368 -0
- package/lib/core/eureka/research-filing.cjs +547 -0
- package/lib/core/eureka/room-native-substrate.cjs +343 -0
- package/lib/core/eureka/tail-quadrant.cjs +177 -0
- package/lib/core/eureka/tri-modal-index.cjs +564 -0
- package/lib/core/eureka/vector-store.cjs +414 -0
- package/lib/core/eureka-critic.cjs +733 -0
- package/lib/core/eureka-deps-resolver.cjs +179 -0
- package/lib/core/expert-genesis.cjs +437 -0
- package/lib/core/expert-library.cjs +303 -0
- package/lib/core/exports-log.cjs +79 -0
- package/lib/core/feynman/ROOM.md +25 -0
- package/lib/core/feynman/dial-memory-renderer.cjs +279 -0
- package/lib/core/feynman/dial-memory-runner.cjs +173 -0
- package/lib/core/feynman/feynman-seed-writer.cjs +187 -0
- package/lib/core/feynman/timeline-renderer.cjs +197 -0
- package/lib/core/feynman/timeline-runner.cjs +281 -0
- package/lib/core/feynman-minto-invariants.cjs +609 -0
- package/lib/core/findings-wirer.cjs +360 -0
- package/lib/core/first-touch-version-stamper.cjs +113 -0
- package/lib/core/folder-memory-async.cjs +424 -0
- package/lib/core/folder-memory-shared.cjs +890 -0
- package/lib/core/folder-memory.cjs +546 -0
- package/lib/core/framework-chain-composer.cjs +583 -0
- package/lib/core/frontmatter-schemas.cjs +468 -0
- package/lib/core/fusion-router.cjs +540 -0
- package/lib/core/futures/causal-cue.cjs +91 -0
- package/lib/core/futures/orchestrator.cjs +1391 -0
- package/lib/core/futures/subsystem-render.cjs +164 -0
- package/lib/core/gate-relevance.cjs +278 -0
- package/lib/core/git-ops.cjs +141 -0
- package/lib/core/graph-backfill.cjs +562 -0
- package/lib/core/graph-candidate-producer.cjs +235 -0
- package/lib/core/graph-derivation.cjs +546 -0
- package/lib/core/graph-derive-classifier.cjs +352 -0
- package/lib/core/graph-ops.cjs +274 -0
- package/lib/core/graph-refine-loop.cjs +194 -0
- package/lib/core/graph-self-heal.cjs +289 -0
- package/lib/core/greeting-intent-detector.cjs +201 -0
- package/lib/core/grill-engine.cjs +459 -0
- package/lib/core/hat-persistence.cjs +274 -0
- package/lib/core/hsi-engine.cjs +439 -0
- package/lib/core/hsi-lsa.cjs +246 -0
- package/lib/core/hsi-spectral.cjs +554 -0
- package/lib/core/hsi-to-graph.test.cjs +168 -0
- package/lib/core/icm-forest.cjs +703 -0
- package/lib/core/ignite-branch-gate.cjs +66 -0
- package/lib/core/index.cjs +60 -0
- package/lib/core/insight-sensors.cjs +1000 -0
- package/lib/core/install-state.cjs +242 -0
- package/lib/core/integration-registry.cjs +232 -0
- package/lib/core/intel-pipeline.cjs +566 -0
- package/lib/core/intelligence-cascade.cjs +852 -0
- package/lib/core/issue-tree.cjs +269 -0
- package/lib/core/larry-thinness-acknowledgment.cjs +64 -0
- package/lib/core/larry-thinness-acknowledgment.test.cjs +97 -0
- package/lib/core/lazygraph-ops.cjs +1453 -0
- package/lib/core/lens-engine.cjs +434 -0
- package/lib/core/leverage-scan.cjs +218 -0
- package/lib/core/llm-name-suggester.cjs +194 -0
- package/lib/core/llm-name-suggester.test.cjs +132 -0
- package/lib/core/lru-cache.cjs +139 -0
- package/lib/core/mcp-dep-heal.cjs +475 -0
- package/lib/core/mcp-dep-heal.test.cjs +253 -0
- package/lib/core/mcp-profiles.cjs +185 -0
- package/lib/core/meeting-ops.cjs +54 -0
- package/lib/core/memory/governance-candidate-raiser.cjs +205 -0
- package/lib/core/memory/governance-candidate.cjs +95 -0
- package/lib/core/memory/reconcile-memory-runner.cjs +653 -0
- package/lib/core/memory-ops.cjs +641 -0
- package/lib/core/meter/gate-density-reader.cjs +112 -0
- package/lib/core/meter/transfer-reader.cjs +276 -0
- package/lib/core/meter/two-gauge.cjs +245 -0
- package/lib/core/methodology-ingest.cjs +346 -0
- package/lib/core/metrics/larryreach-loop-health.cjs +142 -0
- package/lib/core/migration-snapshot.cjs +287 -0
- package/lib/core/migration-snapshot.test.cjs +174 -0
- package/lib/core/migrations/ROOM.md +33 -0
- package/lib/core/migrations/phase-109-nodes-provenance.cjs +400 -0
- package/lib/core/migrations/phase-109-session-focus.cjs +99 -0
- package/lib/core/migrations/phase-160-nodes-bitemporal.cjs +168 -0
- package/lib/core/migrations/phase-160-nodes-bitemporal.test.cjs +140 -0
- package/lib/core/migrations/phase-162-section-nodes.cjs +156 -0
- package/lib/core/migrations/phase-222-ranker-weights.cjs +62 -0
- package/lib/core/migrations/phase-224-edge-review-status.cjs +87 -0
- package/lib/core/mindrian-brain-shim.test.cjs +221 -0
- package/lib/core/mode-select-sidechannel.cjs +259 -0
- package/lib/core/model-profiles.cjs +246 -0
- package/lib/core/mullins-scaffold.cjs +258 -0
- package/lib/core/mullins-scaffold.test.cjs +128 -0
- package/lib/core/mva-agent-contract.cjs +170 -0
- package/lib/core/mva-agent-contract.test.cjs +169 -0
- package/lib/core/mva-budget.cjs +75 -0
- package/lib/core/mva-budget.test.cjs +68 -0
- package/lib/core/mva-classifier.cjs +392 -0
- package/lib/core/mva-classifier.test.cjs +248 -0
- package/lib/core/mva-deck-builder.cjs +452 -0
- package/lib/core/mva-deck-builder.test.cjs +287 -0
- package/lib/core/mva-detect.smoke.test.cjs +209 -0
- package/lib/core/mva-dispatcher.cjs +110 -0
- package/lib/core/mva-dispatcher.test.cjs +216 -0
- package/lib/core/mva-option-router.cjs +414 -0
- package/lib/core/mva-option-router.test.cjs +483 -0
- package/lib/core/mva-orchestrator.cjs +365 -0
- package/lib/core/mva-orchestrator.test.cjs +916 -0
- package/lib/core/mva-progressive-renderer.cjs +194 -0
- package/lib/core/mva-progressive-renderer.test.cjs +157 -0
- package/lib/core/mva-rule-linter.cjs +458 -0
- package/lib/core/mva-rule-linter.test.cjs +484 -0
- package/lib/core/mva-state.cjs +159 -0
- package/lib/core/mva-telemetry.cjs +58 -0
- package/lib/core/mva-telemetry.test.cjs +196 -0
- package/lib/core/mva-vercel-deploy.cjs +168 -0
- package/lib/core/mva-vercel-deploy.test.cjs +239 -0
- package/lib/core/nav-dial.cjs +440 -0
- package/lib/core/navigation/ROOM.md +15 -0
- package/lib/core/navigation/abstraction-claim.cjs +185 -0
- package/lib/core/navigation/calibration-gate.cjs +284 -0
- package/lib/core/navigation/calibration-log.cjs +141 -0
- package/lib/core/navigation/confirm-node.cjs +73 -0
- package/lib/core/navigation/dashboard-helpers.cjs +145 -0
- package/lib/core/navigation/edges.cjs +1150 -0
- package/lib/core/navigation/evidence-claim.cjs +186 -0
- package/lib/core/navigation/explanation.cjs +48 -0
- package/lib/core/navigation/file-evidence-readback.cjs +242 -0
- package/lib/core/navigation/focus.cjs +155 -0
- package/lib/core/navigation/get-domains-for-trends.cjs +277 -0
- package/lib/core/navigation/governance.cjs +101 -0
- package/lib/core/navigation/grant-rubric.cjs +218 -0
- package/lib/core/navigation/graph-export.cjs +325 -0
- package/lib/core/navigation/ingestion.cjs +109 -0
- package/lib/core/navigation/insights-stale.test.cjs +127 -0
- package/lib/core/navigation/insights.cjs +574 -0
- package/lib/core/navigation/lens-nodes.cjs +315 -0
- package/lib/core/navigation/memory-artifacts.cjs +437 -0
- package/lib/core/navigation/memory-cortex-packet.cjs +274 -0
- package/lib/core/navigation/memory-events.cjs +811 -0
- package/lib/core/navigation/neighborhood.cjs +79 -0
- package/lib/core/navigation/packet.cjs +420 -0
- package/lib/core/navigation/planning-artifacts.cjs +219 -0
- package/lib/core/navigation/projections.cjs +295 -0
- package/lib/core/navigation/ranker-weights.cjs +133 -0
- package/lib/core/navigation/reasoning-write.cjs +211 -0
- package/lib/core/navigation/reconcile-guard.cjs +98 -0
- package/lib/core/navigation/reified-claim.cjs +287 -0
- package/lib/core/navigation/research-preflight.cjs +156 -0
- package/lib/core/navigation/room-birth.cjs +1213 -0
- package/lib/core/navigation/room-context.cjs +380 -0
- package/lib/core/navigation/room-home.cjs +142 -0
- package/lib/core/navigation/spine-events.cjs +548 -0
- package/lib/core/navigation/synthetic-expert.cjs +177 -0
- package/lib/core/navigation/transitions.cjs +253 -0
- package/lib/core/navigation/typed-claim.cjs +208 -0
- package/lib/core/navigation/typed-domain.cjs +249 -0
- package/lib/core/navigation/typed-entity.cjs +236 -0
- package/lib/core/navigation/typed-frame.cjs +257 -0
- package/lib/core/navigation/typed-open-question.cjs +130 -0
- package/lib/core/navigation/typed-opportunity.cjs +418 -0
- package/lib/core/navigation-engine-offer.cjs +776 -0
- package/lib/core/navigation-engine-shared.cjs +256 -0
- package/lib/core/navigation-engine.cjs +1696 -0
- package/lib/core/navigation.cjs +686 -0
- package/lib/core/nl-graph-queries.cjs +164 -0
- package/lib/core/node-insert-epistemic.test.cjs +212 -0
- package/lib/core/node-insert-overrides.test.cjs +273 -0
- package/lib/core/node-insert.cjs +274 -0
- package/lib/core/npm-cli-resolve.cjs +151 -0
- package/lib/core/npm-cli-resolve.test.cjs +153 -0
- package/lib/core/npm-install-lock.cjs +326 -0
- package/lib/core/npm-install-lock.test.cjs +379 -0
- package/lib/core/numeric/sklearn-stopwords-v1.json +325 -0
- package/lib/core/numeric/svd.cjs +377 -0
- package/lib/core/numeric/tfidf.cjs +241 -0
- package/lib/core/offer-presenter.cjs +406 -0
- package/lib/core/opportunity-extractor.cjs +183 -0
- package/lib/core/opportunity-ops.cjs +1423 -0
- package/lib/core/orchestration-candidate-lift.cjs +284 -0
- package/lib/core/part8-egress-guard.cjs +563 -0
- package/lib/core/part8-egress-guard.test.cjs +194 -0
- package/lib/core/part8-egress-ontology.cjs +174 -0
- package/lib/core/part8-egress-ontology.test.cjs +133 -0
- package/lib/core/persona-ops.cjs +692 -0
- package/lib/core/persona-override.cjs +327 -0
- package/lib/core/persona-taxonomy.cjs +328 -0
- package/lib/core/pinecone-inference.cjs +176 -0
- package/lib/core/pitch-feedback-schemas.cjs +303 -0
- package/lib/core/planning/artifact-brain-packet.cjs +212 -0
- package/lib/core/planning/reconcile-runner.cjs +347 -0
- package/lib/core/platform-gates.cjs +120 -0
- package/lib/core/platform.cjs +257 -0
- package/lib/core/proactive-intelligence.cjs +528 -0
- package/lib/core/problem-type-router.cjs +315 -0
- package/lib/core/publish-needs-default-lane.cjs +110 -0
- package/lib/core/ralph-loop-gate.cjs +48 -0
- package/lib/core/reader/ab-harness.cjs +177 -0
- package/lib/core/reader/decide-projection-reader.cjs +358 -0
- package/lib/core/reasoning-ops.cjs +639 -0
- package/lib/core/recipe-maps.cjs +442 -0
- package/lib/core/recovery/case-file.cjs +358 -0
- package/lib/core/recovery/controller.cjs +1008 -0
- package/lib/core/recovery/dispatcher.cjs +533 -0
- package/lib/core/recovery/result-semantics.cjs +488 -0
- package/lib/core/recovery/stage-envelope.cjs +338 -0
- package/lib/core/refusal-messaging.cjs +569 -0
- package/lib/core/refusal-messaging.test.cjs +220 -0
- package/lib/core/repo-version.cjs +134 -0
- package/lib/core/research-cache.cjs +165 -0
- package/lib/core/research-cache.test.cjs +137 -0
- package/lib/core/research-context-extractor.cjs +283 -0
- package/lib/core/research-corpus.cjs +814 -0
- package/lib/core/research-corpus.test.cjs +280 -0
- package/lib/core/research-filing-selector.cjs +189 -0
- package/lib/core/resolve-active-room.cjs +602 -0
- package/lib/core/resolve-brain-key.cjs +273 -0
- package/lib/core/resolve-umbilical-target.cjs +288 -0
- package/lib/core/resolve-vercel-key.cjs +107 -0
- package/lib/core/resolve-vercel-key.test.cjs +137 -0
- package/lib/core/reverse-salient-persona-suffix.cjs +115 -0
- package/lib/core/room-auto-create.cjs +318 -0
- package/lib/core/room-auto-create.test.cjs +198 -0
- package/lib/core/room-chooser.cjs +244 -0
- package/lib/core/room-classifier-strict-mode.cjs +235 -0
- package/lib/core/room-db.cjs +348 -0
- package/lib/core/room-discard-cascade.cjs +238 -0
- package/lib/core/room-discard-cascade.test.cjs +135 -0
- package/lib/core/room-name-validator.cjs +132 -0
- package/lib/core/room-name-validator.test.cjs +156 -0
- package/lib/core/room-naming-selector.cjs +357 -0
- package/lib/core/room-naming-selector.test.cjs +277 -0
- package/lib/core/room-open.cjs +259 -0
- package/lib/core/room-ops-async.cjs +92 -0
- package/lib/core/room-ops-shared.cjs +64 -0
- package/lib/core/room-ops-sync.cjs +70 -0
- package/lib/core/room-ops.cjs +32 -0
- package/lib/core/room-receipt-emit.cjs +63 -0
- package/lib/core/room-root.cjs +93 -0
- package/lib/core/room-skeleton-scaffold.cjs +669 -0
- package/lib/core/room-skeleton-scaffold.test.cjs +296 -0
- package/lib/core/room-type-detector.cjs +386 -0
- package/lib/core/rs-backend-dispatch.cjs +64 -0
- package/lib/core/rs-brain-substrate-prompts.cjs +129 -0
- package/lib/core/rs-brain-substrate.cjs +570 -0
- package/lib/core/rs-breakthrough-scorer.cjs +255 -0
- package/lib/core/rs-canon-violations.cjs +82 -0
- package/lib/core/rs-chain-feeder.cjs +381 -0
- package/lib/core/rs-commercial-assessor.cjs +280 -0
- package/lib/core/rs-corpus-quality-gate.cjs +62 -0
- package/lib/core/rs-differential-scorer.cjs +629 -0
- package/lib/core/rs-domain-analyzer.cjs +385 -0
- package/lib/core/rs-egress-prompts.cjs +113 -0
- package/lib/core/rs-egress-telemetry.cjs +225 -0
- package/lib/core/rs-egress-violations.cjs +53 -0
- package/lib/core/rs-engine.cjs +597 -0
- package/lib/core/rs-expert-brain-projection.cjs +280 -0
- package/lib/core/rs-expert-mapper.cjs +467 -0
- package/lib/core/rs-fetcher-academic.cjs +697 -0
- package/lib/core/rs-fetcher-experts.cjs +314 -0
- package/lib/core/rs-fetcher-industry.cjs +731 -0
- package/lib/core/rs-fetcher-patents.cjs +564 -0
- package/lib/core/rs-innovation-classifier.cjs +194 -0
- package/lib/core/rs-math.cjs +458 -0
- package/lib/core/rs-mind-map.cjs +656 -0
- package/lib/core/rs-neo4j-writer.cjs +388 -0
- package/lib/core/rs-nl-to-query.cjs +435 -0
- package/lib/core/rs-pinecone-bridge.cjs +344 -0
- package/lib/core/rs-preprocessor.cjs +350 -0
- package/lib/core/rs-query-matrix.cjs +316 -0
- package/lib/core/rs-query-to-text.cjs +438 -0
- package/lib/core/rs-sqlite-mirror.cjs +495 -0
- package/lib/core/rs-thesis-generator.cjs +188 -0
- package/lib/core/rs_cache.py +635 -0
- package/lib/core/rs_corpus.py +562 -0
- package/lib/core/rs_corpus_exclude.py +62 -0
- package/lib/core/rs_hybrid.py +589 -0
- package/lib/core/rs_math.py +287 -0
- package/lib/core/rs_rooms.py +196 -0
- package/lib/core/salient-governance.cjs +315 -0
- package/lib/core/scheduled-scanner.cjs +658 -0
- package/lib/core/scratchpad-ops.cjs +316 -0
- package/lib/core/seam-liveness.cjs +191 -0
- package/lib/core/seam-liveness.test.cjs +177 -0
- package/lib/core/section-8-trace-schema.cjs +138 -0
- package/lib/core/section-registry.cjs +167 -0
- package/lib/core/security/agentshield-adapters.test.cjs +104 -0
- package/lib/core/security/agentshield-run.cjs +343 -0
- package/lib/core/security/agentshield-scanner.cjs +314 -0
- package/lib/core/security/agentshield-scanner.test.cjs +259 -0
- package/lib/core/sensors/hat-scoping-table.cjs +103 -0
- package/lib/core/sensors/sensor-circularity.cjs +278 -0
- package/lib/core/sensors/sensor-content-relevance.cjs +407 -0
- package/lib/core/sensors/sensor-diffusion-adoption.cjs +230 -0
- package/lib/core/sensors/sensor-eureka.cjs +208 -0
- package/lib/core/sensors/sensor-expert-skill.cjs +293 -0
- package/lib/core/sensors/sensor-external-fact.cjs +184 -0
- package/lib/core/sensors/sensor-gate-approach.cjs +104 -0
- package/lib/core/sensors/sensor-jtbd-reweight.cjs +141 -0
- package/lib/core/sensors/sensor-lagging-component.cjs +115 -0
- package/lib/core/sensors/sensor-memory-cortex.cjs +111 -0
- package/lib/core/sensors/sensor-methodology-decision.cjs +131 -0
- package/lib/core/sensors/sensor-opportunity-harvest.cjs +195 -0
- package/lib/core/sensors/sensor-perspective-lock.cjs +174 -0
- package/lib/core/sensors/sensor-priority.cjs +183 -0
- package/lib/core/sensors/sensor-recency.cjs +151 -0
- package/lib/core/sensors/sensor-roadmap-type.cjs +421 -0
- package/lib/core/sensors/sensor-room-pick.cjs +238 -0
- package/lib/core/sensors/sensor-show-share.cjs +215 -0
- package/lib/core/sensors/sensor-temporal-blindness.cjs +123 -0
- package/lib/core/sensors/sensor-types.cjs +294 -0
- package/lib/core/sensors/sensor-url-ingest.cjs +234 -0
- package/lib/core/session-binding.cjs +208 -0
- package/lib/core/session-presence.cjs +404 -0
- package/lib/core/session-register.cjs +138 -0
- package/lib/core/session-state.cjs +144 -0
- package/lib/core/shallow-doc-parser.cjs +353 -0
- package/lib/core/shallow-doc-parser.test.cjs +226 -0
- package/lib/core/skill-activation-router.cjs +284 -0
- package/lib/core/skillopt-schemas.cjs +509 -0
- package/lib/core/stale-copy-scanner.cjs +190 -0
- package/lib/core/stance-state.cjs +153 -0
- package/lib/core/state-aware-router.cjs +78 -0
- package/lib/core/state-ops.cjs +80 -0
- package/lib/core/state-version.cjs +350 -0
- package/lib/core/statusline-cache.cjs +266 -0
- package/lib/core/statusline-liveness-gate.cjs +105 -0
- package/lib/core/surface-fence.cjs +127 -0
- package/lib/core/synthesizers/comparison-matrix.cjs +82 -0
- package/lib/core/synthesizers/convergence-map.cjs +107 -0
- package/lib/core/synthesizers/domain-hierarchy.cjs +138 -0
- package/lib/core/synthesizers/source-comparison.cjs +56 -0
- package/lib/core/synthesizers/tension-map.cjs +119 -0
- package/lib/core/synthetic-expert-behavior-gate.cjs +99 -0
- package/lib/core/synthetic-expert-construction-gate.cjs +170 -0
- package/lib/core/telemetry/schema.cjs +168 -0
- package/lib/core/telemetry/schema.test.cjs +124 -0
- package/lib/core/telemetry/validator.cjs +200 -0
- package/lib/core/telemetry/validator.test.cjs +188 -0
- package/lib/core/telemetry/writer.cjs +141 -0
- package/lib/core/telemetry/writer.test.cjs +331 -0
- package/lib/core/temporal/date-sync-gate.cjs +256 -0
- package/lib/core/temporal/date-sync-gate.test.cjs +191 -0
- package/lib/core/temporal/dual-stamp.cjs +172 -0
- package/lib/core/temporal/dual-stamp.test.cjs +172 -0
- package/lib/core/temporal/point-in-time.cjs +76 -0
- package/lib/core/temporal/point-in-time.test.cjs +169 -0
- package/lib/core/temporal/recency-decay.cjs +119 -0
- package/lib/core/temporal/recency-decay.test.cjs +140 -0
- package/lib/core/temporal/reference-now.cjs +281 -0
- package/lib/core/temporal/reference-now.test.cjs +225 -0
- package/lib/core/temporal/resolve-relative-time.cjs +116 -0
- package/lib/core/temporal/resolve-relative-time.test.cjs +138 -0
- package/lib/core/temporal/supersession.cjs +250 -0
- package/lib/core/temporal/supersession.test.cjs +103 -0
- package/lib/core/terminal-capability.cjs +88 -0
- package/lib/core/token-estimator.cjs +348 -0
- package/lib/core/tone-filter.cjs +147 -0
- package/lib/core/trending-to-absurd/orchestrator.cjs +341 -0
- package/lib/core/trending-to-absurd/stage7-roadmap.cjs +317 -0
- package/lib/core/trending-to-absurd/variance.cjs +169 -0
- package/lib/core/unknowns/bandit.cjs +332 -0
- package/lib/core/unknowns/corpus-adapter.cjs +327 -0
- package/lib/core/unknowns/dsp.cjs +356 -0
- package/lib/core/unknowns/edge-writer.cjs +211 -0
- package/lib/core/unknowns/iface.cjs +212 -0
- package/lib/core/unknowns/orchestrator.cjs +375 -0
- package/lib/core/unknowns/pattern-miner.cjs +214 -0
- package/lib/core/unknowns/rumsfeld-matrix.cjs +155 -0
- package/lib/core/unknowns/verdict.cjs +254 -0
- package/lib/core/update-path.cjs +57 -0
- package/lib/core/url-ingest.cjs +568 -0
- package/lib/core/user-archetype.cjs +284 -0
- package/lib/core/user-md-ops.cjs +578 -0
- package/lib/core/venture-shape-nudge.cjs +178 -0
- package/lib/core/venture-shape-nudge.test.cjs +266 -0
- package/lib/core/verb-reach-affinity.cjs +299 -0
- package/lib/core/visual-ops.cjs +692 -0
- package/lib/core/voice-transition-detector.cjs +125 -0
- package/lib/core/watched-sources.cjs +237 -0
- package/lib/core/write-lock.cjs +149 -0
- package/lib/graph/canvas-graph.js +467 -0
- package/lib/graph/constellation-config.cjs +299 -0
- package/lib/graph/graph-detail-panel.js +165 -0
- package/lib/hmi/ROOM.md +47 -0
- package/lib/hmi/across-session-memory.cjs +669 -0
- package/lib/hmi/agentshield-drift-gate.cjs +142 -0
- package/lib/hmi/brain-review-packet.cjs +221 -0
- package/lib/hmi/cortex-reach-adapter.cjs +271 -0
- package/lib/hmi/cross-room-memory.cjs +618 -0
- package/lib/hmi/decoy-tier.cjs +395 -0
- package/lib/hmi/depth-state.cjs +164 -0
- package/lib/hmi/dial-label-composer.cjs +410 -0
- package/lib/hmi/dial-presenter.cjs +508 -0
- package/lib/hmi/dial-reach-orchestrator.cjs +377 -0
- package/lib/hmi/dial-selector.cjs +239 -0
- package/lib/hmi/f1-pick-capture-cli.cjs +131 -0
- package/lib/hmi/f3-depth-capture-cli.cjs +77 -0
- package/lib/hmi/f4-scope-capture-cli.cjs +86 -0
- package/lib/hmi/f8-action-capture-cli.cjs +145 -0
- package/lib/hmi/f8-capture.test.cjs +77 -0
- package/lib/hmi/f9-ordered-capture-cli.cjs +138 -0
- package/lib/hmi/harvest-scope-state.cjs +202 -0
- package/lib/hmi/hats-persona-cache.cjs +142 -0
- package/lib/hmi/jtbd-classifier.cjs +219 -0
- package/lib/hmi/jtbd-state.cjs +263 -0
- package/lib/hmi/jtbd-taxonomy.json +402 -0
- package/lib/hmi/mindrian-ascii-logo.cjs +96 -0
- package/lib/hmi/part8-egress-gate.cjs +149 -0
- package/lib/hmi/reach-component-map.json +47 -0
- package/lib/hmi/reach-relevance-gate.cjs +147 -0
- package/lib/hmi/selector-dispatcher.cjs +1201 -0
- package/lib/hmi/selector-dispatcher.test.cjs +141 -0
- package/lib/hmi/selector-telemetry.cjs +269 -0
- package/lib/hmi/shape-f0-renderer.cjs +145 -0
- package/lib/hmi/shape-f1-fallback.cjs +80 -0
- package/lib/hmi/shape-f1-renderer.cjs +219 -0
- package/lib/hmi/shape-f2-renderer.cjs +132 -0
- package/lib/hmi/shape-f3-parity.test.cjs +64 -0
- package/lib/hmi/shape-f3-renderer.cjs +66 -0
- package/lib/hmi/shape-f4-parity.test.cjs +72 -0
- package/lib/hmi/shape-f4-renderer.cjs +72 -0
- package/lib/hmi/shape-f5-renderer.cjs +155 -0
- package/lib/hmi/shape-f6-plan-review-renderer.cjs +324 -0
- package/lib/hmi/shape-f6-renderer.cjs +144 -0
- package/lib/hmi/shape-f7-breakthrough-renderer.cjs +234 -0
- package/lib/hmi/shape-f7-breakthrough-renderer.test.cjs +233 -0
- package/lib/hmi/shape-f8-renderer.cjs +150 -0
- package/lib/hmi/shape-f8-renderer.test.cjs +70 -0
- package/lib/hmi/shape-f9-renderer.cjs +187 -0
- package/lib/hmi/shape-f9-renderer.test.cjs +80 -0
- package/lib/hmi/shape-g-renderer.cjs +219 -0
- package/lib/hmi/shape-h-renderer.cjs +222 -0
- package/lib/hmi/tier-check.cjs +63 -0
- package/lib/hmi/turn-text.cjs +268 -0
- package/lib/hmi/voice-color-mark.cjs +318 -0
- package/lib/hmi/voice-style-log.cjs +276 -0
- package/lib/import/PRECONDITIONS.md +41 -0
- package/lib/import/branding.cjs +210 -0
- package/lib/import/branding.test.cjs +235 -0
- package/lib/import/classifications-sync.cjs +104 -0
- package/lib/import/classifications-sync.test.cjs +129 -0
- package/lib/import/enricher.cjs +296 -0
- package/lib/import/enricher.test.cjs +273 -0
- package/lib/import/integration.test.cjs +376 -0
- package/lib/import/manifest.cjs +129 -0
- package/lib/import/manifest.schema.json +185 -0
- package/lib/import/manifest.test.cjs +123 -0
- package/lib/import/meeting-detector.cjs +92 -0
- package/lib/import/meeting-detector.test.cjs +100 -0
- package/lib/import/person-detector.cjs +229 -0
- package/lib/import/person-detector.test.cjs +149 -0
- package/lib/import/report.cjs +186 -0
- package/lib/import/report.test.cjs +186 -0
- package/lib/import/room-md-scaffolder.cjs +49 -0
- package/lib/import/router.cjs +224 -0
- package/lib/import/router.test.cjs +356 -0
- package/lib/import/run-all-tests.cjs +36 -0
- package/lib/import/smoke-test.cjs +213 -0
- package/lib/import/smoke-test.test.cjs +148 -0
- package/lib/import/undo.test.cjs +199 -0
- package/lib/import/vault-scanner.cjs +105 -0
- package/lib/import/vault-scanner.test.cjs +67 -0
- package/lib/lens-engine/correlation-resolver.cjs +174 -0
- package/lib/lens-engine/source-lens-driver.cjs +736 -0
- package/lib/mcp/adapter-client.cjs +103 -0
- package/lib/mcp/app-html/dashboard.html +316 -0
- package/lib/mcp/app-html/graph.html +428 -0
- package/lib/mcp/app-html/mindrian-platform.html +1841 -0
- package/lib/mcp/app-html/wiki.html +383 -0
- package/lib/mcp/app-views.cjs +322 -0
- package/lib/mcp/brain-composition-census.cjs +184 -0
- package/lib/mcp/brain-router.cjs +551 -0
- package/lib/mcp/capability-registry.cjs +62 -0
- package/lib/mcp/contract-version.cjs +59 -0
- package/lib/mcp/daemon-lifecycle.cjs +324 -0
- package/lib/mcp/gate-dedup.cjs +120 -0
- package/lib/mcp/gate-ledger.cjs +145 -0
- package/lib/mcp/gate-render.cjs +483 -0
- package/lib/mcp/hook-adapter-audit.cjs +199 -0
- package/lib/mcp/larry-context.cjs +42 -0
- package/lib/mcp/mcp-first-flag.cjs +147 -0
- package/lib/mcp/no-instructions.test.cjs +270 -0
- package/lib/mcp/pipeline-state.cjs +424 -0
- package/lib/mcp/prompts.cjs +421 -0
- package/lib/mcp/register-core-tools.cjs +78 -0
- package/lib/mcp/resources.cjs +359 -0
- package/lib/mcp/runtime-instructions.cjs +38 -0
- package/lib/mcp/session-catchup.cjs +349 -0
- package/lib/mcp/session-registry.cjs +113 -0
- package/lib/mcp/session-room.cjs +124 -0
- package/lib/mcp/sse-event-bus.cjs +98 -0
- package/lib/mcp/stop-gate-handler.cjs +589 -0
- package/lib/mcp/surface-detect.cjs +186 -0
- package/lib/mcp/tool-router.cjs +2115 -0
- package/lib/mcp/tools/chain.cjs +674 -0
- package/lib/mcp/tools/claim.cjs +180 -0
- package/lib/mcp/tools/context.cjs +92 -0
- package/lib/mcp/tools/dual-path.cjs +79 -0
- package/lib/mcp/tools/gate.cjs +392 -0
- package/lib/mcp/tools/graph-reason.cjs +130 -0
- package/lib/mcp/tools/graph.cjs +321 -0
- package/lib/mcp/tools/identity.cjs +174 -0
- package/lib/mcp/tools/room.cjs +449 -0
- package/lib/mcp/tools/sensors.cjs +450 -0
- package/lib/mcp/tools/status.cjs +183 -0
- package/lib/mcp/tools/stop-gate.cjs +103 -0
- package/lib/mcp/tools/views.cjs +382 -0
- package/lib/mcp/tree-watcher.cjs +199 -0
- package/lib/memory/.mindrian/auto-explore-mat-test-001.json +11 -0
- package/lib/memory/aaak-compress.cjs +403 -0
- package/lib/memory/aaak-compress.test.cjs +288 -0
- package/lib/memory/async-artifact-auto-commit.test.cjs +223 -0
- package/lib/memory/bearer-token.test.cjs +315 -0
- package/lib/memory/body-shape-coverage.test.cjs +268 -0
- package/lib/memory/brain-cache-lru.test.cjs +259 -0
- package/lib/memory/brain-client-query-shape.test.cjs +160 -0
- package/lib/memory/brain-cypher-chain-slice.test.cjs +368 -0
- package/lib/memory/brain-derivation-graceful-degradation.test.cjs +1019 -0
- package/lib/memory/brain-derivation-queue.test.cjs +553 -0
- package/lib/memory/brain-derivation.test.cjs +639 -0
- package/lib/memory/brain-derive-command.test.cjs +534 -0
- package/lib/memory/brain-derive-curation.test.cjs +243 -0
- package/lib/memory/brain-md-invariants-validator.test.cjs +704 -0
- package/lib/memory/brain-md-schema.test.cjs +467 -0
- package/lib/memory/brain-md-staleness.test.cjs +525 -0
- package/lib/memory/brain-server-resolution.test.cjs +314 -0
- package/lib/memory/brain-suggestion-template.test.cjs +200 -0
- package/lib/memory/chain-recommender-canonical.test.cjs +208 -0
- package/lib/memory/chain-recommender.test.cjs +233 -0
- package/lib/memory/chat-context.test.cjs +128 -0
- package/lib/memory/command-registry.test.cjs +220 -0
- package/lib/memory/connector-registry.test.cjs +94 -0
- package/lib/memory/correlation-label-index.test.cjs +119 -0
- package/lib/memory/correlation.test.cjs +253 -0
- package/lib/memory/cross-room-aggregator.test.cjs +909 -0
- package/lib/memory/curation-132-03-dedup-held-rename.test.cjs +251 -0
- package/lib/memory/curation-132-05-pseudonymize.test.cjs +205 -0
- package/lib/memory/curation-batch.test.cjs +213 -0
- package/lib/memory/dashboard-server.test.cjs +256 -0
- package/lib/memory/debouncer-drain-at-prompt.test.cjs +389 -0
- package/lib/memory/decision-capture.test.cjs +632 -0
- package/lib/memory/decision-capture.worker.cjs +70 -0
- package/lib/memory/doctor-deprecation-surface.test.cjs +188 -0
- package/lib/memory/dual-graph-health.test.cjs +485 -0
- package/lib/memory/explain-decision-command.test.cjs +521 -0
- package/lib/memory/explain-decision-footer.test.cjs +316 -0
- package/lib/memory/explored-materials-store.cjs +392 -0
- package/lib/memory/f-selector-ranker.test.cjs +593 -0
- package/lib/memory/feynman-minto-guardian.test.cjs +863 -0
- package/lib/memory/feynman-minto-invariants.test.cjs +554 -0
- package/lib/memory/feynman-prompts-drift.test.cjs +144 -0
- package/lib/memory/feynman-prompts.cjs +151 -0
- package/lib/memory/feynman-prompts.test.cjs +96 -0
- package/lib/memory/first-touch-version.test.cjs +198 -0
- package/lib/memory/folder-memory-quadruple.test.cjs +548 -0
- package/lib/memory/folder-memory.test.cjs +503 -0
- package/lib/memory/framework-chain-composer.test.cjs +549 -0
- package/lib/memory/frontmatter-schema-validator.test.cjs +344 -0
- package/lib/memory/guardian-onstop-reaches-user.test.cjs +396 -0
- package/lib/memory/heal-command.test.cjs +604 -0
- package/lib/memory/help-coverage.test.cjs +108 -0
- package/lib/memory/help-renderer.test.cjs +145 -0
- package/lib/memory/huji-run-one-async-parity.test.cjs +242 -0
- package/lib/memory/hypergraph-event-schema.test.cjs +116 -0
- package/lib/memory/index-artifact-transaction.test.cjs +333 -0
- package/lib/memory/lazygraph-rs-discoveries-view.test.cjs +122 -0
- package/lib/memory/local-chain-recommender.test.cjs +172 -0
- package/lib/memory/mcp-input-validation.test.cjs +240 -0
- package/lib/memory/mcp-server-brain-deps.test.cjs +270 -0
- package/lib/memory/mcp-stack-fallback.test.cjs +433 -0
- package/lib/memory/minto-debounce-consumer-census.test.cjs +567 -0
- package/lib/memory/minto-debouncer.test.cjs +407 -0
- package/lib/memory/minto-debouncer.worker.cjs +46 -0
- package/lib/memory/minto-migration-v88.test.cjs +265 -0
- package/lib/memory/minto-schema-v88.test.cjs +390 -0
- package/lib/memory/mos-status-renderer.test.cjs +631 -0
- package/lib/memory/narrative-schema.cjs +376 -0
- package/lib/memory/narrative-schema.test.cjs +209 -0
- package/lib/memory/nav-dial.test.cjs +414 -0
- package/lib/memory/navigation-engine-core.test.cjs +712 -0
- package/lib/memory/navigation-engine-offer.test.cjs +404 -0
- package/lib/memory/navigation-hook-resolver.test.cjs +177 -0
- package/lib/memory/navigation-invariants.test.cjs +483 -0
- package/lib/memory/navigation-projections.test.cjs +241 -0
- package/lib/memory/navigation-write-edge.test.cjs +206 -0
- package/lib/memory/offer-closer.test.cjs +258 -0
- package/lib/memory/offer-presenter.test.cjs +554 -0
- package/lib/memory/on-stop-snapshot.test.cjs +404 -0
- package/lib/memory/orchestration-projection.test.cjs +706 -0
- package/lib/memory/packet-chain-hint.test.cjs +407 -0
- package/lib/memory/packet-schema-validation.test.cjs +317 -0
- package/lib/memory/palette-consistency.test.cjs +127 -0
- package/lib/memory/pending-tension-store.cjs +453 -0
- package/lib/memory/per-command-jtbd-derivation.test.cjs +130 -0
- package/lib/memory/per-command-teaching.test.cjs +110 -0
- package/lib/memory/post-compact-reinjection.test.cjs +854 -0
- package/lib/memory/post-write-triple.test.cjs +317 -0
- package/lib/memory/pre-compact-snapshot.test.cjs +495 -0
- package/lib/memory/precommit-real-commit.test.cjs +301 -0
- package/lib/memory/problem-type-router.test.cjs +656 -0
- package/lib/memory/query-efficiency-telemetry.test.cjs +612 -0
- package/lib/memory/recompile-room-references.test.cjs +392 -0
- package/lib/memory/recompile-room-references.worker.cjs +42 -0
- package/lib/memory/record-decision-dual-write.test.cjs +454 -0
- package/lib/memory/render-v2-disposition.test.cjs +199 -0
- package/lib/memory/room-classifier-strict-mode.test.cjs +430 -0
- package/lib/memory/room-minto-hook.test.cjs +398 -0
- package/lib/memory/rs-discovery-engine.test.cjs +323 -0
- package/lib/memory/run-feynman-tests.cjs +2101 -0
- package/lib/memory/security-trifecta.test.cjs +329 -0
- package/lib/memory/selector-alias-map.test.cjs +172 -0
- package/lib/memory/selector-decisions.test.cjs +417 -0
- package/lib/memory/selector-miss.test.cjs +290 -0
- package/lib/memory/session-start-brain-staleness.test.cjs +363 -0
- package/lib/memory/session-start-triple-injection.test.cjs +514 -0
- package/lib/memory/sessionstart-banner-formatter.cjs +318 -0
- package/lib/memory/sessionstart-coordinator.test.cjs +446 -0
- package/lib/memory/sessionstart-minto-banner.test.cjs +373 -0
- package/lib/memory/skill-activation-router.test.cjs +465 -0
- package/lib/memory/skill-vs-code-drift.test.cjs +257 -0
- package/lib/memory/soft-alias.test.cjs +144 -0
- package/lib/memory/spine-events-correlation.test.cjs +198 -0
- package/lib/memory/stale-copy-scanner.test.cjs +294 -0
- package/lib/memory/stamp-artifact-write.test.cjs +304 -0
- package/lib/memory/state-aware-router.test.cjs +90 -0
- package/lib/memory/statusline-active-room-write.test.cjs +245 -0
- package/lib/memory/statusline-active-room.test.cjs +315 -0
- package/lib/memory/statusline-minto-segment.test.cjs +292 -0
- package/lib/memory/statusline-two-row.test.cjs +338 -0
- package/lib/memory/suggest-next-workflow.test.cjs +176 -0
- package/lib/memory/sync-async-entry-points.test.cjs +204 -0
- package/lib/memory/terminal-capability.test.cjs +155 -0
- package/lib/memory/test-bridge-writer-enhanced.cjs +452 -0
- package/lib/memory/test-rs-brain-substrate-shape.cjs +529 -0
- package/lib/memory/test-rs-brain-substrate.cjs +636 -0
- package/lib/memory/test-rs-breakthrough-scorer.cjs +375 -0
- package/lib/memory/test-rs-canon-violations.cjs +218 -0
- package/lib/memory/test-rs-chain-feeder-core.cjs +344 -0
- package/lib/memory/test-rs-chain-feeder-skill-spawn.cjs +297 -0
- package/lib/memory/test-rs-commercial-assessor.cjs +385 -0
- package/lib/memory/test-rs-differential-scorer.cjs +480 -0
- package/lib/memory/test-rs-discovery-engine.cjs +648 -0
- package/lib/memory/test-rs-domain-analyzer.cjs +492 -0
- package/lib/memory/test-rs-egress-primitives.cjs +420 -0
- package/lib/memory/test-rs-expert-mapper.cjs +547 -0
- package/lib/memory/test-rs-explain-command.cjs +443 -0
- package/lib/memory/test-rs-fetcher-academic.cjs +848 -0
- package/lib/memory/test-rs-fetcher-experts.cjs +496 -0
- package/lib/memory/test-rs-fetcher-industry.cjs +702 -0
- package/lib/memory/test-rs-fetcher-patents.cjs +674 -0
- package/lib/memory/test-rs-innovation-classifier.cjs +301 -0
- package/lib/memory/test-rs-mind-map.cjs +646 -0
- package/lib/memory/test-rs-neo4j-writer.cjs +518 -0
- package/lib/memory/test-rs-nl-to-query.cjs +449 -0
- package/lib/memory/test-rs-pinecone-bridge.cjs +282 -0
- package/lib/memory/test-rs-preprocessor.cjs +433 -0
- package/lib/memory/test-rs-query-matrix.cjs +391 -0
- package/lib/memory/test-rs-query-to-text.cjs +551 -0
- package/lib/memory/test-rs-sqlite-mirror.cjs +649 -0
- package/lib/memory/test-rs-thesis-generator.cjs +360 -0
- package/lib/memory/triple-context-formatter.cjs +473 -0
- package/lib/memory/triple-context-formatter.test.cjs +442 -0
- package/lib/memory/user-md-persona.test.cjs +565 -0
- package/lib/memory/userpromptsubmit-integration.test.cjs +787 -0
- package/lib/memory/validators/README.md +157 -0
- package/lib/memory/validators/brain-md-invariants.cjs +475 -0
- package/lib/memory/validators/brain-substrate-invariants.cjs +285 -0
- package/lib/memory/validators/external-academic-invariants.cjs +249 -0
- package/lib/memory/validators/external-industry-invariants.cjs +271 -0
- package/lib/memory/validators/external-patents-invariants.cjs +266 -0
- package/lib/memory/validators/minto-invariants.cjs +62 -0
- package/lib/memory/validators/navigation-invariants.cjs +340 -0
- package/lib/memory/validators/queue-health.cjs +95 -0
- package/lib/memory/validators/snapshot-integrity.cjs +129 -0
- package/lib/memory/validators/stale-lifecycle.cjs +116 -0
- package/lib/memory/vault-section-minto-generator-atomic.test.cjs +556 -0
- package/lib/memory/vault-section-minto-generator-atomic.worker.cjs +73 -0
- package/lib/memory/workflow-layer-e2e.test.cjs +262 -0
- package/lib/memory/write-lock-atomic.test.cjs +137 -0
- package/lib/memory/write-lock-atomic.worker.cjs +55 -0
- package/lib/parity/check-parity.cjs +83 -0
- package/lib/presentation/presentation-server.cjs +101 -0
- package/lib/presentation/presentation-watcher.cjs +123 -0
- package/lib/quickview/hub-server.cjs +719 -0
- package/lib/quickview/server.cjs +533 -0
- package/lib/render/JTBD-PALETTES.md +145 -0
- package/lib/render/ROOM.md +111 -0
- package/lib/render/render-v2.cjs +532 -0
- package/lib/render/render-v2.test.cjs +267 -0
- package/lib/render/render.cjs +65 -0
- package/lib/sessionstart/budget-compressor.cjs +130 -0
- package/lib/sessionstart/contributor-interface.cjs +134 -0
- package/lib/sessionstart/contributor-isolator.cjs +128 -0
- package/lib/sessionstart/precedence-ladder.cjs +47 -0
- package/lib/state/ROOM.md +46 -0
- package/lib/state/state-md-parser.cjs +215 -0
- package/lib/statusline/ROOM.md +38 -0
- package/lib/statusline/banner-suppression.cjs +50 -0
- package/lib/statusline/cockpit-renderer.cjs +443 -0
- package/lib/statusline/cockpit-signals.cjs +312 -0
- package/lib/statusline/cockpit-telemetry.cjs +152 -0
- package/lib/statusline/ctx-window.cjs +135 -0
- package/lib/statusline/governing-thought-truncator.cjs +45 -0
- package/lib/statusline/next-move-cache.cjs +235 -0
- package/lib/statusline/ratification-next.cjs +164 -0
- package/lib/statusline/room-health-cache.cjs +200 -0
- package/lib/statusline/surface-detect.cjs +85 -0
- package/lib/statusline/two-row-renderer.cjs +207 -0
- package/lib/statusline/version-resolver.cjs +81 -0
- package/lib/ui/design-system.cjs +19 -0
- package/lib/update-bootstrap.sh.template +145 -0
- package/lib/vault/frontmatter-schema.cjs +297 -0
- package/lib/vault/room-scanner.cjs +365 -0
- package/lib/vault/wikilink-builder.cjs +231 -0
- package/lib/vault/wikilink-builder.test.cjs +182 -0
- package/lib/wiki/briefing.cjs +193 -0
- package/lib/wiki/editor-dist/wiki-editor.css +1 -0
- package/lib/wiki/editor-dist/wiki-editor.js +1327 -0
- package/lib/wiki/graph-links.cjs +281 -0
- package/lib/wiki/page-renderer.cjs +229 -0
- package/lib/wiki/room-home.cjs +353 -0
- package/lib/wiki/wiki-chat.cjs +81 -0
- package/lib/wiki/wiki-export.cjs +364 -0
- package/lib/wiki/wiki-layout.cjs +1143 -0
- package/lib/wiki/wiki-search.cjs +142 -0
- package/lib/wiki/wiki-server.cjs +748 -0
- package/lib/wiki/wiki-watcher.cjs +105 -0
- package/lib/workflow/ROOM.md +47 -0
- package/lib/workflow/chain-source.cjs +179 -0
- package/lib/workflow/command-resolver.cjs +155 -0
- package/lib/workflow/command-resolver.test.cjs +235 -0
- package/lib/workflow/cross-room-umbilical-closer.cjs +364 -0
- package/lib/workflow/dial-close-reach.cjs +405 -0
- package/lib/workflow/f-selector-ranker.cjs +1148 -0
- package/lib/workflow/f1-pick-consumer.cjs +232 -0
- package/lib/workflow/f3-depth-consumer.cjs +98 -0
- package/lib/workflow/f4-scope-consumer.cjs +112 -0
- package/lib/workflow/f8-consumer.test.cjs +82 -0
- package/lib/workflow/f8-fanout-consumer.cjs +208 -0
- package/lib/workflow/f9-consumer.test.cjs +71 -0
- package/lib/workflow/f9-ordered-consumer.cjs +199 -0
- package/lib/workflow/local-chain-recommender.cjs +330 -0
- package/lib/workflow/memory-cascade-f9-adapter.cjs +273 -0
- package/lib/workflow/memory-governance-closer.cjs +384 -0
- package/lib/workflow/offer-closer.cjs +407 -0
- package/lib/workflow/reach-hedge-ranker.cjs +809 -0
- package/lib/workflow/reach-reject-reader.cjs +372 -0
- package/lib/workflow/reconcile-f9-adapter.cjs +299 -0
- package/lib/workflow/selector-decisions.cjs +478 -0
- package/lib/workflow/session-binding-consumer.cjs +249 -0
- package/npm-shrinkwrap.json +1544 -0
- package/output-styles/destijl.md +67 -0
- package/package.json +22 -4
- package/pipelines/PWS_grading/01-deep-grade.md +48 -0
- package/pipelines/PWS_grading/02-mullins.md +50 -0
- package/pipelines/PWS_grading/03-build-thesis.md +60 -0
- package/pipelines/PWS_grading/04-structure-argument.md +77 -0
- package/pipelines/PWS_grading/CHAIN.md +79 -0
- package/pipelines/analogy/01-decompose.md +80 -0
- package/pipelines/analogy/02-abstract.md +87 -0
- package/pipelines/analogy/03-search.md +135 -0
- package/pipelines/analogy/04-transfer.md +101 -0
- package/pipelines/analogy/05-validate.md +106 -0
- package/pipelines/analogy/CHAIN.md +73 -0
- package/pipelines/discovery/01-explore-domains.md +44 -0
- package/pipelines/discovery/02-think-hats.md +50 -0
- package/pipelines/discovery/03-analyze-needs.md +54 -0
- package/pipelines/discovery/CHAIN.md +48 -0
- package/pipelines/thesis/01-structure-argument.md +45 -0
- package/pipelines/thesis/02-challenge-assumptions.md +48 -0
- package/pipelines/thesis/03-build-thesis.md +54 -0
- package/pipelines/thesis/CHAIN.md +48 -0
- package/references/brain/causal-directives.md +91 -0
- package/references/brain/causal-enrichment.cypher +165 -0
- package/references/brain/command-triggers-schema.md +15 -0
- package/references/brain/graph-architecture.md +317 -0
- package/references/brain/query-patterns.md +504 -0
- package/references/brain/room-hierarchy-schema.md +224 -0
- package/references/brain/schema.md +86 -0
- package/references/capability-radar/capabilities-index.md +269 -0
- package/references/capability-radar/changelog-cache.md +95 -0
- package/references/causal/causal-schema.md +103 -0
- package/references/design/email-template-standard.md +169 -0
- package/references/design/graph-visualization-standard.md +178 -0
- package/references/design/newsletter-email-template.html +307 -0
- package/references/document-generation.md +179 -0
- package/references/hsi/HSI-TOOLS-REFERENCE.md +222 -0
- package/references/import-config.md +141 -0
- package/references/integrations/detection-patterns.md +101 -0
- package/references/meeting/artifact-template.md +377 -0
- package/references/meeting/cross-meeting-intelligence.md +216 -0
- package/references/meeting/cross-relationship-patterns.md +202 -0
- package/references/meeting/extraction-perspectives.md +225 -0
- package/references/meeting/filing-protocol.md +222 -0
- package/references/meeting/knowledge-typing.md +242 -0
- package/references/meeting/live-join-interface.md +244 -0
- package/references/meeting/section-mapping.md +192 -0
- package/references/meeting/segment-classification.md +258 -0
- package/references/meeting/speaker-profile-template.md +219 -0
- package/references/meeting/summary-template.md +348 -0
- package/references/meeting/transcript-patterns.md +226 -0
- package/references/methodology/analyze-needs.md +135 -0
- package/references/methodology/analyze-systems.md +121 -0
- package/references/methodology/analyze-timing.md +149 -0
- package/references/methodology/beautiful-question.md +109 -0
- package/references/methodology/build-knowledge.md +161 -0
- package/references/methodology/build-thesis-scored.md +60 -0
- package/references/methodology/build-thesis.md +237 -0
- package/references/methodology/causal-loop-diagrams.md +65 -0
- package/references/methodology/challenge-assumptions.md +127 -0
- package/references/methodology/diagnose.md +169 -0
- package/references/methodology/dominant-designs.md +212 -0
- package/references/methodology/explore-domains.md +147 -0
- package/references/methodology/explore-futures.md +163 -0
- package/references/methodology/explore-trends.md +129 -0
- package/references/methodology/find-bottlenecks.md +131 -0
- package/references/methodology/grade.md +211 -0
- package/references/methodology/huji-stage-a-intake.md +246 -0
- package/references/methodology/index.md +34 -0
- package/references/methodology/leadership.md +200 -0
- package/references/methodology/lean-canvas.md +116 -0
- package/references/methodology/leverage-scan-signatures.md +83 -0
- package/references/methodology/macro-trends.md +192 -0
- package/references/methodology/map-unknowns.md +137 -0
- package/references/methodology/mullins-7-domains.md +104 -0
- package/references/methodology/problem-types.md +65 -0
- package/references/methodology/root-cause.md +178 -0
- package/references/methodology/rubric-huji.md +160 -0
- package/references/methodology/sapphire-encoding.md +355 -0
- package/references/methodology/scenario-plan.md +190 -0
- package/references/methodology/score-innovation.md +154 -0
- package/references/methodology/skillopt-judge-rubric.md +48 -0
- package/references/methodology/skillopt-queries-rubric.md +60 -0
- package/references/methodology/skillopt-refute-rubric.md +59 -0
- package/references/methodology/skillopt-review-rubric.md +72 -0
- package/references/methodology/skillopt-revise-rubric.md +48 -0
- package/references/methodology/structure-argument.md +158 -0
- package/references/methodology/systems-thinking.md +231 -0
- package/references/methodology/think-hats.md +147 -0
- package/references/methodology/triz-matrix.json +751 -0
- package/references/methodology/triz-principles.md +501 -0
- package/references/methodology/user-needs.md +199 -0
- package/references/methodology/validate.md +163 -0
- package/references/methodology/value-proposition.md +244 -0
- package/references/opportunities/funding-lifecycle.md +103 -0
- package/references/opportunities/grant-api-patterns.md +99 -0
- package/references/opportunities/opportunity-template.md +84 -0
- package/references/opportunities/tnufa-rubric.md +81 -0
- package/references/personality/assessment-philosophy.md +72 -0
- package/references/personality/lexicon.md +100 -0
- package/references/personality/persona-chains.md +56 -0
- package/references/personality/pws-lexicon-full.md +499 -0
- package/references/personality/voice-dna.md +156 -0
- package/references/personas/hat-perspectives.md +76 -0
- package/references/personas/persona-template.md +63 -0
- package/references/pipeline/act-output-contract.md +88 -0
- package/references/pipeline/chains-index.md +39 -0
- package/references/pws-profile-generation.md +79 -0
- package/references/reasoning/reasoning-schema.md +143 -0
- package/references/reasoning/reasoning-template.md +68 -0
- package/references/reasoning/run-template.md +38 -0
- package/references/research/RESEARCH_14_CLAUDE_CODE_SOURCE_ARCHITECTURE.md +209 -0
- package/references/research/RESEARCH_15_V1.8_OPTIMIZATION_JTBD.md +375 -0
- package/references/research/RESEARCH_16_NATIVE_FIRST_PLUGIN_ARCHITECTURE.md +575 -0
- package/references/research/RESEARCH_17_MCP_UI_FRAMEWORKS.md +272 -0
- package/references/security/agentshield-baseline.json +8 -0
- package/references/security/cve-db.json +220 -0
- package/references/taxonomy/TAXONOMY.md +192 -0
- package/references/templates/MINTO.md +36 -0
- package/references/user-research/2026-04-05-leah-lawrence-session.md +202 -0
- package/references/vault-kit/README.md +35 -0
- package/references/vault-kit/app.json +12 -0
- package/references/vault-kit/appearance.json +12 -0
- package/references/vault-kit/graph.json +35 -0
- package/references/vault-kit/snippets/mindrian-destijl.css +297 -0
- package/references/vault-kit/templates/new-artifact.md +37 -0
- package/references/vault-kit/templates/new-meeting-note.md +35 -0
- package/references/vault-kit/templates/new-team-profile.md +29 -0
- package/references/vault-kit/templates/new-xref.md +35 -0
- package/references/visual/ROOM.md +55 -0
- package/references/visual/palette.json +54 -0
- package/references/visual/symbol-system.md +151 -0
- package/scripts/189-plurai-gate-check.cjs +88 -0
- package/scripts/198-plurai-gate-check.cjs +118 -0
- package/scripts/198-rollback-rehearsal.cjs +233 -0
- package/scripts/83-scope-injection.test.cjs +648 -0
- package/scripts/PYTHON_GATES.md +78 -0
- package/scripts/__pycache__/compute-hsi.cpython-312.pyc +0 -0
- package/scripts/__pycache__/detect-reverse-salients.cpython-312.pyc +0 -0
- package/scripts/__pycache__/rs-engine.cpython-312.pyc +0 -0
- package/scripts/act-command.cjs +518 -0
- package/scripts/admin-brain-write.cjs +442 -0
- package/scripts/admin-command-gate.cjs +178 -0
- package/scripts/agentshield-scan-cli.cjs +226 -0
- package/scripts/agentshield-sessionstart-scan.cjs +282 -0
- package/scripts/analogy-fitness-report.cjs +266 -0
- package/scripts/analyze-room +1079 -0
- package/scripts/apply-teaching-content.cjs +298 -0
- package/scripts/async-artifact-auto-commit.cjs +485 -0
- package/scripts/audit-active-phase-resolver.cjs +160 -0
- package/scripts/audit-body-shape-coverage.cjs +213 -0
- package/scripts/auto-explore-drain.cjs +274 -0
- package/scripts/auto-explore-fingerprint.cjs +354 -0
- package/scripts/auto-explore-fire.cjs +359 -0
- package/scripts/backfill-correlation-id.cjs +425 -0
- package/scripts/backfill-hitl-shape.cjs +276 -0
- package/scripts/backfill-hitl-shape.test.cjs +307 -0
- package/scripts/backup-modifications +68 -0
- package/scripts/banner +182 -0
- package/scripts/brain-derivation-drain.cjs +291 -0
- package/scripts/brain-derive-command.cjs +846 -0
- package/scripts/brain-normalize-books.cypher +505 -0
- package/scripts/brain-normalize-final.cypher +1355 -0
- package/scripts/brain-normalize-problemtype.cypher +475 -0
- package/scripts/brain-normalize-supplement.cypher +449 -0
- package/scripts/brain-normalize-targeted.cypher +344 -0
- package/scripts/brain-normalize-v194.cypher +61 -0
- package/scripts/brain-normalize.cypher +530 -0
- package/scripts/brain-response-sanitize-hook.cjs +165 -0
- package/scripts/build-brain-census.cjs +957 -0
- package/scripts/build-brain-packet-schema.cjs +225 -0
- package/scripts/build-command-registry.cjs +587 -0
- package/scripts/build-connector-registry.cjs +1331 -0
- package/scripts/build-corpus-stats.cjs +408 -0
- package/scripts/build-dist-bundles.cjs +495 -0
- package/scripts/build-ecosystem-graph.cjs +490 -0
- package/scripts/build-graph +1462 -0
- package/scripts/build-graph-from-sqlite.cjs +97 -0
- package/scripts/build-harness-manifest.cjs +1090 -0
- package/scripts/build-jtbd-nudges +205 -0
- package/scripts/build-new-surface.cjs +805 -0
- package/scripts/build-orchestration-projection.cjs +1221 -0
- package/scripts/build-render-coverage.cjs +637 -0
- package/scripts/build-skill-mirrors.cjs +681 -0
- package/scripts/cache-hitrate-report.cjs +216 -0
- package/scripts/causal-to-graph.cjs +163 -0
- package/scripts/check-abstraction-fixture-neutral.cjs +160 -0
- package/scripts/check-admin-identity.cjs +212 -0
- package/scripts/check-brain-tool-liveness.cjs +502 -0
- package/scripts/check-card-fire.cjs +1809 -0
- package/scripts/check-cirs-declaration.cjs +279 -0
- package/scripts/check-deck-design.cjs +104 -0
- package/scripts/check-dual-graph-health.cjs +645 -0
- package/scripts/check-first-touch-drift.cjs +220 -0
- package/scripts/check-flagship-floor.cjs +391 -0
- package/scripts/check-framework-vocabulary-drift.cjs +563 -0
- package/scripts/check-gate-seam.cjs +178 -0
- package/scripts/check-graph-derive-health.cjs +208 -0
- package/scripts/check-graph-export-typemap.cjs +118 -0
- package/scripts/check-help-coverage.cjs +290 -0
- package/scripts/check-hitl-stages.cjs +219 -0
- package/scripts/check-hook-schema-compatibility.cjs +231 -0
- package/scripts/check-hsi-deps +42 -0
- package/scripts/check-kuzu-reintroduction.cjs +251 -0
- package/scripts/check-onboard +43 -0
- package/scripts/check-onboard-statusline.cjs +363 -0
- package/scripts/check-palette-consistency.cjs +106 -0
- package/scripts/check-pending-ambiguous.cjs +244 -0
- package/scripts/check-pending-breakthrough.cjs +189 -0
- package/scripts/check-pending-breakthrough.test.cjs +166 -0
- package/scripts/check-pending-naming-decision.cjs +97 -0
- package/scripts/check-plugin-path-anchoring.cjs +830 -0
- package/scripts/check-publish-needs.cjs +126 -0
- package/scripts/check-registry-drift.cjs +206 -0
- package/scripts/check-release-payload-ceiling.cjs +269 -0
- package/scripts/check-render-coverage.cjs +558 -0
- package/scripts/check-research-isomorphism.cjs +446 -0
- package/scripts/check-reward-before-investment.cjs +261 -0
- package/scripts/check-room-blueprints.cjs +213 -0
- package/scripts/check-schema-aliases.cjs +532 -0
- package/scripts/check-shape-declaration.cjs +958 -0
- package/scripts/check-shape-declaration.test.cjs +185 -0
- package/scripts/check-skill-spec.cjs +312 -0
- package/scripts/check-skill-vs-code-drift.cjs +178 -0
- package/scripts/check-substrate.cjs +513 -0
- package/scripts/check-tool-honesty.cjs +1601 -0
- package/scripts/check-update +60 -0
- package/scripts/check-version-and-sha.cjs +366 -0
- package/scripts/check-voice-style.cjs +184 -0
- package/scripts/check-worktree-hygiene.cjs +530 -0
- package/scripts/classify-insight +59 -0
- package/scripts/coherence-smoke-test.cjs +489 -0
- package/scripts/collect-cold-install-evidence.cjs +411 -0
- package/scripts/compute-bayesian-surprise.py +175 -0
- package/scripts/compute-blindspot-mass.py +209 -0
- package/scripts/compute-disruption-index.py +211 -0
- package/scripts/compute-element-novelty.py +254 -0
- package/scripts/compute-external-whitespace.py +563 -0
- package/scripts/compute-hsi.py +947 -0
- package/scripts/compute-meetings-intelligence +716 -0
- package/scripts/compute-opportunity-state +17 -0
- package/scripts/compute-state +393 -0
- package/scripts/compute-team +1112 -0
- package/scripts/compute-whitespace-embeddings.py +464 -0
- package/scripts/compute-whitespace-gaps.py +562 -0
- package/scripts/compute_topic_forest.py +684 -0
- package/scripts/consolidate-pinecone.py +265 -0
- package/scripts/context-monitor +943 -0
- package/scripts/create-speaker-profile +311 -0
- package/scripts/cross-room-detect.cjs +195 -0
- package/scripts/csv-to-idea-graph.cjs +755 -0
- package/scripts/ctxl-eval.cjs +846 -0
- package/scripts/curation-132-03-dedup-held-rename.cjs +395 -0
- package/scripts/curation-132-05-pseudonymize.cjs +189 -0
- package/scripts/derive-verb-reach-affinity.cjs +507 -0
- package/scripts/detect-reverse-salients.py +242 -0
- package/scripts/diagnostics-command.cjs +345 -0
- package/scripts/dial-memory-refresh-command.cjs +147 -0
- package/scripts/discover-analogy-whitespace.py +433 -0
- package/scripts/discover-hsi-whitespace.py +352 -0
- package/scripts/discover-rs-whitespace.py +327 -0
- package/scripts/discovery-cycle.cjs +625 -0
- package/scripts/disposition-render-v2.cjs +229 -0
- package/scripts/doctor-preflight-format.cjs +101 -0
- package/scripts/doctor.cjs +4327 -0
- package/scripts/dogfood-bridge/append-to-queue.sh +59 -0
- package/scripts/dogfood-bridge/path-filter.cjs +86 -0
- package/scripts/dogfood-derive.cjs +158 -0
- package/scripts/dogfood-emit.cjs +126 -0
- package/scripts/empathy-observation-emit.cjs +108 -0
- package/scripts/enrichment-queue-append.cjs +157 -0
- package/scripts/ensure-brain-baseline.cjs +117 -0
- package/scripts/entity-extract.cjs +1135 -0
- package/scripts/eureka-command.cjs +687 -0
- package/scripts/eureka-critic-run.cjs +662 -0
- package/scripts/eureka-portfolio-report.cjs +2038 -0
- package/scripts/eureka-room-report.cjs +419 -0
- package/scripts/explain-decision-command.cjs +499 -0
- package/scripts/export-pinecone-embeddings.cjs +516 -0
- package/scripts/extract-room-intelligence.cjs +714 -0
- package/scripts/fetch-brain-baseline.cjs +190 -0
- package/scripts/fetch-brain-baseline.py +360 -0
- package/scripts/feynman-minto-guardian.cjs +672 -0
- package/scripts/feynman-timeline-refresh-command.cjs +270 -0
- package/scripts/file-asset +253 -0
- package/scripts/fire-sensor-event.cjs +83 -0
- package/scripts/first-install-router.cjs +968 -0
- package/scripts/frontmatter-schema-validator.cjs +339 -0
- package/scripts/fts-index-drain.cjs +221 -0
- package/scripts/generate-chat-embed.cjs +179 -0
- package/scripts/generate-deck.cjs +322 -0
- package/scripts/generate-export.cjs +474 -0
- package/scripts/generate-hub.cjs +2553 -0
- package/scripts/generate-lobby.cjs +718 -0
- package/scripts/generate-presentation.cjs +988 -0
- package/scripts/generate-presentation.test.cjs +405 -0
- package/scripts/generate-section-intelligence.cjs +330 -0
- package/scripts/generate-snapshot.cjs +1410 -0
- package/scripts/generate-standalone +159 -0
- package/scripts/git-ops +211 -0
- package/scripts/graph-heal-pipeline.cjs +321 -0
- package/scripts/gsd-artifact-graph-hook.cjs +219 -0
- package/scripts/gsd-graph-derive-drain.cjs +571 -0
- package/scripts/gsd-graph-derive-sweep.cjs +195 -0
- package/scripts/heal-command.cjs +1365 -0
- package/scripts/hedge-refit-pipeline.cjs +207 -0
- package/scripts/help-renderer.cjs +303 -0
- package/scripts/hmi-compliance-poll.cjs +451 -0
- package/scripts/hmi-status-command.cjs +510 -0
- package/scripts/hooked-rescore-117.cjs +224 -0
- package/scripts/hooks/pre-commit +533 -0
- package/scripts/hooks/pre-commit-room-minto-guard.cmd +43 -0
- package/scripts/hooks/pre-commit-room-minto-guard.sh +533 -0
- package/scripts/hsi-to-graph.cjs +194 -0
- package/scripts/huji-batch.cjs +821 -0
- package/scripts/huji-eval.cjs +1158 -0
- package/scripts/huji-intake.cjs +563 -0
- package/scripts/huji-pin-smoketest.cjs +454 -0
- package/scripts/huji-run-one-async.cjs +305 -0
- package/scripts/huji-run-one.cjs +671 -0
- package/scripts/install-pre-commit.sh +113 -0
- package/scripts/intent-classifier +106 -0
- package/scripts/intent-classifier.cjs +3620 -0
- package/scripts/interpret-whitespace.cjs +691 -0
- package/scripts/jtbd-command.cjs +810 -0
- package/scripts/jtbd-update.cjs +299 -0
- package/scripts/label-topic-forest.cjs +667 -0
- package/scripts/learn-from-usage +168 -0
- package/scripts/lib/__pycache__/ensure_ml_deps.cpython-312.pyc +0 -0
- package/scripts/lib/ensure_ml_deps.py +97 -0
- package/scripts/load-embeddings-into-neo4j.cjs +569 -0
- package/scripts/memory-artifact-graph-hook.cjs +191 -0
- package/scripts/memory-command.cjs +687 -0
- package/scripts/memory-completion-detector.cjs +217 -0
- package/scripts/memory-lifecycle.cjs +620 -0
- package/scripts/memory-resume-nudge.cjs +233 -0
- package/scripts/methodology-ingest-local.sh +36 -0
- package/scripts/migrate-brain-mcp-from-http-to-stdio.cjs +190 -0
- package/scripts/migrate-brain-mcp-from-http-to-stdio.test.cjs +242 -0
- package/scripts/migrate-hats-to-roomdb.cjs +217 -0
- package/scripts/migrate-lazygraph.cjs +250 -0
- package/scripts/migrate-minto-schema-v88.cjs +296 -0
- package/scripts/migrate-plugin-root-refs.cjs +168 -0
- package/scripts/migrate-room-sections-v275.cjs +556 -0
- package/scripts/migrate-rooms +417 -0
- package/scripts/migrate-skill-frontmatter.cjs +472 -0
- package/scripts/migrate-stale-user-settings.cjs +296 -0
- package/scripts/migrate-telemetry-v1.cjs +384 -0
- package/scripts/migrate-telemetry-v1.test.cjs +356 -0
- package/scripts/minto-debouncer.cjs +428 -0
- package/scripts/mos-status.cjs +622 -0
- package/scripts/mva-detect.cjs +229 -0
- package/scripts/mva-run.cjs +36 -0
- package/scripts/on-agent-complete +163 -0
- package/scripts/on-cwd-changed +149 -0
- package/scripts/on-file-changed +68 -0
- package/scripts/on-stop +617 -0
- package/scripts/on-task-complete +194 -0
- package/scripts/operator-command.cjs +858 -0
- package/scripts/operator-update.cjs +308 -0
- package/scripts/part8-egress-guard-hook.cjs +229 -0
- package/scripts/pipeline-command.cjs +271 -0
- package/scripts/post-compact +383 -0
- package/scripts/post-update-activation.cjs +339 -0
- package/scripts/post-write +283 -0
- package/scripts/power-demo-prompt.md +621 -0
- package/scripts/pre-compact +273 -0
- package/scripts/preflight-auto-explore.cjs +314 -0
- package/scripts/preflight-doctor.cjs +225 -0
- package/scripts/preflight-release-drift.cjs +168 -0
- package/scripts/preflight-tension-surface.cjs +414 -0
- package/scripts/probe-brain-contract.cjs +502 -0
- package/scripts/publish-ops +346 -0
- package/scripts/query-efficiency-telemetry.cjs +364 -0
- package/scripts/query-semantic-scholar.cjs +545 -0
- package/scripts/reapply-modifications +49 -0
- package/scripts/reassign-primary.cjs +125 -0
- package/scripts/recompile-room-references.cjs +601 -0
- package/scripts/release-beta-preflight.sh +69 -0
- package/scripts/render-pdf +588 -0
- package/scripts/render-viz +190 -0
- package/scripts/research-speaker +239 -0
- package/scripts/resolve-room +204 -0
- package/scripts/restore-post-compact-context.cjs +320 -0
- package/scripts/room-auto-create-nudge.cjs +136 -0
- package/scripts/room-naming-selector.cjs +201 -0
- package/scripts/room-registry +767 -0
- package/scripts/rs-discovery-engine.cjs +725 -0
- package/scripts/rs-engine.py +2073 -0
- package/scripts/rs-experts-command.cjs +300 -0
- package/scripts/rs-explain-command.cjs +323 -0
- package/scripts/rs-fetch-command.cjs +170 -0
- package/scripts/rs-thesis-command.cjs +203 -0
- package/scripts/rs-vector-bridge.cjs +410 -0
- package/scripts/run-harness.cjs +890 -0
- package/scripts/scout-cadence-guard.cjs +323 -0
- package/scripts/scout-cadence-runner.cjs +509 -0
- package/scripts/scout-telemetry-aggregator.cjs +268 -0
- package/scripts/sealed-walker.py +96 -0
- package/scripts/seed-brain-commands.cjs +324 -0
- package/scripts/self-update +105 -0
- package/scripts/sentinel-deadline-monitor +241 -0
- package/scripts/sentinel-health-check +198 -0
- package/scripts/sentinel-snapshot +42 -0
- package/scripts/serve-dashboard +103 -0
- package/scripts/serve-dashboard-live +932 -0
- package/scripts/serve-presentation +97 -0
- package/scripts/serve-wiki +90 -0
- package/scripts/session-end-presence.cjs +79 -0
- package/scripts/session-start +1943 -0
- package/scripts/sessionstart-coordinator.cjs +249 -0
- package/scripts/sessionstart-npm-reconcile.cjs +111 -0
- package/scripts/sessionstart-post-update-preflight.cjs +303 -0
- package/scripts/sessionstart-reference-now-seed.cjs +137 -0
- package/scripts/setup-hooks.sh +112 -0
- package/scripts/skillopt-codereview.cjs +830 -0
- package/scripts/skillopt-eval.cjs +519 -0
- package/scripts/skillopt-funnel.cjs +1076 -0
- package/scripts/skillopt-genqueries.cjs +571 -0
- package/scripts/skillopt-inventory.cjs +319 -0
- package/scripts/skillopt-merge.cjs +656 -0
- package/scripts/skillopt-triggerloop.cjs +1126 -0
- package/scripts/soft-alias-runner.cjs +116 -0
- package/scripts/stamp-artifact-write.cjs +276 -0
- package/scripts/stamp-firing-block.cjs +325 -0
- package/scripts/state-write.cjs +97 -0
- package/scripts/statusline-fallback-echo.cjs +297 -0
- package/scripts/statusline-mos +116 -0
- package/scripts/statusline-mos-dispatch +127 -0
- package/scripts/suggest-next-command.cjs +416 -0
- package/scripts/sweep-skill-descriptions.cjs +263 -0
- package/scripts/sync-rooms-graph +264 -0
- package/scripts/telemetry-command-invocation.cjs +120 -0
- package/scripts/test-doctor-recovery.cjs +242 -0
- package/scripts/test-fresh-install.md +140 -0
- package/scripts/track-analytics +156 -0
- package/scripts/transcribe-audio +148 -0
- package/scripts/transcript-ingest.cjs +225 -0
- package/scripts/update-icm-index +153 -0
- package/scripts/v182-brain-optimize.cypher +1191 -0
- package/scripts/validate-model-profiles +93 -0
- package/scripts/vault-content-reformatter.cjs +581 -0
- package/scripts/vault-export-orchestrator.cjs +400 -0
- package/scripts/vault-footer-injector.cjs +315 -0
- package/scripts/vault-import.cjs +839 -0
- package/scripts/vault-integration-test.cjs +318 -0
- package/scripts/vault-regenerate-all.cjs +216 -0
- package/scripts/vault-regenerate-all.test.cjs +138 -0
- package/scripts/vault-rules-generator.cjs +220 -0
- package/scripts/vault-section-minto-generator.cjs +1642 -0
- package/scripts/vault-section-minto-generator.integration.test.cjs +576 -0
- package/scripts/vault-section-minto-generator.test.cjs +291 -0
- package/scripts/vault-section-state-generator.cjs +385 -0
- package/scripts/vault-welcome-generator.cjs +403 -0
- package/scripts/vault-wikilink-injector.cjs +449 -0
- package/scripts/verify-phase-132.cjs +338 -0
- package/scripts/verify-release +744 -0
- package/scripts/whitespace-command.cjs +831 -0
- package/scripts/whitespace-to-brain.cjs +384 -0
- package/scripts/whitespace-to-graph.cjs +220 -0
- package/scripts/wikilink-batch.cjs +102 -0
- package/scripts/wikilink-file.cjs +139 -0
- package/scripts/write-bridge-artifacts.cjs +140 -0
- package/scripts/write-scope-check +12 -0
- package/scripts/write-scope-check.cjs +461 -0
- package/scripts/write-whitespace-sections.cjs +483 -0
- package/settings.json +7 -0
- package/skills/act/SKILL.md +523 -0
- package/skills/admin/SKILL.md +437 -0
- package/skills/agentshield/SKILL.md +50 -0
- package/skills/analyze-needs/SKILL.md +74 -0
- package/skills/analyze-systems/SKILL.md +69 -0
- package/skills/analyze-timing/SKILL.md +94 -0
- package/skills/auto-explore/SKILL.md +84 -0
- package/skills/beautiful-question/SKILL.md +72 -0
- package/skills/bono/SKILL.md +146 -0
- package/skills/brain-connector/SKILL.md +206 -0
- package/skills/brain-derive/SKILL.md +140 -0
- package/skills/build-knowledge/SKILL.md +118 -0
- package/skills/build-thesis/SKILL.md +90 -0
- package/skills/causal/SKILL.md +265 -0
- package/skills/challenge-assumptions/SKILL.md +74 -0
- package/skills/client-discovery-interview/SKILL.md +94 -0
- package/skills/client-discovery-interview/discovery-scaffold.json +41 -0
- package/skills/client-discovery-interview/question-bank.md +149 -0
- package/skills/compare-ventures/SKILL.md +113 -0
- package/skills/context-engine/SKILL.md +169 -0
- package/skills/conversation-mode/SKILL.md +189 -0
- package/skills/correct-reference-now/SKILL.md +86 -0
- package/skills/dashboard/SKILL.md +142 -0
- package/skills/deck/SKILL.md +113 -0
- package/skills/deep-grade/SKILL.md +210 -0
- package/skills/diagnose/SKILL.md +128 -0
- package/skills/diagnostics/SKILL.md +193 -0
- package/skills/dial-memory-refresh/SKILL.md +116 -0
- package/skills/diffusion/SKILL.md +125 -0
- package/skills/discover/SKILL.md +216 -0
- package/skills/doctor/SKILL.md +269 -0
- package/skills/dogfood-flush/SKILL.md +133 -0
- package/skills/dominant-designs/SKILL.md +72 -0
- package/skills/eureka/SKILL.md +313 -0
- package/skills/explain-decision/SKILL.md +138 -0
- package/skills/explore-domains/SKILL.md +74 -0
- package/skills/explore-futures/SKILL.md +64 -0
- package/skills/explore-opportunity/SKILL.md +168 -0
- package/skills/explore-trends/SKILL.md +74 -0
- package/skills/export/SKILL.md +126 -0
- package/skills/feynman-timeline-refresh/SKILL.md +105 -0
- package/skills/file-meeting/SKILL.md +1190 -0
- package/skills/find-analogies/SKILL.md +360 -0
- package/skills/find-bottlenecks/SKILL.md +104 -0
- package/skills/find-connections/SKILL.md +108 -0
- package/skills/funding/SKILL.md +110 -0
- package/skills/futures/SKILL.md +124 -0
- package/skills/grade/SKILL.md +252 -0
- package/skills/grade-grant/SKILL.md +293 -0
- package/skills/graph/SKILL.md +216 -0
- package/skills/hat-briefing/SKILL.md +160 -0
- package/skills/heal/SKILL.md +69 -0
- package/skills/help/SKILL.md +172 -0
- package/skills/hmi-status/SKILL.md +73 -0
- package/skills/ignite/SKILL.md +225 -0
- package/skills/ingest-methodology/SKILL.md +125 -0
- package/skills/intel-pipeline/SKILL.md +128 -0
- package/skills/intelligence-orchestrator/SKILL.md +262 -0
- package/skills/jtbd/SKILL.md +261 -0
- package/skills/larry-personality/SKILL.md +571 -0
- package/skills/larry-personality/framework-chains.md +92 -0
- package/skills/larry-personality/mode-engine.md +185 -0
- package/skills/leadership/SKILL.md +109 -0
- package/skills/lean-canvas/SKILL.md +70 -0
- package/skills/macro-trends/SKILL.md +84 -0
- package/skills/map-unknowns/SKILL.md +72 -0
- package/skills/memory/SKILL.md +212 -0
- package/skills/memory-cortex-reach/SKILL.md +80 -0
- package/skills/models/SKILL.md +197 -0
- package/skills/mos/SKILL.md +160 -0
- package/skills/mos-deck-engine/SKILL.md +329 -0
- package/skills/mos-reason/SKILL.md +484 -0
- package/skills/mullins/SKILL.md +151 -0
- package/skills/mullins-scaffold/SKILL.md +132 -0
- package/skills/mullins-scaffold/scaffold.json +223 -0
- package/skills/mva-brief/SKILL.md +87 -0
- package/skills/mva-option/SKILL.md +120 -0
- package/skills/mva-pipeline/SKILL.md +158 -0
- package/skills/mva-report/SKILL.md +79 -0
- package/skills/new-project/SKILL.md +629 -0
- package/skills/new-surface/SKILL.md +112 -0
- package/skills/onboard/SKILL.md +485 -0
- package/skills/operator/SKILL.md +167 -0
- package/skills/opportunities/SKILL.md +171 -0
- package/skills/organize/SKILL.md +69 -0
- package/skills/persona/SKILL.md +272 -0
- package/skills/pipeline/SKILL.md +164 -0
- package/skills/present/SKILL.md +123 -0
- package/skills/publish/SKILL.md +224 -0
- package/skills/pws-brain/SKILL.md +152 -0
- package/skills/pws-methodology/SKILL.md +92 -0
- package/skills/qualify-opportunity/SKILL.md +111 -0
- package/skills/query/SKILL.md +68 -0
- package/skills/radar/SKILL.md +106 -0
- package/skills/reanalyze/SKILL.md +122 -0
- package/skills/research/SKILL.md +462 -0
- package/skills/room/SKILL.md +381 -0
- package/skills/room-passive/SKILL.md +174 -0
- package/skills/room-proactive/SKILL.md +344 -0
- package/skills/rooms/SKILL.md +678 -0
- package/skills/root-cause/SKILL.md +73 -0
- package/skills/rs-experts/SKILL.md +151 -0
- package/skills/rs-explain/SKILL.md +130 -0
- package/skills/rs-fetch/SKILL.md +115 -0
- package/skills/rs-thesis/SKILL.md +129 -0
- package/skills/scenario-plan/SKILL.md +76 -0
- package/skills/scheduled-tasks/SKILL.md +301 -0
- package/skills/score-innovation/SKILL.md +74 -0
- package/skills/scout/SKILL.md +370 -0
- package/skills/setup/SKILL.md +654 -0
- package/skills/show/SKILL.md +68 -0
- package/skills/skill/SKILL.md +104 -0
- package/skills/snapshot/SKILL.md +178 -0
- package/skills/speakers/SKILL.md +116 -0
- package/skills/splash/SKILL.md +54 -0
- package/skills/stance/SKILL.md +89 -0
- package/skills/status/SKILL.md +107 -0
- package/skills/structure-argument/SKILL.md +78 -0
- package/skills/suggest-next/SKILL.md +137 -0
- package/skills/systems-thinking/SKILL.md +220 -0
- package/skills/think-hats/SKILL.md +82 -0
- package/skills/trending-to-absurd/SKILL.md +100 -0
- package/skills/ui-system/SKILL.md +474 -0
- package/skills/ui-system/design-system/M-OS-DESIGN-SYSTEM.md +273 -0
- package/skills/ui-system/design-system/SPEC.md +72 -0
- package/skills/ui-system/design-system/image-prompt-style.md +29 -0
- package/skills/ui-system/design-system/mos-design-system.css +240 -0
- package/skills/ui-system/rules/design-system.md +60 -0
- package/skills/ui-system/rules/dual-palette.md +156 -0
- package/skills/ui-system/rules/glyph-disambiguation.md +171 -0
- package/skills/ui-system/rules/shape-f-zero-and-six.md +169 -0
- package/skills/update/SKILL.md +254 -0
- package/skills/user-needs/SKILL.md +73 -0
- package/skills/validate/SKILL.md +73 -0
- package/skills/value-proposition/SKILL.md +141 -0
- package/skills/vault/SKILL.md +326 -0
- package/skills/visualize/SKILL.md +69 -0
- package/skills/whitespace/SKILL.md +539 -0
- package/skills/wiki/SKILL.md +94 -0
- package/templates/_base.html +20 -0
- package/templates/chat-panel.html +205 -0
- package/templates/constellation-chat-hooks.js +89 -0
- package/templates/constellation.html +1272 -0
- package/templates/destijl-base.css +268 -0
- package/templates/discovery/discovery-brief-template.md +97 -0
- package/templates/due-diligence.html +49 -0
- package/templates/executive-summary.html +40 -0
- package/templates/icm/CLAUDE.md +31 -0
- package/templates/icm/GROUP-CLAUDE.md +33 -0
- package/templates/icm/INDEX.md +26 -0
- package/templates/import/stage-contracts/01-ingest.md +34 -0
- package/templates/import/stage-contracts/02-classify.md +48 -0
- package/templates/import/stage-contracts/03-route.md +42 -0
- package/templates/import/stage-contracts/04-enrich.md +40 -0
- package/templates/investment-thesis.html +25 -0
- package/templates/meeting-report.html +361 -0
- package/templates/presentation/dashboard.html +1150 -0
- package/templates/presentation/deck.html +540 -0
- package/templates/presentation/diagrams.html +437 -0
- package/templates/presentation/graph.html +391 -0
- package/templates/presentation/insights.html +548 -0
- package/templates/presentation/wiki.html +533 -0
- package/templates/profile.html +136 -0
- package/templates/room-context/last-session.md +56 -0
- package/templates/room-context/methodology-history.md +28 -0
- package/templates/room-context/rejection-log.md +25 -0
- package/templates/room-context/weekly-digest.md +54 -0
- package/templates/room-skeleton/MINTO.md.tmpl +19 -0
- package/templates/room-skeleton/ROOM.md.identity.tmpl +13 -0
- package/templates/room-skeleton/ROOM.md.section.tmpl +33 -0
- package/templates/room-skeleton/STATE.md.tmpl +33 -0
- package/templates/room-skeleton/USER.md.tmpl +23 -0
- package/templates/room-skeleton/references/.gitkeep +0 -0
- package/templates/room-skeleton/references/SECTION-SCHEMA.md +213 -0
- package/templates/room-skeleton/references/SUB-SCHEMAS.md +91 -0
- package/templates/room-skeleton/section-contracts/.gitkeep +0 -0
- package/templates/room-skeleton/section-contracts/business-model.md +32 -0
- package/templates/room-skeleton/section-contracts/competitive-analysis.md +33 -0
- package/templates/room-skeleton/section-contracts/financial-model.md +30 -0
- package/templates/room-skeleton/section-contracts/funding.md +41 -0
- package/templates/room-skeleton/section-contracts/legal-ip.md +30 -0
- package/templates/room-skeleton/section-contracts/market-analysis.md +32 -0
- package/templates/room-skeleton/section-contracts/opportunity-bank.md +39 -0
- package/templates/room-skeleton/section-contracts/problem-definition.md +32 -0
- package/templates/room-skeleton/section-contracts/solution-design.md +36 -0
- package/templates/room-skeleton/section-contracts/strategy.md +35 -0
- package/templates/room-skeleton/section-contracts/team-execution.md +36 -0
- package/templates/shared.css +427 -0
- package/templates/showcase/blueprint.html +432 -0
- package/templates/showcase/library.html +571 -0
- package/templates/showcase/narrative.html +361 -0
- package/templates/showcase/overview.html +468 -0
- package/templates/showcase/synthesis.html +473 -0
- package/templates/signature-footer.html +34 -0
|
@@ -0,0 +1,1453 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MindrianOS Plugin -- LazyGraph Operations
|
|
3
|
+
* SQLite-backed per-project queryable knowledge graph via node:sqlite DatabaseSync.
|
|
4
|
+
* Graph stored in room/.mindrian/room.db (WAL mode for concurrent reads).
|
|
5
|
+
*
|
|
6
|
+
* Exports: openGraph, closeGraph, initSchema, indexArtifact,
|
|
7
|
+
* rebuildGraph, queryGraph, graphStats, embedArtifact,
|
|
8
|
+
* + 12 edge-creator functions + EDGE_TYPES constant
|
|
9
|
+
* + the Phase 236 (GRAPHDB-01) indexer ownership allowlist:
|
|
10
|
+
* INDEXER_OWNED_NODE_TYPES / INDEXER_OWNED_EDGE_TYPES, the readable
|
|
11
|
+
* DATA contract scoping rebuildGraph's destructive DELETE to exactly
|
|
12
|
+
* what the indexer can regenerate. scripts/build-ecosystem-graph.cjs
|
|
13
|
+
* IMPORTS these rather than declaring its own copy.
|
|
14
|
+
*
|
|
15
|
+
* All functions remain async for backward compatibility with callers
|
|
16
|
+
* that use await. Awaiting a synchronous return resolves immediately.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const crypto = require('crypto');
|
|
24
|
+
const { DatabaseSync } = require('node:sqlite');
|
|
25
|
+
const { discoverSections, isIndexableArtifactFile } = require('./section-registry.cjs');
|
|
26
|
+
const { insertNode } = require('./node-insert.cjs');
|
|
27
|
+
|
|
28
|
+
// --- Schema ---
|
|
29
|
+
|
|
30
|
+
/** All relationship (edge) types in the LazyGraph */
|
|
31
|
+
const EDGE_TYPES = ['INFORMS', 'CONTRADICTS', 'CONVERGES', 'ENABLES', 'INVALIDATES', 'BELONGS_TO', 'REASONING_INFORMS', 'HSI_CONNECTION', 'REVERSE_SALIENT', 'ANALOGOUS_TO', 'STRUCTURALLY_ISOMORPHIC', 'RESOLVES_VIA', 'CAUSES', 'ROOT_CAUSE_OF', 'CASCADES_TO', 'EXTRACTED_FROM', 'WHITESPACE_DETECTED', 'WHITESPACE_NEAR', 'DISCOVERY_CYCLE_SOURCE', 'DISCOVERED', 'DERIVED_FROM', 'AUTHORED_BY', 'AFFILIATED_WITH'];
|
|
32
|
+
|
|
33
|
+
// Phase 236 (GRAPHDB-01): THE INDEXER OWNERSHIP ALLOWLIST.
|
|
34
|
+
//
|
|
35
|
+
// RCA: .planning/debug/graph-rebuild-truncates-memory-journal.md
|
|
36
|
+
//
|
|
37
|
+
// WHY THIS EXISTS. rebuildGraph used to run an unconditional
|
|
38
|
+
// `DELETE FROM edges; DELETE FROM nodes;`. The nodes/edges tables hold TWO
|
|
39
|
+
// populations with opposite lifecycles and NO discriminator column:
|
|
40
|
+
//
|
|
41
|
+
// DERIVED, regenerable -- Artifact / Section nodes and BELONGS_TO edges,
|
|
42
|
+
// written by _indexArtifactBody from files on disk.
|
|
43
|
+
// ORIGINAL, IRREPLACEABLE -- memory_event (the append-only audit journal),
|
|
44
|
+
// human-confirmed truth-claim and decision nodes,
|
|
45
|
+
// and opportunity nodes carrying the D-17
|
|
46
|
+
// append-only stage_history[].
|
|
47
|
+
//
|
|
48
|
+
// The reindex that follows the DELETE restores ONLY the derived subset, so every
|
|
49
|
+
// original row was permanently gone the moment the transaction committed. This is
|
|
50
|
+
// NOT a crash-safety problem: the BEGIN/COMMIT/ROLLBACK wrap below already works
|
|
51
|
+
// (proven by live crash injection in 236-RESEARCH.md Evidence A). The loss
|
|
52
|
+
// happened on the HAPPY path, atomically, every single time.
|
|
53
|
+
//
|
|
54
|
+
// WHY THE IRREPLACEABLE TYPES ARE EXCLUDED BY CONSTRUCTION. They exist nowhere
|
|
55
|
+
// else. There is no markdown file, no secondary store, and no upstream export to
|
|
56
|
+
// re-derive them from, and the schema carries no soft-delete or tombstone column
|
|
57
|
+
// to recover from (RCA CLAIM-11). Once deleted they are gone for good, so the
|
|
58
|
+
// only safe contract is an allowlist of what the indexer can REGENERATE.
|
|
59
|
+
//
|
|
60
|
+
// THESE TWO CONSTANTS ARE THE EXACT SET _indexArtifactBody WRITES, and nothing
|
|
61
|
+
// wider. It writes precisely three type literals: insertNode(..., 'Artifact', ...)
|
|
62
|
+
// and insertNode(..., 'Section', ...), plus a BELONGS_TO edge. The four cascade
|
|
63
|
+
// edge types (CONTRADICTS / INFORMS / ENABLES / INVALIDATES) are DISABLED here as
|
|
64
|
+
// of Phase 169 D-169-08 and navigation.writeEdge is now their sole writer, so the
|
|
65
|
+
// indexer can no longer restore them and therefore MUST NOT delete them. Do not
|
|
66
|
+
// widen these to EDGE_TYPES (the legal vocabulary) or to node-insert.cjs's
|
|
67
|
+
// header list (which names CausalClaim / WhitespaceZone, written by
|
|
68
|
+
// createCausalClaim / addWhitespaceZone, which rebuildGraph never calls).
|
|
69
|
+
// Widening either constant reintroduces the data loss at a narrower scope.
|
|
70
|
+
//
|
|
71
|
+
// LEGACY-SCHEMA FOREIGN-KEY NOTE. Phase 169 D-169-11 removed the hard FK from
|
|
72
|
+
// edges(source/target) to nodes(id), but under an if-not-exists guard, so it
|
|
73
|
+
// applies to NEW dbs only; a pre-169 room.db keeps its prior schema WITH the FK,
|
|
74
|
+
// and openRoomDb sets PRAGMA foreign_keys = ON. On such a db a now-SCOPED
|
|
75
|
+
// DELETE FROM nodes can be REJECTED where the old delete-everything statement was
|
|
76
|
+
// not, because a surviving non-indexer edge may still reference an Artifact node
|
|
77
|
+
// being removed. Deleting edges BEFORE nodes is the mitigation, and the existing
|
|
78
|
+
// ROLLBACK makes any residual rejection loud and atomic rather than partial.
|
|
79
|
+
|
|
80
|
+
/** Node types the artifact indexer OWNS: it writes them and can fully regenerate them. */
|
|
81
|
+
const INDEXER_OWNED_NODE_TYPES = Object.freeze(['Artifact', 'Section']);
|
|
82
|
+
|
|
83
|
+
/** Edge types the artifact indexer OWNS: it writes them and can fully regenerate them. */
|
|
84
|
+
const INDEXER_OWNED_EDGE_TYPES = Object.freeze(['BELONGS_TO']);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Phase 236 (GRAPHDB-01): THE ownership-scoped wipe. One implementation, two
|
|
88
|
+
* call sites (rebuildGraph below, and scripts/build-ecosystem-graph.cjs), so the
|
|
89
|
+
* two destructive reindex paths over room.db can never drift apart.
|
|
90
|
+
*
|
|
91
|
+
* It lives HERE rather than in the calling script for two reasons. First,
|
|
92
|
+
* ownership is a property of the write path that CREATES the rows, so the delete
|
|
93
|
+
* belongs beside the constants that define it. Second, Canon Part 9: this module
|
|
94
|
+
* is one of the few substrate-adjacent modules allow-listed by
|
|
95
|
+
* scripts/check-substrate.cjs to issue raw graph SQL, and adding a second raw-SQL
|
|
96
|
+
* wipe site in scripts/ would either trip that guard or require widening the
|
|
97
|
+
* chokepoint exemption allowlist, which is a governance change this fix does not
|
|
98
|
+
* need to make.
|
|
99
|
+
*
|
|
100
|
+
* Ordering is load-bearing: edges are deleted BEFORE nodes so a legacy
|
|
101
|
+
* pre-Phase-169 room.db that still carries the hard edges -> nodes FK cannot
|
|
102
|
+
* reject the node delete. See the rationale block above.
|
|
103
|
+
*
|
|
104
|
+
* DERIVED-EDGE SCOPING, and why it is by ENDPOINT and not by type alone. Callers
|
|
105
|
+
* that regenerate MORE edge types than the indexer does (the ecosystem builder
|
|
106
|
+
* writes INFORMS / CONTRADICTS / CONVERGES on top of BELONGS_TO) pass those types
|
|
107
|
+
* in `extraDerivedEdgeTypes`. Those are NOT deleted by type alone, because
|
|
108
|
+
* navigation.writeEdge has been the sole writer of INFORMS and CONTRADICTS since
|
|
109
|
+
* Phase 169 D-169-08 and writes them between NON-artifact nodes too (claims,
|
|
110
|
+
* memory events, decisions). A type-only predicate looks correctly scoped and
|
|
111
|
+
* still destroys derivation-authored cascade edges no caller can rebuild: the
|
|
112
|
+
* same defect class, one level down. The edges table has no provenance column to
|
|
113
|
+
* discriminate on, so ENDPOINT OWNERSHIP is the discriminator: a derived edge is
|
|
114
|
+
* removed only when BOTH endpoints are ids currently carrying an indexer-owned
|
|
115
|
+
* node type. Because edges go before nodes, those rows still exist here.
|
|
116
|
+
*
|
|
117
|
+
* Every statement is parameterized; the constants are never interpolated into
|
|
118
|
+
* SQL text, so they stay the single source of truth.
|
|
119
|
+
*
|
|
120
|
+
* @param {import('node:sqlite').DatabaseSync} conn - an OPEN handle. The CALLER
|
|
121
|
+
* owns the transaction: both call sites wrap this in BEGIN/COMMIT/ROLLBACK.
|
|
122
|
+
* @param {string[]} [extraDerivedEdgeTypes] - caller-regenerable edge types
|
|
123
|
+
* beyond INDEXER_OWNED_EDGE_TYPES, deleted only between indexer-owned endpoints.
|
|
124
|
+
* @returns {void}
|
|
125
|
+
*/
|
|
126
|
+
function clearIndexerOwnedRows(conn, extraDerivedEdgeTypes) {
|
|
127
|
+
const ph = (arr) => arr.map(() => '?').join(',');
|
|
128
|
+
|
|
129
|
+
// 1. The structural indexer-owned edges.
|
|
130
|
+
conn.prepare(
|
|
131
|
+
'DELETE FROM edges WHERE type IN (' + ph(INDEXER_OWNED_EDGE_TYPES) + ')'
|
|
132
|
+
).run(...INDEXER_OWNED_EDGE_TYPES);
|
|
133
|
+
|
|
134
|
+
// 2. Caller-supplied derived edges, scoped by type AND by BOTH endpoints being
|
|
135
|
+
// indexer-owned node ids. Already-owned types are filtered out so step 1
|
|
136
|
+
// stays the only place BELONGS_TO is removed.
|
|
137
|
+
const derived = Array.isArray(extraDerivedEdgeTypes)
|
|
138
|
+
? extraDerivedEdgeTypes.filter((t) => INDEXER_OWNED_EDGE_TYPES.indexOf(t) === -1)
|
|
139
|
+
: [];
|
|
140
|
+
if (derived.length > 0) {
|
|
141
|
+
conn.prepare(
|
|
142
|
+
'DELETE FROM edges WHERE type IN (' + ph(derived) + ') '
|
|
143
|
+
+ 'AND source IN (SELECT id FROM nodes WHERE type IN (' + ph(INDEXER_OWNED_NODE_TYPES) + ')) '
|
|
144
|
+
+ 'AND target IN (SELECT id FROM nodes WHERE type IN (' + ph(INDEXER_OWNED_NODE_TYPES) + '))'
|
|
145
|
+
).run(...derived, ...INDEXER_OWNED_NODE_TYPES, ...INDEXER_OWNED_NODE_TYPES);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 3. The indexer-owned nodes. Edges first, above.
|
|
149
|
+
conn.prepare(
|
|
150
|
+
'DELETE FROM nodes WHERE type IN (' + ph(INDEXER_OWNED_NODE_TYPES) + ')'
|
|
151
|
+
).run(...INDEXER_OWNED_NODE_TYPES);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Create nodes and edges tables with indexes. Idempotent.
|
|
156
|
+
* @param {import('node:sqlite').DatabaseSync} db - node:sqlite DatabaseSync instance
|
|
157
|
+
*/
|
|
158
|
+
function initSchema(db) {
|
|
159
|
+
db.exec(`
|
|
160
|
+
CREATE TABLE IF NOT EXISTS nodes (
|
|
161
|
+
id TEXT PRIMARY KEY,
|
|
162
|
+
type TEXT NOT NULL,
|
|
163
|
+
properties TEXT DEFAULT '{}'
|
|
164
|
+
);
|
|
165
|
+
-- Phase 169 D-169-11: the edges table no longer hard-FKs source/target to
|
|
166
|
+
-- nodes(id). The room-lineage NESTED_WITHIN edge (source room:<child>, target
|
|
167
|
+
-- room:<parent>) and the rollup it powers reference ROOM node ids that are not
|
|
168
|
+
-- always materialized as nodes(id) rows in the same db (a child room node
|
|
169
|
+
-- lives in the child's db, not the parent's). The canonical writers
|
|
170
|
+
-- (findings-wirer.wireAccept, graph-derivation.runDerivation) still write the
|
|
171
|
+
-- proposed truth-claim NODE before the cascade edge, so cascade edges keep
|
|
172
|
+
-- their node provenance; but a hard FK that REJECTS a lineage / derived edge
|
|
173
|
+
-- whose endpoint node lives in another room db (or is healed later) breaks the
|
|
174
|
+
-- D-169-11 fractal joint. The PRIMARY KEY (source, target, type) still enforces
|
|
175
|
+
-- edge uniqueness. The IF-NOT-EXISTS clause makes this apply to NEW dbs only;
|
|
176
|
+
-- existing dbs keep their prior schema (no destructive migration).
|
|
177
|
+
CREATE TABLE IF NOT EXISTS edges (
|
|
178
|
+
source TEXT NOT NULL,
|
|
179
|
+
target TEXT NOT NULL,
|
|
180
|
+
type TEXT NOT NULL,
|
|
181
|
+
properties TEXT DEFAULT '{}',
|
|
182
|
+
PRIMARY KEY (source, target, type)
|
|
183
|
+
);
|
|
184
|
+
CREATE INDEX IF NOT EXISTS idx_nodes_type ON nodes(type);
|
|
185
|
+
CREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source);
|
|
186
|
+
CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target);
|
|
187
|
+
CREATE INDEX IF NOT EXISTS idx_edges_type ON edges(type);
|
|
188
|
+
CREATE INDEX IF NOT EXISTS idx_edges_source_type ON edges(source, type);
|
|
189
|
+
CREATE INDEX IF NOT EXISTS idx_edges_target_type ON edges(target, type);
|
|
190
|
+
CREATE TABLE IF NOT EXISTS stakeholders (
|
|
191
|
+
id TEXT PRIMARY KEY,
|
|
192
|
+
type TEXT NOT NULL,
|
|
193
|
+
name TEXT NOT NULL,
|
|
194
|
+
canonical_ref TEXT,
|
|
195
|
+
notes TEXT,
|
|
196
|
+
metadata TEXT DEFAULT '{}',
|
|
197
|
+
created_at TEXT NOT NULL,
|
|
198
|
+
updated_at TEXT NOT NULL
|
|
199
|
+
);
|
|
200
|
+
CREATE INDEX IF NOT EXISTS idx_stakeholders_type ON stakeholders(type);
|
|
201
|
+
CREATE INDEX IF NOT EXISTS idx_stakeholders_canonical ON stakeholders(canonical_ref);
|
|
202
|
+
-- rs_discoveries: contract bridge between the RS SQLite mirror (writer) and
|
|
203
|
+
-- the RS NL/SQL readers. rs-sqlite-mirror.cjs writes RSDiscovery records
|
|
204
|
+
-- into the nodes table with the payload in a JSON properties bag
|
|
205
|
+
-- (keys: classification, breakthrough_score, dominant_dimension, thesis,
|
|
206
|
+
-- bridge_concept, diff, lsa, bert, ..., created_at, room_id, domain). The
|
|
207
|
+
-- readers (rs-nl-to-query.cjs SQL templates and scripts/rs-thesis-command.cjs)
|
|
208
|
+
-- query SELECT * FROM rs_discoveries WHERE room_slug = ? and
|
|
209
|
+
-- SELECT id, thesis, rs_type, breakthrough_score, room_slug, created_at
|
|
210
|
+
-- FROM rs_discoveries WHERE id = ? -- there was no such table, so queryGraph
|
|
211
|
+
-- swallowed the "no such table" error as []. This VIEW closes that gap: it
|
|
212
|
+
-- json_extract's the payload keys into the columns the queries expect and
|
|
213
|
+
-- renames the writer's room_id JSON key to the reader's room_slug column
|
|
214
|
+
-- and classification to rs_type. node:sqlite's bundled SQLite ships the
|
|
215
|
+
-- JSON1 extension so json_extract works. NOTE: room_id is mapped to
|
|
216
|
+
-- room_slug verbatim -- if ctx.room_id passed by the RS engine is ever
|
|
217
|
+
-- not a room slug, that is a separate data-lineage fix in
|
|
218
|
+
-- rs-discovery-engine.cjs / rs-sqlite-mirror.cjs; this view only aligns the
|
|
219
|
+
-- column NAMES the queries already use. CREATE VIEW IF NOT EXISTS makes it
|
|
220
|
+
-- idempotent -- existing room.db files pick it up on the next openGraph.
|
|
221
|
+
CREATE VIEW IF NOT EXISTS rs_discoveries AS
|
|
222
|
+
SELECT
|
|
223
|
+
id,
|
|
224
|
+
json_extract(properties, '$.thesis') AS thesis,
|
|
225
|
+
json_extract(properties, '$.classification') AS rs_type,
|
|
226
|
+
json_extract(properties, '$.breakthrough_score') AS breakthrough_score,
|
|
227
|
+
json_extract(properties, '$.room_id') AS room_slug,
|
|
228
|
+
json_extract(properties, '$.created_at') AS created_at,
|
|
229
|
+
json_extract(properties, '$.bridge_concept') AS bridge_concept,
|
|
230
|
+
json_extract(properties, '$.dominant_dimension') AS dominant_dimension,
|
|
231
|
+
json_extract(properties, '$.diff') AS diff,
|
|
232
|
+
json_extract(properties, '$.lsa') AS lsa,
|
|
233
|
+
json_extract(properties, '$.bert') AS bert,
|
|
234
|
+
json_extract(properties, '$.domain') AS domain,
|
|
235
|
+
properties AS properties_json
|
|
236
|
+
FROM nodes
|
|
237
|
+
WHERE type = 'RSDiscovery';
|
|
238
|
+
`);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// --- Stakeholder helpers (Phase 84-05, SCOPE-NB-03 / SCOPE-NB-04) ---
|
|
242
|
+
|
|
243
|
+
/** Allowed stakeholder.type values per Phase 84-05 spec. */
|
|
244
|
+
const STAKEHOLDER_TYPES = ['person', 'org', 'coalition', 'role'];
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Validate a stakeholder type string. Throws TypeError on mismatch.
|
|
248
|
+
* @param {string} type
|
|
249
|
+
*/
|
|
250
|
+
function validateStakeholderType(type) {
|
|
251
|
+
if (!STAKEHOLDER_TYPES.includes(type)) {
|
|
252
|
+
throw new TypeError(`Invalid stakeholder type: ${type}. Must be one of ${STAKEHOLDER_TYPES.join(', ')}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Create a new Stakeholder row.
|
|
258
|
+
* Generates a UUID, stamps created_at and updated_at, inserts the row.
|
|
259
|
+
* @param {import('node:sqlite').DatabaseSync} db
|
|
260
|
+
* @param {object} fields
|
|
261
|
+
* @param {string} fields.type - person | org | coalition | role
|
|
262
|
+
* @param {string} fields.name
|
|
263
|
+
* @param {string} [fields.canonical_ref]
|
|
264
|
+
* @param {string} [fields.notes]
|
|
265
|
+
* @param {object|string} [fields.metadata]
|
|
266
|
+
* @returns {Promise<object|null>} The new row or null on failure.
|
|
267
|
+
*/
|
|
268
|
+
async function createStakeholder(db, fields) {
|
|
269
|
+
try {
|
|
270
|
+
const { type, name } = fields || {};
|
|
271
|
+
validateStakeholderType(type);
|
|
272
|
+
if (!name || typeof name !== 'string') {
|
|
273
|
+
throw new TypeError('Stakeholder name is required');
|
|
274
|
+
}
|
|
275
|
+
const id = crypto.randomUUID();
|
|
276
|
+
const now = new Date().toISOString();
|
|
277
|
+
const canonical_ref = fields.canonical_ref || null;
|
|
278
|
+
const notes = fields.notes || null;
|
|
279
|
+
const metadata = typeof fields.metadata === 'string'
|
|
280
|
+
? fields.metadata
|
|
281
|
+
: JSON.stringify(fields.metadata || {});
|
|
282
|
+
db.prepare(
|
|
283
|
+
'INSERT INTO stakeholders (id, type, name, canonical_ref, notes, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
|
|
284
|
+
).run(id, type, name, canonical_ref, notes, metadata, now, now);
|
|
285
|
+
return Promise.resolve({ id, type, name, canonical_ref, notes, metadata, created_at: now, updated_at: now });
|
|
286
|
+
} catch (e) {
|
|
287
|
+
if (e instanceof TypeError) throw e;
|
|
288
|
+
return Promise.resolve(null);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Get a Stakeholder row by id.
|
|
294
|
+
* @param {import('node:sqlite').DatabaseSync} db
|
|
295
|
+
* @param {string} id
|
|
296
|
+
* @returns {Promise<object|null>}
|
|
297
|
+
*/
|
|
298
|
+
async function getStakeholder(db, id) {
|
|
299
|
+
try {
|
|
300
|
+
const row = db.prepare('SELECT * FROM stakeholders WHERE id = ?').get(id);
|
|
301
|
+
return Promise.resolve(row || null);
|
|
302
|
+
} catch (e) {
|
|
303
|
+
return Promise.resolve(null);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Upsert a Stakeholder by canonical_ref. Updates in place if present, else inserts.
|
|
309
|
+
* Updates updated_at on every call.
|
|
310
|
+
* @param {import('node:sqlite').DatabaseSync} db
|
|
311
|
+
* @param {string} canonical_ref
|
|
312
|
+
* @param {object} fields
|
|
313
|
+
* @returns {Promise<object|null>}
|
|
314
|
+
*/
|
|
315
|
+
async function upsertStakeholder(db, canonical_ref, fields) {
|
|
316
|
+
try {
|
|
317
|
+
if (!canonical_ref) {
|
|
318
|
+
throw new TypeError('canonical_ref is required for upsertStakeholder');
|
|
319
|
+
}
|
|
320
|
+
const existing = db.prepare('SELECT * FROM stakeholders WHERE canonical_ref = ?').get(canonical_ref);
|
|
321
|
+
const now = new Date().toISOString();
|
|
322
|
+
if (existing) {
|
|
323
|
+
const type = fields.type || existing.type;
|
|
324
|
+
validateStakeholderType(type);
|
|
325
|
+
const name = fields.name || existing.name;
|
|
326
|
+
const notes = fields.notes !== undefined ? fields.notes : existing.notes;
|
|
327
|
+
const metadata = fields.metadata !== undefined
|
|
328
|
+
? (typeof fields.metadata === 'string' ? fields.metadata : JSON.stringify(fields.metadata))
|
|
329
|
+
: existing.metadata;
|
|
330
|
+
db.prepare(
|
|
331
|
+
'UPDATE stakeholders SET type = ?, name = ?, notes = ?, metadata = ?, updated_at = ? WHERE id = ?'
|
|
332
|
+
).run(type, name, notes, metadata, now, existing.id);
|
|
333
|
+
return Promise.resolve({ ...existing, type, name, notes, metadata, updated_at: now });
|
|
334
|
+
}
|
|
335
|
+
return createStakeholder(db, { ...fields, canonical_ref });
|
|
336
|
+
} catch (e) {
|
|
337
|
+
if (e instanceof TypeError) throw e;
|
|
338
|
+
return Promise.resolve(null);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Find stakeholders connected to a claim artifact via INFORMS edges.
|
|
344
|
+
* Walks both directions (stakeholder INFORMS claim, claim INFORMS stakeholder).
|
|
345
|
+
* @param {import('node:sqlite').DatabaseSync} db
|
|
346
|
+
* @param {string} claim_artifact_id
|
|
347
|
+
* @returns {Promise<Array<object>>}
|
|
348
|
+
*/
|
|
349
|
+
async function findStakeholdersByClaim(db, claim_artifact_id) {
|
|
350
|
+
try {
|
|
351
|
+
const rows = db.prepare(
|
|
352
|
+
`SELECT s.* FROM stakeholders s
|
|
353
|
+
WHERE s.id IN (
|
|
354
|
+
SELECT source FROM edges WHERE target = ? AND type = 'INFORMS'
|
|
355
|
+
UNION
|
|
356
|
+
SELECT target FROM edges WHERE source = ? AND type = 'INFORMS'
|
|
357
|
+
)
|
|
358
|
+
LIMIT 20`
|
|
359
|
+
).all(claim_artifact_id, claim_artifact_id);
|
|
360
|
+
return Promise.resolve(rows || []);
|
|
361
|
+
} catch (e) {
|
|
362
|
+
return Promise.resolve([]);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// --- Helpers ---
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Get artifact ID from file path relative to room dir.
|
|
370
|
+
* @param {string} filePath - Absolute path to .md file
|
|
371
|
+
* @param {string} roomDir - Absolute path to room directory
|
|
372
|
+
* @returns {string} e.g. "problem-definition/market-trends"
|
|
373
|
+
*/
|
|
374
|
+
function getArtifactId(filePath, roomDir) {
|
|
375
|
+
const rel = path.relative(path.resolve(roomDir), path.resolve(filePath));
|
|
376
|
+
// Phase 169 GDH-04: strip the non-.md artifact extensions too (.docx/.html/.htm)
|
|
377
|
+
// so a flat-root .docx artifact gets a clean id, not one carrying the extension.
|
|
378
|
+
return rel.replace(/\.(md|docx|html|htm)$/i, '').replace(/\\/g, '/');
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Extract title from first # heading in file content.
|
|
383
|
+
* @param {string} content - File content
|
|
384
|
+
* @param {string} filePath - Fallback basename
|
|
385
|
+
* @returns {string}
|
|
386
|
+
*/
|
|
387
|
+
function extractTitle(content, filePath) {
|
|
388
|
+
const match = content.match(/^# (.+)$/m);
|
|
389
|
+
return match ? match[1].trim() : path.basename(filePath, '.md');
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Extract a frontmatter field value.
|
|
394
|
+
* @param {string} content - File content
|
|
395
|
+
* @param {string} field - Field name
|
|
396
|
+
* @returns {string}
|
|
397
|
+
*/
|
|
398
|
+
function extractFrontmatter(content, field) {
|
|
399
|
+
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
400
|
+
if (!fmMatch) return '';
|
|
401
|
+
const line = fmMatch[1].split('\n').find(l => l.startsWith(field + ':'));
|
|
402
|
+
if (!line) return '';
|
|
403
|
+
return line.slice(field.length + 1).trim().replace(/^["']|["']$/g, '');
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Compute MD5 content hash (first 8 hex chars).
|
|
408
|
+
* @param {string} content
|
|
409
|
+
* @returns {string}
|
|
410
|
+
*/
|
|
411
|
+
function computeHash(content) {
|
|
412
|
+
return crypto.createHash('md5').update(content).digest('hex').slice(0, 8);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// --- Contradiction detection terms ---
|
|
416
|
+
const CONTRADICT_TERMS = ['however', 'contradicts', 'unlike', 'disagrees', 'conflicts', 'contrary', 'opposes'];
|
|
417
|
+
|
|
418
|
+
// --- Core Functions ---
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Open (or create) a SQLite database at {roomDir}/.mindrian/room.db.
|
|
422
|
+
* Enables WAL mode and foreign keys. Initializes schema.
|
|
423
|
+
* @param {string} roomDir - Path to room directory
|
|
424
|
+
* @returns {Promise<{db: import('node:sqlite').DatabaseSync, conn: import('node:sqlite').DatabaseSync}>}
|
|
425
|
+
*/
|
|
426
|
+
async function openGraph(roomDir) {
|
|
427
|
+
const resolved = path.resolve(roomDir);
|
|
428
|
+
const dbDir = path.join(resolved, '.mindrian');
|
|
429
|
+
const dbPath = path.join(dbDir, 'room.db');
|
|
430
|
+
|
|
431
|
+
// Ensure directories exist
|
|
432
|
+
fs.mkdirSync(dbDir, { recursive: true });
|
|
433
|
+
|
|
434
|
+
// Phase 276 (C4) write-safety: fold the busy-timeout constructor option
|
|
435
|
+
// into the DatabaseSync options object. This is the most-used room.db
|
|
436
|
+
// opener in the repo (roughly 38 call sites). Without it, node:sqlite
|
|
437
|
+
// fails a contended write in 0ms with SQLITE_BUSY; the option turns that
|
|
438
|
+
// into a roughly 5s busy-wait window. Strictly more forgiving - a longer
|
|
439
|
+
// wait, never a new failure mode - because WAL readers never block writers.
|
|
440
|
+
// Adapted from the one correct site, lib/core/room-db.cjs:242-251.
|
|
441
|
+
const db = new DatabaseSync(dbPath, { timeout: 5000 });
|
|
442
|
+
db.exec('PRAGMA journal_mode = WAL');
|
|
443
|
+
db.exec('PRAGMA foreign_keys = ON');
|
|
444
|
+
|
|
445
|
+
// D-276-4 follow-up (registered, not built here): routing this opener
|
|
446
|
+
// through lib/core/room-db.cjs's openRoomDb would also close Phase 273's
|
|
447
|
+
// M12 and C2's residue, but was NOT done in Phase 276 because openRoomDb
|
|
448
|
+
// is synchronous and returns a bare handle while openGraph is async and
|
|
449
|
+
// returns { db, conn } across roughly 38-50 call sites (re-measured at
|
|
450
|
+
// 276-09 execution time: 50 non-test occurrences of "openGraph(" in the
|
|
451
|
+
// tree, up from the plan's own "roughly 38" estimate), and because
|
|
452
|
+
// openRoomDb runs a 7-step migration chain on every open. Named as a
|
|
453
|
+
// registered follow-up of Phase 276, tracked in the ROADMAP by plan
|
|
454
|
+
// 276-16, not silently dropped.
|
|
455
|
+
initSchema(db);
|
|
456
|
+
|
|
457
|
+
// conn === db in SQLite (single object handles both)
|
|
458
|
+
return Promise.resolve({ db, conn: db });
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Close SQLite database.
|
|
463
|
+
* @param {import('node:sqlite').DatabaseSync} db - node:sqlite DatabaseSync instance
|
|
464
|
+
*/
|
|
465
|
+
async function closeGraph(db) {
|
|
466
|
+
try {
|
|
467
|
+
db.close();
|
|
468
|
+
} catch (e) {
|
|
469
|
+
// Handle already-closed or invalid db gracefully
|
|
470
|
+
}
|
|
471
|
+
return Promise.resolve();
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Index a single .md artifact into the graph.
|
|
476
|
+
* Creates Artifact node, Section node, BELONGS_TO edge.
|
|
477
|
+
* Scans for [[wikilinks]] to create INFORMS edges.
|
|
478
|
+
* Scans for contradiction terms near wikilinks to create CONTRADICTS edges.
|
|
479
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
480
|
+
* @param {string} roomDir - Absolute path to room directory
|
|
481
|
+
* @param {string} filePath - Absolute path to .md file
|
|
482
|
+
* @returns {Promise<{id: string, section: string, title: string, contentHash: string}>}
|
|
483
|
+
*/
|
|
484
|
+
/**
|
|
485
|
+
* Internal: run the INSERT body of indexArtifact WITHOUT opening a transaction.
|
|
486
|
+
* The caller is responsible for transaction semantics. Used by:
|
|
487
|
+
* - indexArtifact() -- wraps this in BEGIN/COMMIT/ROLLBACK
|
|
488
|
+
* - rebuildGraph() -- calls this inside its own outer BEGIN/COMMIT so the
|
|
489
|
+
* whole rebuild is atomic (no nested transactions, which SQLite forbids
|
|
490
|
+
* without SAVEPOINT).
|
|
491
|
+
* @param {import('node:sqlite').DatabaseSync} conn
|
|
492
|
+
* @param {string} roomDir
|
|
493
|
+
* @param {string} filePath
|
|
494
|
+
* @returns {{id: string, section: string, title: string, contentHash: string}}
|
|
495
|
+
*/
|
|
496
|
+
/**
|
|
497
|
+
* Phase 169 GDH-04: read the artifact text. .md stays the plain readFileSync
|
|
498
|
+
* path; .docx/.html route through doc-text-extractor.extractDocText so the
|
|
499
|
+
* non-.md reach lands in the index path. extractDocText opens the source for
|
|
500
|
+
* READ only (D-169-03 non-destructive). A missing extractor / empty extraction
|
|
501
|
+
* degrades to '' so a non-text artifact still mints its node (content_hash over
|
|
502
|
+
* the empty string is stable and harmless). No em-dashes.
|
|
503
|
+
* @param {string} filePath
|
|
504
|
+
* @returns {string}
|
|
505
|
+
*/
|
|
506
|
+
function _readArtifactContent(filePath) {
|
|
507
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
508
|
+
if (ext === '.docx' || ext === '.html' || ext === '.htm') {
|
|
509
|
+
try {
|
|
510
|
+
const { extractDocText } = require('./doc-text-extractor.cjs');
|
|
511
|
+
return extractDocText(filePath) || '';
|
|
512
|
+
} catch (_e) {
|
|
513
|
+
return '';
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function _indexArtifactBody(conn, roomDir, filePath) {
|
|
520
|
+
const content = _readArtifactContent(filePath);
|
|
521
|
+
const id = getArtifactId(filePath, roomDir);
|
|
522
|
+
const section = id.split('/')[0];
|
|
523
|
+
const title = extractTitle(content, filePath);
|
|
524
|
+
const methodology = extractFrontmatter(content, 'methodology');
|
|
525
|
+
const created = extractFrontmatter(content, 'date');
|
|
526
|
+
const contentHash = computeHash(content);
|
|
527
|
+
const enables = extractFrontmatter(content, 'enables');
|
|
528
|
+
const invalidates = extractFrontmatter(content, 'invalidates');
|
|
529
|
+
const wikilinks = content.match(/\[\[([^\]]+)\]\]/g) || [];
|
|
530
|
+
const artifactProps = JSON.stringify({ title, section, methodology, created, content_hash: contentHash });
|
|
531
|
+
const sectionLabel = section.replace(/-/g, ' ').toUpperCase();
|
|
532
|
+
const sectionProps = JSON.stringify({ name: section, label: sectionLabel });
|
|
533
|
+
|
|
534
|
+
// Upsert Artifact node (HARD-02: shared NOT-NULL-safe helper, D-02 + D-02a).
|
|
535
|
+
// R17-02: epistemic_type 'observation' -- system-bookkeeping node, records
|
|
536
|
+
// that an artifact file was indexed, not a truth-claim about the venture.
|
|
537
|
+
insertNode(conn, id, 'Artifact', artifactProps, { epistemic_type: 'observation' });
|
|
538
|
+
|
|
539
|
+
// Upsert Section node (HARD-02: shared NOT-NULL-safe helper, D-02 + D-02a).
|
|
540
|
+
// R17-02: epistemic_type 'observation' (same system-bookkeeping bucket).
|
|
541
|
+
insertNode(conn, section, 'Section', sectionProps, { epistemic_type: 'observation' });
|
|
542
|
+
|
|
543
|
+
// Upsert BELONGS_TO edge (the structural section-membership edge -- NOT a
|
|
544
|
+
// cascade type; it STAYS. Only the four cascade writes below are disabled.)
|
|
545
|
+
conn.prepare(
|
|
546
|
+
'INSERT INTO edges (source, target, type) VALUES (?, ?, ?) ON CONFLICT DO NOTHING'
|
|
547
|
+
).run(id, section, 'BELONGS_TO');
|
|
548
|
+
|
|
549
|
+
// Phase 169 D-169-08 (MEDIUM-4): the legacy raw-SQL cascade is DISABLED.
|
|
550
|
+
// The wikilink-driven CONTRADICTS + INFORMS writes, plus the frontmatter
|
|
551
|
+
// ENABLES + INVALIDATES writes, used to land cascade edges DIRECTLY via raw
|
|
552
|
+
// INSERT INTO edges -- bypassing the Part 9 navigation.writeEdge chokepoint and
|
|
553
|
+
// auto-confirming them. Derivation (graph-derivation.cjs runDerivation, which
|
|
554
|
+
// critiques each candidate via fable-mode and lands a PROPOSED truth-claim node
|
|
555
|
+
// plus a typed edge through navigation.writeEdge) is now the SOLE writer of the
|
|
556
|
+
// CONTRADICTS / INFORMS / ENABLES / INVALIDATES cascade types. The wikilinks /
|
|
557
|
+
// enables / invalidates frontmatter values are still READ above (the content
|
|
558
|
+
// hash + node props carry them), but no cascade edge is written here. BELONGS_TO
|
|
559
|
+
// (the structural edge) is preserved above; the cascade edges are no longer
|
|
560
|
+
// raw-SQL written.
|
|
561
|
+
void wikilinks;
|
|
562
|
+
void enables;
|
|
563
|
+
void invalidates;
|
|
564
|
+
void CONTRADICT_TERMS;
|
|
565
|
+
|
|
566
|
+
return { id, section, title, contentHash };
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
async function indexArtifact(conn, roomDir, filePath) {
|
|
570
|
+
// --- Transaction: all INSERTs or none (Plan 87-06 / CASCADE-04) ---
|
|
571
|
+
// node:sqlite DatabaseSync does NOT expose a transaction(fn) higher-order
|
|
572
|
+
// helper (that is a better-sqlite3 API). We use explicit BEGIN/COMMIT with
|
|
573
|
+
// ROLLBACK on any throw. On successful completion, SQLite commits the
|
|
574
|
+
// block; on any error, we roll back the partial writes and re-throw so
|
|
575
|
+
// the caller sees the original error.
|
|
576
|
+
//
|
|
577
|
+
// Why this matters (CASCADE-04): a pre-patch throw between two INSERTs
|
|
578
|
+
// could leave dangling nodes without their edges, or vice versa. The
|
|
579
|
+
// BEGIN/COMMIT wrapper converts the whole indexArtifact body into a
|
|
580
|
+
// single atomic unit. The post-condition is either "all writes survive"
|
|
581
|
+
// or "no writes survive" -- there is no middle state.
|
|
582
|
+
//
|
|
583
|
+
// Pure computation (file read, hash, wikilink scan) runs inside the txn
|
|
584
|
+
// but is idempotent and side-effect free. Moving it outside would require
|
|
585
|
+
// duplicating it in _indexArtifactBody and the rebuildGraph call site;
|
|
586
|
+
// keeping it inside keeps indexArtifact a thin BEGIN/COMMIT shell.
|
|
587
|
+
conn.prepare('BEGIN').run();
|
|
588
|
+
let result;
|
|
589
|
+
try {
|
|
590
|
+
result = _indexArtifactBody(conn, roomDir, filePath);
|
|
591
|
+
conn.prepare('COMMIT').run();
|
|
592
|
+
} catch (err) {
|
|
593
|
+
// ROLLBACK undoes every INSERT issued since BEGIN. We swallow any error
|
|
594
|
+
// from ROLLBACK itself (rare: can happen if the connection is already
|
|
595
|
+
// aborted) and always re-throw the ORIGINAL error so the caller sees
|
|
596
|
+
// the failure reason, not a ROLLBACK noise error.
|
|
597
|
+
try { conn.prepare('ROLLBACK').run(); } catch (_rbErr) { /* ignore */ }
|
|
598
|
+
throw err;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
return Promise.resolve(result);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Rebuild the entire graph from all room artifacts.
|
|
606
|
+
* Clears existing data, walks all sections, indexes every .md file.
|
|
607
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
608
|
+
* @param {string} roomDir - Absolute path to room directory
|
|
609
|
+
* @returns {Promise<{success: boolean, artifacts: number, sections: number}>}
|
|
610
|
+
*/
|
|
611
|
+
// Phase 169 GDH-03/04 (D-169-07): the artifact-extension filter used by BOTH
|
|
612
|
+
// the section walk and the ROOT-FILES pass. Accepts .md/.docx/.html/.htm while
|
|
613
|
+
// excluding the identity files STATE.md / ROOM.md (and any dot-prefixed file).
|
|
614
|
+
// The predicate now lives in section-registry.cjs as the SINGLE SOURCE OF TRUTH
|
|
615
|
+
// (quick fix 260705-qi8: shared by discoverSections' nested-qualification pass
|
|
616
|
+
// so the two walks can never drift). Aliased here to keep the internal name and
|
|
617
|
+
// all existing call sites (section walk, ROOT-FILES pass) unchanged.
|
|
618
|
+
const _isIndexableArtifactFile = isIndexableArtifactFile;
|
|
619
|
+
|
|
620
|
+
// Phase 169 GDH-03 (D-169-02 / D-169-11): detect the direct sub-rooms of roomDir
|
|
621
|
+
// -- the immediate child directories that each carry a `.room-root` FILE sentinel
|
|
622
|
+
// (the heal-command isContainerDir precedent at scripts/heal-command.cjs:909-921).
|
|
623
|
+
// Returns absolute paths. A sub-room is a full room with its OWN room.db; the
|
|
624
|
+
// rebuild recurses into each (and into ITS sub-rooms) at arbitrary depth.
|
|
625
|
+
function _detectSubRooms(roomDir) {
|
|
626
|
+
const out = [];
|
|
627
|
+
let entries;
|
|
628
|
+
try {
|
|
629
|
+
entries = fs.readdirSync(roomDir, { withFileTypes: true });
|
|
630
|
+
} catch (_e) {
|
|
631
|
+
return out;
|
|
632
|
+
}
|
|
633
|
+
for (const entry of entries) {
|
|
634
|
+
if (!entry.isDirectory()) continue;
|
|
635
|
+
if (entry.name.startsWith('.')) continue;
|
|
636
|
+
const childDir = path.join(roomDir, entry.name);
|
|
637
|
+
if (fs.existsSync(path.join(childDir, '.room-root'))) {
|
|
638
|
+
out.push(path.resolve(childDir));
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return out;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Rebuild the entire graph from all room artifacts.
|
|
646
|
+
* Clears existing data, walks all sections, indexes every artifact file.
|
|
647
|
+
*
|
|
648
|
+
* Phase 169 GDH-03/04 + D-169-07 + D-169-11 extensions:
|
|
649
|
+
* - ROOT-FILES pass: top-level .md/.docx/.html artifacts that sit in the room
|
|
650
|
+
* ROOT (a flat room) are indexed alongside the section walk.
|
|
651
|
+
* - non-.md reach: .docx/.html artifacts route through extractDocText (via
|
|
652
|
+
* _indexArtifactBody / _readArtifactContent).
|
|
653
|
+
* - TRANSITIVE sub-room recursion: a room with sub-rooms rebuilds each sub-room
|
|
654
|
+
* into ITS OWN room.db, and recurses into a sub-room's own sub-rooms at
|
|
655
|
+
* arbitrary depth (a sub-sub-room is rebuilt into its own db, never a parent
|
|
656
|
+
* conn). Cycle-guarded by a visited-set of resolved absolute paths.
|
|
657
|
+
*
|
|
658
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
659
|
+
* @param {string} roomDir - Absolute path to room directory
|
|
660
|
+
* @param {Set<string>} [_visited] - internal cycle-guard (resolved abs paths)
|
|
661
|
+
* @returns {Promise<{success: boolean, artifacts: number, sections: number, subRooms: number}>}
|
|
662
|
+
*/
|
|
663
|
+
async function rebuildGraph(conn, roomDir, _visited) {
|
|
664
|
+
const resolved = path.resolve(roomDir);
|
|
665
|
+
|
|
666
|
+
// Cycle guard for the transitive sub-room recursion (T-169-20): a visited-set
|
|
667
|
+
// of resolved absolute paths so a cyclic / symlinked .room-root graph cannot
|
|
668
|
+
// spin. The TOP-level call seeds the set with its own resolved path.
|
|
669
|
+
const visited = (_visited instanceof Set) ? _visited : new Set();
|
|
670
|
+
if (visited.has(resolved)) {
|
|
671
|
+
return Promise.resolve({ success: true, artifacts: 0, sections: 0, subRooms: 0 });
|
|
672
|
+
}
|
|
673
|
+
visited.add(resolved);
|
|
674
|
+
|
|
675
|
+
// Wrap entire rebuild in a transaction for atomicity.
|
|
676
|
+
// If anything throws mid-rebuild, the DB rolls back to pre-rebuild state.
|
|
677
|
+
//
|
|
678
|
+
// NOTE (Plan 87-06): use explicit BEGIN/COMMIT/ROLLBACK because
|
|
679
|
+
// node:sqlite DatabaseSync does NOT expose a transaction(fn) higher-order
|
|
680
|
+
// helper (that is a better-sqlite3 API). Calling the inner
|
|
681
|
+
// `_indexArtifactBody` (not `indexArtifact`) avoids a nested BEGIN that
|
|
682
|
+
// SQLite would reject ("cannot start a transaction within a transaction"
|
|
683
|
+
// without SAVEPOINT).
|
|
684
|
+
const discovery = discoverSections(resolved);
|
|
685
|
+
const sectionNames = discovery.all;
|
|
686
|
+
let artifactCount = 0;
|
|
687
|
+
|
|
688
|
+
conn.prepare('BEGIN').run();
|
|
689
|
+
try {
|
|
690
|
+
// Clear existing INDEXER-OWNED data (edges first for FK compliance).
|
|
691
|
+
// Phase 236 (GRAPHDB-01): the ONE ownership-scoped wipe, shared with
|
|
692
|
+
// scripts/build-ecosystem-graph.cjs. rebuildGraph passes no extra derived
|
|
693
|
+
// edge types because it regenerates nothing beyond BELONGS_TO.
|
|
694
|
+
clearIndexerOwnedRows(conn);
|
|
695
|
+
|
|
696
|
+
for (const sectionName of sectionNames) {
|
|
697
|
+
const sectionDir = path.join(resolved, sectionName);
|
|
698
|
+
let files;
|
|
699
|
+
try {
|
|
700
|
+
files = fs.readdirSync(sectionDir).filter(_isIndexableArtifactFile);
|
|
701
|
+
} catch (e) {
|
|
702
|
+
continue; // skip this section
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
for (const file of files) {
|
|
706
|
+
const filePath = path.join(sectionDir, file);
|
|
707
|
+
_indexArtifactBody(conn, resolved, filePath); // inside outer BEGIN, no nested txn
|
|
708
|
+
artifactCount++;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// Nested-artifact walk (CLAUDE.md decision #16, v1.9.7; quick fix
|
|
712
|
+
// 260705-qi8): under the Obsidian-nested convention every artifact sits in
|
|
713
|
+
// its own subfolder (section/name/name.md), so the flat readdir above never
|
|
714
|
+
// sees it. Descend EXACTLY ONE level: for each immediate child directory of
|
|
715
|
+
// the section, index its indexable files. Skip any child carrying a
|
|
716
|
+
// .room-root sentinel -- recursing into a sub-room here would double-index
|
|
717
|
+
// its artifacts into the PARENT db, violating the Phase 169 D-169-02 /
|
|
718
|
+
// D-169-11 per-sub-room-db isolation (sub-rooms rebuild into their own
|
|
719
|
+
// room.db in the recursion block below). One level only; no unbounded walk.
|
|
720
|
+
let childDirs;
|
|
721
|
+
try {
|
|
722
|
+
childDirs = fs.readdirSync(sectionDir, { withFileTypes: true })
|
|
723
|
+
.filter(e => e.isDirectory() && !e.name.startsWith('.'))
|
|
724
|
+
.map(e => e.name);
|
|
725
|
+
} catch (e) {
|
|
726
|
+
childDirs = [];
|
|
727
|
+
}
|
|
728
|
+
for (const childName of childDirs) {
|
|
729
|
+
const childDir = path.join(sectionDir, childName);
|
|
730
|
+
if (fs.existsSync(path.join(childDir, '.room-root'))) continue; // sub-room: its own db
|
|
731
|
+
let nestedFiles;
|
|
732
|
+
try {
|
|
733
|
+
nestedFiles = fs.readdirSync(childDir).filter(_isIndexableArtifactFile);
|
|
734
|
+
} catch (e) {
|
|
735
|
+
continue; // skip unreadable child dirs
|
|
736
|
+
}
|
|
737
|
+
for (const file of nestedFiles) {
|
|
738
|
+
const filePath = path.join(childDir, file);
|
|
739
|
+
_indexArtifactBody(conn, resolved, filePath); // inside outer BEGIN, no nested txn
|
|
740
|
+
artifactCount++;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// Phase 169 D-169-07 ROOT-FILES pass: index top-level .md/.docx/.html
|
|
746
|
+
// artifacts that sit in the room ROOT (a flat room whose artifacts are not in
|
|
747
|
+
// section subfolders -- e.g. the b2 sub-room: 39 artifacts in the root). This
|
|
748
|
+
// is a general fix for any flat room, not a fixture hack.
|
|
749
|
+
let rootFiles;
|
|
750
|
+
try {
|
|
751
|
+
rootFiles = fs.readdirSync(resolved, { withFileTypes: true })
|
|
752
|
+
.filter(e => e.isFile() && _isIndexableArtifactFile(e.name))
|
|
753
|
+
.map(e => e.name);
|
|
754
|
+
} catch (_e) {
|
|
755
|
+
rootFiles = [];
|
|
756
|
+
}
|
|
757
|
+
for (const file of rootFiles) {
|
|
758
|
+
const filePath = path.join(resolved, file);
|
|
759
|
+
_indexArtifactBody(conn, resolved, filePath);
|
|
760
|
+
artifactCount++;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// Phase 244 (TRIG-01, T-244-09): reconcile the derived eureka_fts lexical
|
|
764
|
+
// index against the nodes table, now that the full reindex above has
|
|
765
|
+
// finished regenerating every Artifact/Section row.
|
|
766
|
+
//
|
|
767
|
+
// WHY THIS RUNS HERE, AFTER THE REINDEX, NOT IMMEDIATELY AFTER
|
|
768
|
+
// clearIndexerOwnedRows. clearIndexerOwnedRows deletes EVERY
|
|
769
|
+
// indexer-owned node on EVERY rebuild (not only the ones whose files were
|
|
770
|
+
// actually removed from disk); the section walk + ROOT-FILES pass above
|
|
771
|
+
// then RESTORES all of them with the same deterministic, path-derived
|
|
772
|
+
// ids (getArtifactId). A reconcile placed between the wipe and the
|
|
773
|
+
// reindex would therefore see a window where NO Artifact/Section node
|
|
774
|
+
// exists yet and would treat every one of their eureka_fts rows as
|
|
775
|
+
// orphaned, wiping the lexical index on every single rebuild rather than
|
|
776
|
+
// only the rows for content that is genuinely gone. Running the DELETE
|
|
777
|
+
// here, after `nodes` has been fully repopulated, is what lets it
|
|
778
|
+
// discriminate a truly deleted artifact (never reinserted, so still
|
|
779
|
+
// absent from `nodes`) from one that was merely wiped-and-regenerated in
|
|
780
|
+
// this same transaction (already reinserted by the time this runs).
|
|
781
|
+
//
|
|
782
|
+
// WHY THIS IS A SEPARATE STATEMENT, NOT FOLDED INTO
|
|
783
|
+
// clearIndexerOwnedRows. eureka_fts (the fts5 virtual table owned by
|
|
784
|
+
// lib/core/eureka/tri-modal-index.cjs) is NOT covered by that wipe --
|
|
785
|
+
// proven live (244-RESEARCH.md Q2): after a scoped clearIndexerOwnedRows
|
|
786
|
+
// wipe of Artifact/Section nodes, eureka_fts KEEPS their rows and a MATCH
|
|
787
|
+
// still returns them, meaning a content-tier trigger could fire on
|
|
788
|
+
// content that no longer exists and point at a dead node_id.
|
|
789
|
+
// clearIndexerOwnedRows's own doc contract (:87-125 above) is an
|
|
790
|
+
// allowlist of what the indexer can REGENERATE over the nodes/edges
|
|
791
|
+
// tables specifically; eureka_fts is neither table, so it does not
|
|
792
|
+
// belong in that allowlist -- it belongs beside the call.
|
|
793
|
+
//
|
|
794
|
+
// THE HAZARD IS RESURRECTION, NOT LOSS: unlike the nodes/edges rows
|
|
795
|
+
// clearIndexerOwnedRows deletes, eureka_fts holds no original data (it is
|
|
796
|
+
// 100% derived from nodes + on-disk artifact bodies), so destroying
|
|
797
|
+
// stale rows here is always safe to do freely.
|
|
798
|
+
//
|
|
799
|
+
// DO NOT widen INDEXER_OWNED_NODE_TYPES or INDEXER_OWNED_EDGE_TYPES to
|
|
800
|
+
// cover this instead. Quoting the header at :66-69 above: "Widening
|
|
801
|
+
// either constant reintroduces the data loss at a narrower scope." Those
|
|
802
|
+
// two constants are typed vocabularies for the nodes/edges tables' OWN
|
|
803
|
+
// irreplaceable-vs-derived split; eureka_fts is a different table with a
|
|
804
|
+
// different safety property (fully derived, freely destroyable).
|
|
805
|
+
//
|
|
806
|
+
// Riding THIS SAME BEGIN is what makes the reconcile atomic for free: if
|
|
807
|
+
// the rebuild throws AFTER this DELETE but before the COMMIT below, the
|
|
808
|
+
// ROLLBACK at the catch block restores BOTH the nodes table and these
|
|
809
|
+
// FTS rows together, because they are the same transaction.
|
|
810
|
+
//
|
|
811
|
+
// Guarded by BOTH ensureFtsAvailable() (the process-wide FTS5 capability
|
|
812
|
+
// probe -- some node:sqlite builds lack the extension) and
|
|
813
|
+
// tableExists(conn, 'eureka_fts') (this db may simply never have built
|
|
814
|
+
// the index at all -- the DEFAULT state of every live room today, per
|
|
815
|
+
// 244-RESEARCH.md Pitfall 2). The whole guarded block is its own
|
|
816
|
+
// try/catch that swallows and continues (T-244-10): a reconcile fault
|
|
817
|
+
// must never abort a rebuild that is otherwise succeeding.
|
|
818
|
+
//
|
|
819
|
+
// Both guards now live INSIDE tri.reconcileFtsOrphans, which is the ONE
|
|
820
|
+
// canonical copy of the prune SQL (Phase 244, RCA
|
|
821
|
+
// eureka-fts-orphan-rows-block-release-gate). This block previously carried
|
|
822
|
+
// its own verbatim duplicate, with a twin in
|
|
823
|
+
// scripts/build-ecosystem-graph.cjs and a comment on each warning that both
|
|
824
|
+
// must be kept in sync. That hazard is retired: when the build path needed
|
|
825
|
+
// the same prune, the SQL was extracted rather than copied a third time, and
|
|
826
|
+
// both former copies now delegate here.
|
|
827
|
+
//
|
|
828
|
+
// The try/catch stays on THIS side deliberately. reconcileFtsOrphans does
|
|
829
|
+
// not swallow (on the build path a swallowed fault would be a "successful"
|
|
830
|
+
// build that silently did not reconcile), so the swallow is the caller's
|
|
831
|
+
// choice, made here for the reason T-244-10 states: a reconcile fault must
|
|
832
|
+
// never abort an otherwise-succeeding rebuild.
|
|
833
|
+
(function reconcileFtsIndexInline() {
|
|
834
|
+
try {
|
|
835
|
+
// Lazy require inside this scoped function (the
|
|
836
|
+
// navigation-engine.cjs:510 cross-layer idiom): avoids a
|
|
837
|
+
// module-load-time require of the eureka subsystem for every caller
|
|
838
|
+
// of lazygraph-ops.cjs, most of which never touch eureka_fts.
|
|
839
|
+
// eslint-disable-next-line global-require
|
|
840
|
+
const tri = require('./eureka/tri-modal-index.cjs');
|
|
841
|
+
// No-op when FTS5 is not compiled in on this build, and when eureka_fts
|
|
842
|
+
// was never built on this db (Pitfall 2, the default state of every live
|
|
843
|
+
// room). Both checks are the helper's own self-guards.
|
|
844
|
+
tri.reconcileFtsOrphans(conn);
|
|
845
|
+
} catch (_e) {
|
|
846
|
+
// Swallow and continue (T-244-10): a reconcile fault must never
|
|
847
|
+
// abort an otherwise-succeeding rebuild.
|
|
848
|
+
}
|
|
849
|
+
})();
|
|
850
|
+
|
|
851
|
+
conn.prepare('COMMIT').run();
|
|
852
|
+
} catch (err) {
|
|
853
|
+
try { conn.prepare('ROLLBACK').run(); } catch (_rbErr) { /* ignore */ }
|
|
854
|
+
throw err;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// Phase 169 D-169-02 / D-169-11 TRANSITIVE sub-room recursion. AFTER the
|
|
858
|
+
// parent's own sections + root are committed, detect direct sub-rooms and
|
|
859
|
+
// rebuild EACH into ITS OWN room.db, recursing into the sub-room's own
|
|
860
|
+
// sub-rooms at arbitrary depth. Per-sub-room db (Part 8 room isolation): never
|
|
861
|
+
// index a sub-room into the parent conn. room-db is lazy-required to avoid the
|
|
862
|
+
// room-db.cjs <-> lazygraph-ops.cjs circular require at module-load time.
|
|
863
|
+
let subRoomCount = 0;
|
|
864
|
+
const subRooms = _detectSubRooms(resolved);
|
|
865
|
+
if (subRooms.length > 0) {
|
|
866
|
+
let openRoomDb, closeRoomDb;
|
|
867
|
+
try {
|
|
868
|
+
({ openRoomDb, closeRoomDb } = require('./room-db.cjs'));
|
|
869
|
+
} catch (_e) {
|
|
870
|
+
openRoomDb = null;
|
|
871
|
+
}
|
|
872
|
+
if (typeof openRoomDb === 'function') {
|
|
873
|
+
for (const subRoom of subRooms) {
|
|
874
|
+
if (visited.has(subRoom)) continue;
|
|
875
|
+
let subConn = null;
|
|
876
|
+
try {
|
|
877
|
+
subConn = openRoomDb(subRoom);
|
|
878
|
+
const r = await rebuildGraph(subConn, subRoom, visited);
|
|
879
|
+
subRoomCount += 1 + (r && typeof r.subRooms === 'number' ? r.subRooms : 0);
|
|
880
|
+
} catch (_e) {
|
|
881
|
+
// a sub-room rebuild fault must not abort the parent rebuild.
|
|
882
|
+
} finally {
|
|
883
|
+
if (subConn && typeof closeRoomDb === 'function') {
|
|
884
|
+
try { closeRoomDb(subConn); } catch (_ce) { /* ignore */ }
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
return Promise.resolve({
|
|
892
|
+
success: true,
|
|
893
|
+
artifacts: artifactCount,
|
|
894
|
+
sections: sectionNames.length,
|
|
895
|
+
subRooms: subRoomCount,
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Execute a SQL query and return all result rows.
|
|
901
|
+
* Gracefully returns empty array on error.
|
|
902
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
903
|
+
* @param {string} sql - SQL query string
|
|
904
|
+
* @param {Array<*>|Object} [params] - bound parameters; array for anonymous (?) placeholders, object for named ($x)
|
|
905
|
+
* @returns {Promise<Array<object>>}
|
|
906
|
+
*/
|
|
907
|
+
async function queryGraph(conn, sql, params) {
|
|
908
|
+
try {
|
|
909
|
+
const stmt = conn.prepare(sql);
|
|
910
|
+
if (params == null) {
|
|
911
|
+
return Promise.resolve(stmt.all());
|
|
912
|
+
}
|
|
913
|
+
if (Array.isArray(params)) {
|
|
914
|
+
return Promise.resolve(params.length ? stmt.all(...params) : stmt.all());
|
|
915
|
+
}
|
|
916
|
+
return Promise.resolve(stmt.all(params));
|
|
917
|
+
} catch (e) {
|
|
918
|
+
return Promise.resolve([]);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Get graph statistics: node counts, edge counts, totals.
|
|
924
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
925
|
+
* @returns {Promise<{nodes: object, edges: object, total: {nodes: number, edges: number}}>}
|
|
926
|
+
*/
|
|
927
|
+
async function graphStats(conn) {
|
|
928
|
+
// Count nodes by type
|
|
929
|
+
// Count ALL node types dynamically (not hardcoded)
|
|
930
|
+
const nodeCounts = {};
|
|
931
|
+
const nodeRows = conn.prepare('SELECT type, COUNT(*) AS cnt FROM nodes GROUP BY type').all();
|
|
932
|
+
for (const row of nodeRows) {
|
|
933
|
+
nodeCounts[row.type] = row.cnt;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// Count edges by type
|
|
937
|
+
const edges = {};
|
|
938
|
+
for (const edgeType of EDGE_TYPES) { edges[edgeType] = 0; }
|
|
939
|
+
const edgeRows = conn.prepare('SELECT type, COUNT(*) AS cnt FROM edges GROUP BY type').all();
|
|
940
|
+
for (const row of edgeRows) {
|
|
941
|
+
if (row.type in edges) {
|
|
942
|
+
edges[row.type] = row.cnt;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
const totalNodes = Object.values(nodeCounts).reduce((sum, n) => sum + n, 0);
|
|
947
|
+
const totalEdges = Object.values(edges).reduce((sum, n) => sum + n, 0);
|
|
948
|
+
|
|
949
|
+
return Promise.resolve({
|
|
950
|
+
nodes: nodeCounts,
|
|
951
|
+
edges,
|
|
952
|
+
total: { nodes: totalNodes, edges: totalEdges },
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Tier 2 Pinecone semantic layer stub.
|
|
958
|
+
* Embeds an artifact for semantic search when Pinecone is configured.
|
|
959
|
+
* Gracefully degrades when Pinecone env vars are not set.
|
|
960
|
+
*
|
|
961
|
+
* Contract: embedArtifact(roomDir, filePath) -> { success: boolean, reason?: string, embeddingId?: string }
|
|
962
|
+
*
|
|
963
|
+
* @param {string} roomDir - Absolute path to room directory
|
|
964
|
+
* @param {string} filePath - Absolute path to .md artifact file
|
|
965
|
+
* @returns {Promise<{success: boolean, reason?: string, embeddingId?: string}>}
|
|
966
|
+
*/
|
|
967
|
+
async function embedArtifact(roomDir, filePath) {
|
|
968
|
+
// Read the artifact content (validates the file exists)
|
|
969
|
+
const resolved = path.resolve(filePath);
|
|
970
|
+
if (!fs.existsSync(resolved)) {
|
|
971
|
+
return { success: false, reason: `Artifact not found: ${filePath}` };
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
const apiKey = process.env.PINECONE_API_KEY;
|
|
975
|
+
const index = process.env.PINECONE_INDEX;
|
|
976
|
+
|
|
977
|
+
if (!apiKey || !index) {
|
|
978
|
+
return {
|
|
979
|
+
success: false,
|
|
980
|
+
reason: 'Pinecone Tier 2 not configured - set PINECONE_API_KEY and PINECONE_INDEX to enable semantic search',
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// Pinecone env vars are set but integration not yet wired
|
|
985
|
+
return {
|
|
986
|
+
success: false,
|
|
987
|
+
reason: 'Pinecone Tier 2 integration not yet implemented - stub ready for future wiring',
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// --- Design-by-Analogy Edge Creation (DBA-08) ---
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Create an ANALOGOUS_TO edge between two artifacts.
|
|
995
|
+
* Records functional analogy with distance, fitness, and transfer mapping.
|
|
996
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
997
|
+
* @param {string} sourceId - Source artifact ID
|
|
998
|
+
* @param {string} targetId - Target artifact ID
|
|
999
|
+
* @param {object} props - Edge properties
|
|
1000
|
+
* @param {string} [props.analogy_distance='near'] - near|far|cross-domain
|
|
1001
|
+
* @param {number} [props.structural_fitness=0.0] - 0-1 structural fitness score
|
|
1002
|
+
* @param {string} [props.source_domain=''] - Domain of the source analogy
|
|
1003
|
+
* @param {string} [props.transfer_map='{}'] - JSON string mapping source to target elements
|
|
1004
|
+
* @param {string} [props.discovery_method='hsi'] - hsi|brain|llm|external|user
|
|
1005
|
+
* @returns {Promise<boolean>}
|
|
1006
|
+
*/
|
|
1007
|
+
async function createAnalogyEdge(conn, sourceId, targetId, props = {}) {
|
|
1008
|
+
const edgeProps = JSON.stringify({
|
|
1009
|
+
analogy_distance: props.analogy_distance || 'near',
|
|
1010
|
+
structural_fitness: props.structural_fitness || 0.0,
|
|
1011
|
+
source_domain: props.source_domain || '',
|
|
1012
|
+
transfer_map: props.transfer_map || '{}',
|
|
1013
|
+
discovery_method: props.discovery_method || 'hsi',
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
conn.prepare(
|
|
1017
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1018
|
+
).run(sourceId, targetId, 'ANALOGOUS_TO', edgeProps);
|
|
1019
|
+
return Promise.resolve(true);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Create a STRUCTURALLY_ISOMORPHIC edge between two sections.
|
|
1024
|
+
* Records identical relational topology between room sections.
|
|
1025
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1026
|
+
* @param {string} sectionA - Source section name
|
|
1027
|
+
* @param {string} sectionB - Target section name
|
|
1028
|
+
* @param {object} props - Edge properties
|
|
1029
|
+
* @param {number} [props.isomorphism_score=0.0] - 0-1 isomorphism score
|
|
1030
|
+
* @param {string} [props.mapped_elements='{}'] - JSON string of element mappings
|
|
1031
|
+
* @param {string} [props.source=''] - Source of the isomorphism detection
|
|
1032
|
+
* @returns {Promise<boolean>}
|
|
1033
|
+
*/
|
|
1034
|
+
async function createIsomorphismEdge(conn, sectionA, sectionB, props = {}) {
|
|
1035
|
+
const edgeProps = JSON.stringify({
|
|
1036
|
+
isomorphism_score: props.isomorphism_score || 0.0,
|
|
1037
|
+
mapped_elements: props.mapped_elements || '{}',
|
|
1038
|
+
source: props.source || '',
|
|
1039
|
+
});
|
|
1040
|
+
|
|
1041
|
+
conn.prepare(
|
|
1042
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1043
|
+
).run(sectionA, sectionB, 'STRUCTURALLY_ISOMORPHIC', edgeProps);
|
|
1044
|
+
return Promise.resolve(true);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Create a RESOLVES_VIA edge linking a contradiction to its resolution.
|
|
1049
|
+
* Closes the loop: contradiction -> analogy/TRIZ -> resolution.
|
|
1050
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1051
|
+
* @param {string} sourceId - Artifact ID (the contradicting artifact)
|
|
1052
|
+
* @param {string} targetId - Artifact ID (the resolution artifact)
|
|
1053
|
+
* @param {object} props - Edge properties
|
|
1054
|
+
* @param {string} [props.resolution_type='direct'] - analogy|triz_principle|direct
|
|
1055
|
+
* @param {string} [props.triz_principle=''] - TRIZ principle number/name if applicable
|
|
1056
|
+
* @param {string} [props.analogy_source=''] - Source analogy reference if applicable
|
|
1057
|
+
* @param {number} [props.confidence=0.0] - 0-1 confidence in resolution
|
|
1058
|
+
* @returns {Promise<boolean>}
|
|
1059
|
+
*/
|
|
1060
|
+
async function createResolutionEdge(conn, sourceId, targetId, props = {}) {
|
|
1061
|
+
const edgeProps = JSON.stringify({
|
|
1062
|
+
resolution_type: props.resolution_type || 'direct',
|
|
1063
|
+
triz_principle: props.triz_principle || '',
|
|
1064
|
+
analogy_source: props.analogy_source || '',
|
|
1065
|
+
confidence: props.confidence || 0.0,
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
conn.prepare(
|
|
1069
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1070
|
+
).run(sourceId, targetId, 'RESOLVES_VIA', edgeProps);
|
|
1071
|
+
return Promise.resolve(true);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// --- Causal Extraction CRUD (Phase 53) ---
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Create or update a CausalClaim node in SQLite.
|
|
1078
|
+
* Writes all 12 properties as JSON. Truncates cause/effect to 200 chars,
|
|
1079
|
+
* mechanism to 300 chars to prevent oversized nodes.
|
|
1080
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1081
|
+
* @param {object} claim - CausalClaim properties
|
|
1082
|
+
* @param {string} claim.id - Unique claim ID
|
|
1083
|
+
* @param {string} claim.cause - Cause statement (truncated to 200 chars)
|
|
1084
|
+
* @param {string} claim.mechanism - Mechanism explanation (truncated to 300 chars)
|
|
1085
|
+
* @param {string} claim.effect - Effect statement (truncated to 200 chars)
|
|
1086
|
+
* @param {number} [claim.confidence=0.5] - Confidence score (0-1)
|
|
1087
|
+
* @param {string} [claim.evidence='[]'] - JSON array of evidence references
|
|
1088
|
+
* @param {string} [claim.source_artifact=''] - Source artifact ID
|
|
1089
|
+
* @param {string} [claim.domain='general'] - Domain classification
|
|
1090
|
+
* @param {string} [claim.falsifiable_prediction=''] - Testable prediction
|
|
1091
|
+
* @param {number} [claim.novelty_score=0.0] - Novelty score (0-1)
|
|
1092
|
+
* @param {string} [claim.extraction_method='inferred'] - observed|asserted|inferred
|
|
1093
|
+
* @param {string} [claim.created=''] - ISO date string
|
|
1094
|
+
* @returns {Promise<boolean>}
|
|
1095
|
+
*/
|
|
1096
|
+
async function createCausalClaim(conn, claim) {
|
|
1097
|
+
const cause = (claim.cause || '').slice(0, 200);
|
|
1098
|
+
const mechanism = (claim.mechanism || '').slice(0, 300);
|
|
1099
|
+
const effect = (claim.effect || '').slice(0, 200);
|
|
1100
|
+
const confidence = typeof claim.confidence === 'number' ? claim.confidence : 0.5;
|
|
1101
|
+
const evidence = Array.isArray(claim.evidence) ? JSON.stringify(claim.evidence) : (claim.evidence || '[]');
|
|
1102
|
+
const sourceArtifact = claim.source_artifact || '';
|
|
1103
|
+
const domain = claim.domain || 'general';
|
|
1104
|
+
const prediction = claim.falsifiable_prediction || '';
|
|
1105
|
+
const novelty = typeof claim.novelty_score === 'number' ? claim.novelty_score : 0.0;
|
|
1106
|
+
const method = claim.extraction_method || 'inferred';
|
|
1107
|
+
const created = claim.created || '';
|
|
1108
|
+
|
|
1109
|
+
const props = JSON.stringify({
|
|
1110
|
+
cause, mechanism, effect, confidence, evidence, source_artifact: sourceArtifact,
|
|
1111
|
+
domain, falsifiable_prediction: prediction, novelty_score: novelty,
|
|
1112
|
+
extraction_method: method, created,
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
// HARD-02: shared NOT-NULL-safe helper (D-02 + D-02a).
|
|
1116
|
+
// R17-02: epistemic_type 'derived_fact' per Task 4 Decision 4 (CausalClaim
|
|
1117
|
+
// reached via lazygraph maps to derived_fact).
|
|
1118
|
+
insertNode(conn, claim.id, 'CausalClaim', props, { epistemic_type: 'derived_fact' });
|
|
1119
|
+
return Promise.resolve(true);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* Create an EXTRACTED_FROM edge linking a CausalClaim to its source Artifact.
|
|
1124
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1125
|
+
* @param {string} claimId - CausalClaim node ID
|
|
1126
|
+
* @param {string} artifactId - Artifact node ID
|
|
1127
|
+
* @returns {Promise<boolean>}
|
|
1128
|
+
*/
|
|
1129
|
+
async function createExtractedFromEdge(conn, claimId, artifactId) {
|
|
1130
|
+
conn.prepare(
|
|
1131
|
+
'INSERT INTO edges (source, target, type) VALUES (?, ?, ?) ON CONFLICT DO NOTHING'
|
|
1132
|
+
).run(claimId, artifactId, 'EXTRACTED_FROM');
|
|
1133
|
+
return Promise.resolve(true);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
// --- Causal Graph Engine (Phase 54) ---
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* Create a CASCADES_TO edge between two CausalClaim nodes.
|
|
1140
|
+
* Idempotent via ON CONFLICT. Records cascade type and severity.
|
|
1141
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1142
|
+
* @param {string} fromClaimId - Source CausalClaim node ID
|
|
1143
|
+
* @param {string} toClaimId - Target CausalClaim node ID
|
|
1144
|
+
* @param {object} [opts] - Edge properties
|
|
1145
|
+
* @param {string} [opts.cascade_type='invalidation'] - invalidation|weakening|dependency
|
|
1146
|
+
* @param {string} [opts.severity='medium'] - high|medium|low
|
|
1147
|
+
* @param {number} [opts.path_length=1] - Hop distance
|
|
1148
|
+
* @returns {Promise<boolean>}
|
|
1149
|
+
*/
|
|
1150
|
+
async function createCascadesToEdge(conn, fromClaimId, toClaimId, opts = {}) {
|
|
1151
|
+
const edgeProps = JSON.stringify({
|
|
1152
|
+
cascade_type: opts.cascade_type || 'invalidation',
|
|
1153
|
+
severity: opts.severity || 'medium',
|
|
1154
|
+
path_length: typeof opts.path_length === 'number' ? opts.path_length : 1,
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
conn.prepare(
|
|
1158
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1159
|
+
).run(fromClaimId, toClaimId, 'CASCADES_TO', edgeProps);
|
|
1160
|
+
return Promise.resolve(true);
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Export all CausalClaim nodes and CASCADES_TO edges as JSON.
|
|
1165
|
+
* Writes .lazygraph-causal-export.json to roomDir for Python engine consumption.
|
|
1166
|
+
* Handles empty graphs gracefully (writes JSON with empty arrays).
|
|
1167
|
+
* @param {string} roomDir - Path to room directory
|
|
1168
|
+
* @returns {Promise<{metadata: object, nodes: Array, edges: Array}>}
|
|
1169
|
+
*/
|
|
1170
|
+
async function exportCausalGraph(roomDir) {
|
|
1171
|
+
const resolved = path.resolve(roomDir);
|
|
1172
|
+
const { db, conn } = await openGraph(resolved);
|
|
1173
|
+
try {
|
|
1174
|
+
// Query all CausalClaim nodes
|
|
1175
|
+
let nodes = [];
|
|
1176
|
+
try {
|
|
1177
|
+
nodes = conn.prepare(
|
|
1178
|
+
"SELECT id, json_extract(properties, '$.cause') AS cause, json_extract(properties, '$.mechanism') AS mechanism, json_extract(properties, '$.effect') AS effect, json_extract(properties, '$.confidence') AS confidence, json_extract(properties, '$.domain') AS domain, json_extract(properties, '$.source_artifact') AS source_artifact FROM nodes WHERE type = 'CausalClaim'"
|
|
1179
|
+
).all();
|
|
1180
|
+
} catch (e) {
|
|
1181
|
+
// table may be empty or schema different
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// Query all CASCADES_TO edges
|
|
1185
|
+
let edges = [];
|
|
1186
|
+
try {
|
|
1187
|
+
edges = conn.prepare(
|
|
1188
|
+
"SELECT source, target, json_extract(properties, '$.cascade_type') AS cascade_type, json_extract(properties, '$.severity') AS severity FROM edges WHERE type = 'CASCADES_TO'"
|
|
1189
|
+
).all();
|
|
1190
|
+
} catch (e) {
|
|
1191
|
+
// no CASCADES_TO edges
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
const exportData = {
|
|
1195
|
+
metadata: {
|
|
1196
|
+
exported_at: new Date().toISOString(),
|
|
1197
|
+
node_count: nodes.length,
|
|
1198
|
+
edge_count: edges.length,
|
|
1199
|
+
},
|
|
1200
|
+
nodes,
|
|
1201
|
+
edges,
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
const exportPath = path.join(resolved, '.lazygraph-causal-export.json');
|
|
1205
|
+
fs.writeFileSync(exportPath, JSON.stringify(exportData, null, 2), 'utf-8');
|
|
1206
|
+
return exportData;
|
|
1207
|
+
} finally {
|
|
1208
|
+
await closeGraph(db);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
// --- TRIZ Contradiction Enrichment (DBA-09) ---
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* Enrich an existing CONTRADICTS edge with TRIZ parameter classification.
|
|
1216
|
+
* Looks up triz-matrix.json to suggest inventive principles for the contradiction.
|
|
1217
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1218
|
+
* @param {string} artifactA - Source artifact ID
|
|
1219
|
+
* @param {string} artifactB - Target artifact ID
|
|
1220
|
+
* @param {string} improvingParam - TRIZ parameter being improved (one of 39)
|
|
1221
|
+
* @param {string} worseningParam - TRIZ parameter being worsened (one of 39)
|
|
1222
|
+
* @returns {Promise<{success: boolean, principles: number[], reason?: string}>}
|
|
1223
|
+
*/
|
|
1224
|
+
async function enrichContradictionWithTRIZ(conn, artifactA, artifactB, improvingParam, worseningParam) {
|
|
1225
|
+
// Load TRIZ matrix
|
|
1226
|
+
const matrixPath = path.join(__dirname, '..', '..', 'references', 'methodology', 'triz-matrix.json');
|
|
1227
|
+
if (!fs.existsSync(matrixPath)) {
|
|
1228
|
+
return { success: false, principles: [], reason: 'triz-matrix.json not found' };
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
let matrix;
|
|
1232
|
+
try {
|
|
1233
|
+
matrix = JSON.parse(fs.readFileSync(matrixPath, 'utf-8'));
|
|
1234
|
+
} catch (e) {
|
|
1235
|
+
return { success: false, principles: [], reason: 'Failed to parse triz-matrix.json' };
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// Look up principles
|
|
1239
|
+
const improvingEntry = matrix[improvingParam];
|
|
1240
|
+
if (!improvingEntry) {
|
|
1241
|
+
return { success: false, principles: [], reason: `Unknown improving parameter: ${improvingParam}` };
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
const principles = improvingEntry[worseningParam];
|
|
1245
|
+
if (!principles || !Array.isArray(principles) || principles.length === 0) {
|
|
1246
|
+
return { success: false, principles: [], reason: `No principles found for ${improvingParam} vs ${worseningParam}` };
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
const principlesStr = principles.join(',');
|
|
1250
|
+
|
|
1251
|
+
// Create a RESOLVES_VIA edge capturing the TRIZ resolution direction
|
|
1252
|
+
const edgeProps = JSON.stringify({
|
|
1253
|
+
resolution_type: 'triz_principle',
|
|
1254
|
+
triz_principle: principlesStr,
|
|
1255
|
+
analogy_source: `${improvingParam} vs ${worseningParam}`,
|
|
1256
|
+
confidence: 0.7,
|
|
1257
|
+
});
|
|
1258
|
+
|
|
1259
|
+
conn.prepare(
|
|
1260
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1261
|
+
).run(artifactA, artifactB, 'RESOLVES_VIA', edgeProps);
|
|
1262
|
+
|
|
1263
|
+
return { success: true, principles };
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
// --- Whitespace Zone CRUD (Phase 61) ---
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Create or update a WhitespaceZone node in SQLite.
|
|
1270
|
+
* Writes all properties as JSON. Idempotent.
|
|
1271
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1272
|
+
* @param {object} zone - WhitespaceZone properties
|
|
1273
|
+
* @param {string} zone.id - Unique zone ID
|
|
1274
|
+
* @param {string} zone.brain_framework - Brain framework name this gap relates to
|
|
1275
|
+
* @param {number} [zone.density_score=0.0] - Embedding space density score
|
|
1276
|
+
* @param {number} [zone.knn_density=0.0] - KNN density from SemNovel algorithm
|
|
1277
|
+
* @param {string} [zone.nearest_frameworks='[]'] - JSON array of nearest framework names
|
|
1278
|
+
* @param {string} [zone.hypothesis=''] - Generated hypothesis about what should fill this gap
|
|
1279
|
+
* @param {number} [zone.strategic_rank=0.0] - Strategic importance ranking
|
|
1280
|
+
* @param {string} [zone.problem_type=''] - Problem type classification
|
|
1281
|
+
* @param {string} [zone.exploration_status='detected'] - detected|exploring|resolved|dismissed
|
|
1282
|
+
* @param {string} [zone.created=''] - ISO date string
|
|
1283
|
+
* @returns {Promise<boolean>}
|
|
1284
|
+
*/
|
|
1285
|
+
async function addWhitespaceZone(conn, zone) {
|
|
1286
|
+
const props = JSON.stringify({
|
|
1287
|
+
brain_framework: zone.brain_framework || '',
|
|
1288
|
+
density_score: typeof zone.density_score === 'number' ? zone.density_score : 0.0,
|
|
1289
|
+
knn_density: typeof zone.knn_density === 'number' ? zone.knn_density : 0.0,
|
|
1290
|
+
nearest_frameworks: Array.isArray(zone.nearest_frameworks) ? JSON.stringify(zone.nearest_frameworks) : (zone.nearest_frameworks || '[]'),
|
|
1291
|
+
hypothesis: (zone.hypothesis || '').slice(0, 500),
|
|
1292
|
+
strategic_rank: typeof zone.strategic_rank === 'number' ? zone.strategic_rank : 0.0,
|
|
1293
|
+
problem_type: zone.problem_type || '',
|
|
1294
|
+
exploration_status: zone.exploration_status || 'detected',
|
|
1295
|
+
created: zone.created || '',
|
|
1296
|
+
});
|
|
1297
|
+
|
|
1298
|
+
// HARD-02: shared NOT-NULL-safe helper (D-02 + D-02a).
|
|
1299
|
+
// R17-02: epistemic_type 'derived_fact' -- a WhitespaceZone is a computed
|
|
1300
|
+
// analytical output (density/strategic-rank scoring over the graph), not a
|
|
1301
|
+
// human truth-claim; not in Task 4's named table, judgment call applying
|
|
1302
|
+
// the same "algorithmically-computed output" class as CausalClaim.
|
|
1303
|
+
insertNode(conn, zone.id, 'WhitespaceZone', props, { epistemic_type: 'derived_fact' });
|
|
1304
|
+
return Promise.resolve(true);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* Create a WHITESPACE_DETECTED edge from a WhitespaceZone to a nearby Artifact.
|
|
1309
|
+
* Records embedding distance. Idempotent.
|
|
1310
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1311
|
+
* @param {string} zoneId - WhitespaceZone node ID
|
|
1312
|
+
* @param {string} artifactId - Artifact node ID
|
|
1313
|
+
* @param {number} [distance=0.0] - Embedding distance between zone centroid and artifact
|
|
1314
|
+
* @returns {Promise<boolean>}
|
|
1315
|
+
*/
|
|
1316
|
+
async function linkWhitespaceToArtifact(conn, zoneId, artifactId, distance = 0.0) {
|
|
1317
|
+
const edgeProps = JSON.stringify({ distance });
|
|
1318
|
+
conn.prepare(
|
|
1319
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1320
|
+
).run(zoneId, artifactId, 'WHITESPACE_DETECTED', edgeProps);
|
|
1321
|
+
return Promise.resolve(true);
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Create a WHITESPACE_NEAR edge from a WhitespaceZone to a Section.
|
|
1326
|
+
* Records relevance score. Idempotent.
|
|
1327
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1328
|
+
* @param {string} zoneId - WhitespaceZone node ID
|
|
1329
|
+
* @param {string} sectionName - Section node name
|
|
1330
|
+
* @param {number} [relevance=0.0] - Relevance score (0-1)
|
|
1331
|
+
* @returns {Promise<boolean>}
|
|
1332
|
+
*/
|
|
1333
|
+
async function linkWhitespaceToSection(conn, zoneId, sectionName, relevance = 0.0) {
|
|
1334
|
+
const edgeProps = JSON.stringify({ relevance });
|
|
1335
|
+
conn.prepare(
|
|
1336
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1337
|
+
).run(zoneId, sectionName, 'WHITESPACE_NEAR', edgeProps);
|
|
1338
|
+
return Promise.resolve(true);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* Link a WhitespaceZone to an Artifact via DISCOVERY_CYCLE_SOURCE edge.
|
|
1343
|
+
* Records which discovery method (hsi, rs, analogy) found this zone.
|
|
1344
|
+
* @param {import('node:sqlite').DatabaseSync} conn - node:sqlite DatabaseSync instance
|
|
1345
|
+
* @param {string} zoneId - WhitespaceZone ID
|
|
1346
|
+
* @param {string} artifactId - Source Artifact ID
|
|
1347
|
+
* @param {string} discoveryMethod - 'hsi' | 'rs' | 'analogy'
|
|
1348
|
+
* @param {string} [cycleTimestamp] - ISO timestamp of discovery cycle run
|
|
1349
|
+
* @returns {Promise<boolean>}
|
|
1350
|
+
*/
|
|
1351
|
+
async function linkDiscoveryCycleSource(conn, zoneId, artifactId, discoveryMethod, cycleTimestamp = '') {
|
|
1352
|
+
const ts = cycleTimestamp || new Date().toISOString();
|
|
1353
|
+
const edgeProps = JSON.stringify({ discovery_method: discoveryMethod, cycle_timestamp: ts });
|
|
1354
|
+
conn.prepare(
|
|
1355
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1356
|
+
).run(zoneId, artifactId, 'DISCOVERY_CYCLE_SOURCE', edgeProps);
|
|
1357
|
+
return Promise.resolve(true);
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// --- Phase 89-07 Wave 1: generic typed-edge upsert primitive ---
|
|
1361
|
+
//
|
|
1362
|
+
// upsertEdge is the single chokepoint by which agentic surfaces (Phase 89-07
|
|
1363
|
+
// ReverseSalientAgent, Phase 116 tension hook, Phase 117 auto-explore, Phase
|
|
1364
|
+
// 118 MVA, Phase 120 breakthrough scan) emit typed cascade edges. It validates
|
|
1365
|
+
// the edge type against EDGE_TYPES and performs the same UPSERT pattern used
|
|
1366
|
+
// by every other edge writer in this module.
|
|
1367
|
+
//
|
|
1368
|
+
// Shape: upsertEdge(conn, { type, source, target, properties }) -> { ok, reason? }
|
|
1369
|
+
// - conn: node:sqlite DatabaseSync instance (or any object with .prepare).
|
|
1370
|
+
// - type: one of EDGE_TYPES (string).
|
|
1371
|
+
// - source: source node id (string).
|
|
1372
|
+
// - target: target node id (string).
|
|
1373
|
+
// - properties: optional object; serialized to JSON.
|
|
1374
|
+
//
|
|
1375
|
+
// Synchronous (no Promise wrapping); the underlying prepare/run is sync per
|
|
1376
|
+
// node:sqlite contract. Per-call shape mirrors the rest of this module.
|
|
1377
|
+
//
|
|
1378
|
+
// Canon Part 4: every choice is graph data; this primitive lets every agent
|
|
1379
|
+
// emit typed edges without bypassing EDGE_TYPES validation. Canon Part 7:
|
|
1380
|
+
// reuse-before-build; sibling agents reuse this instead of inlining SQL.
|
|
1381
|
+
function upsertEdge(conn, edge) {
|
|
1382
|
+
if (!edge || typeof edge !== 'object') {
|
|
1383
|
+
return { ok: false, reason: 'invalid_edge_object' };
|
|
1384
|
+
}
|
|
1385
|
+
const { type, source, target } = edge;
|
|
1386
|
+
if (typeof type !== 'string' || !EDGE_TYPES.includes(type)) {
|
|
1387
|
+
return { ok: false, reason: 'invalid_edge_type', detail: String(type).slice(0, 40) };
|
|
1388
|
+
}
|
|
1389
|
+
if (typeof source !== 'string' || source.length === 0) {
|
|
1390
|
+
return { ok: false, reason: 'invalid_source_id' };
|
|
1391
|
+
}
|
|
1392
|
+
if (typeof target !== 'string' || target.length === 0) {
|
|
1393
|
+
return { ok: false, reason: 'invalid_target_id' };
|
|
1394
|
+
}
|
|
1395
|
+
const props = edge.properties && typeof edge.properties === 'object' ? edge.properties : {};
|
|
1396
|
+
let propsJson;
|
|
1397
|
+
try {
|
|
1398
|
+
propsJson = JSON.stringify(props);
|
|
1399
|
+
} catch (_e) {
|
|
1400
|
+
return { ok: false, reason: 'properties_serialize_failed' };
|
|
1401
|
+
}
|
|
1402
|
+
try {
|
|
1403
|
+
conn.prepare(
|
|
1404
|
+
'INSERT INTO edges (source, target, type, properties) VALUES (?, ?, ?, ?) ON CONFLICT(source, target, type) DO UPDATE SET properties = excluded.properties'
|
|
1405
|
+
).run(source, target, type, propsJson);
|
|
1406
|
+
} catch (e) {
|
|
1407
|
+
return { ok: false, reason: 'edge_write_failed', detail: String(e.message || '').slice(0, 80) };
|
|
1408
|
+
}
|
|
1409
|
+
return { ok: true, type, source, target };
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// --- Exports ---
|
|
1413
|
+
|
|
1414
|
+
module.exports = {
|
|
1415
|
+
EDGE_TYPES,
|
|
1416
|
+
// Phase 236 (GRAPHDB-01): the indexer ownership allowlist, exported so other
|
|
1417
|
+
// modules and tests read the contract as DATA instead of re-deriving it.
|
|
1418
|
+
INDEXER_OWNED_NODE_TYPES,
|
|
1419
|
+
INDEXER_OWNED_EDGE_TYPES,
|
|
1420
|
+
clearIndexerOwnedRows,
|
|
1421
|
+
upsertEdge,
|
|
1422
|
+
openGraph,
|
|
1423
|
+
closeGraph,
|
|
1424
|
+
initSchema,
|
|
1425
|
+
indexArtifact,
|
|
1426
|
+
rebuildGraph,
|
|
1427
|
+
queryGraph,
|
|
1428
|
+
graphStats,
|
|
1429
|
+
embedArtifact,
|
|
1430
|
+
// Design-by-Analogy (DBA-08, DBA-09)
|
|
1431
|
+
createAnalogyEdge,
|
|
1432
|
+
createIsomorphismEdge,
|
|
1433
|
+
createResolutionEdge,
|
|
1434
|
+
enrichContradictionWithTRIZ,
|
|
1435
|
+
// Causal Extraction (Phase 53)
|
|
1436
|
+
createCausalClaim,
|
|
1437
|
+
createExtractedFromEdge,
|
|
1438
|
+
// Causal Graph Engine (Phase 54)
|
|
1439
|
+
createCascadesToEdge,
|
|
1440
|
+
exportCausalGraph,
|
|
1441
|
+
// Whitespace Zone Layer (Phase 61)
|
|
1442
|
+
addWhitespaceZone,
|
|
1443
|
+
linkWhitespaceToArtifact,
|
|
1444
|
+
linkWhitespaceToSection,
|
|
1445
|
+
// Discovery Cycle (Phase 64)
|
|
1446
|
+
linkDiscoveryCycleSource,
|
|
1447
|
+
// Stakeholder node type (Phase 84-05, SCOPE-NB-03 / SCOPE-NB-04)
|
|
1448
|
+
STAKEHOLDER_TYPES,
|
|
1449
|
+
createStakeholder,
|
|
1450
|
+
getStakeholder,
|
|
1451
|
+
upsertStakeholder,
|
|
1452
|
+
findStakeholdersByClaim,
|
|
1453
|
+
};
|