Skip to content

feat: relevance-ranked decision delivery, SessionStart + edit-time injection with usage feedback#776

Merged
RaghavChamadiya merged 3 commits into
mainfrom
feat/decision-injection
Jul 11, 2026
Merged

feat: relevance-ranked decision delivery, SessionStart + edit-time injection with usage feedback#776
RaghavChamadiya merged 3 commits into
mainfrom
feat/decision-injection

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

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.db sidecar (new injections table). At update time the session miner judges each shown decision against that session's mined user corrections: a contradicting correction bumps staleness (the evolution amended move), 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:

  • Link node ids are stored OS-native (backslashes on Windows) while the working set is POSIX; comparisons are normalized both ways.
  • A legacy record linked to a top-level module (packages) "governed" every file in the tree; module links now require at least two path segments.
  • Legacy records that echo the same truncated text into title, decision, and rationale produced "X because X" notices; echoed fields are dropped.
  • The per-session JSON state is written read-modify-write by two concurrently registered hook processes and loses updates, so the same notice re-fired. Dedup is now an atomic INSERT OR IGNORE into the sidecar; the state list is only a fast path.

Latency

Measured on this repo (hook budget: no LLM, indexed lookups):

  • Edit-time notice: ~15ms per call.
  • SessionStart decision scoring: ~135ms, dominated by git subprocess startup on Windows (dirty files + branch come from a single git status --porcelain --branch call); 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.

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.
@repowise-bot

repowise-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

✅ Health: 7.6 (unchanged)

📋 At a glance
2 files changed health · 5 hotspots touched · 12 new findings introduced · 5 co-change pairs left out · 1 file with recent fix history · 1 dead-code finding. Scoped to packages.

🚨 Change risk: high (riskier than 83% of this repo's commits · raw 9.6/10)
This change's risk is driven by:

  • more lines added than baseline
  • more scattered than baseline

🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)

File Score Δ Why
.../augment_cmd/read_state.py 7.6 → 7.3 ▼ -0.3 🔻 introduced dry violation, error handling, primitive obsession
.../augment_cmd/session_start.py 8.8 → 9.6 ▲ +0.7 🔻 introduced error handling · ✅ resolved complex method

💡 .../augment_cmd/read_state.py: De-duplicate the clone. Extract the shared block into a private helper, or push it down to a base class if the structure is genuinely shared rather than coincidental.

🔎 More signals (3)

🔥 Hotspots touched (5)

  • .../sessions/staging.py — 1 commits/90d, 3 dependents · primary owner: Raghav Chamadiya (100%)
  • .../update_cmd/command.py — 13 commits/90d, 3 dependents · primary owner: Raghav Chamadiya (90%)
  • .../miners/decisions.py — 1 commits/90d, 4 dependents · primary owner: Raghav Chamadiya (100%)
2 more
  • .../augment_cmd/session_start.py — 1 commits/90d, 1 dependents · primary owner: Raghav Chamadiya (100%)
  • .../augment_cmd/command.py — 2 commits/90d, 1 dependents · primary owner: Raghav Chamadiya (100%)

🔗 Hidden coupling (1 file)

  • .../update_cmd/command.py co-changes with these files (not in this PR):
    • .../update_cmd/persistence.py (6× — 🟢 routine)
    • docs/CLI_REFERENCE.md (5× — 🟢 routine)
    • .../cli/helpers.py (4× — 🟢 routine)
    • .../workspace/update.py (3× — 🟢 routine)
    • .../update_cmd/reporting.py (3× — 🟢 routine)

💀 Dead code (1 finding)

  • 💀 .../miners/decisions.py _prefilter (confidence 0.65)

📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-11 08:32 UTC
Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot

@RaghavChamadiya RaghavChamadiya changed the title Relevance-ranked decision delivery: SessionStart + edit-time injection with usage feedback feat: relevance-ranked decision delivery, SessionStart + edit-time injection with usage feedback Jul 11, 2026
@RaghavChamadiya RaghavChamadiya merged commit e3fd88b into main Jul 11, 2026
7 checks passed
@RaghavChamadiya RaghavChamadiya deleted the feat/decision-injection branch July 11, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants