opencode-self-improvement 0.30.5 → 0.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +71 -244
  2. package/docs/auto-capture-evidence.md +8 -1
  3. package/docs/contradiction-authority.md +40 -4
  4. package/docs/development.md +23 -3
  5. package/docs/export-import.md +61 -0
  6. package/docs/flags.md +10 -2
  7. package/docs/import-quarantine.md +18 -2
  8. package/docs/injection-cost.md +10 -5
  9. package/docs/install.md +45 -0
  10. package/docs/options.md +41 -0
  11. package/docs/pre-release-ritual.md +4 -0
  12. package/docs/recall-quality.md +56 -0
  13. package/docs/repo-scoping.md +29 -5
  14. package/docs/secret-redaction.md +51 -0
  15. package/docs/store-concurrency.md +14 -1
  16. package/docs/surfaces.md +39 -0
  17. package/docs/troubleshooting.md +29 -0
  18. package/docs/use-ledger.md +61 -0
  19. package/docs/write-gates.md +17 -2
  20. package/docs/write-latency.md +25 -0
  21. package/package.json +1 -1
  22. package/src/capture/candidates.ts +1 -1
  23. package/src/capture/prompt.ts +1 -1
  24. package/src/capture/runtime.ts +19 -17
  25. package/src/capture/triggers.ts +1 -1
  26. package/src/consolidate/propose.ts +1 -1
  27. package/src/core/config/paths.ts +1 -1
  28. package/src/events.ts +2 -2
  29. package/src/gate/gate.ts +1 -1
  30. package/src/identity/session-context.ts +1 -1
  31. package/src/index.ts +18 -18
  32. package/src/init/run.ts +1 -1
  33. package/src/init/stamp.ts +1 -1
  34. package/src/inject/digest.ts +1 -1
  35. package/src/inject/epochs.ts +2 -2
  36. package/src/recall/gate.ts +30 -4
  37. package/src/status/report.ts +4 -4
  38. package/src/status/store-summary.ts +1 -1
  39. package/src/store/files/load.ts +1 -1
  40. package/src/store/lock.ts +1 -1
  41. package/src/store/prune.ts +1 -1
  42. package/src/store/tombstones/rejection.ts +1 -1
  43. package/src/store/tombstones/tombstone.ts +1 -1
  44. package/src/store/undo.ts +1 -1
  45. package/src/tools/consolidate.ts +2 -2
  46. package/src/tools/decay.ts +1 -1
  47. package/src/tools/deps.ts +1 -1
  48. package/src/tools/evidence.ts +1 -1
  49. package/src/tools/merge-review.ts +1 -1
  50. package/src/tools/recall.ts +15 -6
  51. package/src/tools/status-tool.ts +1 -1
  52. package/src/tools/update.ts +1 -1
  53. package/src/viewer/mutate.ts +1 -1
  54. /package/src/{command → init}/ensure.ts +0 -0
  55. /package/src/{hits → telemetry}/ledger.ts +0 -0
  56. /package/src/{evidence → telemetry}/record.ts +0 -0
