trm-closed-loop-research
End-to-end Topic Research Mining (TRM) closed-loop pipeline across all registered NotebookLM notebooks in trm-vault. Runs multi-notebook live mining (trm mine-notebooklm), WhichLLM hardware-aware mode
Files5
View on GitHubSKILL.mdskills/trm-closed-loop-research/SKILL.md
GitHubTopic Research Mining (TRM) Closed-Loop Research Workflow
This skill executes the end-to-end Topic Research Mining (TRM) research loop: mining live research notebooks in trm-vault, expanding and triaging discovered knowledge gaps against the local SQLite context cache, synthesizing Layer 2 wiki notes, and building thematic .nlm_pack files for NotebookLM grounding.
Architecture Overview
flowchart TD
A["notebooklm-registry.json (12 Notebooks)"] --> B["1. Live Mining Sweep (schedule-task-wrapper-TRM-Notebooklm-Mine.ps1)"]
B --> C["C:/Users/soren/trm-vault/trm/research-gaps/*.md"]
C --> D["2. Multi-Model Cost Router & MHS Sweep (run-closed-loop-research-v2.mjs)"]
D --> E["3. Cognitive Gap Triage (query-expander.mjs & trm-bot-runner.mjs)"]
E --> F["wiki/research/rfc-gap-*.md Decision Notes"]
D --> G["4. Layer 2 Wiki Synthesis (Tier 1 Mistral/DeepSeek or Tier 2 Frontier)"]
D --> H["5. Thematic Knowledge Packs (.nlm_pack/pack_*.txt)"]
F & G --> I["6. Wiki & Git Push (npm run wiki:publish)"]
Execution Procedures
1. Multi-Notebook Mining Sweep
To mine all registered notebooks in notebooklm-registry.json into C:\Users\soren\trm-vault\trm\research-gaps\:
pwsh.exe -NoProfile -ExecutionPolicy Bypass -File C:\dev\schedule-task-wrapper-TRM-Notebooklm-Mine.ps1
Outputs updated markdown tables for:
cic-kb.mdcic-daily-research.mdwillow-run-videos.mdcast-iron-charlie-research-logs.mdthe-sorensen-photographic-archive-industrial-giants-at-willow-run.mdcastironcharlie-facebook.mdcic-reddit.mdcic-cuban-seizures-retired-assets.mdcic-willow-run-aviation-engineering.mdcic-post-war-willys-overland.mdcic-ford-executive-dynamics-politics.mdcic-research-deltas-living-matrix.md
2. Closed-Loop Orchestration & Wiki Synthesis
Run the live closed-loop synthesis orchestrator from the C:\dev repository root:
# Ingest mined gaps, synthesize Layer 2 wiki topics, and build .nlm_pack files
$env:TRM_SKIP_MINE='1'; node scripts/run-closed-loop-research-v2.mjs
Actions performed:
- Step 0 — Cost-Routing Gateway & MHS Sweep: Reads host hardware profile (
ModelHardwareStandard) and benchmark matrix (_integration/model_selection.json) to assign Tier 0 ($0 Ollama/FreeLLM), Tier 1 (Muscle Cloud), and Tier 2 (Frontier). - Step 1 — Gaps Ingestion: Writes consolidated snapshot to
trm-research-gaps.md. - Step 2 — NotebookLM Grounding: Uploads gaps snapshot to the target daily notebook.
- Step 3 — Topic Derivation: Extracts the 4 core research dimensions (
open-contradictions,under-sourced,adjacent-topics,follow-up). - Step 4 — Layer 2 Wiki Synthesis: Synthesizes structured markdown pages in
wiki/research/via routed Muscle/Frontier inference. - Step 5 — Audit Log: Appends run telemetry, net cost savings, and SHA-256 hash chains to
wiki/Log.md. - Step 6 — Knowledge Packs: Rebuilds thematic
.nlm_pack/pack_*.txtfiles.
3. Automated Gap Triage & RFC Note Drafting
Evaluate pending gaps using cognitive query expansion against the SQLite context cache (.kb_cache/knowledge.db):
# Full daily wrapper with cache pre-sync and logging
npm run trm:triage:daily
# Direct CLI run with auto provider (Ollama -> OpenRouter -> Heuristic)
npm run trm:triage:auto
Actions performed:
- Expands each pending gap query using local or remote LLMs with SQLite
LIMIT 0dry-run validation. - Queries SQLite FTS5 index for sub-millisecond lexical snippet matches.
- Generates structured RFC decision notes in
wiki/research/rfc-gap-*.md. - Mutates
trm-research-gaps.mdby linking in-progress gaps to their drafted RFCs.
4. Publish and Sync Knowledge Base & Wiki
Publish newly synthesized RFCs, concept nodes, and research topics to the GitHub Wiki:
# Synchronize and push all wiki docs to GitHub Wiki
npm run wiki:publish
Verifying & Testing
# Run TRM query expander unit tests (25 tests)
node --test kb-sync/tests/query-expander.test.mjs
# Run local SQLite cache tests
npm run test:cache
# Run TRM pipeline sandbox validation tests
npm run test:trm