Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(decisions): stop mining transcripts unless asked (#2286)
Raghav Chamadiyabb1512a169ed
diff --git a/README.md b/README.mdindex dabf76a2b..6d524d8ae 100644--- a/README.md+++ b/README.md@@ -144,11 +144,14 @@ a file with a run of recent bug fixes, a compact briefing at session start. Repoalso generates your `CLAUDE.md` and `AGENTS.md` from the real index, so even an agentwith no MCP support starts informed.-**It learns from how you actually work.** Repowise reads your own agent transcripts-for the corrections you keep making ("use the shared HTTP client, not raw requests")-and turns the durable ones into tracked decisions it delivers back later. The wiki-generation budget tilts toward the modules you and your agent ask about most. All-local, all deterministic, no extra LLM calls.+**It learns from how you actually work.** Switch on transcript capture+(`repowise decision source set session --on`) and Repowise reads your own agent+transcripts for the corrections you keep making ("use the shared HTTP client,+not raw requests"), turning the durable ones into tracked decisions it delivers+back later. Transcripts never leave your machine; one batched model call per+update turns the candidates that clear the deterministic gates into records, and+`--no-llm` keeps the gates and drops that call. The wiki generation budget tilts+toward the modules you and your agent ask about most, with no switch needed.<details><summary><strong>What the index builds</strong></summary>diff --git a/docs/layers/DECISIONS.md b/docs/layers/DECISIONS.mdindex 0932ef223..788b47235 100644--- a/docs/layers/DECISIONS.md+++ b/docs/layers/DECISIONS.md@@ -255,10 +255,10 @@ history, or the graph it just built.| Conventions | `conventions` | Import edges and wrapper bodies | Off by default (`repowise decision source set conventions --on`), no model. A wrapper of an I/O library (HTTP client, database driver, subprocess, filesystem, lock) that most files reach the library through while few import it directly; the record states the counts and names the direct importers. Go and Java are counted by package. Up to 10 per index. |Three more sources sit outside the index-time set: `session` (deterministic-gates over your coding-agent transcripts, below), `session_discovery` (one-broad model pass over the same transcript prose, below, off unless you enable-it), and `cli` (a decision you typed yourself, the most authoritative source-there is).+gates over your coding-agent transcripts, below, off unless you enable it),+`session_discovery` (one broad model pass over the same transcript prose,+below, also off unless you enable it), and `cli` (a decision you typed+yourself, the most authoritative source there is).### Controlling capture@@ -492,11 +492,24 @@ Three stages, in order:govern. Repeated observations accrete evidence rows and raise confidencewithout ever creating authority.+**This source ships off.** What it captured on this repository read as working+agreements from a transcript — "pause before pushing", "avoid duplication" —+rather than decisions the codebase had taken: of 139 records, none carried a+context and 115 carried neither a context nor a rationale. Turn it on with+`repowise decision source set session --on`; the `local_only`, `balanced` and+`full` presets carry it already.+Everything stays on your machine. Transcripts are read locally, staging lives in`.repowise/sessions/sessions.db`, and only the distilled decision text about the-codebase is stored. Turn the pipeline off with-`repowise decision source set session --off`, or keep the transcript reading and-drop only the structuring call with `--no-llm`.+codebase is stored. `--off` turns the pipeline back off, or keep the transcript+reading and drop only the structuring call with `--no-llm`.++This switch is the transcript boundary, so two things ride on it. Injected-+decision feedback is inert without it — its only evidence is this lane's mined+corrections — and update-time hook-efficacy replay stops, which leaves+`repowise hook stats` with what the live hook recorded first-hand and without+the columns only a replay can fill. `repowise hook backfill` fills those on+demand.### Broad session discoverydiff --git a/docs/reference/CLI_REFERENCE.md b/docs/reference/CLI_REFERENCE.mdindex f6a6e5eee..562f57967 100644--- a/docs/reference/CLI_REFERENCE.md+++ b/docs/reference/CLI_REFERENCE.md@@ -223,14 +223,14 @@ plus the exported `knowledge-graph.json`. In docs mode it also regenerates theaffected wiki pages. Index-only updates carry forward the previously generatedlayer names and node summaries, so no LLM call is ever made without docs mode.-Docs-mode updates (and `init`) also mine local coding-agent session+Docs-mode updates (and `init`) can also mine local coding-agent sessiontranscripts for durable decisions: user corrections, explicit choices with astated reason, and failed approaches replaced by working ones. Candidatespass deterministic gates and a verbatim-quote grounding check; a decisionobserved in two or more sessions (or one direct user correction) is promotedinto the decision records with `source: session`. Everything stays on your-machine. Disable with `decisions.session_mining: false` in-`.repowise/config.yaml` (see [CONFIG.md](CONFIG.md)).+machine. **This lane is off by default**; `repowise decision source set session+--on` enables it (see [CONFIG.md](CONFIG.md)).If any best-effort step fails (git metadata, decisions, dead code, ...), therun still exits 0 but lists the degraded steps in the completion panel (and indiff --git a/docs/reference/CONFIG.md b/docs/reference/CONFIG.mdindex 9fe0b209a..8257d8bd2 100644--- a/docs/reference/CONFIG.md+++ b/docs/reference/CONFIG.md@@ -397,8 +397,8 @@ decisions:adr: true # ADR filespr: true # PR / squash-merge bodiescomment: false # comment archaeology on top central files- session: # long form: run the source, skip its model stage- enabled: true+ session: # off by default; long form runs the deterministic+ enabled: true # parse and skips the model stagellm: falsesession_discovery: true # one broad model pass over new transcript proseconventions: false # import patterns the graph proves, no model@@ -411,7 +411,11 @@ Every key is optional. **A config with no `decisions:` block behaves exactly asit did before these switches existed**: every source that shipped on is on,model stages on. That resolved policy is named `default`. A source added afterthose switches existed (`session_discovery` and `conventions`) stays off until you-ask for it, so upgrading never starts a model call nobody enabled. The same+ask for it, so upgrading never starts a model call nobody enabled. `session` is+the one default that has moved: it now ships **off**, because what it captured+read as working agreements from a transcript rather than decisions the codebase+had taken. `repowise decision source set session --on` turns it back on, and+`local_only` still carries it. The sameholds for a config that names a preset *and* lists its sources: that list iswhat the preset covered when it was written, so a source added to that presetlater does not join it retroactively. Re-apply the preset to pick it up.@@ -433,10 +437,10 @@ still loads, it just says which key it ignored.| Preset | Effect ||--------|--------|-| `default` | What a config with no `decisions:` block resolves to. Every long-standing source on, broad discovery off. |+| `default` | What a config with no `decisions:` block resolves to. Every long-standing source on; session mining and broad discovery off. || `off` | No automatic capture. Stored decisions and manual entry keep working. |-| `local_only` | Deterministic capture only. Zero decision-extraction model calls. |-| `balanced` | The high-signal sources plus session mining and broad session discovery; comment archaeology off. |+| `local_only` | Deterministic capture only, session mining included — it is the only lane that produces without a key. Zero decision-extraction model calls. |+| `balanced` | The high-signal sources plus session mining and broad session discovery, which is fed by it; comment archaeology off. || `full` | Every source, every model stage. |Editing any individual key after applying a preset drops the `preset` line and@@ -464,8 +468,10 @@ and `--format json` for scripts. Writes are atomic and preserve every unrelatedkey in `config.yaml`.The legacy `decisions.session_mining: true|false` key is still honoured and-resolves to the `session` source. The first write through the CLI or the API-replaces it with `sources.session`.+resolves to the `session` source, in both directions: since that source now+ships off, a config that says `true` still switches it on. An explicit+`sources.session` may narrow that, never widen it. The first write through the+CLI or the API replaces the legacy key with `sources.session`.### `.repowise/decisions.yaml`@@ -477,7 +483,8 @@ reconciles the store to it, with the file as the authority. Its format carriesits own `version`, and a file written by a newer repowise is refused rather thandowngraded. See [DECISIONS.md](../layers/DECISIONS.md) for the round trip.-`session` mining lets `repowise update` read coding-agent session transcripts+`session` mining is **off by default**. Switched on, it lets `repowise update`+read coding-agent session transcripts(Claude Code's `~/.claude/projects/`) for durable decisions: user corrections,explicit choices with a stated reason, and failed approaches replaced by workingones. Candidates pass deterministic gates first, then one batched LLMdiff --git a/packages/cli/src/repowise/cli/commands/update_cmd/command.py b/packages/cli/src/repowise/cli/commands/update_cmd/command.pyindex 0df934753..c2217ed15 100644--- a/packages/cli/src/repowise/cli/commands/update_cmd/command.py+++ b/packages/cli/src/repowise/cli/commands/update_cmd/command.py@@ -1846,8 +1846,8 @@ def run_update(# Session-sourced decisions: mine agent transcript lines appended since# the last update, structure new candidates in one batched LLM pass, and# collect the observation-qualified promotions. They ride the same- # decision upsert as the marker re-scan below. Everything stays local;- # `decisions.session_mining: false` in .repowise/config.yaml disables it.+ # decision upsert as the marker re-scan below. Everything stays local, and+ # the lane ships off: `decision source set session --on` enables it.session_decisions: list = []try:from repowise.core.sessions.miners.decisions import mine_session_decisions@@ -1902,6 +1902,13 @@ def run_update(# sessions are judged against those sessions' mined corrections (followed# -> staleness relaxes, contradicted -> staleness bumps). Pure SQLite over# the staging sidecar + decision_records; no LLM.+ #+ # Gated on the ``session`` source even though it judges injected decisions+ # of *every* source: its only evidence is that session's mined user+ # corrections, which no other lane writes. With the lane off, every row+ # would be judgeable=False and settle as ``unjudgeable`` — and+ # ``mark_injection_evaluated`` is terminal, so turning the lane on later+ # could never recover them. Inert without the lane, like session discovery.try:from repowise.core.sessions.miners.decisions import apply_injection_feedback@@ -1946,6 +1953,13 @@ def run_update(# so they are judged by what the agent did next — which only the transcript# knows. Scoped to transcripts touched since the last update; the whole# history is a one-off `repowise hook backfill`.+ #+ # Gated on the ``session`` source because that switch is documented as what+ # stops repowise reading your transcripts, and this reads them. It is the+ # privacy boundary, not a statement about what the rows are for, so it fails+ # closed: with the lane off the live hook still records its own firings and+ # only the replay-filled columns are missing, which `repowise hook backfill`+ # fills on demand.try:from repowise.core.sessions.efficacy import ingest_transcript_efficacydiff --git a/packages/core/src/repowise/core/analysis/decisions/evolution.py b/packages/core/src/repowise/core/analysis/decisions/evolution.pyindex 19678f265..b3d46f07c 100644--- a/packages/core/src/repowise/core/analysis/decisions/evolution.py+++ b/packages/core/src/repowise/core/analysis/decisions/evolution.py@@ -83,13 +83,36 @@ SUPERSEDE_AUTOFLIP_CONFIDENCE = 0.85# supersession is a chain, 18-in is noise) and auto-retired 74 records, 25% of# the store, correct ones included.#-# It stays as code rather than a deletion because the *shape* is right and-# Phase 2 re-enables it structurally: a conflict must require intersecting node-# sets — two records that touch the same code — and similarity may then rank-# those candidates but never scope them. The 3B tests flip it to True to-# exercise the machinery; flipping it in a real run does not work, because both-# persist paths run ``unretire_auto_superseded`` ahead of the detector and the-# next run reverts whatever the previous one wrote.+# The fix this comment used to propose — require intersecting node sets, let+# similarity only rank — was then measured against the same store and does not+# work. Replaying this function over 626 real records with their real vectors:+# 475 edges, and requiring a shared *file* link leaves 465. A 2% cut, because+# decisions mined from one repository share files as a matter of course.+#+# The reason no gate helped is that the band is mislabelled. ``[RELATED_TAU,+# DEFAULT_DEDUP_TAU)`` is described above as "related but not a duplicate"; on+# real data it is exactly where the duplicates that 0.83 failed to merge live.+# Of the 465 pairs, 418 share an evidence commit and 232 have a title Jaccard+# over 0.3; all 20 of a random sample and all 23 of the pairs matching neither+# were read by hand and every one is the same decision written twice, by two+# runs that phrased the title differently. This store contains no supersession+# for the detector to find, so everything it finds is a duplicate.+#+# ``contradicts`` is what converts them into edges, and it is not a+# contradiction test: ``is_reversal`` reads the record's *own subject matter* —+# a decision to replace something in the code — as a signal that it reverses+# another decision. 171 of the 465 fired on the bare word "replace".+#+# One more thing to know before re-enabling: the ``conflicts_with`` branch+# below is unreachable in a real store. It needs both sides ``active``, and+# after the entity split machine capture lands at ``proposed`` (0 of 626 here+# are active), so every pair takes the supersedes branch and 87 records — 14%+# — would be auto-retired. Re-enabling means fixing that, fixing+# ``contradicts``, and finding a corpus that actually contains a supersession;+# not a threshold and not a node-set gate. Both persist paths also run+# ``unretire_auto_superseded`` ahead of the detector, so the next run reverts+# whatever the previous one wrote. The 3B tests flip this to True to exercise+# the machinery.## ``run_update_evolution`` (3C) is a different mechanism — diff-driven, per# changed file, with an LLM verdict — and is not gated by this flag.diff --git a/packages/core/src/repowise/core/analysis/decisions/policy.py b/packages/core/src/repowise/core/analysis/decisions/policy.pyindex 583bb3c97..d4a4924f4 100644--- a/packages/core/src/repowise/core/analysis/decisions/policy.py+++ b/packages/core/src/repowise/core/analysis/decisions/policy.py@@ -123,7 +123,15 @@ SOURCE_SPECS: tuple[SourceSpec, ...] = (deterministic=True,llm=True,authority="machine",- default_enabled=True,+ # Off by default. Measured over this repo's own 626-record store: the+ # lane produced 139 records (22%), all 139 with no context and 115 with+ # neither context nor rationale — the shape the acceptance gate now+ # blocks outright. It was tolerated while it looked like the only lane+ # still producing, and that reading came from the provider-reporting bug+ # PR #2279 fixed: `pr`, `comment` and `git_archaeology` were running all+ # along. Still switchable with `decision source set session --on`, and+ # `local_only` keeps it, being the preset for a machine with no key.+ default_enabled=False,),SourceSpec(key="session_discovery",@@ -163,6 +171,16 @@ CAPTURE_SOURCE_KEYS: tuple[str, ...] = tuple(spec.key for spec in SOURCE_SPECS if spec.authority == "machine")+#: Sources that did not exist when the presets did. Only these are treated as+#: absent-because-new when a config names a preset *and* enumerates its sources;+#: see the note at that check in :func:`resolve_policy`. Deliberately a list of+#: names rather than ``not default_enabled``: a source that shipped on and was+#: later turned off by default — ``session`` — is missing from such an+#: enumeration because it predates it, not because it is new, and reading it the+#: other way would switch it off under ``local_only`` and ``full``, which both+#: name it explicitly.+_POST_PRESET_SOURCES: frozenset[str] = frozenset({"session_discovery", "conventions"})+#: Index-time sources, in the order ``DecisionExtractor.extract_all`` runs them.#: ``session`` is mined separately by the transcript miner.INDEX_SOURCE_KEYS: tuple[str, ...] = (@@ -251,7 +269,12 @@ PRESETS: dict[str, dict[str, Any]] = {"balanced": {"enabled": True,"llm": True,- "sources": _preset(comment=_OFF, session_discovery=_ON),+ # ``session`` is named explicitly although it used to come from the+ # spec default: ``session_discovery``'s queue is filled by the span+ # collector inside the transcript miner, so discovery without the+ # session lane is a switch that can never produce. The maintainer's+ # call was that only the *default* preset drops the lane.+ "sources": _preset(comment=_OFF, session=_ON, session_discovery=_ON),},"full": {"enabled": True,@@ -264,8 +287,10 @@ PRESET_NAMES: tuple[str, ...] = tuple(PRESETS)#: What an absent ``decisions:`` block resolves to: every source whose spec#: says it shipped on, with the model enabled, because that is what a repo-#: indexed before this module existed already did and a config-less repo must-#: not change behavior on upgrade. Deliberately *not* ``full``: ``full`` means+#: indexed before this module existed already did, so a config-less repo does+#: not change behavior on upgrade — except where a spec default is deliberately+#: flipped, as ``session`` was on the evidence recorded beside it, which is the+#: one way this default is allowed to move. Deliberately *not* ``full``: ``full`` means#: every source there is, so a source added later joins it, and reusing it here#: would switch that source on for every repository that never asked for it.#: New repos pick a preset explicitly instead of inheriting a hidden default.@@ -546,6 +571,17 @@ def _as_bool(value: Any) -> bool | None:return value if isinstance(value, bool) else None+def _states_enabled(raw_source: Any) -> bool:+ """Does a raw ``sources.<key>`` entry state an on/off of its own?++ ``{"llm": false}`` configures the source without saying whether it runs, so+ it must not count as an opinion the legacy ``session_mining`` key defers to.+ """+ if isinstance(raw_source, bool):+ return True+ return isinstance(raw_source, dict) and isinstance(raw_source.get("enabled"), bool)++def resolve_policy(repo_config: dict[str, Any] | None) -> PolicyResolution:"""Resolve a loaded ``.repowise/config.yaml`` dict into one policy.@@ -600,7 +636,7 @@ def resolve_policy(repo_config: dict[str, Any] | None) -> PolicyResolution:# live declaration and does get the preset's current membership.if preset_name and enumerated:for spec in SOURCE_SPECS:- if spec.togglable and not spec.default_enabled and spec.key not in raw_sources:+ if spec.togglable and spec.key in _POST_PRESET_SOURCES and spec.key not in raw_sources:sources[spec.key] = SourceSetting(enabled=False, llm=spec.llm)for key, value in raw_sources.items():@@ -633,19 +669,31 @@ def resolve_policy(repo_config: dict[str, Any] | None) -> PolicyResolution:f"`decisions.sources.{spec.key}` must be a boolean or a mapping; ignoring it.")- # Legacy: session_mining gated the whole transcript miner. It only narrows,- # so it is ANDed with sources.session rather than shadowed by it. Letting an- # explicit `sources.session: true` win would start reading transcripts on a- # config that had switched them off, which is the one thing this resolver- # must never do.+ # Legacy: session_mining gated the whole transcript miner, and it is still+ # the statement the user wrote, in both directions. It replaces the *spec+ # default* for `session` — and only that. Anything newer is a stated+ # opinion the legacy key may narrow but never widen: an explicit+ # `sources.session`, and a `preset:`, which postdates this key entirely.+ # Letting `sources.session: true` win over `session_mining: false` would+ # start reading transcripts on a config that switched them off, which is the+ # one thing this resolver must never do — and, since `session` ships off,+ # dropping a legacy `true` on the floor would silently read a config that+ # says on as off, which is the same defect pointed the other way.session_mining = raw.get("session_mining")if session_mining is not None:legacy.append("session_mining")if isinstance(session_mining, bool):current = sources["session"]- sources["session"] = SourceSetting(- enabled=current.enabled and session_mining, llm=current.llm- )+ stated = bool(preset_name) or _states_enabled(raw_sources.get("session"))+ enabled_session = current.enabled and session_mining if stated else session_mining+ if session_mining and not enabled_session and preset_name:+ # Written `true` and resolved off. Say so: a discarded opt-in+ # that reads as a working switch is the defect P1f fixed.+ warnings.append(+ f"`decisions.session_mining: true` is overridden by "+ f"`preset: {preset_name}`, which switches this source off."+ )+ sources["session"] = SourceSetting(enabled=enabled_session, llm=current.llm)else:warnings.append("`decisions.session_mining` is not a boolean; ignoring it.")diff --git a/packages/core/src/repowise/core/sessions/miners/decisions.py b/packages/core/src/repowise/core/sessions/miners/decisions.pyindex 5797c7886..7fee41962 100644--- a/packages/core/src/repowise/core/sessions/miners/decisions.py+++ b/packages/core/src/repowise/core/sessions/miners/decisions.py@@ -20,7 +20,7 @@ those moments into ``decision_records`` rows via three stages:from surrounding tool activity.2. **One batched LLM structuring pass** per ``repowise update``- (config-gated ``decisions.session_mining``, default on): candidates to+ (config-gated ``decisions.sources.session``, off by default): candidates to``{title, decision, rationale, affected_files, source_quote}``. Everyproduced field is then grounded against the verbatim quotes with theshared :func:`~repowise.core.analysis.decisions.provenance.verify_quote`@@ -37,8 +37,9 @@ those moments into ``decision_records`` rows via three stages:Privacy: transcripts never leave the machine. Mining is local and the onlything stored is distilled decision text about the codebase, with verbatim-quotes as evidence. Kill switch: ``decisions.session_mining: false`` in-``.repowise/config.yaml``.+quotes as evidence. The lane ships off; ``repowise decision source set+session --on`` (or ``decisions.sources.session: true`` in+``.repowise/config.yaml``) turns it back on."""from __future__ import annotationsdiff --git a/packages/ui/src/decisions/decision-capture-settings.tsx b/packages/ui/src/decisions/decision-capture-settings.tsxindex 0347733e4..59fe511ac 100644--- a/packages/ui/src/decisions/decision-capture-settings.tsx+++ b/packages/ui/src/decisions/decision-capture-settings.tsx@@ -56,10 +56,10 @@ const MICRO_LABEL =* button rather than disappearing.*/const PRESET_BLURB: Record<string, string> = {- default: "The deterministic sources, and no broad model pass.",+ default: "The deterministic sources, without transcripts or a broad model pass.",off: "Capture nothing. Decisions you record by hand still work.",local_only: "Only what this checkout can see, with no model call at all.",- balanced: "The deterministic sources plus one broad pass over new sessions.",+ balanced: "The deterministic sources plus transcripts and one broad pass over new sessions.",full: "Every source, model stages included.",};diff --git a/tests/unit/analysis/test_decision_policy.py b/tests/unit/analysis/test_decision_policy.pyindex 9e7589a01..0b591ce41 100644--- a/tests/unit/analysis/test_decision_policy.py+++ b/tests/unit/analysis/test_decision_policy.py@@ -71,6 +71,23 @@ def test_legacy_session_mining_is_reported_not_swallowed():assert resolution.legacy_keys == ("session_mining",)+def test_legacy_session_mining_true_still_enables_an_off_by_default_lane():+ """`session` ships off, so a config that says on must still read as on."""+ policy = resolve_policy({"decisions": {"session_mining": True}}).policy++ assert policy.source_enabled("session") is True+++def test_legacy_session_mining_defers_only_to_a_stated_source_enabled():+ """`{"llm": false}` configures the source without saying whether it runs."""+ policy = resolve_policy(+ {"decisions": {"session_mining": True, "sources": {"session": {"llm": False}}}}+ ).policy++ assert policy.source_enabled("session") is True+ assert policy.llm_allowed("session") is False++def test_legacy_session_mining_off_cannot_be_widened_by_a_source_key():"""The kill switch wins. Widening past it would start reading transcriptson a config that had switched them off."""@@ -373,6 +390,90 @@ def test_discovery_is_off_by_default_and_on_in_the_discovery_presets():assert preset_policy("full").llm_allowed("session_discovery") is True+def test_session_is_off_in_the_default_preset_only():+ """`default` is the one preset that drops the lane."""+ assert preset_policy("default").source_enabled("session") is False+ assert resolve_policy(None).policy.source_enabled("session") is False+ # `local_only` is the preset for a machine with no key, where the+ # transcript miner is the only lane that produces anything at all;+ # `balanced` needs it to feed discovery; `full` means every source.+ for preset in ("local_only", "balanced", "full"):+ assert preset_policy(preset).source_enabled("session") is True, preset+++def test_session_off_by_default_is_still_switchable_back_on():+ """`decision source set session --on` must reach it, config-less."""+ assert resolve_policy(None).policy.with_source("session", enabled=True).source_enabled(+ "session"+ )+ written = resolve_policy({"decisions": {"sources": {"session": True}}}).policy+ assert written.source_enabled("session") is True++[email protected]("preset", ["local_only", "full", "balanced"])+def test_a_partial_enumeration_does_not_switch_off_a_source_older_than_presets(preset):+ """`session` is missing from a hand-written list because it predates it.++ The absent-means-new rule exists for sources added after the presets. A+ source that shipped on and was later defaulted off is not one of those, and+ reading it that way would drop it from the two presets that name it.+ """+ policy = resolve_policy({"decisions": {"preset": preset, "sources": {"comment": False}}}).policy++ assert policy.source_enabled("session") is True+ # The rule itself still holds for the sources it was written for.+ assert policy.source_enabled("session_discovery") is False+++def test_every_default_off_source_is_declared_new_or_deliberately_flipped():+ """Guards `_POST_PRESET_SOURCES`, which a new source must be added to.++ `off` and `full` enrol every machine source automatically, so a source+ added tomorrow joins `full`. If it is not also named here, a config that+ stored `preset: full` with its sources enumerated *before* that source+ existed would silently acquire it — the exact thing the absent-means-new+ rule prevents. The set is hand-maintained because `default_enabled` can no+ longer distinguish "new" from "shipped on and later flipped off"; this+ test is what keeps the two readings in sync.+ """+ from repowise.core.analysis.decisions.policy import _POST_PRESET_SOURCES++ default_off = {spec.key for spec in SOURCE_SPECS if spec.togglable and not spec.default_enabled}++ # `session` is the one deliberate flip: it predates the presets, so it is+ # absent from an old enumeration because it was always there.+ assert default_off - _POST_PRESET_SOURCES == {"session"}+ assert default_off >= _POST_PRESET_SOURCES+++def test_a_preset_overriding_the_legacy_key_says_so():+ """Silently discarding a written `true` is what P1f was about."""+ resolution = resolve_policy({"decisions": {"preset": "default", "session_mining": True}})++ assert resolution.policy.source_enabled("session") is False+ assert any("session_mining" in w and "preset" in w for w in resolution.warnings), (+ resolution.warnings+ )+++def test_balanced_keeps_the_lane_its_discovery_pass_depends_on():+ """Discovery's queue is filled by the transcript miner; without it the+ switch cannot produce."""+ policy = preset_policy("balanced")++ assert policy.source_enabled("session_discovery") is True+ assert policy.source_enabled("session") is True+++def test_a_preset_outranks_the_legacy_session_key():+ """`session_mining` predates presets, so it may narrow one, never widen it."""+ policy = resolve_policy({"decisions": {"preset": "off", "session_mining": True}}).policy++ assert policy.source_enabled("session") is False+ assert policy.sources["session"].enabled is False+ assert policy.preset_name() == "off"++def test_the_legacy_default_is_not_the_full_preset():"""Reusing ``full`` here is how a new source switches itself on everywhere."""assert resolve_policy(None).policy != preset_policy("full")diff --git a/tests/unit/server/test_decision_settings_api.py b/tests/unit/server/test_decision_settings_api.pyindex 6b10f6813..087f18ebc 100644--- a/tests/unit/server/test_decision_settings_api.py+++ b/tests/unit/server/test_decision_settings_api.py@@ -98,7 +98,10 @@ async def test_put_preset_then_source_override_in_one_call(client: AsyncClient):by_key = {s["key"]: s for s in body["sources"]}assert by_key["comment"]["enabled"] is True- assert by_key["session"]["enabled"] is True+ # Untouched members keep the preset's own value, in both directions.+ assert by_key["inline_marker"]["enabled"] is True+ assert by_key["session_discovery"]["enabled"] is True+ assert by_key["conventions"]["enabled"] is Falseassert body["preset"] == "custom"diff --git a/tests/unit/sessions/test_decision_miner.py b/tests/unit/sessions/test_decision_miner.pyindex 77a2eed49..49aa44456 100644--- a/tests/unit/sessions/test_decision_miner.py+++ b/tests/unit/sessions/test_decision_miner.py@@ -345,8 +345,11 @@ def test_candidate_hash_is_content_stable():def test_session_mining_enabled_parsing():- assert session_mining_enabled(None) is True- assert session_mining_enabled({}) is True+ # The lane ships off, so an absent or unreadable `decisions:` block means+ # no transcript is read until somebody asks for it.+ assert session_mining_enabled(None) is False+ assert session_mining_enabled({}) is False+ assert session_mining_enabled({"decisions": "garbage"}) is False+ assert session_mining_enabled({"decisions": {"sources": {"session": True}}}) is Trueassert session_mining_enabled({"decisions": {"session_mining": True}}) is Trueassert session_mining_enabled({"decisions": {"session_mining": False}}) is False- assert session_mining_enabled({"decisions": "garbage"}) is Truediff --git a/tests/unit/sessions/test_session_decisions_e2e.py b/tests/unit/sessions/test_session_decisions_e2e.pyindex 3c4a8bafe..ae2a5d37a 100644--- a/tests/unit/sessions/test_session_decisions_e2e.py+++ b/tests/unit/sessions/test_session_decisions_e2e.py@@ -169,6 +169,12 @@ async def test_init_pipeline_appends_session_decisions(tmp_path, monkeypatch):monkeypatch.setattr("repowise.core.sessions.miners.decisions.mine_session_decisions", fake_mine)+ # The lane ships off; this covers the fold-in, not the default.+ (tmp_path / ".repowise").mkdir()+ (tmp_path / ".repowise" / "config.yaml").write_text(+ "decisions:\n sources:\n session: true\n", encoding="utf-8"+ )+class Graph:def graph(self):return None