@@ -0,0 +1,61 @@
1
+ # The use ledger
2
+
3
+ A due-date card for every row: who looked at it, when, and how it reached them.
4
+ It answers one question you cannot answer any other way — is this memory
5
+ earning its place, or has nothing touched it in six months?
6
+
7
+ The ledger is `<memory-root>/hits.logfmt`: append-only, rotated at 2 MB, never
8
+ ingested as a memory, and reported in `memory_status` and the `/memory` panel.
9
+
10
+ ## What it looks like
11
+
12
+ Illustrative output — shape, not a measurement:
13
+
14
+ ```
15
+ STORE
16
+ 41 active · 12 superseded · 4 open · 6 scopes
17
+ retrieved 33 rows in the last 30d; never retrieved 8 (20%) — reported, not acted on
18
+ 24.1 KB total · 604 B per row · 1.3 rows/day (30d)
19
+ ```
20
+
21
+ ## What counts as use
22
+
23
+ Credit comes from three distinct sources, because "the model asked" and "the
24
+ harness offered" are different facts:
25
+
26
+ 1. the row rode the injected block;
27
+ 2. `memory_recall` returned it;
28
+ 3. a grep/read pull appended it.
29
+
30
+ Credit requires ≥2 shared terms with the query and is throttled to one line per
31
+ memory per session per source per hour, so one busy session cannot inflate a
32
+ row's standing.
33
+
34
+ **No prompt content is stored.** The ledger keeps a scan-truncated string from
35
+ the *memory* side, never your message.
36
+
37
+ ## What use is allowed to do
38
+
39
+ Reinforcement is a tie-break only (`useBoost ≤ 1.0`): a recently used row wins a
40
+ tie and can never outrank a real score gap. In consolidation, the most recently
41
+ used member of a cluster is never the merge loser.
42
+
43
+ `never retrieved` is stated, not acted on. Pruning is your decision, and retired
44
+ rows cannot inherit reinforcement: ledger rows are verified against the store on
45
+ read.
46
+
47
+ ## Whose numbers these are
48
+
49
+ Aggregate STORE counts are machine-wide by decision (#213 B): they count every
50
+ repository's rows in the shared store on this machine, never just the reading
51
+ session's repository. The numbers describe the store, not your slice of it.
52
+
53
+ Privacy applies to the content surfaces instead. `memory_evidence` and the
54
+ recent-blocked-writes list in `memory_status` and `/memory` follow each reader's
55
+ repository visibility (#306).
56
+
57
+ ## Capture lag
58
+
59
+ Capture lag is how stale the newest message was when auto-capture fired. The
60
+ line prints only when at least one `capture_lag` sample exists, which needs
61
+ auto-capture to have fired.
@@ -1,6 +1,21 @@
1
1
  # Write gates and promotion evidence
2
2
 
3
- What promotion evidence samples, and how the four gates order their audit
4
- lines. The gate list and the undo contract stay in the README.
3
+ A memory is a claim about your code, so it is checked the way a pull request
4
+ is: does the reference resolve, is something already on file stale, is it a
5
+ duplicate, and does it land or come back with a reason. The four gates and the
6
+ undo contract stay in the README. This file is what the audit trail keeps, and
7
+ what an update carries with it.
8
+
9
+ ## What promotion evidence samples
5
10
 
6
11
  Promotion evidence keeps a bounded sample of call IDs: the ten most recent code-engagement calls, plus the latest gate check, the latest recorded gate FAIL/fix/PASS recovery, and the latest recorded tool FAIL/PASS retry (at most 16 distinct IDs). `evidence_refs_count` is the total number of recorded session calls before sampling, including non-code tools; the sampled IDs are audit pointers, not a complete history. Grounding and memory attribution still use the full in-memory ledger. Existing evidence day-files are left unchanged: this upgrade does not backfill, compact, or delete historical audit records.
12
+
13
+ ## What an update carries forward
14
+
15
+ `memory_update` picks its row by `query`: the row's id, a clock fragment such as `00:11:22.123`, or a unique substring of its text. Omit it and the newest entry of that scope and type is the target. A query that matches nothing, or that matches several rows, writes nothing and says so — an ambiguous selector is never resolved by picking one.
16
+
17
+ A prose edit carries the previous row's ordinary tags, issue link, retrieval keywords, open/settled standing and repository forward to the new row, so updating a `global` row from one machine keeps it global for every other. Capture-only guidance provenance is stripped by the replacement: an ordinary edit cannot re-mint a `user-guided` tag or a contradiction verdict.
18
+
19
+ Naming a row that an earlier update already superseded reports the duplicate when the live successor already holds exactly that content. When only the metadata you named differs, the update runs against the successor instead of dead-ending.
20
+
21
+ If a failure happens after the new row is already durable, the reply says `PARTIAL`. The message names what failed, the replacement stands on disk, and `memory_undo` (merge or force) brings the old row back.
@@ -0,0 +1,25 @@
1
+ # Write latency: one tree walk per write
2
+
3
+ A write that cites code references could scan your source tree once per
4
+ reference. It does not: one recursive walk, shared by GATE-1 and GATE-2, prunes
5
+ `node_modules` and VCS directories, and reads each source file at most once. The
6
+ table below is the difference between "walk the tree" and "walk it five times".
7
+
8
+ **Bench** — measured on a 5,300-file fixture (300 sources + 5,000 `node_modules`
9
+ decoys), scope seeded with 5 embedded call forms:
10
+
11
+ | Call forms in the write | Shipped | One scan per form |
12
+ | --- | ---: | ---: |
13
+ | 1 | 17ms | 105ms |
14
+ | 3 | 15ms | 136ms |
15
+ | 5 | 20ms | 169ms |
16
+
17
+ The shipped column is flat: the tree is walked once no matter how many references
18
+ the write cites.
19
+
20
+ ```sh
21
+ bun run bench:write
22
+ ```
23
+
24
+ What each gate does with what the walk finds:
25
+ [docs/write-gates.md](write-gates.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.30.5",
3
+ "version": "0.31.1",
4
4
  "description": "Durable memory for opencode: remember facts, decisions, and commands across sessions, plus a one-command per-repo setup (/repo-init).",
5
5
  "main": "index.ts",
6
6
  "exports": {
@@ -1,5 +1,5 @@
1
1
  // candidates — split from src/capture.ts. Declaration bodies are unchanged.
2
- // Opt-in auto-capture parsing, prompt, and lag helpers. Host access and model
2
+ // Auto-capture parsing, prompt, and lag helpers. Host access and model
3
3
  // calls live in src/index.ts. Every candidate that leaves this module flows
4
4
  // through runWriteGate in index.ts: capture NEVER writes memories directly,
5
5
  // so dupes/stale/canonical rules keep the moat (same as model-authored writes).
@@ -1,5 +1,5 @@
1
1
  // prompt — split from src/capture.ts. Declaration bodies are unchanged.
2
- // Opt-in auto-capture parsing, prompt, and lag helpers. Host access and model
2
+ // Auto-capture parsing, prompt, and lag helpers. Host access and model
3
3
  // calls live in src/index.ts. Every candidate that leaves this module flows
4
4
  // through runWriteGate in index.ts: capture NEVER writes memories directly,
5
5
  // so dupes/stale/canonical rules keep the moat (same as model-authored writes).
@@ -9,7 +9,7 @@ import {
9
9
  RESTATABLE_TAG,
10
10
  USER_GUIDED_TAG,
11
11
  } from "../core/tags.ts";
12
- import { record, recordCaptureLag } from "../evidence/record.ts";
12
+ import { record, recordCaptureLag } from "../telemetry/record.ts";
13
13
  import { type GateContext, runWriteGate } from "../gate/gate.ts";
14
14
  import { captureSessionID } from "../identity/host-events.ts";
15
15
  import { bindSessionProvisional, writeTarget } from "../identity/repokey.ts";
@@ -190,28 +190,29 @@ export function configureAutoCapture(
190
190
  ) {
191
191
  let onCompactCapture: ((sid: string, messages: unknown) => void) | undefined;
192
192
  let captureCleanup: Cleanup | undefined;
193
- if (ctx.options?.autoCapture === true) {
194
- const captureModelOpt = ctx.options.captureModel;
195
- // an OMITTED captureModel no longer disables the subscription. It
193
+ const options = ctx.options ?? {};
194
+ if (options.autoCapture !== false) {
195
+ const captureModelOpt = options.captureModel;
196
+ // an OMITTED captureModel does not disable the subscription. It
196
197
  // resolves per capture — the per-session ref last seen on session.context,
197
198
  // else the host default — and only when both are missing does the pass
198
- // skip. autoCapture:true is already the explicit opt-in; a second required
199
- // config string was a syntax tax whose failure mode was a console.warn
200
- // nobody reads. An explicit but INVALID captureModel keeps today's
201
- // fail-closed setup behaviour: silently substituting another model than
202
- // the one the user typed is worse than the tax it replaces.
199
+ // skip. autoCapture is on by default, so the switch itself is the consent;
200
+ // requiring a second config string would be a syntax tax whose failure mode
201
+ // is a console.warn nobody reads. An explicit but INVALID captureModel
202
+ // keeps the fail-closed setup behaviour: silently substituting another
203
+ // model than the one the user typed is worse than the tax it replaces.
203
204
  const omitted = captureModelOpt === undefined;
204
- const captureMax = Number(ctx.options.captureMax) || 3;
205
+ const captureMax = Number(options.captureMax) || 3;
205
206
  // Deterministic guided-candidate pre-pass (POC): default OFF, the bench
206
207
  // picks the default-on arm (FINDINGS 2026-11-08 §4.4).
207
- const guidedRules = ctx.options?.captureGuidedRules === true;
208
- const captureOnCompact = ctx.options?.captureOnCompact !== false;
208
+ const guidedRules = options.captureGuidedRules === true;
209
+ const captureOnCompact = options.captureOnCompact !== false;
209
210
  // two cost levers, both OFF by default until the benchmark says which
210
211
  // way to set them. `captureOnSignal` skips a capture whose turn produced
211
212
  // nothing durable; `captureDelta` mines only the turns since the last
212
213
  // capture instead of re-reading the whole session every time.
213
- const captureOnSignal = ctx.options?.captureOnSignal === true;
214
- const captureDelta = ctx.options?.captureDelta === true;
214
+ const captureOnSignal = options.captureOnSignal === true;
215
+ const captureDelta = options.captureDelta === true;
215
216
  const modelRef = omitted ? null : parseModelRef(captureModelOpt);
216
217
  if (!omitted && !modelRef) {
217
218
  // Invalid explicit model: skip registering the whole subscription
@@ -1180,10 +1181,11 @@ export function configureAutoCapture(
1180
1181
  };
1181
1182
  }
1182
1183
  }
1183
- } else if (ctx.options?.captureOnCompact === true) {
1184
- // autoCapture is the master switch (zero-token default preserved).
1184
+ } else if (options.captureOnCompact === true) {
1185
+ // autoCapture is the master switch, so an explicit false wins over a
1186
+ // compaction trigger that was never turned off.
1185
1187
  console.warn(
1186
- "[opencode-self-improvement] captureOnCompact is on but autoCapture is off; compaction capture stays disabled (autoCapture is the master switch).",
1188
+ "[opencode-self-improvement] captureOnCompact is on but autoCapture is false; compaction capture stays disabled (autoCapture is the master switch).",
1187
1189
  );
1188
1190
  }
1189
1191
  return { onCompactCapture, cleanup: captureCleanup };
@@ -2,7 +2,7 @@
2
2
  // tool results, never by a model decision. Nothing here injects into chat.
3
3
  import { existsSync } from "node:fs";
4
4
  import { join } from "node:path";
5
- import { record } from "../evidence/record.ts";
5
+ import { record } from "../telemetry/record.ts";
6
6
  import { evidenceDir } from "../core/config/paths.ts";
7
7
  import { parseLine } from "../core/logfmt/format.ts";
8
8
  import { readLines } from "../core/logfmt/read.ts";
@@ -27,7 +27,7 @@
27
27
  // proposal through memory_merge_review (supersede-not-delete, recoverable).
28
28
  // 4. The most recently used member is never a loser (the rule, inherited).
29
29
  import type { Memory } from "../store/model/memory.ts";
30
- import type { UseSignal } from "../hits/ledger.ts";
30
+ import type { UseSignal } from "../telemetry/ledger.ts";
31
31
  import { cmpTs } from "../core/cmp-ts.ts";
32
32
  import { formatMemory } from "../inject/format.ts";
33
33
  import { scoreMemories, words } from "../recall/score.ts";
@@ -53,7 +53,7 @@ export function canonicalFile(): string {
53
53
  return join(memoryRoot(), "canonical.logfmt");
54
54
  }
55
55
 
56
- // The use ledger (src/hits.ts). Lives in the store root beside the day files
56
+ // The use ledger (src/telemetry/ledger.ts). Lives in the store root beside the day files
57
57
  // but is NOT a memory file: memory.ts's RESERVED set keeps it out of loadAll().
58
58
  export const HITS_FILENAME = "hits.logfmt";
59
59
 
package/src/events.ts CHANGED
@@ -4,9 +4,9 @@ import type { PluginCtx } from "./core/host.ts";
4
4
  import type { guarded as Guarded } from "./core/hooks.ts";
5
5
  import type { createInjectionEpochs } from "./inject/epochs.ts";
6
6
  import type { Measured } from "./status/payload.ts";
7
- import type { HitSource } from "./hits/ledger.ts";
7
+ import type { HitSource } from "./telemetry/ledger.ts";
8
8
  import type { Memory } from "./store/model/memory.ts";
9
- import { useSignals } from "./hits/ledger.ts";
9
+ import { useSignals } from "./telemetry/ledger.ts";
10
10
  import { setCurrent } from "./core/state.ts";
11
11
  import {
12
12
  bindSessionProvisional,
package/src/gate/gate.ts CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  contentHash,
26
26
  record,
27
27
  recordWriteBlocked,
28
- } from "../evidence/record.ts";
28
+ } from "../telemetry/record.ts";
29
29
  import { getCurrent, noteAuthored } from "../core/state.ts";
30
30
  import { MAX_WRITE_EVIDENCE_REFS } from "../capture/triggers.ts";
31
31
  import { flattenMemoryText } from "../store/sanitize.ts";
@@ -1,7 +1,7 @@
1
1
  // Per-setup session binding and caller context. The host object is kept
2
2
  // intact so optional API methods retain their receiver and are read at call time.
3
3
  import type { GateContext } from "../gate/gate.ts";
4
- import { captureEvidenceContext, record } from "../evidence/record.ts";
4
+ import { captureEvidenceContext, record } from "../telemetry/record.ts";
5
5
  import { unresolvedWriteMessage } from "../store/files/append.ts";
6
6
  import { readerFromSid } from "../store/model/visibility.ts";
7
7
  import { getCurrent } from "../core/state.ts";
package/src/index.ts CHANGED
@@ -37,10 +37,10 @@ import { findStaleOpen } from "./portable/decay.ts";
37
37
  import { exportMemories } from "./portable/export.ts";
38
38
  import { importMemories } from "./portable/import.ts";
39
39
  import { listSnapshots, restoreSnapshot } from "./store/undo.ts";
40
- import { evidenceFileFor, record } from "./evidence/record.ts";
40
+ import { evidenceFileFor, record } from "./telemetry/record.ts";
41
41
  import { proposeConsolidations } from "./consolidate/propose.ts";
42
42
  import { renderProposals } from "./consolidate/render.ts";
43
- import { readReads } from "./hits/ledger.ts";
43
+ import { readReads } from "./telemetry/ledger.ts";
44
44
  import { formatMemory } from "./inject/format.ts";
45
45
  import { sharedTerms } from "./recall/shared-terms.ts";
46
46
  import {
@@ -62,13 +62,10 @@ import {
62
62
  neverRetrieved,
63
63
  recordHits,
64
64
  type HitSource,
65
- } from "./hits/ledger.ts";
65
+ } from "./telemetry/ledger.ts";
66
66
  import { formatInit } from "./init/format.ts";
67
67
  import { runInit } from "./init/run.ts";
68
- import {
69
- ensureInitCommand,
70
- ensureMemoryReportCommand,
71
- } from "./command/ensure.ts";
68
+ import { ensureInitCommand, ensureMemoryReportCommand } from "./init/ensure.ts";
72
69
  import { captureLag, captureLagLines, rowsPerDay } from "./status/metrics.ts";
73
70
  import { type Measured, type StoreCounts } from "./status/payload.ts";
74
71
  import { renderMemoryReport } from "./status/report.ts";
@@ -227,9 +224,10 @@ const impl = {
227
224
  );
228
225
  // ---- hooks (all fail-closed) -------------------------------------------
229
226
  // Seam set by the auto-capture wiring below ONLY when the compaction
230
- // trigger is live (autoCapture on, captureOnCompact not false, valid
231
- // captureModel). The compaction hook calls it fire-and-forget; undefined
232
- // means "off". Declared here because the hook registers before capture.
227
+ // trigger is live (autoCapture not false, captureOnCompact not false, and a
228
+ // model that resolves — the option, the session, or the host default). The
229
+ // compaction hook calls it fire-and-forget; undefined means "off".
230
+ // Declared here because the hook registers before capture.
233
231
  let onCompactCapture:
234
232
  | ((sid: string, messages: unknown) => void)
235
233
  | undefined;
@@ -246,13 +244,13 @@ const impl = {
246
244
  flushStatus,
247
245
  getCompactCapture: () => onCompactCapture,
248
246
  });
249
- // ---- opt-in auto-capture (idle + compaction triggers) ------------------
250
- // Default OFF: capture never reads sessions and never calls a model. (The
251
- // measured-cache listener above does subscribe to the event stream by
252
- // default, but it is zero-model: pure bookkeeping of message usage.) When
253
- // enabled (options.autoCapture === true AND a valid captureModel), each
254
- // supported turn-end event — and, unless captureOnCompact === false, each
255
- // compaction hook call too — runs ONE cheap ctx.generate.text call whose
247
+ // ---- auto-capture (turn-end + compaction triggers) ---------------------
248
+ // Armed unless the config sets `autoCapture: false`. (The measured-cache
249
+ // listener above also subscribes to the event stream, and it is
250
+ // zero-model: pure bookkeeping of message usage.) While armed — the switch
251
+ // not false, and a parseable `captureModel` whenever one is given — each
252
+ // supported turn-end event, and unless `captureOnCompact` is false each
253
+ // compaction hook call too, runs ONE cheap ctx.generate.text call whose
256
254
  // reply is parsed into candidates that go through the SAME runWriteGate as
257
255
  // model-authored writes — capture can never bypass the moat, and it only
258
256
  // ever writes through the gate. A per-session, per-trigger cooldown bounds
@@ -293,7 +291,9 @@ const impl = {
293
291
  } catch {
294
292
  // a heartbeat with an unknown version still beats no heartbeat
295
293
  }
296
- const wantCapture = ctx.options?.autoCapture === true;
294
+ // Auto-capture is armed unless the config opts it out: an absent key
295
+ // means on, so the switch is read as a negative opt-out.
296
+ const wantCapture = ctx.options?.autoCapture !== false;
297
297
  // an omitted captureModel is a valid arm — the capture inherits
298
298
  // the session's model (session.context) or the host default. Only an
299
299
  // explicit but malformed string is invalid_model.
package/src/init/run.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  import { basename } from "node:path";
11
11
  import { readerFromSid } from "../store/model/visibility.ts";
12
12
  import { runWriteGate, type GateContext } from "../gate/gate.ts";
13
- import { captureEvidenceContext, record } from "../evidence/record.ts";
13
+ import { captureEvidenceContext, record } from "../telemetry/record.ts";
14
14
  import { writeEvidence, hasGateCheck } from "../capture/triggers.ts";
15
15
  import { writeTarget } from "../identity/repokey.ts";
16
16
  import { quarantineCandidate } from "../store/quarantine/quarantine.ts";
package/src/init/stamp.ts CHANGED
@@ -26,7 +26,7 @@ import { INIT_STAMP_TAG } from "../core/tags.ts";
26
26
  import { preparePrivateFile, tightenDirectory } from "../core/permissions.ts";
27
27
  import { parseLine } from "../core/logfmt/format.ts";
28
28
  import { readLines } from "../core/logfmt/read.ts";
29
- import { evidenceFileFor } from "../evidence/record.ts";
29
+ import { evidenceFileFor } from "../telemetry/record.ts";
30
30
  import { resolveRepo } from "../identity/repokey.ts";
31
31
  import { loadAll } from "../store/files/load.ts";
32
32
  import { markSuperseded } from "../store/files/supersede.ts";
@@ -3,7 +3,7 @@ import { loadAll } from "../store/files/load.ts";
3
3
  import { type Memory } from "../store/model/memory.ts";
4
4
  import { isInjectable } from "../store/model/predicates.ts";
5
5
  import { readerFromSid, visibleTo } from "../store/model/visibility.ts";
6
- import { captureEvidenceContext, record } from "../evidence/record.ts";
6
+ import { captureEvidenceContext, record } from "../telemetry/record.ts";
7
7
  import { frontierBudget } from "../core/config/budgets.ts";
8
8
  import { SESSION_CAP, SessionLru } from "../core/lru.ts";
9
9
  import { dateStr } from "../core/time.ts";
@@ -5,7 +5,7 @@ import { type Memory } from "../store/model/memory.ts";
5
5
  import { isInjectable } from "../store/model/predicates.ts";
6
6
  import { isVisibleTo, readerFromSid } from "../store/model/visibility.ts";
7
7
  import { SESSION_CAP, SessionLru } from "../core/lru.ts";
8
- import { captureEvidenceContext, record } from "../evidence/record.ts";
8
+ import { captureEvidenceContext, record } from "../telemetry/record.ts";
9
9
  import { capToBudget, injectedRows } from "./budget.ts";
10
10
  import { systemDigest } from "./digest.ts";
11
11
  import { storeVersion } from "./version.ts";
@@ -15,7 +15,7 @@ import {
15
15
  deriveMemoryRefs,
16
16
  type MemoryRefs,
17
17
  } from "./attribution.ts";
18
- import { readLedger, useSignals } from "../hits/ledger.ts";
18
+ import { readLedger, useSignals } from "../telemetry/ledger.ts";
19
19
  import { summarizeStore } from "../status/store-summary.ts";
20
20
  import {
21
21
  emptyStats,
@@ -2,10 +2,8 @@
2
2
  //
3
3
  // A query of LONG_QUERY_TOKENS concepts or more is a deliberate search: a row
4
4
  // must share two whole-word concepts with it to be returned. Shorter queries
5
- // keep the matcher's permissive one-concept admission. This is the rule the
6
- // injection path already applies (LONG_QUERY_TOKENS in score.ts); the two
7
- // paths must agree on when nothing is a good enough answer. Admission only:
8
- // ranking, scoring and window size are untouched.
5
+ // keep one-concept admission. Explicit lookup also accepts a complete authored
6
+ // alias that identifies a single candidate. Automatic injection stays stricter.
9
7
  //
10
8
  // ON by default. Off only for an explicit negative (see gateEnabled): a
11
9
  // quality fix that nobody flips on is not a fix, and a typo must not disable
@@ -93,6 +91,34 @@ export function rowConcepts(m: Memory): Set<string> {
93
91
  return out;
94
92
  }
95
93
 
94
+ /** A literal query term may name one visible row by its complete authored alias. */
95
+ export function exactAliasMatches(
96
+ query: string,
97
+ concepts: readonly string[],
98
+ rows: readonly Memory[],
99
+ ): Set<Memory> {
100
+ const matches = new Set<Memory>();
101
+ if (concepts.length < LONG_QUERY_TOKENS) return matches;
102
+ const terms = new Set(
103
+ (query.toLowerCase().match(/[a-z0-9_.\-/]+/g) ?? [])
104
+ .map((id) => id.replace(/^[./-]+|[./-]+$/g, ""))
105
+ .filter((id) => id.length > 2 && !QUERY_STOPWORDS.has(id)),
106
+ );
107
+ const owners = new Map<string, Memory>();
108
+ for (const row of rows)
109
+ for (const alias of row.kw ?? [])
110
+ if (terms.has(alias)) owners.set(alias, row);
111
+ if (!owners.size) return matches;
112
+ for (const row of rows) {
113
+ const indexed = rowConcepts(row);
114
+ for (const [alias, owner] of owners)
115
+ if (row !== owner && indexed.has(alias)) owners.delete(alias);
116
+ if (!owners.size) break;
117
+ }
118
+ for (const owner of owners.values()) matches.add(owner);
119
+ return matches;
120
+ }
121
+
96
122
  /** How many of `concepts` the row contains as whole words (or identifier segments). */
97
123
  export function sharedConcepts(
98
124
  m: Memory,
@@ -158,18 +158,18 @@ export function attributionLines(p: StatusPayload): string[] {
158
158
  export function captureLines(c: CaptureHealth): string[] {
159
159
  switch (c.state) {
160
160
  case "off":
161
- return [" auto-capture: off (default)"];
161
+ return [" auto-capture: off (autoCapture: false)"];
162
162
  case "invalid_model":
163
163
  return [
164
- " auto-capture: invalid_model — autoCapture is on but captureModel is malformed; nothing fires",
164
+ ' auto-capture: invalid_model — captureModel is malformed, so auto-capture is disabled; expected "provider/id"',
165
165
  ];
166
166
  case "no_capabilities":
167
167
  return [
168
- " auto-capture: no_capabilities — autoCapture is on but the host lacks event.subscribe/generate.text/session.context",
168
+ " auto-capture: no_capabilities — the host lacks event.subscribe/generate.text/session.context, so auto-capture is disabled",
169
169
  ];
170
170
  case "switch_mismatch":
171
171
  return [
172
- " auto-capture: switch_mismatch — captureOnCompact is on but autoCapture is off; nothing fires",
172
+ " auto-capture: switch_mismatch — captureOnCompact is on but autoCapture is false; nothing fires",
173
173
  ];
174
174
  case "on": {
175
175
  // Inert means NO execution evidence at all: no candidate line and no
@@ -1,6 +1,6 @@
1
1
  // Shared store counts for epoch payloads and the chat report.
2
2
  // Callers own I/O and visibility policy; this summarizes exactly their rows.
3
- import { neverRetrieved, type UseLedger } from "../hits/ledger.ts";
3
+ import { neverRetrieved, type UseLedger } from "../telemetry/ledger.ts";
4
4
  import type { Memory } from "../store/model/memory.ts";
5
5
  import { isActive } from "../store/model/predicates.ts";
6
6
  import type { StoreCounts } from "./payload.ts";
@@ -29,7 +29,7 @@ const RESERVED = new Set([
29
29
  // Value-keyed rejection tombstones. Hashes only, never prose — and it
30
30
  // must never be ingested as a row, exported, or restored by undo.
31
31
  "rejected.logfmt",
32
- // The use ledger (src/hits.ts): telemetry, not memory. A hit line must never
32
+ // The use ledger (src/telemetry/ledger.ts): telemetry, not memory. A hit line must never
33
33
  // be able to become a row — or to be superseded, exported, or injected.
34
34
  HITS_FILENAME,
35
35
  ]);
package/src/store/lock.ts CHANGED
@@ -54,7 +54,7 @@ import { chmod, unlink } from "node:fs/promises";
54
54
  import { basename, dirname, join } from "node:path";
55
55
  import { Database } from "bun:sqlite";
56
56
  import { ensureDir } from "../core/logfmt/publish.ts";
57
- import { record } from "../evidence/record.ts";
57
+ import { record } from "../telemetry/record.ts";
58
58
 
59
59
  /**
60
60
  * The lock database for ONE store file: `.store-lock.<file>.sqlite`, beside it.
@@ -2,7 +2,7 @@
2
2
  // reversible (snapshot) and never touches a repo. The `prune` evidence line is
3
3
  // emitted after prune() returns so S5 can assert the reason and snapshot.
4
4
  import { deletionsFile } from "../core/config/paths.ts";
5
- import { record } from "../evidence/record.ts";
5
+ import { record } from "../telemetry/record.ts";
6
6
  import { type PruneResult, prune } from "./files/prune.ts";
7
7
  import { readerFromSid } from "./model/visibility.ts";
8
8
 
@@ -1,7 +1,7 @@
1
1
  // rejection — split from src/tombstones.ts. Declaration bodies are unchanged.
2
2
  import { join } from "node:path";
3
3
  import { memoryRoot } from "../../core/config/paths.ts";
4
- import { contentHash } from "../../evidence/record.ts";
4
+ import { contentHash } from "../../telemetry/record.ts";
5
5
  import {
6
6
  differsIn,
7
7
  NEAR_FLOOR,
@@ -59,7 +59,7 @@ import {
59
59
  STOPWORDS,
60
60
  tokens,
61
61
  } from "../../core/tokenize.ts";
62
- import { contentHash } from "../../evidence/record.ts";
62
+ import { contentHash } from "../../telemetry/record.ts";
63
63
  import { LOCK_WRITE, withStoreLock } from "../lock.ts";
64
64
  import { redactSecrets } from "../secrets.ts";
65
65
  import {
package/src/store/undo.ts CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  writeAtomic,
37
37
  } from "../core/logfmt/publish.ts";
38
38
  import { readLines } from "../core/logfmt/read.ts";
39
- import { contentHash } from "../evidence/record.ts";
39
+ import { contentHash } from "../telemetry/record.ts";
40
40
  import { isWithin } from "./containment.ts";
41
41
  import { snapshotFiles } from "./files/snapshots.ts";
42
42
  import { LOCK_RESTORE, withStoreLock } from "./lock.ts";
@@ -4,8 +4,8 @@
4
4
  import type { ToolRegister } from "./deps.ts";
5
5
  import { proposeConsolidations } from "../consolidate/propose.ts";
6
6
  import { renderProposals } from "../consolidate/render.ts";
7
- import { captureEvidenceContext, record } from "../evidence/record.ts";
8
- import { readLedger, readReads } from "../hits/ledger.ts";
7
+ import { captureEvidenceContext, record } from "../telemetry/record.ts";
8
+ import { readLedger, readReads } from "../telemetry/ledger.ts";
9
9
  import { loadAll } from "../store/files/load.ts";
10
10
  import { isInjectable } from "../store/model/predicates.ts";
11
11
  import { isVisibleTo, readerFromSid } from "../store/model/visibility.ts";
@@ -2,7 +2,7 @@
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
5
- import { captureEvidenceContext, record } from "../evidence/record.ts";
5
+ import { captureEvidenceContext, record } from "../telemetry/record.ts";
6
6
  import { snapshotFiles } from "../store/files/snapshots.ts";
7
7
  import { markManySuperseded } from "../store/files/supersede.ts";
8
8
  import { findStaleOpen } from "../portable/decay.ts";
package/src/tools/deps.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  // so a tool file never reaches into the plugin setup closure.
4
4
  import type { GateContext } from "../gate/gate.ts";
5
5
  import type { createInjectionEpochs } from "../inject/epochs.ts";
6
- import type { HitSource } from "../hits/ledger.ts";
6
+ import type { HitSource } from "../telemetry/ledger.ts";
7
7
  import type { Memory } from "../store/model/memory.ts";
8
8
 
9
9
  export interface ToolDeps {
@@ -2,7 +2,7 @@
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
5
- import { evidenceFileFor } from "../evidence/record.ts";
5
+ import { evidenceFileFor } from "../telemetry/record.ts";
6
6
  import { parseLine } from "../core/logfmt/format.ts";
7
7
  import { readLines } from "../core/logfmt/read.ts";
8
8
  import { evidenceVisibleTo, readerFromSid } from "../store/model/visibility.ts";
@@ -2,7 +2,7 @@
2
2
  // Closure access arrives through ToolDeps.
3
3
  import type { ToolRegister } from "./deps.ts";
4
4
  import { memoryRoot } from "../core/config/paths.ts";
5
- import { record } from "../evidence/record.ts";
5
+ import { record } from "../telemetry/record.ts";
6
6
  import { withStoreBatch } from "../store/lock.ts";
7
7
  import { loadAll } from "../store/files/load.ts";
8
8
  import { clearSuperseded, markSuperseded } from "../store/files/supersede.ts";