@chenhw7/dsh-memory 0.4.0 → 0.5.0

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 (54) hide show
  1. package/README.md +3 -1
  2. package/README.zh-CN.md +3 -1
  3. package/lib/benchmark/index.d.ts +125 -0
  4. package/lib/benchmark/index.d.ts.map +1 -0
  5. package/lib/benchmark/index.js +150 -0
  6. package/lib/benchmark/index.js.map +1 -0
  7. package/lib/brand.d.ts +11 -0
  8. package/lib/brand.d.ts.map +1 -1
  9. package/lib/brand.js +7 -0
  10. package/lib/brand.js.map +1 -1
  11. package/lib/client/index.js +844 -185
  12. package/lib/context/index.d.ts +22 -3
  13. package/lib/context/index.d.ts.map +1 -1
  14. package/lib/context/index.js +59 -13
  15. package/lib/context/index.js.map +1 -1
  16. package/lib/context/policy.d.ts +6 -0
  17. package/lib/context/policy.d.ts.map +1 -1
  18. package/lib/context/policy.js +26 -9
  19. package/lib/context/policy.js.map +1 -1
  20. package/lib/index.d.ts +44 -5
  21. package/lib/index.d.ts.map +1 -1
  22. package/lib/index.js +48 -2
  23. package/lib/index.js.map +1 -1
  24. package/lib/notes/index.d.ts +1 -1
  25. package/lib/notes/index.d.ts.map +1 -1
  26. package/lib/notes/index.js +37 -7
  27. package/lib/notes/index.js.map +1 -1
  28. package/lib/notes/writer.d.ts +33 -0
  29. package/lib/notes/writer.d.ts.map +1 -1
  30. package/lib/notes/writer.js +61 -1
  31. package/lib/notes/writer.js.map +1 -1
  32. package/lib/remote/index.d.ts +71 -1
  33. package/lib/remote/index.d.ts.map +1 -1
  34. package/lib/remote/index.js +94 -1
  35. package/lib/remote/index.js.map +1 -1
  36. package/lib/remote/typert.remote-client.d.ts +31 -3
  37. package/lib/review/extract.d.ts +48 -4
  38. package/lib/review/extract.d.ts.map +1 -1
  39. package/lib/review/extract.js +164 -11
  40. package/lib/review/extract.js.map +1 -1
  41. package/lib/review/index.d.ts +6 -0
  42. package/lib/review/index.d.ts.map +1 -1
  43. package/lib/review/index.js +12 -10
  44. package/lib/review/index.js.map +1 -1
  45. package/lib/store/index.d.ts +56 -3
  46. package/lib/store/index.d.ts.map +1 -1
  47. package/lib/store/index.js +238 -9
  48. package/lib/store/index.js.map +1 -1
  49. package/lib/tool/index.d.ts.map +1 -1
  50. package/lib/tool/index.js +156 -25
  51. package/lib/tool/index.js.map +1 -1
  52. package/lib/types.d.ts +83 -2
  53. package/lib/types.d.ts.map +1 -1
  54. package/package.json +5 -1
@@ -51,6 +51,7 @@ export const Config = z.object({
51
51
  curatorEveryNSessions: z.number().step(1).min(1).default(20),
52
52
  curatorMaxEntries: z.number().step(1).min(1).default(5),
53
53
  curatorMinChars: z.number().step(1).min(1).default(400),
54
+ confirmBeforeWrite: z.boolean().default(false),
54
55
  });
55
56
  /** Best-effort timeout for the dispose flush, in milliseconds. */
56
57
  const DISPOSE_FLUSH_TIMEOUT_MS = 5_000;
@@ -73,6 +74,7 @@ function resolveConfig(config) {
73
74
  curatorEveryNSessions: config.curatorEveryNSessions ?? 20,
74
75
  curatorMaxEntries: config.curatorMaxEntries ?? 5,
75
76
  curatorMinChars: config.curatorMinChars ?? 400,
77
+ confirmBeforeWrite: config.confirmBeforeWrite ?? false,
76
78
  };
77
79
  }
78
80
  /** Render one derived message as a flush fragment (role-prefixed text). */
@@ -110,15 +112,15 @@ function findCompactionSummary(session, compactionId) {
110
112
  return undefined;
111
113
  }
112
114
  /** Fire-and-forget flush on `compaction/end`: extract the shadowed fragments. */
