Commit Graph

2 Commits

Author SHA1 Message Date
ruv 2b9e2de89f feat(intelligence): Round B (post-edit/-command + trajectory-end → globalStats) + Round C structured distillation (ADR-076)
Round B — closes the wiring-side gap from ADR-074 / ADR-075:
- hooks_post-edit now synthesises a one-step trajectory from {filePath,
  success, agent} and calls recordTrajectory(), so globalStats reflects
  edit outcomes.
- hooks_post-command does the same for command outcomes.
- hooks_intelligence_trajectory-end also bumps globalStats (was only
  feeding sonaCoordinator); the response includes
  learning.globalStatsTrajectoriesDelta.
- Each handler returns learningPath ('trajectory-pipeline'|'recorded-only')
  + a note naming exactly what fired.

Round C — Structured Distillation (#2241 §SOTA, arXiv:2603.13017):
- src/memory/structured-distill.ts: 4-field schema (summary/detail/labels/
  paths), rule-based extractor, embedding-ready serialiser that places
  high-signal tokens (labels, paths) at the front.
- bench/trajectory-mrr-corpus.json: 30 paired (raw, query) trajectories.
- scripts/benchmark-trajectory-mrr.mjs: raw vs distilled retrieval MRR
  harness; uses bridge ONNX embedder, falls back to hash-deterministic
  with an explicit "degraded" warning.

Measured proof (bridge ONNX, Xenova/all-MiniLM-L6-v2, N=30):
  MRR raw 0.0964 → distilled 0.1367 (Δ +0.0403, +41.8% relative).
  Direction matches arXiv:2603.13017 (+0.014 absolute on a 214K paper
  corpus); relative delta is larger here because the small curated corpus
  benefits more from the labels-and-paths-first serialisation order.

Tests: 9 Round-C schema tests + 3 Round-B wiring tests = 12 new.
Full affected suite (self-learning + unified-stats + round-b + structured-
distill + mcp-tools-deep): 135/135.

Honest: a rule-based distiller cannot deliver the paper's 11× byte
compression (current ratio: 0.74× — distilled is 35% bigger). The schema,
corpus, harness, and serialiser are in place so a future round can plug
in a learned distiller as a drop-in extractor swap and pick up that
compression number while keeping this MRR direction.

Bump 3.10.15 → 3.10.16.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-30 12:30:58 -04:00
ruv 0988d92ce8 feat(intelligence): deterministic Tier-1 codemods replacing Agent Booster (ADR-143)
The ADR-026 Tier-1 "Agent Booster, $0, no LLM" path was dead code AND wired
wrong (it fed natural-language instructions to a snippet-merge engine that
expects target code), and the module didn't even resolve. Replace it with real
deterministic codemods so the $0/no-LLM claim is literally true.

- engine.ts: TS-compiler codemods (var-to-const, remove-console, add-logging)
  with formatting-preserving text-range edits + a parse-diagnostic safety net.
- scope-analysis.ts: function-scope reassignment resolution (var→const promotes
  more vars to const without ever producing an incorrect const).
- enhanced-model-router: Tier-1 gated on deterministic intents; route-time
  dry-run only emits [CODEMOD_AVAILABLE] when the edit actually changes a file;
  add-types/add-error-handling/async-await honestly route to a model.
- hooks_codemod MCP tool: real executable Tier-1 surface — single file, files[],
  or glob batch; $0; path-contained.
- Honest [CODEMOD_AVAILABLE] emitters replace [AGENT_BOOSTER_AVAILABLE] and the
  phantom agent_booster_edit_file reference; CLAUDE.md Tier-1 tables corrected.
- Benchmark + golden corpus (12 cases, 100% correct, ~0.55ms/edit, $0) with a
  CI guardrail test; run JSON in cost-trend schema.

Tests: codemod-engine (23), codemod-routing (4), codemod-corpus (13); full CLI
suite 2086 pass / 46 skipped. Closes #2238.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-29 15:40:11 -04:00