renor-engine 1.2.0 → 1.4.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 (216) hide show
  1. package/README.md +34 -2
  2. package/THIRD-PARTY-NOTICES +2661 -0
  3. package/bin/renor-engine.cjs +38 -0
  4. package/dist/BUILD.json +6 -0
  5. package/dist/cli.js +1674 -516
  6. package/package.json +17 -80
  7. package/dist/.tsbuildinfo +0 -1
  8. package/dist/api/apiAuth.js +0 -43
  9. package/dist/api/server.js +0 -174
  10. package/dist/buildIdentity.js +0 -149
  11. package/dist/callPhases.js +0 -82
  12. package/dist/cli-extractors.js +0 -46
  13. package/dist/config.js +0 -65
  14. package/dist/context/composer.js +0 -320
  15. package/dist/context/readHonesty.js +0 -478
  16. package/dist/context/rowStore.js +0 -238
  17. package/dist/conversation/formatter.js +0 -81
  18. package/dist/conversation/parser.js +0 -193
  19. package/dist/conversation/types.js +0 -2
  20. package/dist/conversation/writer.js +0 -42
  21. package/dist/db/client.js +0 -149
  22. package/dist/db/handoffTable.js +0 -31
  23. package/dist/db/indexSalvage.js +0 -101
  24. package/dist/db/migrations.js +0 -670
  25. package/dist/db/readCache.js +0 -109
  26. package/dist/db/schema.js +0 -5
  27. package/dist/db/sqlite.js +0 -396
  28. package/dist/db/statements.js +0 -89
  29. package/dist/digests/digestCache.js +0 -146
  30. package/dist/digests/digests.js +0 -597
  31. package/dist/digests/worker.js +0 -350
  32. package/dist/embeddings/caching.js +0 -337
  33. package/dist/embeddings/coalescing.js +0 -177
  34. package/dist/embeddings/interactive.js +0 -103
  35. package/dist/embeddings/local.js +0 -70
  36. package/dist/embeddings/openai.js +0 -106
  37. package/dist/embeddings/rebuild.js +0 -166
  38. package/dist/embeddings/simdScan.js +0 -260
  39. package/dist/embeddings/space.js +0 -21
  40. package/dist/embeddings/types.js +0 -14
  41. package/dist/embeddings/vectorIndex.js +0 -674
  42. package/dist/embeddings/vertex.js +0 -334
  43. package/dist/eval/artifacts.js +0 -42
  44. package/dist/eval/cacheReport.js +0 -146
  45. package/dist/eval/comparison.js +0 -182
  46. package/dist/eval/context700-candidate.js +0 -145
  47. package/dist/eval/evalCache.js +0 -568
  48. package/dist/eval/hashEmbedding.js +0 -35
  49. package/dist/eval/indexSnapshots.js +0 -549
  50. package/dist/eval/longmemeval.js +0 -56
  51. package/dist/eval/metrics.js +0 -181
  52. package/dist/eval/pageDump.js +0 -67
  53. package/dist/eval/renorbenchBaseline.js +0 -486
  54. package/dist/eval/renorbenchDocuments.js +0 -134
  55. package/dist/eval/renorbenchProduct.js +0 -182
  56. package/dist/eval/runLedger.js +0 -279
  57. package/dist/eval/runManifest.js +0 -485
  58. package/dist/eval/scoring.js +0 -197
  59. package/dist/eval/textTokens.js +0 -17
  60. package/dist/evidence/attach.js +0 -264
  61. package/dist/evidence/background.js +0 -147
  62. package/dist/evidence/evidenceCache.js +0 -182
  63. package/dist/evidence/gate.js +0 -37
  64. package/dist/evidence/keyPool.js +0 -85
  65. package/dist/evidence/ollamaChat.js +0 -84
  66. package/dist/evidence/optin.js +0 -165
  67. package/dist/evidence/options.js +0 -151
  68. package/dist/evidence/secondPass.js +0 -294
  69. package/dist/extraction/classifyCapture.js +0 -34
  70. package/dist/extraction/decision-model.js +0 -174
  71. package/dist/extraction/eventExtractor.js +0 -113
  72. package/dist/extraction/extractionClient.js +0 -122
  73. package/dist/extraction/factExtractor.js +0 -46
  74. package/dist/extraction/factsWritePath.js +0 -179
  75. package/dist/extraction/jevDecisionModel.js +0 -307
  76. package/dist/extraction/preferenceExtractor.js +0 -150
  77. package/dist/extraction/secretGuard.js +0 -180
  78. package/dist/extraction/secretScanner.js +0 -665
  79. package/dist/extraction/typedFacts.js +0 -224
  80. package/dist/extraction/writePathAdjudication.js +0 -110
  81. package/dist/importing/apply.js +0 -672
  82. package/dist/importing/bundle-write.js +0 -80
  83. package/dist/importing/cli.js +0 -408
  84. package/dist/importing/existing.js +0 -51
  85. package/dist/importing/facts.js +0 -121
  86. package/dist/importing/forgetImported.js +0 -79
  87. package/dist/importing/hosted.js +0 -467
  88. package/dist/importing/journalLog.js +0 -96
  89. package/dist/importing/markdown.js +0 -98
  90. package/dist/importing/plan.js +0 -201
  91. package/dist/importing/secretScreen.js +0 -113
  92. package/dist/importing/serialize.js +0 -188
  93. package/dist/importing/source.js +0 -463
  94. package/dist/importing/types.js +0 -6
  95. package/dist/indexer/chunker.js +0 -319
  96. package/dist/indexer/dailyEntries.js +0 -63
  97. package/dist/indexer/hasher.js +0 -10
  98. package/dist/indexer/laneRuns.js +0 -48
  99. package/dist/indexer/o200k.js +0 -481
  100. package/dist/indexer/outsideRoot.js +0 -77
  101. package/dist/indexer/parser.js +0 -170
  102. package/dist/indexer/pipeline.js +0 -988
  103. package/dist/indexer/staleness.js +0 -201
  104. package/dist/indexer/tokenizer.js +0 -77
  105. package/dist/indexer/walker.js +0 -170
  106. package/dist/learning/cli.js +0 -113
  107. package/dist/learning/schema.js +0 -144
  108. package/dist/learning/settings.js +0 -45
  109. package/dist/learning/store.js +0 -267
  110. package/dist/learning/tap.js +0 -401
  111. package/dist/mcp/hive.js +0 -88
  112. package/dist/mcp/requestErrors.js +0 -47
  113. package/dist/mcp/server.js +0 -426
  114. package/dist/memory/agentLease.js +0 -43
  115. package/dist/memory/confinedWrite.js +0 -315
  116. package/dist/memory/controls.js +0 -73
  117. package/dist/memory/dailyNote.js +0 -265
  118. package/dist/memory/dreamer/adjudicate.js +0 -215
  119. package/dist/memory/dreamer/apply.js +0 -120
  120. package/dist/memory/dreamer/budget.js +0 -64
  121. package/dist/memory/dreamer/candidates.js +0 -149
  122. package/dist/memory/dreamer/collection.js +0 -104
  123. package/dist/memory/dreamer/dreamer.js +0 -352
  124. package/dist/memory/dreamer/review.js +0 -111
  125. package/dist/memory/durableAppend.js +0 -57
  126. package/dist/memory/factConflicts.js +0 -205
  127. package/dist/memory/factTerms.js +0 -321
  128. package/dist/memory/handoff.js +0 -363
  129. package/dist/memory/hiveNameHeader.cjs +0 -10
  130. package/dist/memory/inventory.js +0 -55
  131. package/dist/memory/invisibleText.js +0 -20
  132. package/dist/memory/lifecycle.js +0 -2014
  133. package/dist/memory/limits.js +0 -13
  134. package/dist/memory/requests.js +0 -183
  135. package/dist/memory/sourceName.js +0 -276
  136. package/dist/memory/statusFacts.js +0 -61
  137. package/dist/memory/whatsNew.js +0 -158
  138. package/dist/memory/writer.js +0 -176
  139. package/dist/memory/writerConflicts.js +0 -85
  140. package/dist/memorymap/memoryMap.js +0 -1594
  141. package/dist/memorymap/replacedJournal.js +0 -58
  142. package/dist/memorymap/replacements.js +0 -410
  143. package/dist/mvp/activity.js +0 -86
  144. package/dist/mvp/agentMemory.js +0 -1803
  145. package/dist/mvp/answerCheck.js +0 -211
  146. package/dist/mvp/auth.js +0 -531
  147. package/dist/mvp/cli.js +0 -86
  148. package/dist/mvp/client-store.js +0 -462
  149. package/dist/mvp/compileCache.js +0 -242
  150. package/dist/mvp/compileSeed.js +0 -33
  151. package/dist/mvp/config.js +0 -292
  152. package/dist/mvp/connectionStatus.js +0 -80
  153. package/dist/mvp/contextDistinct.js +0 -53
  154. package/dist/mvp/contextProfile.js +0 -87
  155. package/dist/mvp/contextRelevance.js +0 -413
  156. package/dist/mvp/directorySurface.js +0 -68
  157. package/dist/mvp/engine.js +0 -1078
  158. package/dist/mvp/exportAll.js +0 -393
  159. package/dist/mvp/factLanePack.js +0 -77
  160. package/dist/mvp/factMarkers.js +0 -65
  161. package/dist/mvp/factsLane.js +0 -203
  162. package/dist/mvp/hiddenSpans.js +0 -585
  163. package/dist/mvp/history.js +0 -414
  164. package/dist/mvp/hitDates.js +0 -31
  165. package/dist/mvp/hitFloor.js +0 -36
  166. package/dist/mvp/identity.js +0 -18
  167. package/dist/mvp/idle.js +0 -113
  168. package/dist/mvp/log.js +0 -118
  169. package/dist/mvp/memoryDir.js +0 -98
  170. package/dist/mvp/posthogMcp.js +0 -210
  171. package/dist/mvp/readScope.js +0 -104
  172. package/dist/mvp/readUsefulness.js +0 -222
  173. package/dist/mvp/sanitize.js +0 -48
  174. package/dist/mvp/schemaRejections.js +0 -91
  175. package/dist/mvp/scope.js +0 -127
  176. package/dist/mvp/server.js +0 -2712
  177. package/dist/mvp/serverCard.js +0 -38
  178. package/dist/mvp/storedSize.js +0 -139
  179. package/dist/mvp/telemetry.js +0 -474
  180. package/dist/net/poolFetch.js +0 -174
  181. package/dist/recall/actionRecall.js +0 -282
  182. package/dist/recall/autoRecall.js +0 -447
  183. package/dist/recall/searchRecall.js +0 -189
  184. package/dist/retrieval/adviceLines.js +0 -195
  185. package/dist/retrieval/adviceQuestion.js +0 -44
  186. package/dist/retrieval/conversationShape.js +0 -44
  187. package/dist/retrieval/dailyEntryTime.js +0 -55
  188. package/dist/retrieval/entityLookup.js +0 -162
  189. package/dist/retrieval/factsFirst.js +0 -188
  190. package/dist/retrieval/keyword.js +0 -84
  191. package/dist/retrieval/ledgerEventTime.js +0 -51
  192. package/dist/retrieval/ledgerLiveness.js +0 -83
  193. package/dist/retrieval/ledgerPresentation.js +0 -161
  194. package/dist/retrieval/noteIdentity.js +0 -57
  195. package/dist/retrieval/orchestrator.js +0 -1224
  196. package/dist/retrieval/plainWording.js +0 -236
  197. package/dist/retrieval/queryHelpers.js +0 -142
  198. package/dist/retrieval/questionSpan.js +0 -475
  199. package/dist/retrieval/rankingTrace.js +0 -184
  200. package/dist/retrieval/readerEvents.js +0 -690
  201. package/dist/retrieval/readerLayout.js +0 -422
  202. package/dist/retrieval/relativeTimeHints.js +0 -113
  203. package/dist/retrieval/semantic.js +0 -67
  204. package/dist/router/routerCache.js +0 -106
  205. package/dist/router/sessionRouter.js +0 -726
  206. package/dist/sharing/cli.js +0 -181
  207. package/dist/sharing/examples.js +0 -136
  208. package/dist/sharing/fields.js +0 -225
  209. package/dist/sharing/loop.js +0 -80
  210. package/dist/sharing/project.js +0 -327
  211. package/dist/sharing/send.js +0 -466
  212. package/dist/sharing/state.js +0 -222
  213. package/dist/sharing/wording.js +0 -48
  214. package/dist/toolRefusal.js +0 -120
  215. package/dist/watcher/watcher.js +0 -77
  216. /package/dist/{indexer/o200k.json → o200k.json} +0 -0
