@miller-tech/uap 1.175.13 → 1.178.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 (99) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/benchmarks/harness-card.d.ts +86 -0
  3. package/dist/benchmarks/harness-card.d.ts.map +1 -0
  4. package/dist/benchmarks/harness-card.js +153 -0
  5. package/dist/benchmarks/harness-card.js.map +1 -0
  6. package/dist/benchmarks/paired/report.d.ts +15 -0
  7. package/dist/benchmarks/paired/report.d.ts.map +1 -1
  8. package/dist/benchmarks/paired/report.js +12 -0
  9. package/dist/benchmarks/paired/report.js.map +1 -1
  10. package/dist/benchmarks/paired/types.d.ts +1 -1
  11. package/dist/bin/cli.js +27 -0
  12. package/dist/bin/cli.js.map +1 -1
  13. package/dist/cli/bench.d.ts.map +1 -1
  14. package/dist/cli/bench.js +64 -3
  15. package/dist/cli/bench.js.map +1 -1
  16. package/dist/cli/harness.d.ts +3 -2
  17. package/dist/cli/harness.d.ts.map +1 -1
  18. package/dist/cli/harness.js +81 -0
  19. package/dist/cli/harness.js.map +1 -1
  20. package/dist/cli/memory.d.ts +7 -1
  21. package/dist/cli/memory.d.ts.map +1 -1
  22. package/dist/cli/memory.js +165 -0
  23. package/dist/cli/memory.js.map +1 -1
  24. package/dist/cli/policy.d.ts +43 -0
  25. package/dist/cli/policy.d.ts.map +1 -1
  26. package/dist/cli/policy.js +80 -27
  27. package/dist/cli/policy.js.map +1 -1
  28. package/dist/delivery/agentic-executor.d.ts +76 -2
  29. package/dist/delivery/agentic-executor.d.ts.map +1 -1
  30. package/dist/delivery/agentic-executor.js +231 -29
  31. package/dist/delivery/agentic-executor.js.map +1 -1
  32. package/dist/delivery/edit-match.d.ts +134 -0
  33. package/dist/delivery/edit-match.d.ts.map +1 -0
  34. package/dist/delivery/edit-match.js +331 -0
  35. package/dist/delivery/edit-match.js.map +1 -0
  36. package/dist/memory/dynamic-retrieval.d.ts.map +1 -1
  37. package/dist/memory/dynamic-retrieval.js +57 -0
  38. package/dist/memory/dynamic-retrieval.js.map +1 -1
  39. package/dist/memory/reconstruct-ingest.d.ts +88 -0
  40. package/dist/memory/reconstruct-ingest.d.ts.map +1 -0
  41. package/dist/memory/reconstruct-ingest.js +165 -0
  42. package/dist/memory/reconstruct-ingest.js.map +1 -0
  43. package/dist/memory/reconstruct-store.d.ts +143 -0
  44. package/dist/memory/reconstruct-store.d.ts.map +1 -0
  45. package/dist/memory/reconstruct-store.js +312 -0
  46. package/dist/memory/reconstruct-store.js.map +1 -0
  47. package/dist/memory/reconstruct.d.ts +272 -0
  48. package/dist/memory/reconstruct.d.ts.map +1 -0
  49. package/dist/memory/reconstruct.js +552 -0
  50. package/dist/memory/reconstruct.js.map +1 -0
  51. package/dist/policies/schemas/policy.d.ts +2 -2
  52. package/dist/self-harness/evidence-proposer.d.ts +58 -0
  53. package/dist/self-harness/evidence-proposer.d.ts.map +1 -0
  54. package/dist/self-harness/evidence-proposer.js +132 -0
  55. package/dist/self-harness/evidence-proposer.js.map +1 -0
  56. package/dist/self-harness/manifest.d.ts +130 -0
  57. package/dist/self-harness/manifest.d.ts.map +1 -0
  58. package/dist/self-harness/manifest.js +247 -0
  59. package/dist/self-harness/manifest.js.map +1 -0
  60. package/dist/self-harness/mods.d.ts +57 -3
  61. package/dist/self-harness/mods.d.ts.map +1 -1
  62. package/dist/self-harness/mods.js +72 -0
  63. package/dist/self-harness/mods.js.map +1 -1
  64. package/dist/self-harness/orchestrator.d.ts +27 -0
  65. package/dist/self-harness/orchestrator.d.ts.map +1 -1
  66. package/dist/self-harness/orchestrator.js +47 -4
  67. package/dist/self-harness/orchestrator.js.map +1 -1
  68. package/dist/self-harness/pending.d.ts +17 -3
  69. package/dist/self-harness/pending.d.ts.map +1 -1
  70. package/dist/self-harness/pending.js +26 -4
  71. package/dist/self-harness/pending.js.map +1 -1
  72. package/dist/self-harness/profile.d.ts +17 -1
  73. package/dist/self-harness/profile.d.ts.map +1 -1
  74. package/dist/self-harness/profile.js +11 -4
  75. package/dist/self-harness/profile.js.map +1 -1
  76. package/dist/self-harness/run.d.ts +19 -0
  77. package/dist/self-harness/run.d.ts.map +1 -1
  78. package/dist/self-harness/run.js +43 -4
  79. package/dist/self-harness/run.js.map +1 -1
  80. package/dist/self-harness/transfer.d.ts.map +1 -1
  81. package/dist/self-harness/transfer.js +2 -0
  82. package/dist/self-harness/transfer.js.map +1 -1
  83. package/dist/self-harness/validate.d.ts +17 -6
  84. package/dist/self-harness/validate.d.ts.map +1 -1
  85. package/dist/self-harness/validate.js +73 -8
  86. package/dist/self-harness/validate.js.map +1 -1
  87. package/dist/telemetry/tool-calls.d.ts +82 -0
  88. package/dist/telemetry/tool-calls.d.ts.map +1 -0
  89. package/dist/telemetry/tool-calls.js +280 -0
  90. package/dist/telemetry/tool-calls.js.map +1 -0
  91. package/dist/telemetry/tool-failure.d.ts +71 -0
  92. package/dist/telemetry/tool-failure.d.ts.map +1 -0
  93. package/dist/telemetry/tool-failure.js +123 -0
  94. package/dist/telemetry/tool-failure.js.map +1 -0
  95. package/docs/plans/harness-engineering-uplift-2026-07-31.md +280 -0
  96. package/package.json +1 -1
  97. package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
  98. package/templates/hooks/__pycache__/deliver_autoroute.cpython-312.pyc +0 -0
  99. package/tools/agents/scripts/__pycache__/toolcall_path_normalizer.cpython-312.pyc +0 -0
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Wiring active reconstruction to UAP's real memory stores (harness plan E3).
3
+ *
4
+ * Resolves where the graph lives, fills it from the stores UAP already writes
5
+ * (short-term SQLite AND the long-term semantic store), and exposes the entry
6
+ * point callers use: `recallActive`.
7
+ *
8
+ * The graph is a DERIVED index, never a source of truth: it can be deleted and
9
+ * rebuilt at any time. (It is not side-effect free, though — opening the
10
+ * short-term store runs `ensureShortTermSchema`, which creates indexes and can
11
+ * backfill FTS. That means a build needs a writable store.)
12
+ *
13
+ * COVERAGE IS THE CORRECTNESS PROPERTY HERE. The passive path queries short-term
14
+ * FTS *and* the long-term semantic store. If active recall indexed only the
15
+ * short-term store — a rolling ~50-entry window — then routing a query here
16
+ * would silently drop every durable memory the project has, which is a
17
+ * regression wearing a feature's clothes. So ingestion covers both tiers, and
18
+ * `recallActive` reports what it covered.
19
+ */
20
+ import { MemoryGraph, type ReconstructionResult, type ReconstructionPolicy } from './reconstruct.js';
21
+ import { type IngestItem, type IngestResult } from './reconstruct-ingest.js';
22
+ /** Where the derived graph lives, alongside the stores it indexes. */
23
+ export declare function memoryGraphPath(cwd: string): string;
24
+ /**
25
+ * Resolve short-term store + project id the way `uap memory query` does.
26
+ *
27
+ * Reading these from the config rather than hardcoding defaults matters: a
28
+ * project with a configured store path, or any project not literally named
29
+ * "project", was otherwise indexing zero rows while reporting success — because
30
+ * `getRecent` filters on `project_id`.
31
+ */
32
+ export declare function resolveStoreConfig(cwd: string, opts?: BuildOptions): {
33
+ shortTermPath: string;
34
+ projectId: string;
35
+ };
36
+ export declare function openMemoryGraph(cwd: string): MemoryGraph;
37
+ export declare function memoryGraphExists(cwd: string): boolean;
38
+ export interface BuildOptions {
39
+ /** Max short-term entries to pull. Default 2000. */
40
+ limit?: number;
41
+ /** Project id for the short-term store. */
42
+ projectId?: string;
43
+ /** Explicit short-term DB path (else the standard location). */
44
+ shortTermPath?: string;
45
+ /** Extra items from a caller (e.g. a long-term export). */
46
+ extra?: IngestItem[];
47
+ /** Rebuild from scratch (truncates the graph) instead of incrementally. */
48
+ rebuild?: boolean;
49
+ /** Skip the long-term tier (tests, or an intentionally short-term-only index). */
50
+ includeLongTerm?: boolean;
51
+ }
52
+ export interface BuildReport extends IngestResult {
53
+ /** Items offered to the graph (before dedupe). */
54
+ considered: number;
55
+ graphPath: string;
56
+ /**
57
+ * Which memory tiers the graph actually covers. Reported because recall over a
58
+ * partial corpus is worse than no recall if the caller believes it is
59
+ * complete.
60
+ */
61
+ coverage: {
62
+ shortTerm: number;
63
+ longTerm: number;
64
+ };
65
+ /** True when another process held the build lock and this call did nothing. */
66
+ skippedConcurrentBuild?: boolean;
67
+ }
68
+ /**
69
+ * Read UAP's short-term store into `IngestItem`s.
70
+ *
71
+ * Isolated and best-effort: a missing or unreadable store yields an empty list
72
+ * rather than failing the build, because the graph is derived and a partial
73
+ * index is more useful than none.
74
+ */
75
+ export declare function itemsFromShortTerm(cwd: string, opts?: BuildOptions): Promise<IngestItem[]>;
76
+ /**
77
+ * Read the LONG-TERM semantic store into ingest items.
78
+ *
79
+ * This tier holds everything durable — `memory store`, `sync-files`,
80
+ * `prepopulate`. Omitting it would make active recall a strict downgrade from
81
+ * the passive path it replaces. Best-effort: an unreachable Qdrant yields [] and
82
+ * the caller reports reduced coverage rather than failing.
83
+ */
84
+ export declare function itemsFromLongTerm(cwd: string, limit?: number): Promise<IngestItem[]>;
85
+ /**
86
+ * Build or refresh the graph from the stores.
87
+ *
88
+ * Incremental by default: source keys already ingested are skipped, so this is
89
+ * cheap to re-run and safe to call before a query.
90
+ */
91
+ export declare function buildMemoryGraph(cwd: string, opts?: BuildOptions): Promise<BuildReport>;
92
+ export interface RecallOptions {
93
+ policy?: ReconstructionPolicy;
94
+ maxSteps?: number;
95
+ /** Ceiling on admitted context. */
96
+ maxContext?: number;
97
+ /**
98
+ * Build/refresh the graph before querying.
99
+ *
100
+ * true — always (the CLI default: an operator asking a question wants
101
+ * the freshest answer and accepts the wait)
102
+ * false — never
103
+ * 'if-stale' — only when the last ingest is older than `staleAfterSeconds`
104
+ *
105
+ * `'if-stale'` exists for the AGENT path. Refreshing on every retrieval would
106
+ * put a full store scan on the hot path of every model turn; never refreshing
107
+ * would serve an index that silently ages out. The TTL is the compromise.
108
+ */
109
+ refresh?: boolean | 'if-stale';
110
+ /** Staleness window for `refresh: 'if-stale'`. Default 900s (15 min). */
111
+ staleAfterSeconds?: number;
112
+ buildOptions?: BuildOptions;
113
+ }
114
+ export interface RecallResult extends ReconstructionResult {
115
+ /** True when there is nothing to traverse — distinct from "nothing matched". */
116
+ graphEmpty: boolean;
117
+ build?: BuildReport;
118
+ }
119
+ /**
120
+ * Recall by ACTIVE RECONSTRUCTION: traverse the graph while reasoning, pruning
121
+ * weak paths before they cost context, instead of one passive top-k pull.
122
+ *
123
+ * This is the caller area E was missing. It is invoked by `uap memory query
124
+ * --active` and by anything that opts in; passive retrieval remains the default
125
+ * until the paired bench measures the lift on our own suite.
126
+ */
127
+ export declare function recallActive(cwd: string, query: string, opts?: RecallOptions): Promise<RecallResult>;
128
+ /**
129
+ * Should a caller use active reconstruction?
130
+ *
131
+ * Both conditions must hold: the operator opted in AND the graph actually has
132
+ * content. Routing to an empty graph would silently return nothing where
133
+ * passive retrieval would have answered — a regression dressed as a feature.
134
+ */
135
+ export declare function shouldUseActiveRecall(cwd: string, graph?: MemoryGraph): boolean;
136
+ /**
137
+ * The retrieval mode actually in force, for the harness disclosure card.
138
+ *
139
+ * One implementation so the bench card and `uap harness card` cannot disagree —
140
+ * two call sites computing this independently is how a card starts lying.
141
+ */
142
+ export declare function describeMemoryMode(cwd: string): string;
143
+ //# sourceMappingURL=reconstruct-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconstruct-store.d.ts","sourceRoot":"","sources":["../../src/memory/reconstruct-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EACL,WAAW,EAIX,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAwB,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEnG,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,YAAiB,GACtB;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,SAAS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QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,YAAa,SAAQ,oBAAoB;IACxD,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,YAAY,CAAC,CAyBvB;AAuBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CAqB/E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMtD"}
@@ -0,0 +1,312 @@
1
+ /**
2
+ * Wiring active reconstruction to UAP's real memory stores (harness plan E3).
3
+ *
4
+ * Resolves where the graph lives, fills it from the stores UAP already writes
5
+ * (short-term SQLite AND the long-term semantic store), and exposes the entry
6
+ * point callers use: `recallActive`.
7
+ *
8
+ * The graph is a DERIVED index, never a source of truth: it can be deleted and
9
+ * rebuilt at any time. (It is not side-effect free, though — opening the
10
+ * short-term store runs `ensureShortTermSchema`, which creates indexes and can
11
+ * backfill FTS. That means a build needs a writable store.)
12
+ *
13
+ * COVERAGE IS THE CORRECTNESS PROPERTY HERE. The passive path queries short-term
14
+ * FTS *and* the long-term semantic store. If active recall indexed only the
15
+ * short-term store — a rolling ~50-entry window — then routing a query here
16
+ * would silently drop every durable memory the project has, which is a
17
+ * regression wearing a feature's clothes. So ingestion covers both tiers, and
18
+ * `recallActive` reports what it covered.
19
+ */
20
+ import { existsSync } from 'node:fs';
21
+ import { join } from 'node:path';
22
+ import { loadUapConfig } from '../utils/config-loader.js';
23
+ import { MemoryGraph, reconstruct, heuristicPolicy, activeReconstructionEnabled, } from './reconstruct.js';
24
+ import { ingestItems, itemKey } from './reconstruct-ingest.js';
25
+ /** Where the derived graph lives, alongside the stores it indexes. */
26
+ export function memoryGraphPath(cwd) {
27
+ return join(cwd, 'agents', 'data', 'memory', 'memory-graph.db');
28
+ }
29
+ /**
30
+ * Resolve short-term store + project id the way `uap memory query` does.
31
+ *
32
+ * Reading these from the config rather than hardcoding defaults matters: a
33
+ * project with a configured store path, or any project not literally named
34
+ * "project", was otherwise indexing zero rows while reporting success — because
35
+ * `getRecent` filters on `project_id`.
36
+ */
37
+ export function resolveStoreConfig(cwd, opts = {}) {
38
+ const config = loadUapConfig(cwd);
39
+ return {
40
+ shortTermPath: opts.shortTermPath ||
41
+ config?.memory?.shortTerm?.path ||
42
+ join(cwd, 'agents', 'data', 'memory', 'short_term.db'),
43
+ projectId: opts.projectId ?? config?.project?.name ?? 'project',
44
+ };
45
+ }
46
+ export function openMemoryGraph(cwd) {
47
+ return new MemoryGraph(memoryGraphPath(cwd));
48
+ }
49
+ export function memoryGraphExists(cwd) {
50
+ return existsSync(memoryGraphPath(cwd));
51
+ }
52
+ /**
53
+ * Read UAP's short-term store into `IngestItem`s.
54
+ *
55
+ * Isolated and best-effort: a missing or unreadable store yields an empty list
56
+ * rather than failing the build, because the graph is derived and a partial
57
+ * index is more useful than none.
58
+ */
59
+ export async function itemsFromShortTerm(cwd, opts = {}) {
60
+ const { shortTermPath: dbPath, projectId } = resolveStoreConfig(cwd, opts);
61
+ if (!existsSync(dbPath))
62
+ return [];
63
+ const { SQLiteShortTermMemory } = await import('./short-term/sqlite.js');
64
+ let store = null;
65
+ try {
66
+ store = new SQLiteShortTermMemory({
67
+ dbPath,
68
+ projectId,
69
+ maxEntries: opts.limit ?? 2000,
70
+ });
71
+ const rows = (await store.getRecent(opts.limit ?? 2000)) ?? [];
72
+ return rows.map((r) => ({
73
+ id: `st:${r.id ?? itemKey({ text: r.content })}`,
74
+ text: r.content,
75
+ type: r.type,
76
+ occurredAt: r.timestamp,
77
+ }));
78
+ }
79
+ catch {
80
+ return [];
81
+ }
82
+ finally {
83
+ // A throw in getRecent used to skip close(), leaking the handle (plus WAL and
84
+ // SHM refs) once per query, since recall refreshes on every call.
85
+ try {
86
+ await store?.close();
87
+ }
88
+ catch {
89
+ /* ignore */
90
+ }
91
+ }
92
+ }
93
+ /**
94
+ * Read the LONG-TERM semantic store into ingest items.
95
+ *
96
+ * This tier holds everything durable — `memory store`, `sync-files`,
97
+ * `prepopulate`. Omitting it would make active recall a strict downgrade from
98
+ * the passive path it replaces. Best-effort: an unreachable Qdrant yields [] and
99
+ * the caller reports reduced coverage rather than failing.
100
+ */
101
+ export async function itemsFromLongTerm(cwd, limit = 2000) {
102
+ try {
103
+ const config = loadUapConfig(cwd);
104
+ const endpoint = config?.memory?.longTerm?.endpoint || 'localhost:6333';
105
+ const url = /^https?:\/\//.test(endpoint) ? endpoint : `http://${endpoint}`;
106
+ const collection = config?.memory?.longTerm?.collection || 'agent_memory';
107
+ const apiKey = config?.memory?.longTerm?.qdrantCloud?.apiKey || process.env.QDRANT_API_KEY;
108
+ const { getQdrantClientClass } = await import('../utils/lazy-imports.js');
109
+ const QdrantClientClass = await getQdrantClientClass();
110
+ // The client defaults to a 300_000ms timeout. On the AGENT path this call
111
+ // is awaited during context assembly, so a black-holed endpoint (firewall
112
+ // drop, not a fast ECONNREFUSED) would block a model turn for five minutes.
113
+ const timeout = Number(process.env.UAP_MEMORY_QDRANT_TIMEOUT_MS) || 3000;
114
+ const client = new QdrantClientClass({ url, apiKey, checkCompatibility: false, timeout });
115
+ const collections = await client.getCollections();
116
+ const names = [collection, `${collection}_prepopulated`].filter((c) => collections.collections.some((col) => col.name === c));
117
+ const items = [];
118
+ for (const name of names) {
119
+ // Scroll the payloads only — the graph indexes text, not vectors.
120
+ let offset = undefined;
121
+ while (items.length < limit) {
122
+ const page = await client.scroll(name, {
123
+ limit: Math.min(256, limit - items.length),
124
+ with_payload: true,
125
+ with_vector: false,
126
+ offset,
127
+ });
128
+ for (const point of page.points ?? []) {
129
+ const payload = (point.payload ?? {});
130
+ const text = String(payload.content ?? '');
131
+ if (!text)
132
+ continue;
133
+ items.push({
134
+ id: `lt:${name}:${String(point.id)}`,
135
+ text,
136
+ type: String(payload.type ?? 'knowledge'),
137
+ tags: Array.isArray(payload.tags) ? payload.tags : undefined,
138
+ occurredAt: typeof payload.timestamp === 'string' ? payload.timestamp : undefined,
139
+ });
140
+ }
141
+ offset = page.next_page_offset;
142
+ if (!offset)
143
+ break;
144
+ }
145
+ }
146
+ return items;
147
+ }
148
+ catch {
149
+ return [];
150
+ }
151
+ }
152
+ /**
153
+ * Build or refresh the graph from the stores.
154
+ *
155
+ * Incremental by default: source keys already ingested are skipped, so this is
156
+ * cheap to re-run and safe to call before a query.
157
+ */
158
+ export async function buildMemoryGraph(cwd, opts = {}) {
159
+ const graph = openMemoryGraph(cwd);
160
+ try {
161
+ if (!graph.acquireBuildLock(Date.now())) {
162
+ // Another process is building. Duplicating that work would insert every
163
+ // item a second time under fresh ids — permanent, since the ledger then
164
+ // reports them indexed.
165
+ return {
166
+ ingested: 0, skipped: 0, storedKeys: [], cues: 0, tags: 0, bridgingTags: 0,
167
+ considered: 0, graphPath: memoryGraphPath(cwd),
168
+ coverage: { shortTerm: 0, longTerm: 0 },
169
+ skippedConcurrentBuild: true,
170
+ };
171
+ }
172
+ const shortTerm = await itemsFromShortTerm(cwd, opts);
173
+ const longTerm = opts.includeLongTerm === false ? [] : await itemsFromLongTerm(cwd, opts.limit);
174
+ const items = [...shortTerm, ...longTerm, ...(opts.extra ?? [])];
175
+ if (opts.rebuild) {
176
+ // A real rebuild TRUNCATES. Clearing only the in-memory dedupe set left
177
+ // every row in place and re-inserted the whole corpus under fresh ids, so
178
+ // two rebuilds meant every memory twice — permanently, since the ledger
179
+ // then reported them as already indexed.
180
+ graph.clear();
181
+ }
182
+ const seen = opts.rebuild ? new Set() : graph.ingestedKeys();
183
+ const result = ingestItems(graph, items, { seen });
184
+ // Mark ONLY what was stored — see IngestResult.storedKeys.
185
+ graph.markIngested(result.storedKeys);
186
+ // Heartbeat REGARDLESS of whether anything was stored. Deriving staleness
187
+ // from stored keys means a refresh that finds nothing new never advances the
188
+ // clock, so the TTL never clears and the index rebuilds every retrieval.
189
+ graph.markRefreshed(new Date().toISOString());
190
+ return {
191
+ ...result,
192
+ considered: items.length,
193
+ graphPath: memoryGraphPath(cwd),
194
+ coverage: { shortTerm: shortTerm.length, longTerm: longTerm.length },
195
+ };
196
+ }
197
+ finally {
198
+ graph.releaseBuildLock();
199
+ graph.close();
200
+ }
201
+ }
202
+ /**
203
+ * Recall by ACTIVE RECONSTRUCTION: traverse the graph while reasoning, pruning
204
+ * weak paths before they cost context, instead of one passive top-k pull.
205
+ *
206
+ * This is the caller area E was missing. It is invoked by `uap memory query
207
+ * --active` and by anything that opts in; passive retrieval remains the default
208
+ * until the paired bench measures the lift on our own suite.
209
+ */
210
+ export async function recallActive(cwd, query, opts = {}) {
211
+ const build = (await shouldRefresh(cwd, opts))
212
+ ? await buildMemoryGraph(cwd, opts.buildOptions)
213
+ : undefined;
214
+ const graph = openMemoryGraph(cwd);
215
+ try {
216
+ if (graph.isEmpty()) {
217
+ return {
218
+ context: [],
219
+ steps: [],
220
+ converged: false,
221
+ stopReason: 'exhausted',
222
+ graphEmpty: true,
223
+ build,
224
+ };
225
+ }
226
+ const result = reconstruct(graph, query, {
227
+ policy: opts.policy ?? heuristicPolicy(),
228
+ maxSteps: opts.maxSteps,
229
+ maxContext: opts.maxContext,
230
+ });
231
+ return { ...result, graphEmpty: false, build };
232
+ }
233
+ finally {
234
+ graph.close();
235
+ }
236
+ }
237
+ /** Decide whether this recall should rebuild the index first. */
238
+ async function shouldRefresh(cwd, opts) {
239
+ if (opts.refresh === false)
240
+ return false;
241
+ if (opts.refresh !== 'if-stale')
242
+ return true;
243
+ if (!memoryGraphExists(cwd))
244
+ return true;
245
+ const graph = openMemoryGraph(cwd);
246
+ try {
247
+ const last = graph.lastRefreshedAt() ?? graph.lastIngestedAt();
248
+ if (!last)
249
+ return true;
250
+ // SQLite datetime('now') is UTC without a zone marker; parse it as such.
251
+ const lastMs = Date.parse(last.endsWith('Z') ? last : `${last.replace(' ', 'T')}Z`);
252
+ if (!Number.isFinite(lastMs))
253
+ return true;
254
+ const ttlMs = (opts.staleAfterSeconds ?? 900) * 1000;
255
+ return Date.now() - lastMs > ttlMs;
256
+ }
257
+ catch {
258
+ return false;
259
+ }
260
+ finally {
261
+ graph.close();
262
+ }
263
+ }
264
+ /**
265
+ * Should a caller use active reconstruction?
266
+ *
267
+ * Both conditions must hold: the operator opted in AND the graph actually has
268
+ * content. Routing to an empty graph would silently return nothing where
269
+ * passive retrieval would have answered — a regression dressed as a feature.
270
+ */
271
+ export function shouldUseActiveRecall(cwd, graph) {
272
+ if (!activeReconstructionEnabled())
273
+ return false;
274
+ if (!memoryGraphExists(cwd))
275
+ return false;
276
+ if (graph) {
277
+ try {
278
+ return !graph.isEmpty();
279
+ }
280
+ catch {
281
+ return false;
282
+ }
283
+ }
284
+ const owned = openMemoryGraph(cwd);
285
+ const graphRef = owned;
286
+ try {
287
+ // Cheap probe, not stats(): this runs on EVERY `uap memory query` and every
288
+ // harness-card render, and stats() is five aggregates over the triples table.
289
+ return !graphRef.isEmpty();
290
+ }
291
+ catch {
292
+ return false;
293
+ }
294
+ finally {
295
+ owned.close();
296
+ }
297
+ }
298
+ /**
299
+ * The retrieval mode actually in force, for the harness disclosure card.
300
+ *
301
+ * One implementation so the bench card and `uap harness card` cannot disagree —
302
+ * two call sites computing this independently is how a card starts lying.
303
+ */
304
+ export function describeMemoryMode(cwd) {
305
+ try {
306
+ return shouldUseActiveRecall(cwd) ? 'active reconstruction' : 'semantic retrieval';
307
+ }
308
+ catch {
309
+ return 'semantic retrieval';
310
+ }
311
+ }
312
+ //# sourceMappingURL=reconstruct-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconstruct-store.js","sourceRoot":"","sources":["../../src/memory/reconstruct-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,WAAW,EACX,WAAW,EACX,eAAe,EACf,2BAA2B,GAG5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAsC,MAAM,yBAAyB,CAAC;AAEnG,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAW,EACX,OAAqB,EAAE;IAEvB,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO;QACL,aAAa,EACX,IAAI,CAAC,aAAa;YAClB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI;YAC/B,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC;QACxD,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,MAAM,EAAE,OAAO,EAAE,IAAI,IAAI,SAAS;KAChE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,IAAI,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,iBAAiB,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