113
- async function flushOnCompaction(ctx, session, compactionId, modelOverride, judgeEnabled) {
115
+ async function flushOnCompaction(ctx, session, compactionId, modelOverride, judgeEnabled, confirmMode) {
114
116
  const summary = findCompactionSummary(session, compactionId);
115
117
  if (summary === undefined)
116
118
  return;
117
119
  const fragments = collectShadowedFragments(session, summary.data.shadowedSeqs);
118
- await runFlushExtraction(ctx, session, fragments, undefined, modelOverride, judgeEnabled);
120
+ await runFlushExtraction(ctx, session, fragments, undefined, modelOverride, judgeEnabled, confirmMode);
119
121
  }
120
122
  /** Fire-and-forget flush on `session/disposed`: extract recent derived messages. */
121
- async function flushOnDispose(ctx, session, modelOverride, judgeEnabled) {
123
+ async function flushOnDispose(ctx, session, modelOverride, judgeEnabled, confirmMode) {
122
124
  const messages = session.deriveMessages();
123
125
  const fragments = [];
124
126
  for (const message of messages) {
@@ -127,7 +129,7 @@ async function flushOnDispose(ctx, session, modelOverride, judgeEnabled) {
127
129
  fragments.push(fragment);
128
130
  }
129
131
  const signal = AbortSignal.timeout(DISPOSE_FLUSH_TIMEOUT_MS);
130
- await runFlushExtraction(ctx, session, fragments, signal, modelOverride, judgeEnabled);
132
+ await runFlushExtraction(ctx, session, fragments, signal, modelOverride, judgeEnabled, confirmMode);
131
133
  }
132
134
  /**
133
135
  * Install the memory-review function plugin.
@@ -191,7 +193,7 @@ export function apply(ctx, config = {}) {
191
193
  const cfg = resolved();
192
194
  if (!signal.aborted && cfg.reviewEnabled) {
193
195
  try {
194
- await maybeRunReview(ctx, agent, cfg.reviewCandidateThreshold, highWaterMarks, cfg.extractionModel, checkBudget, cfg.judgeEnabled);
196
+ await maybeRunReview(ctx, agent, cfg.reviewCandidateThreshold, highWaterMarks, cfg.extractionModel, checkBudget, cfg.judgeEnabled, cfg.confirmBeforeWrite);
195
197
  }
196
198
  catch (_reviewError) {
197
199
  // Best-effort: a review failure must never block the step.
@@ -210,7 +212,7 @@ export function apply(ctx, config = {}) {
210
212
  return;
211
213
  if (!checkBudget(session))
212
214
  return;
213
- void flushOnCompaction(ctx, session, event.data.compactionId, cfg.extractionModel, cfg.judgeEnabled).catch(() => {
215
+ void flushOnCompaction(ctx, session, event.data.compactionId, cfg.extractionModel, cfg.judgeEnabled, cfg.confirmBeforeWrite).catch(() => {
214
216
  // Best-effort: a flush failure is logged by the runtime, not thrown here.
215
217
  });
216
218
  });
@@ -221,7 +223,7 @@ export function apply(ctx, config = {}) {
221
223
  return;
222
224
  if (!checkBudget(session))
223
225
  return;
224
- void flushOnDispose(ctx, session, cfg.extractionModel, cfg.judgeEnabled).catch(() => {
226
+ void flushOnDispose(ctx, session, cfg.extractionModel, cfg.judgeEnabled, cfg.confirmBeforeWrite).catch(() => {
225
227
  // Best-effort: dispose must not block on memory extraction.
226
228
  });
227
229
  });
@@ -263,7 +265,7 @@ export function apply(ctx, config = {}) {
263
265
  return;
264
266
  if (!checkBudget(session))
265
267
  return;
266
- void runCuration(ctx, session, selected, cfg.extractionModel).catch(() => {
268
+ void runCuration(ctx, session, selected, cfg.extractionModel, cfg.confirmBeforeWrite).catch(() => {
267
269
  // Best-effort: curation failures never surface into session creation.
268
270
  });
269
271
  }, { global: true });
@@ -277,7 +279,7 @@ export function apply(ctx, config = {}) {
277
279
  * dedup prefilter + LLM judge. The `agent/pre-step` listener wraps this call
278
280
  * in try/catch, so the failure never blocks the step (§3.6 best-effort).
279
281
  */
280
- async function maybeRunReview(ctx, agent, threshold, highWaterMarks, modelOverride, checkBudget, judgeEnabled) {
282
+ async function maybeRunReview(ctx, agent, threshold, highWaterMarks, modelOverride, checkBudget, judgeEnabled, confirmMode) {
281
283
  const projections = ctx.get('sessionProjections');
282
284
  if (projections === undefined)
283
285
  return;
@@ -292,7 +294,7 @@ async function maybeRunReview(ctx, agent, threshold, highWaterMarks, modelOverri
292
294
  return;
293
295
  if (!checkBudget(session))
294
296
  return;
295
- await runReviewExtraction(ctx, agent, unprocessed, modelOverride, judgeEnabled);
297
+ await runReviewExtraction(ctx, agent, unprocessed, modelOverride, judgeEnabled, confirmMode);
296
298
  const nextMark = unprocessed.reduce((max, candidate) => Math.max(max, candidate.seq), mark);
297
299
  highWaterMarks.set(session, nextMark);
298
300
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/review/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AACrF,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,IAAI,WAAW,KAAK,SAAS;QAAE,OAAM;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;IAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,4BAA4B,CAAiC,CAAA;IAC3F,IAAI,KAAK,KAAK,SAAS;QAAE,OAAM;IAC/B,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9C,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,GAAG,IAAI,CAAC,CAAA;IAC9E,IAAI,WAAW,CAAC,MAAM,GAAG,SAAS;QAAE,OAAM;IAC1C,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QAAE,OAAM;IACjC,MAAM,mBAAmB,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,CAAC,CAAA;IAC5F,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAA;IAC3F,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACvC,CAAC"}
@@ -12,12 +12,14 @@
12
12
  */
13
13
  import type { Context } from '@deepseek-ai/cordis';
14
14
  import type { KvTable } from '@deepseek-ai/dsh-storage-domain';
15
- import { MemoryStore, MemoryId, AuditId } from '../index.ts';
16
- import type { AddMemoryInput, AddMemoryResult, AuditEntry, MemoryEntry, MemoryHealth, MemorySearchQuery, SearchMemoryResult, UpdateMemoryInput } from '../types.ts';
15
+ import { MemoryStore, MemoryId, AuditId, SuggestionId } from '../index.ts';
16
+ import type { AddMemoryInput, AddMemoryResult, AddSuggestionInput, AdoptSuggestionOverride, AuditEntry, MemoryEntry, MemoryHealth, MemorySearchQuery, MemorySuggestion, SearchMemoryResult, UpdateMemoryInput } from '../types.ts';
17
17
  /** The entries table from the opened domain. */
18
18
  type EntriesTable = KvTable<MemoryId, MemoryEntry>;
19
19
  /** The audit table from the opened domain. */
20
20
  type AuditTable = KvTable<AuditId, AuditEntry>;
21
+ /** The suggestions table from the opened domain (P1-1 review queue). */
22
+ type SuggestionsTable = KvTable<SuggestionId, MemorySuggestion>;
21
23
  /** Cordis plugin name. */
22
24
  export declare const name = "memory-store-domain";
23
25
  /** Services required before this provider can mount. */
@@ -37,10 +39,12 @@ export declare function apply(ctx: Context): Promise<void>;
37
39
  export declare class DomainMemoryStore extends MemoryStore {
38
40
  private readonly entries;
39
41
  private readonly audit;
42
+ private readonly suggestions;
40
43
  private readonly auditCap;
44
+ private readonly suggestionCap;
41
45
  /** Last audit `seq` handed out; lazily initialized from the medium on first append. */
42
46
  private auditSeq;
43
- constructor(entries: EntriesTable, audit: AuditTable, auditCap?: number);
47
+ constructor(entries: EntriesTable, audit: AuditTable, suggestions: SuggestionsTable, auditCap?: number, suggestionCap?: number);
44
48
  /** Next monotonic audit sequence number (survives reopen via the medium). */
45
49
  private nextAuditSeq;
46
50
  add(input: AddMemoryInput): Promise<AddMemoryResult>;
@@ -62,8 +66,57 @@ export declare class DomainMemoryStore extends MemoryStore {
62
66
  * without recall tracking stay contract-conformant.
63
67
  */
64
68
  markRecalled(ids: readonly string[]): void;
69
+ /**
70
+ * Record one extraction/model proposal in the pending-review queue.
71
+ *
72
+ * Dedup semantics ("frequency is signal", evolve-style): when a similar
73
+ * proposal already exists in the same scope — or one targeting the same
74
+ * entry — the observation bumps its `hits` and refreshes `lastSeenAt`
75
+ * instead of creating a row; missing metadata (category/summary) is filled
76
+ * from the newer proposal, and strictly more informative content (a
77
+ * superset) replaces the original. Otherwise the proposal joins with
78
+ * `hits: 1`.
79
+ * @param input - the proposal to record.
80
+ * @returns the stored suggestion (existing row updated, or newly created).
81
+ * @throws when the proposed content fails validation or the scanner.
82
+ */
83
+ observeSuggestion(input: AddSuggestionInput): Promise<MemorySuggestion>;
84
+ /**
85
+ * List pending suggestions for the review UI: highest `hits` first (the
86
+ * repeatedly-re-proposed signals float up), then most recently seen.
87
+ */
88
+ listSuggestions(): readonly MemorySuggestion[];
89
+ getSuggestion(id: SuggestionId): MemorySuggestion | undefined;
90
+ /**
91
+ * Adopt one pending suggestion — the human yes that turns a proposal into
92
+ * memory. With `targetEntryId` set, the (possibly edited) content updates
93
+ * the targeted entry (P1-2: the model's change applies only here);
94
+ * otherwise a new entry is created. The override carries the "edit before
95
+ * adopt" tweaks made in the review UI. The adopted write goes through the
96
+ * full store contract (scanner included) and the audit trail with source
97
+ * `'ui'`; the suggestion row is removed afterwards.
98
+ * @param id - the suggestion id.
99
+ * @param override - optional human edits applied on top of the proposal.
100
+ * @returns the written entry, or `undefined` when the suggestion is gone.
101
+ */
102
+ adoptSuggestion(id: SuggestionId, override?: AdoptSuggestionOverride): Promise<MemoryEntry | undefined>;
103
+ /**
104
+ * Reject one pending suggestion: the row leaves the queue and nothing is
105
+ * written. @returns whether a suggestion was actually removed.
106
+ */
107
+ rejectSuggestion(id: SuggestionId): Promise<boolean>;
108
+ /** Trim the suggestion queue to its cap, evicting the lowest-signal rows. */
109
+ private trimSuggestions;
65
110
  pin(id: MemoryId): Promise<MemoryEntry | undefined>;
66
111
  unpin(id: MemoryId): Promise<MemoryEntry | undefined>;
112
+ /**
113
+ * Archive one entry manually (P1-7): stamp `staleSince` (idempotent — an
114
+ * already-stale entry is returned unchanged) and record a `'ui'`-sourced
115
+ * audit update. Hidden from injection; still searchable; recall revives.
116
+ */
117
+ archiveEntry(id: MemoryId): Promise<MemoryEntry | undefined>;
118
+ /** Lift a manual or janitor dormancy stamp without counting it as a recall. */
119
+ unarchiveEntry(id: MemoryId): Promise<MemoryEntry | undefined>;
67
120
  /**
68
121
  * Run the janitor pass with the lifecycle's two-tier policy:
69
122
  * - `project` entries overdue by `decayDays` (pinned exempt) are REMOVED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,iCAAiC,CAAA;AAEtE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAsD,MAAM,aAAa,CAAA;AAEhH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,UAAU,EAGV,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAiDpB,gDAAgD;AAChD,KAAK,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;AAElD,8CAA8C;AAC9C,KAAK,UAAU,GAAG,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;AAoB9C,0BAA0B;AAC1B,eAAO,MAAM,IAAI,wBAAwB,CAAA;AAEzC,wDAAwD;AACxD,eAAO,MAAM,MAAM,UAAoB,CAAA;AAEvC;;;;GAIG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAQvD;AAED;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,uFAAuF;IACvF,OAAO,CAAC,QAAQ,CAAoB;IAEpC,YAAY,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,GAAE,MAA0B,EAKzF;IA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D,eAAe;IAUd,GAAG,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAMjE;IAEc,KAAK,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAMnE;IAED;;;;OAIG;IACY,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAQ1E;IAED,+EAA+E;IAChE,cAAc,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAQ5E;IAED;;;;;;;;;;OAUG;IACY,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBnF;IAED;;;OAGG;IACH,SAAS,IAAI,SAAS,UAAU,EAAE,CAKjC;IAEQ,MAAM,IAAI,YAAY,CAsB9B;IAEQ,cAAc,IAAI,SAAS,UAAU,EAAE,CAK/C;IAED;;;;OAIG;YACW,WAAW;IA2BzB,oEAAoE;YACtD,SAAS;CAUxB"}
@@ -12,14 +12,16 @@
12
12
  */
13
13
  import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';
14
14
  import { z } from 'zod';
15
- import { MemoryStore, MemoryId, AuditId, scanContent, validateProjectScope, validateContent } from '../index.js';
15
+ import { MemoryStore, MemoryId, AuditId, SuggestionId, scanContent, validateProjectScope, validateContent } from '../index.js';
16
16
  import { Bm25Index, tokenizeForSearch } from './bm25.js';
17
+ import { jaccardSimilarity, tokenize } from '../review/dedup.js';
17
18
  /** Zod schema for one memory entry record on the durable medium. */
18
19
  const memoryEntrySchema = z.object({
19
20
  id: z.string().min(1),
20
21
  scope: z.enum(['global', 'project', 'user']),
21
22
  category: z.enum(['failure', 'correction', 'insight', 'preference', 'convention', 'tool-quirk', 'procedure']).optional(),
22
23
  content: z.string(),
24
+ summary: z.string().optional(),
23
25
  projectName: z.string().optional(),
24
26
  createdAt: z.number(),
25
27
  updatedAt: z.number(),
@@ -40,12 +42,27 @@ const auditEntrySchema = z.object({
40
42
  seq: z.number().optional(),
41
43
  contentPreview: z.string(),
42
44
  });
45
+ /** Zod schema for one pending suggestion in the human-review queue (P1-1). */
46
+ const suggestionSchema = z.object({
47
+ id: z.string().min(1),
48
+ scope: z.enum(['global', 'project', 'user']),
49
+ category: z.enum(['failure', 'correction', 'insight', 'preference', 'convention', 'tool-quirk', 'procedure']).optional(),
50
+ content: z.string(),
51
+ summary: z.string().optional(),
52
+ projectName: z.string().optional(),
53
+ hits: z.number(),
54
+ firstSeenAt: z.number(),
55
+ lastSeenAt: z.number(),
56
+ targetEntryId: z.string().optional(),
57
+ source: z.enum(['tool', 'review', 'flush', 'ui', 'janitor']),
58
+ sessionId: z.string().optional(),
59
+ });
43
60
  /**
44
61
  * The memory domain spec: `entries` (memory records keyed by id) plus `audit`
45
- * (mutation audit trail). Domain version stays at 0 — the `audit` table is a
46
- * forward-compatible addition: storage-json reads only declared tables and
47
- * initializes any absent table as an empty map, so existing v0 media reopen
48
- * without migration.
62
+ * (mutation audit trail) plus `suggestions` (P1-1 pending-review queue).
63
+ * Domain version stays at 0 — both later tables are forward-compatible
64
+ * additions: storage-json reads only declared tables and initializes any
65
+ * absent table as an empty map, so existing v0 media reopen without migration.
49
66
  */
50
67
  const memoryDomainSpec = defineDomain({
51
68
  name: 'memory',
@@ -53,10 +70,23 @@ const memoryDomainSpec = defineDomain({
53
70
  tables: {
54
71
  entries: domainTable(memoryEntrySchema),
55
72
  audit: domainTable(auditEntrySchema),
73
+ suggestions: domainTable(suggestionSchema),
56
74
  },
57
75
  });
58
76
  /** Maximum audit records retained; oldest are trimmed on overflow. */
59
77
  const DEFAULT_AUDIT_CAP = 200;
78
+ /**
79
+ * Maximum pending suggestions retained (P1-1). Overflow evicts the
80
+ * lowest-signal rows first: fewest hits, then oldest `lastSeenAt`.
81
+ */
82
+ const DEFAULT_SUGGESTION_CAP = 200;
83
+ /**
84
+ * Jaccard similarity above which two same-scope proposals count as the same
85
+ * suggestion (re-observation, not a new row). Matches the entry-dedup
86
+ * prefilter threshold so "the model keeps proposing X" and "X is already
87
+ * stored" draw the same near-duplicate line.
88
+ */
89
+ const SUGGESTION_DUP_THRESHOLD = 0.15;
60
90
  /**
61
91
  * Deterministic audit ordering: newest/oldest by `ts`, ties broken by the
62
92
  * monotonic append `seq`, then by id for records written before `seq` existed.
@@ -83,8 +113,9 @@ export async function apply(ctx) {
83
113
  const domain = await ctx.storageDomain.open(memoryDomainSpec);
84
114
  const entries = domain.table('entries');
85
115
  const audit = domain.table('audit');
116
+ const suggestions = domain.table('suggestions');
86
117
  ctx.effect(() => async () => { await domain.close(); });
87
- ctx.provide('memory', new DomainMemoryStore(entries, audit));
118
+ ctx.provide('memory', new DomainMemoryStore(entries, audit, suggestions));
88
119
  }
89
120
  /**
90
121
  * MemoryStore implementation backed by a storage-domain KV table. Reads are
@@ -95,14 +126,18 @@ export async function apply(ctx) {
95
126
  export class DomainMemoryStore extends MemoryStore {
96
127
  entries;
97
128
  audit;
129
+ suggestions;
98
130
  auditCap;
131
+ suggestionCap;
99
132
  /** Last audit `seq` handed out; lazily initialized from the medium on first append. */
100
133
  auditSeq;
101
- constructor(entries, audit, auditCap = DEFAULT_AUDIT_CAP) {
134
+ constructor(entries, audit, suggestions, auditCap = DEFAULT_AUDIT_CAP, suggestionCap = DEFAULT_SUGGESTION_CAP) {
102
135
  super();
103
136
  this.entries = entries;
104
137
  this.audit = audit;
138
+ this.suggestions = suggestions;
105
139
  this.auditCap = auditCap;
140
+ this.suggestionCap = suggestionCap;
106
141
  }
107
142
  /** Next monotonic audit sequence number (survives reopen via the medium). */
108
143
  nextAuditSeq() {
@@ -129,6 +164,7 @@ export class DomainMemoryStore extends MemoryStore {
129
164
  scope: input.scope,
130
165
  category: input.category,
131
166
  content: input.content,
167
+ ...(input.summary !== undefined && input.summary.length > 0 ? { summary: input.summary } : {}),
132
168
  projectName: input.projectName,
133
169
  createdAt: now,
134
170
  updatedAt: now,
@@ -161,12 +197,19 @@ export class DomainMemoryStore extends MemoryStore {
161
197
  if (!scan.allowed) {
162
198
  throw new Error(`memory content rejected by scanner: ${scan.reasons.join('; ')}`);
163
199
  }
164
- const updated = {
200
+ // summary semantics: `undefined` = keep existing; `''` = explicitly clear;
201
+ // a non-empty string = replace. Build the updated entry accordingly.
202
+ const base = {
165
203
  ...existing,
166
204
  content: newContent,
167
205
  category: input.category ?? existing.category,
168
206
  updatedAt: Date.now(),
169
207
  };
208
+ const updated = input.summary === ''
209
+ ? (() => { const { summary: _c, ...rest } = base; return rest; })()
210
+ : input.summary !== undefined
211
+ ? { ...base, summary: input.summary }
212
+ : base;
170
213
  await this.entries.put(id, updated);
171
214
  await this.appendAudit('update', id, updated, input.source, input.sessionId);
172
215
  return updated;
@@ -222,7 +265,10 @@ export class DomainMemoryStore extends MemoryStore {
222
265
  all = limit > 0 ? all.slice(0, limit) : all;
223
266
  // Fire-and-forget: stamp the returned entries with a recall timestamp
224
267
  // so the janitor can decay entries that have not been recalled recently.
225
- void this.stampRecalled(all);
268
+ // Read-only consumers (management UI) opt out via recordRecall: false —
269
+ // merely viewing entries must not rewrite their recall metadata.
270
+ if (query.recordRecall !== false)
271
+ void this.stampRecalled(all);
226
272
  return { entries: all, total };
227
273
  }
228
274
  /**
@@ -252,6 +298,162 @@ export class DomainMemoryStore extends MemoryStore {
252
298
  return;
253
299
  void this.stampRecalled(ids.map(id => this.entries.get(id)).filter((e) => e !== undefined));
254
300
  }
301
+ // ─── Suggestion queue (P1-1 optional human-confirm mode) ──────────────────
302
+ /**
303
+ * Record one extraction/model proposal in the pending-review queue.
304
+ *
305
+ * Dedup semantics ("frequency is signal", evolve-style): when a similar
306
+ * proposal already exists in the same scope — or one targeting the same
307
+ * entry — the observation bumps its `hits` and refreshes `lastSeenAt`
308
+ * instead of creating a row; missing metadata (category/summary) is filled
309
+ * from the newer proposal, and strictly more informative content (a
310
+ * superset) replaces the original. Otherwise the proposal joins with
311
+ * `hits: 1`.
312
+ * @param input - the proposal to record.
313
+ * @returns the stored suggestion (existing row updated, or newly created).
314
+ * @throws when the proposed content fails validation or the scanner.
315
+ */
316
+ async observeSuggestion(input) {
317
+ validateProjectScope({ ...input, projectName: input.projectName ?? (input.targetEntryId !== undefined ? this.entries.get(input.targetEntryId)?.projectName : undefined) });
318
+ validateContent(input.content);
319
+ const scan = scanContent(input.content);
320
+ if (!scan.allowed) {
321
+ throw new Error(`suggestion content rejected by scanner: ${scan.reasons.join('; ')}`);
322
+ }
323
+ const now = Date.now();
324
+ // Match against existing proposals: same target entry wins outright;
325
+ // otherwise nearest-content in the same scope above the dedup threshold.
326
+ let matched;
327
+ for (const [, suggestion] of this.suggestions.entries()) {
328
+ if (input.targetEntryId !== undefined) {
329
+ if (suggestion.targetEntryId === input.targetEntryId) {
330
+ matched = suggestion;
331
+ break;
332
+ }
333
+ continue;
334
+ }
335
+ if (suggestion.scope !== input.scope)
336
+ continue;
337
+ const similarity = jaccardSimilarity(tokenize(input.content), tokenize(suggestion.content));
338
+ if (similarity > SUGGESTION_DUP_THRESHOLD) {
339
+ matched = suggestion;
340
+ break;
341
+ }
342
+ }
343
+ if (matched !== undefined) {
344
+ const improved = input.content.length > matched.content.length && input.content.includes(matched.content);
345
+ const updated = {
346
+ ...matched,
347
+ content: improved ? input.content : matched.content,
348
+ category: matched.category ?? input.category,
349
+ summary: matched.summary ?? input.summary,
350
+ projectName: matched.projectName ?? input.projectName,
351
+ hits: matched.hits + 1,
352
+ lastSeenAt: now,
353
+ };
354
+ await this.suggestions.put(matched.id, updated);
355
+ return updated;
356
+ }
357
+ const suggestion = {
358
+ id: SuggestionId(),
359
+ scope: input.scope,
360
+ content: input.content,
361
+ hits: 1,
362
+ firstSeenAt: now,
363
+ lastSeenAt: now,
364
+ source: input.source,
365
+ ...input.category !== undefined ? { category: input.category } : {},
366
+ ...input.summary !== undefined ? { summary: input.summary } : {},
367
+ ...input.projectName !== undefined ? { projectName: input.projectName } : {},
368
+ ...input.targetEntryId !== undefined ? { targetEntryId: input.targetEntryId } : {},
369
+ ...input.sessionId !== undefined ? { sessionId: input.sessionId } : {},
370
+ };
371
+ await this.suggestions.put(suggestion.id, suggestion);
372
+ await this.trimSuggestions();
373
+ return suggestion;
374
+ }
375
+ /**
376
+ * List pending suggestions for the review UI: highest `hits` first (the
377
+ * repeatedly-re-proposed signals float up), then most recently seen.
378
+ */
379
+ listSuggestions() {
380
+ const all = [];
381
+ for (const [, suggestion] of this.suggestions.entries())
382
+ all.push(suggestion);
383
+ return all.sort((a, b) => b.hits - a.hits || b.lastSeenAt - a.lastSeenAt || (a.id < b.id ? -1 : 1));
384
+ }
385
+ getSuggestion(id) {
386
+ return this.suggestions.get(id);
387
+ }
388
+ /**
389
+ * Adopt one pending suggestion — the human yes that turns a proposal into
390
+ * memory. With `targetEntryId` set, the (possibly edited) content updates
391
+ * the targeted entry (P1-2: the model's change applies only here);
392
+ * otherwise a new entry is created. The override carries the "edit before
393
+ * adopt" tweaks made in the review UI. The adopted write goes through the
394
+ * full store contract (scanner included) and the audit trail with source
395
+ * `'ui'`; the suggestion row is removed afterwards.
396
+ * @param id - the suggestion id.
397
+ * @param override - optional human edits applied on top of the proposal.
398
+ * @returns the written entry, or `undefined` when the suggestion is gone.
399
+ */
400
+ async adoptSuggestion(id, override) {
401
+ const suggestion = this.suggestions.get(id);
402
+ if (suggestion === undefined)
403
+ return undefined;
404
+ const content = override?.content ?? suggestion.content;
405
+ validateContent(content);
406
+ const scan = scanContent(content);
407
+ if (!scan.allowed) {
408
+ throw new Error(`adopted content rejected by scanner: ${scan.reasons.join('; ')}`);
409
+ }
410
+ const category = override?.category !== undefined
411
+ ? (override.category.length > 0 ? override.category : undefined)
412
+ : suggestion.category;
413
+ const summary = override?.summary !== undefined
414
+ ? (override.summary.length > 0 ? override.summary : undefined)
415
+ : suggestion.summary;
416
+ let entry;
417
+ if (suggestion.targetEntryId !== undefined && this.entries.get(suggestion.targetEntryId) !== undefined) {
418
+ entry = await this.update(suggestion.targetEntryId, {
419
+ content,
420
+ ...(category !== undefined ? { category } : {}),
421
+ ...(summary !== undefined ? { summary } : { summary: '' }),
422
+ source: 'ui',
423
+ });
424
+ }
425
+ else {
426
+ const result = await this.add({
427
+ scope: suggestion.scope,
428
+ content,
429
+ source: 'ui',
430
+ ...(category !== undefined ? { category } : {}),
431
+ ...(summary !== undefined ? { summary } : {}),
432
+ ...(suggestion.projectName !== undefined ? { projectName: suggestion.projectName } : {}),
433
+ });
434
+ entry = result.entry;
435
+ }
436
+ await this.suggestions.delete(id);
437
+ return entry;
438
+ }
439
+ /**
440
+ * Reject one pending suggestion: the row leaves the queue and nothing is
441
+ * written. @returns whether a suggestion was actually removed.
442
+ */
443
+ async rejectSuggestion(id) {
444
+ return this.suggestions.delete(id);
445
+ }
446
+ /** Trim the suggestion queue to its cap, evicting the lowest-signal rows. */
447
+ async trimSuggestions() {
448
+ if (this.suggestions.size <= this.suggestionCap)
449
+ return;
450
+ const all = [...this.suggestions.entries()].map(([, s]) => s);
451
+ all.sort((a, b) => a.hits - b.hits || a.lastSeenAt - b.lastSeenAt);
452
+ const excess = all.length - this.suggestionCap;
453
+ for (let i = 0; i < excess; i++) {
454
+ await this.suggestions.delete(all[i].id);
455
+ }
456
+ }
255
457
  async pin(id) {
256
458
  const existing = this.entries.get(id);
257
459
  if (existing === undefined)
@@ -268,6 +470,33 @@ export class DomainMemoryStore extends MemoryStore {
268
470
  await this.entries.put(id, updated);
269
471
  return updated;
270
472
  }
473
+ /**
474
+ * Archive one entry manually (P1-7): stamp `staleSince` (idempotent — an
475
+ * already-stale entry is returned unchanged) and record a `'ui'`-sourced
476
+ * audit update. Hidden from injection; still searchable; recall revives.
477
+ */
478
+ async archiveEntry(id) {
479
+ const existing = this.entries.get(id);
480
+ if (existing === undefined)
481
+ return undefined;
482
+ if (existing.staleSince !== undefined)
483
+ return existing;
484
+ const updated = { ...existing, staleSince: Date.now() };
485
+ await this.entries.put(id, updated);
486
+ await this.appendAudit('update', id, updated, 'ui', undefined);
487
+ return updated;
488
+ }
489
+ /** Lift a manual or janitor dormancy stamp without counting it as a recall. */
490
+ async unarchiveEntry(id) {
491
+ const existing = this.entries.get(id);
492
+ if (existing === undefined || existing.staleSince === undefined)
493
+ return existing;
494
+ const { staleSince: _cleared, ...rest } = existing;
495
+ const updated = rest;
496
+ await this.entries.put(id, updated);
497
+ await this.appendAudit('update', id, updated, 'ui', undefined);
498
+ return updated;
499
+ }
271
500
  /**
272
501
  * Run the janitor pass with the lifecycle's two-tier policy:
273
502
  * - `project` entries overdue by `decayDays` (pinned exempt) are REMOVED