feat: relevance-ranked decision delivery, SessionStart + edit-time injection with usage feedback#776
Conversation
SessionStart now scores active decisions against the session's likely working set (dirty/staged files, branch-vs-main diff, previous session's edits, branch-name tokens) expanded one hop through import edges and co-change partners, and injects the top few under a hard ~400-token cap with a relevance floor: relevance or silence, never top-confidence globally. Repo-wide session rules (no node links) carry a flat base relevance since SessionStart is their only delivery path. PostToolUse Edit/Write additionally surfaces the edited file's governing decision once per session per decision, under a strict per-session cap. Dedup is an atomic INSERT OR IGNORE into the sessions.db sidecar because the JSON session state is written read-modify-write by concurrently racing hook processes and loses updates. Shown-decision ids land in a new injections table; at update time the miner judges each one against that session's mined user corrections: contradiction bumps staleness (the evolution amended move), silence relaxes it (reaffirmed). Binary on purpose for v1; the followed vs ignored split is validation-gated backlog. All hook lookups are raw read-only stdlib sqlite3. Measured on this repo: edit notice ~15ms, SessionStart decision scoring ~135ms (git subprocess dominated), no LLM, no network. Dogfood-driven guards: link node ids are compared in POSIX (Windows extraction stores backslashes), top-level module links never fire, and legacy rows that echo the title into decision/rationale are not repeated.
Cold-start dogfood promoted a few one-off task instructions to active alongside the durable rules. Dismissals handle the records themselves, but the block now also caps always-eligible unlinked rules at two per session so a future mis-promotion costs one slot instead of the whole block, and working-set-linked decisions can never be crowded out.
|
✅ Health: 7.6 (unchanged) 📋 At a glance 🚨 Change risk: high (riskier than 83% of this repo's commits · raw 9.6/10)
🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)
🔎 More signals (3)🔥 Hotspots touched (5)
2 more
🔗 Hidden coupling (1 file)
💀 Dead code (1 finding)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-11 08:32 UTC |
What
The decision layer now reaches the agent at the moment it matters, ranked by relevance to what the session is actually doing. Two delivery moments, both pure indexed-SQLite lookups (no LLM, no network):
SessionStart block. The augment hook scores the repo's active decisions against the session's likely working set: dirty/staged files, files changed on the branch vs main, the previous session's edited files, and branch-name tokens, expanded one hop through import edges and co-change partners. Scoring is hop-weighted overlap x confidence x freshness with a relevance floor and a hard ~400-token cap. Nothing clears the floor, nothing is injected: relevance or silence, never top-confidence-globally. Repo-wide rules mined from user corrections (no file links, so no other delivery path) compete at a flat base relevance.
Edit-time notice. When the agent edits a file with a governing decision (
decision_node_links, file links plus module-prefix links), it gets a one-line "governed by: <title> because , confirmed across N sessions" notice, once per session per decision under a strict per-session cap.Usage feedback v1. Every injected decision id is recorded in the
.repowise/sessions/sessions.dbsidecar (newinjectionstable). At update time the session miner judges each shown decision against that session's mined user corrections: a contradicting correction bumps staleness (the evolutionamendedmove), silence relaxes it (reaffirmed). Deliberately binary for v1.Noise guards (dogfood-driven)
Running the hooks live on this repo while building surfaced four failure modes, each now guarded and tested:
packages) "governed" every file in the tree; module links now require at least two path segments.INSERT OR IGNOREinto the sidecar; the state list is only a fast path.Latency
Measured on this repo (hook budget: no LLM, indexed lookups):
git status --porcelain --branchcall); SQLite lookups are ~40ms. Runs once per session.Tests
31 new tests: SessionStart relevance/floor/cap/silence, one-hop expansion via graph edges and co-change partners, branch tokens, global rules, edit-notice dedup (including the state-loss race), path normalization, module-depth and echo guards, injection recording, and the followed/contradicted feedback pass including the min-age gate and schema compatibility between the hook-side raw table and the staging store.