@@ -1,181 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.roleOf = roleOf;
4
- exports.hitMatchesTarget = hitMatchesTarget;
5
- exports.matchedTargetIndexes = matchedTargetIndexes;
6
- exports.hitAtK = hitAtK;
7
- exports.recallAtK = recallAtK;
8
- exports.recallAllAtK = recallAllAtK;
9
- exports.forbiddenRetrieved = forbiddenRetrieved;
10
- exports.reciprocalRank = reciprocalRank;
11
- exports.ndcgAtK = ndcgAtK;
12
- exports.contradictionFirst = contradictionFirst;
13
- /**
14
- * Role resolution for a gold target.
15
- *
16
- * Explicit `role` always wins. Otherwise RenorBench v0 semantics apply:
17
- * - relevance >= 2 -> positive (creditable for Hit/Recall/MRR and nDCG)
18
- * - relevance === 1 -> forbidden (superseded/contradictory value that is NOT
19
- * the answer to the query; never creditable, and surfacing it first is an
20
- * error tracked by contradictionFirst)
21
- * - relevance absent -> positive (the target is the only/primary gold)
22
- *
23
- * Use explicit `role: 'supporting'` when a low-grade target is genuinely
24
- * acceptable evidence (nDCG-graded but never counted by binary metrics).
25
- */
26
- function roleOf(target) {
27
- if (target.role)
28
- return target.role;
29
- if (target.relevance === undefined)
30
- return 'positive';
31
- return target.relevance >= 2 ? 'positive' : 'forbidden';
32
- }
33
- function normalized(value) {
34
- return (value ?? '').trim().toLowerCase();
35
- }
36
- /**
37
- * Matching semantics:
38
- *
39
- * - Path-pinned targets (notePath set) require the hit to come from exactly
40
- * that note, and credit a needle occurring in the hit text or in the pinned
41
- * path itself (session-id style metadata matching, used by LongMemEval).
42
- * - Text-scoped targets (no notePath) match against the retrieved text ONLY.
43
- * A needle appearing merely in a filename never earns textual relevance
44
- * credit, and unrelated notes can never satisfy the target.
45
- */
46
- function hitMatchesTarget(hit, target) {
47
- const needle = normalized(target.match);
48
- if (!needle)
49
- return false;
50
- if (target.notePath !== undefined) {
51
- if (normalized(hit.notePath) !== normalized(target.notePath))
52
- return false;
53
- return normalized(hit.text).includes(needle) || normalized(target.notePath).includes(needle);
54
- }
55
- return normalized(hit.text).includes(needle);
56
- }
57
- function creditableTargets(targets) {
58
- return targets.filter(target => roleOf(target) === 'positive');
59
- }
60
- function matchedTargetIndexes(hits, targets, k) {
61
- const matched = new Set();
62
- for (const hit of hits.slice(0, k)) {
63
- targets.forEach((target, index) => {
64
- if (hitMatchesTarget(hit, target))
65
- matched.add(index);
66
- });
67
- }
68
- return matched;
69
- }
70
- /**
71
- * Binary Hit@K: credit only positive evidence. Stale/forbidden or merely
72
- * supporting gold targets can never produce a Hit.
73
- */
74
- function hitAtK(hits, targets, k) {
75
- const positive = creditableTargets(targets);
76
- if (positive.length === 0)
77
- return 0;
78
- return matchedTargetIndexes(hits, positive, k).size > 0 ? 1 : 0;
79
- }
80
- /**
81
- * Recall@K over positive evidence only.
82
- */
83
- function recallAtK(hits, targets, k) {
84
- const positive = creditableTargets(targets);
85
- if (positive.length === 0)
86
- return 0;
87
- return matchedTargetIndexes(hits, positive, k).size / positive.length;
88
- }
89
- /**
90
- * All-required-evidence retrieval (multi-hop): 1 only when every required
91
- * target is matched within top-K. Single-target lists reduce to Hit@K.
92
- */
93
- function recallAllAtK(hits, targets, k) {
94
- const positive = creditableTargets(targets);
95
- if (positive.length === 0)
96
- return 0;
97
- return matchedTargetIndexes(hits, positive, k).size === positive.length ? 1 : 0;
98
- }
99
- /**
100
- * True when any forbidden-evidence target is retrieved within top-K.
101
- * Used for deletion/erasure cases: retrieving deleted or must-not-surface
102
- * content is a violation regardless of ordering.
103
- */
104
- function forbiddenRetrieved(hits, targets, k) {
105
- const forbidden = targets.filter(target => roleOf(target) === 'forbidden');
106
- if (forbidden.length === 0)
107
- return false;
108
- return matchedTargetIndexes(hits, forbidden, k).size > 0;
109
- }
110
- /**
111
- * Reciprocal rank of the first positive-evidence hit.
112
- */
113
- function reciprocalRank(hits, targets) {
114
- const positive = creditableTargets(targets);
115
- if (positive.length === 0)
116
- return 0;
117
- const rank = hits.findIndex(hit => positive.some(target => hitMatchesTarget(hit, target)));
118
- return rank === -1 ? 0 : 1 / (rank + 1);
119
- }
120
- function dcg(relevances) {
121
- return relevances.reduce((sum, relevance, index) => {
122
- if (relevance <= 0)
123
- return sum;
124
- return sum + (Math.pow(2, relevance) - 1) / Math.log2(index + 2);
125
- }, 0);
126
- }
127
- /**
128
- * Graded nDCG where each gold target can receive credit at most once.
129
- * This prevents duplicated retrieval rows from inflating the score.
130
- * Forbidden targets are excluded entirely; supporting targets keep their grade.
131
- */
132
- function ndcgAtK(hits, targets, k) {
133
- const graded = targets
134
- .map((target, index) => ({ target, index }))
135
- .filter(({ target }) => roleOf(target) !== 'forbidden');
136
- if (graded.length === 0)
137
- return 0;
138
- const credited = new Set();
139
- const observed = [];
140
- for (const hit of hits.slice(0, k)) {
141
- let bestIndex = -1;
142
- let bestRelevance = 0;
143
- graded.forEach(({ target, index }) => {
144
- if (credited.has(index) || !hitMatchesTarget(hit, target))
145
- return;
146
- const relevance = target.relevance ?? 1;
147
- if (relevance > bestRelevance) {
148
- bestRelevance = relevance;
149
- bestIndex = index;
150
- }
151
- });
152
- if (bestIndex >= 0)
153
- credited.add(bestIndex);
154
- observed.push(bestRelevance);
155
- }
156
- const ideal = graded
157
- .map(({ target }) => target.relevance ?? 1)
158
- .sort((a, b) => b - a)
159
- .slice(0, k);
160
- const idealDcg = dcg(ideal);
161
- return idealDcg === 0 ? 0 : dcg(observed) / idealDcg;
162
- }
163
- /**
164
- * True when the highest-ranked gold-matching hit matches only forbidden
165
- * targets: an obsolete/contradictory answer was surfaced ahead of the
166
- * current one. Cases without both positive and forbidden targets never
167
- * trigger this.
168
- */
169
- function contradictionFirst(hits, targets) {
170
- const hasPositive = targets.some(target => roleOf(target) === 'positive');
171
- const hasForbidden = targets.some(target => roleOf(target) === 'forbidden');
172
- if (!hasPositive || !hasForbidden)
173
- return false;
174
- for (const hit of hits) {
175
- const matched = targets.filter(target => hitMatchesTarget(hit, target));
176
- if (matched.length === 0)
177
- continue;
178
- return matched.every(target => roleOf(target) === 'forbidden');
179
- }
180
- return false;
181
- }
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.jsonl = void 0;
7
- exports.pagesSha256Of = pagesSha256Of;
8
- exports.verifyPageDump = verifyPageDump;
9
- const node_fs_1 = __importDefault(require("node:fs"));
10
- const node_path_1 = __importDefault(require("node:path"));
11
- const node_crypto_1 = __importDefault(require("node:crypto"));
12
- /**
13
- * The page dump (scripts/eval/dump-longmemeval-pages.ts) is step one of a two-step LongMemEval run: the pages, made with no model
14
- * and no key, possibly on another machine. Step two (scripts/eval/run-longmemeval-qa.ts --run <dump>) reads it and answers and grades.
15
- * This module is what both ends agree on: how the pages are hashed, and the check that a dump on disk is the dump its manifest
16
- * describes, made before the QA run spends anything. The QA manifest then carries the dump's provenance (which caches its pages came
17
- * from), so the output alone can show it after the dump directory is gone.
18
- */
19
- const sha256 = (data) => node_crypto_1.default.createHash('sha256').update(data).digest('hex');
20
- const jsonl = (rows) => rows.map(row => JSON.stringify(row)).join('\n') + '\n';
21
- exports.jsonl = jsonl;
22
- /** The pages alone, no timings: equal for two dumps of the same questions exactly when the reader would see the same pages. */
23
- function pagesSha256Of(resultRows) {
24
- return sha256((0, exports.jsonl)(resultRows.map(row => ({ id: row.id, hits: row.hits }))));
25
- }
26
- const readRows = (file) => node_fs_1.default.readFileSync(file, 'utf8').split('\n').filter(Boolean).map(line => JSON.parse(line));
27
- /**
28
- * Null for a run directory that is not a page dump (a retrieval run from run-longmemeval.ts). For a page dump: recompute the hashes
29
- * from the files and throw unless they are the manifest's, so a dump that was edited, truncated or mixed with another one is refused
30
- * before the first model call.
31
- */
32
- function verifyPageDump(runDir, manifest) {
33
- if (manifest.kind !== 'page-dump')
34
- return null;
35
- const fail = (what) => { throw new Error(`Refused: page dump ${runDir} does not match its manifest (${what}); dump it again`); };
36
- if (manifest.scored !== false || manifest.noModelCalls !== true)
37
- fail('a page dump is unscored and made with no model call');
38
- const resultsPath = node_path_1.default.join(runDir, 'results.jsonl');
39
- const casesPath = node_path_1.default.join(runDir, 'cases.jsonl');
40
- const resultsBytes = node_fs_1.default.readFileSync(resultsPath);
41
- const casesBytes = node_fs_1.default.readFileSync(casesPath);
42
- if (sha256(resultsBytes) !== manifest.resultsSha256)
43
- fail('results.jsonl hash');
44
- if (sha256(casesBytes) !== manifest.casesSha256)
45
- fail('cases.jsonl hash');
46
- const rows = readRows(resultsPath);
47
- if (pagesSha256Of(rows) !== manifest.pagesSha256)
48
- fail('pages hash');
49
- if (rows.length !== manifest.selectedCases)
50
- fail(`${rows.length} pages for ${String(manifest.selectedCases)} selected questions`);
51
- const ids = Array.isArray(manifest.selectionIds) ? manifest.selectionIds : [];
52
- if (ids.length !== rows.length || ids.some((id, index) => rows[index].id !== id))
53
- fail('selected question ids');
54
- return {
55
- kind: 'page-dump',
56
- pagesSha256: manifest.pagesSha256,
57
- resultsSha256: manifest.resultsSha256,
58
- casesSha256: manifest.casesSha256,
59
- selectedCases: rows.length,
60
- cachesUsed: manifest.cachesUsed ?? null,
61
- gitSha: manifest.gitSha ?? null,
62
- gitShaSource: manifest.gitShaSource ?? null,
63
- gitDirty: manifest.gitDirty ?? null,
64
- noModelCalls: true,
65
- verified: true,
66
- };
67
- }