renor-engine 1.2.0 → 1.3.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 (215) hide show
  1. package/README.md +21 -1
  2. package/THIRD-PARTY-NOTICES +2661 -0
  3. package/dist/BUILD.json +6 -0
  4. package/dist/cli.js +1656 -516
  5. package/package.json +16 -80
  6. package/dist/.tsbuildinfo +0 -1
  7. package/dist/api/apiAuth.js +0 -43
  8. package/dist/api/server.js +0 -174
  9. package/dist/buildIdentity.js +0 -149
  10. package/dist/callPhases.js +0 -82
  11. package/dist/cli-extractors.js +0 -46
  12. package/dist/config.js +0 -65
  13. package/dist/context/composer.js +0 -320
  14. package/dist/context/readHonesty.js +0 -478
  15. package/dist/context/rowStore.js +0 -238
  16. package/dist/conversation/formatter.js +0 -81
  17. package/dist/conversation/parser.js +0 -193
  18. package/dist/conversation/types.js +0 -2
  19. package/dist/conversation/writer.js +0 -42
  20. package/dist/db/client.js +0 -149
  21. package/dist/db/handoffTable.js +0 -31
  22. package/dist/db/indexSalvage.js +0 -101
  23. package/dist/db/migrations.js +0 -670
  24. package/dist/db/readCache.js +0 -109
  25. package/dist/db/schema.js +0 -5
  26. package/dist/db/sqlite.js +0 -396
  27. package/dist/db/statements.js +0 -89
  28. package/dist/digests/digestCache.js +0 -146
  29. package/dist/digests/digests.js +0 -597
  30. package/dist/digests/worker.js +0 -350
  31. package/dist/embeddings/caching.js +0 -337
  32. package/dist/embeddings/coalescing.js +0 -177
  33. package/dist/embeddings/interactive.js +0 -103
  34. package/dist/embeddings/local.js +0 -70
  35. package/dist/embeddings/openai.js +0 -106
  36. package/dist/embeddings/rebuild.js +0 -166
  37. package/dist/embeddings/simdScan.js +0 -260
  38. package/dist/embeddings/space.js +0 -21
  39. package/dist/embeddings/types.js +0 -14
  40. package/dist/embeddings/vectorIndex.js +0 -674
  41. package/dist/embeddings/vertex.js +0 -334
  42. package/dist/eval/artifacts.js +0 -42
  43. package/dist/eval/cacheReport.js +0 -146
  44. package/dist/eval/comparison.js +0 -182
  45. package/dist/eval/context700-candidate.js +0 -145
  46. package/dist/eval/evalCache.js +0 -568
  47. package/dist/eval/hashEmbedding.js +0 -35
  48. package/dist/eval/indexSnapshots.js +0 -549
  49. package/dist/eval/longmemeval.js +0 -56
  50. package/dist/eval/metrics.js +0 -181
  51. package/dist/eval/pageDump.js +0 -67
  52. package/dist/eval/renorbenchBaseline.js +0 -486
  53. package/dist/eval/renorbenchDocuments.js +0 -134
  54. package/dist/eval/renorbenchProduct.js +0 -182
  55. package/dist/eval/runLedger.js +0 -279
  56. package/dist/eval/runManifest.js +0 -485
  57. package/dist/eval/scoring.js +0 -197
  58. package/dist/eval/textTokens.js +0 -17
  59. package/dist/evidence/attach.js +0 -264
  60. package/dist/evidence/background.js +0 -147
  61. package/dist/evidence/evidenceCache.js +0 -182
  62. package/dist/evidence/gate.js +0 -37
  63. package/dist/evidence/keyPool.js +0 -85
  64. package/dist/evidence/ollamaChat.js +0 -84
  65. package/dist/evidence/optin.js +0 -165
  66. package/dist/evidence/options.js +0 -151
  67. package/dist/evidence/secondPass.js +0 -294
  68. package/dist/extraction/classifyCapture.js +0 -34
  69. package/dist/extraction/decision-model.js +0 -174
  70. package/dist/extraction/eventExtractor.js +0 -113
  71. package/dist/extraction/extractionClient.js +0 -122
  72. package/dist/extraction/factExtractor.js +0 -46
  73. package/dist/extraction/factsWritePath.js +0 -179
  74. package/dist/extraction/jevDecisionModel.js +0 -307
  75. package/dist/extraction/preferenceExtractor.js +0 -150
  76. package/dist/extraction/secretGuard.js +0 -180
  77. package/dist/extraction/secretScanner.js +0 -665
  78. package/dist/extraction/typedFacts.js +0 -224
  79. package/dist/extraction/writePathAdjudication.js +0 -110
  80. package/dist/importing/apply.js +0 -672
  81. package/dist/importing/bundle-write.js +0 -80
  82. package/dist/importing/cli.js +0 -408
  83. package/dist/importing/existing.js +0 -51
  84. package/dist/importing/facts.js +0 -121
  85. package/dist/importing/forgetImported.js +0 -79
  86. package/dist/importing/hosted.js +0 -467
  87. package/dist/importing/journalLog.js +0 -96
  88. package/dist/importing/markdown.js +0 -98
  89. package/dist/importing/plan.js +0 -201
  90. package/dist/importing/secretScreen.js +0 -113
  91. package/dist/importing/serialize.js +0 -188
  92. package/dist/importing/source.js +0 -463
  93. package/dist/importing/types.js +0 -6
  94. package/dist/indexer/chunker.js +0 -319
  95. package/dist/indexer/dailyEntries.js +0 -63
  96. package/dist/indexer/hasher.js +0 -10
  97. package/dist/indexer/laneRuns.js +0 -48
  98. package/dist/indexer/o200k.js +0 -481
  99. package/dist/indexer/outsideRoot.js +0 -77
  100. package/dist/indexer/parser.js +0 -170
  101. package/dist/indexer/pipeline.js +0 -988
  102. package/dist/indexer/staleness.js +0 -201
  103. package/dist/indexer/tokenizer.js +0 -77
  104. package/dist/indexer/walker.js +0 -170
  105. package/dist/learning/cli.js +0 -113
  106. package/dist/learning/schema.js +0 -144
  107. package/dist/learning/settings.js +0 -45
  108. package/dist/learning/store.js +0 -267
  109. package/dist/learning/tap.js +0 -401
  110. package/dist/mcp/hive.js +0 -88
  111. package/dist/mcp/requestErrors.js +0 -47
  112. package/dist/mcp/server.js +0 -426
  113. package/dist/memory/agentLease.js +0 -43
  114. package/dist/memory/confinedWrite.js +0 -315
  115. package/dist/memory/controls.js +0 -73
  116. package/dist/memory/dailyNote.js +0 -265
  117. package/dist/memory/dreamer/adjudicate.js +0 -215
  118. package/dist/memory/dreamer/apply.js +0 -120
  119. package/dist/memory/dreamer/budget.js +0 -64
  120. package/dist/memory/dreamer/candidates.js +0 -149
  121. package/dist/memory/dreamer/collection.js +0 -104
  122. package/dist/memory/dreamer/dreamer.js +0 -352
  123. package/dist/memory/dreamer/review.js +0 -111
  124. package/dist/memory/durableAppend.js +0 -57
  125. package/dist/memory/factConflicts.js +0 -205
  126. package/dist/memory/factTerms.js +0 -321
  127. package/dist/memory/handoff.js +0 -363
  128. package/dist/memory/hiveNameHeader.cjs +0 -10
  129. package/dist/memory/inventory.js +0 -55
  130. package/dist/memory/invisibleText.js +0 -20
  131. package/dist/memory/lifecycle.js +0 -2014
  132. package/dist/memory/limits.js +0 -13
  133. package/dist/memory/requests.js +0 -183
  134. package/dist/memory/sourceName.js +0 -276
  135. package/dist/memory/statusFacts.js +0 -61
  136. package/dist/memory/whatsNew.js +0 -158
  137. package/dist/memory/writer.js +0 -176
  138. package/dist/memory/writerConflicts.js +0 -85
  139. package/dist/memorymap/memoryMap.js +0 -1594
  140. package/dist/memorymap/replacedJournal.js +0 -58
  141. package/dist/memorymap/replacements.js +0 -410
  142. package/dist/mvp/activity.js +0 -86
  143. package/dist/mvp/agentMemory.js +0 -1803
  144. package/dist/mvp/answerCheck.js +0 -211
  145. package/dist/mvp/auth.js +0 -531
  146. package/dist/mvp/cli.js +0 -86
  147. package/dist/mvp/client-store.js +0 -462
  148. package/dist/mvp/compileCache.js +0 -242
  149. package/dist/mvp/compileSeed.js +0 -33
  150. package/dist/mvp/config.js +0 -292
  151. package/dist/mvp/connectionStatus.js +0 -80
  152. package/dist/mvp/contextDistinct.js +0 -53
  153. package/dist/mvp/contextProfile.js +0 -87
  154. package/dist/mvp/contextRelevance.js +0 -413
  155. package/dist/mvp/directorySurface.js +0 -68
  156. package/dist/mvp/engine.js +0 -1078
  157. package/dist/mvp/exportAll.js +0 -393
  158. package/dist/mvp/factLanePack.js +0 -77
  159. package/dist/mvp/factMarkers.js +0 -65
  160. package/dist/mvp/factsLane.js +0 -203
  161. package/dist/mvp/hiddenSpans.js +0 -585
  162. package/dist/mvp/history.js +0 -414
  163. package/dist/mvp/hitDates.js +0 -31
  164. package/dist/mvp/hitFloor.js +0 -36
  165. package/dist/mvp/identity.js +0 -18
  166. package/dist/mvp/idle.js +0 -113
  167. package/dist/mvp/log.js +0 -118
  168. package/dist/mvp/memoryDir.js +0 -98
  169. package/dist/mvp/posthogMcp.js +0 -210
  170. package/dist/mvp/readScope.js +0 -104
  171. package/dist/mvp/readUsefulness.js +0 -222
  172. package/dist/mvp/sanitize.js +0 -48
  173. package/dist/mvp/schemaRejections.js +0 -91
  174. package/dist/mvp/scope.js +0 -127
  175. package/dist/mvp/server.js +0 -2712
  176. package/dist/mvp/serverCard.js +0 -38
  177. package/dist/mvp/storedSize.js +0 -139
  178. package/dist/mvp/telemetry.js +0 -474
  179. package/dist/net/poolFetch.js +0 -174
  180. package/dist/recall/actionRecall.js +0 -282
  181. package/dist/recall/autoRecall.js +0 -447
  182. package/dist/recall/searchRecall.js +0 -189
  183. package/dist/retrieval/adviceLines.js +0 -195
  184. package/dist/retrieval/adviceQuestion.js +0 -44
  185. package/dist/retrieval/conversationShape.js +0 -44
  186. package/dist/retrieval/dailyEntryTime.js +0 -55
  187. package/dist/retrieval/entityLookup.js +0 -162
  188. package/dist/retrieval/factsFirst.js +0 -188
  189. package/dist/retrieval/keyword.js +0 -84
  190. package/dist/retrieval/ledgerEventTime.js +0 -51
  191. package/dist/retrieval/ledgerLiveness.js +0 -83
  192. package/dist/retrieval/ledgerPresentation.js +0 -161
  193. package/dist/retrieval/noteIdentity.js +0 -57
  194. package/dist/retrieval/orchestrator.js +0 -1224
  195. package/dist/retrieval/plainWording.js +0 -236
  196. package/dist/retrieval/queryHelpers.js +0 -142
  197. package/dist/retrieval/questionSpan.js +0 -475
  198. package/dist/retrieval/rankingTrace.js +0 -184
  199. package/dist/retrieval/readerEvents.js +0 -690
  200. package/dist/retrieval/readerLayout.js +0 -422
  201. package/dist/retrieval/relativeTimeHints.js +0 -113
  202. package/dist/retrieval/semantic.js +0 -67
  203. package/dist/router/routerCache.js +0 -106
  204. package/dist/router/sessionRouter.js +0 -726
  205. package/dist/sharing/cli.js +0 -181
  206. package/dist/sharing/examples.js +0 -136
  207. package/dist/sharing/fields.js +0 -225
  208. package/dist/sharing/loop.js +0 -80
  209. package/dist/sharing/project.js +0 -327
  210. package/dist/sharing/send.js +0 -466
  211. package/dist/sharing/state.js +0 -222
  212. package/dist/sharing/wording.js +0 -48
  213. package/dist/toolRefusal.js +0 -120
  214. package/dist/watcher/watcher.js +0 -77
  215. /package/dist/{indexer/o200k.json → o200k.json} +0 -0
@@ -1,485 +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.EVALUATOR_SOURCES = exports.GOLD_RUNTIME_FIELD_NAMES = exports.PRODUCT_FEATURE_FLAGS = exports.SIDECAR_FLAGS = exports.RESEARCH_WATERMARK = exports.RESEARCH_RUNTIME_FIELD_ALLOWLIST = exports.PRODUCT_RUNTIME_FIELD_ALLOWLIST = exports.MANIFEST_CONTRACT_VERSION = void 0;
7
- exports.productFeatureFlagOverrides = productFeatureFlagOverrides;
8
- exports.researchTruthFields = researchTruthFields;
9
- exports.validateTruthFields = validateTruthFields;
10
- exports.assertNoSidecarFlags = assertNoSidecarFlags;
11
- exports.assertGoldIsolatedRuntimeInputs = assertGoldIsolatedRuntimeInputs;
12
- exports.assertProductScoreEligibility = assertProductScoreEligibility;
13
- exports.evaluatorSourceHash = evaluatorSourceHash;
14
- exports.gitState = gitState;
15
- exports.datasetSha256File = datasetSha256File;
16
- exports.packageLockSha256 = packageLockSha256;
17
- const node_fs_1 = __importDefault(require("node:fs"));
18
- const node_path_1 = __importDefault(require("node:path"));
19
- const node_crypto_1 = __importDefault(require("node:crypto"));
20
- const node_child_process_1 = require("node:child_process");
21
- // ─── Product-truth manifest contract (Wave C, Task 6) ─────────────────────────
22
- //
23
- // These fields distinguish RESEARCH execution (gold-derived fields may reach
24
- // runtime; never a Renor product score) from PRODUCT-PUBLIC execution (every
25
- // answer context comes from a public MCP/API/CLI surface, gold-blind).
26
- // The contract is additive and versioned: legacy manifests without these
27
- // fields remain valid research manifests, but can never carry a product label
28
- // (scorer refuses, fail closed). Contract shape per
29
- // docs/evals/productization/inventory-harness.md §4.
30
- /**
31
- * Bump when the truth-field semantics change. v2 is the first versioned
32
- * contract (introduces executionKind/watermark/refusal rules).
33
- */
34
- exports.MANIFEST_CONTRACT_VERSION = 2;
35
- /**
36
- * ONLY these dataset fields may reach the product runtime in a
37
- * product-public execution. Corpus rendering inputs (markdown generation)
38
- * and the question itself are product-observable; everything else
39
- * (answer, answer_session_ids, question_type, shouldAbstain) is scorer
40
- * or offline-analysis input only.
41
- */
42
- exports.PRODUCT_RUNTIME_FIELD_ALLOWLIST = [
43
- 'question_id',
44
- 'question',
45
- 'question_date',
46
- 'haystack_sessions',
47
- 'haystack_dates',
48
- 'haystack_session_ids',
49
- ];
50
- /**
51
- * Research manifests may expose more (benchmark categories, abstention
52
- * labels drive research-only routing). Recorded honestly so a research
53
- * manifest can never be relabeled product-public.
54
- */
55
- exports.RESEARCH_RUNTIME_FIELD_ALLOWLIST = [
56
- ...exports.PRODUCT_RUNTIME_FIELD_ALLOWLIST,
57
- 'category',
58
- 'shouldAbstain',
59
- ];
60
- /** Required non-null watermark on every research manifest/report. */
61
- exports.RESEARCH_WATERMARK = 'RESEARCH-ONLY';
62
- /** Research sidecar flags: legal only in research runners; refused for product-public execution. */
63
- exports.SIDECAR_FLAGS = [
64
- '--facts-file',
65
- '--chronicle-file',
66
- '--prefs-file',
67
- '--temporal-sidecar',
68
- '--context-compiler',
69
- '--completion-run',
70
- ];
71
- /**
72
- * Shipped default-off product feature flags (Wave B components, ADR-0003).
73
- * The product runner may arm these in the public CLI process ONLY when the
74
- * operator explicitly sets them in the runner environment — the passthrough
75
- * never invents a value, and every armed flag is recorded in the manifest's
76
- * productMode.overrides so a screen arm is self-describing. Each flag's
77
- * default remains OFF inside product code, except RENOR_SESSION_EXPAND (on at five notes unless set to 0) and
78
- * RENOR_SESSION_DIVERSITY (searches capped at 2 chunks per note; get_context uncapped by default): see their entries; this list governs EVAL
79
- * ARMING only.
80
- */
81
- exports.PRODUCT_FEATURE_FLAGS = [
82
- { env: 'RENOR_STRUCTURED_CONTEXT', component: 'C0-composer' },
83
- { env: 'RENOR_TYPED_FACTS', component: 'C2-facts' },
84
- { env: 'RENOR_CHRONICLE', component: 'C3-chronicle' },
85
- { env: 'RENOR_PREFS', component: 'C4-prefs' },
86
- { env: 'RENOR_QUERY_SCOPED_ROWS', component: 'C5-qscope' },
87
- // Evidence second-pass gate policy (src/evidence/gate.ts: off|auto|always).
88
- // It is a shipped default-off product surface (RENOR_SEARCH_EVIDENCE) with a
89
- // policy knob, and it is forwarded to the product process by the runner — so
90
- // two arms differing only in this value are genuinely different arms and must
91
- // not share a provenance record. Measured 2026-09-26: without this entry, the
92
- // auto and always arms produced byte-identical productMode.overrides.
93
- { env: 'RENOR_EVIDENCE_MODE', component: 'evidence-gate' },
94
- { env: 'RENOR_EVIDENCE_SESSIONS', component: 'evidence-coverage' },
95
- // Session-diversity top-K window (retrieval orchestrator, search default 2 chunks per note, get_context default 0, explicit 0 is off).
96
- // Forwarded so a capped screen arm's manifest is self-describing, like the other flags. An unset value is the
97
- // product default, so an arm that must run without the cap sets 0.
98
- { env: 'RENOR_SESSION_DIVERSITY', component: 'session-diversity' },
99
- // Session expansion (retrieval orchestrator, default ON at five notes, 0 is off): how many of the window's best
100
- // notes are expanded, the token budget of what they add, and the longest statement it may add. Each is recorded, so
101
- // two arms differing only in the budget or the statement limit differ here too. An unset value is the product
102
- // default, so an arm that must run without the expansion sets 0.
103
- { env: 'RENOR_SESSION_EXPAND', component: 'session-expand' },
104
- { env: 'RENOR_SESSION_EXPAND_TOKENS', component: 'session-expand-budget' },
105
- { env: 'RENOR_SESSION_EXPAND_STATEMENT_TOKENS', component: 'session-expand-statement' },
106
- { env: 'RENOR_SESSION_EXPAND_DOCUMENT_STATEMENT_TOKENS', component: 'session-expand-document-statement' },
107
- // The operator's declaration that an OpenAI-compatible endpoint returns a calibrated provider's vectors (retrieval
108
- // orchestrator calibratedModelKey, default unset): it arms the ranked expansion on the CLI path the way a hosted
109
- // workspace has it, so an arm that sets it is a different arm from its control and is recorded as one.
110
- { env: 'RENOR_EMBEDDING_SERVED_BY', component: 'embedding-served-by' },
111
- // Session router (src/router/sessionRouter.ts, default OFF: off|replace|union) and the two models it calls. The
112
- // models are recorded because two router arms that differ only in a model are different arms.
113
- { env: 'RENOR_SESSION_ROUTER', component: 'session-router' },
114
- { env: 'RENOR_ROUTER_MODEL', component: 'session-router-model' },
115
- { env: 'RENOR_ROUTER_SUMMARY_MODEL', component: 'session-router-summary-model' },
116
- // Write-time digests (src/digests/digests.ts, default OFF) and the knobs that change what they hold or show.
117
- { env: 'RENOR_DIGESTS', component: 'write-time-digests' },
118
- { env: 'RENOR_DIGEST_MODEL', component: 'write-time-digests-model' },
119
- { env: 'RENOR_DIGEST_REASONING_EFFORT', component: 'write-time-digests-effort' },
120
- { env: 'RENOR_DIGEST_TOKENS', component: 'write-time-digests-budget' },
121
- // P1 strip-excerpt-meta (run-longmemeval-product --strip-excerpt-meta):
122
- // deterministic strip of the pure-meta header lines inside each excerpt
123
- // block; content + Session date footers preserved. Default-off; armed only
124
- // when the operator sets RENOR_STRIP_EXCERPT_META in the runner env.
125
- { env: 'RENOR_STRIP_EXCERPT_META', component: 'P1-excerpt-meta' },
126
- { env: 'RENOR_EVIDENCE_ENUMERATE', component: 'evidence-enumeration' },
127
- // Evidence request bounds (src/evidence/options.ts, default unset = no bound).
128
- // A bounded arm is a different extractor configuration from an unbounded
129
- // one, so each armed bound is recorded like the other evidence knobs.
130
- { env: 'RENOR_EVIDENCE_MAX_TOKENS', component: 'evidence-max-tokens' },
131
- { env: 'RENOR_EVIDENCE_REASONING_EFFORT', component: 'evidence-reasoning-effort' },
132
- ];
133
- /**
134
- * Resolve the armed subset for a run: the exact flag values that will be
135
- * passed through to the product process, as `NAME=value` manifest override
136
- * strings. Deterministic order (declared above); unset flags are omitted so
137
- * default-off stays default-off and the manifest shows an empty arm list for
138
- * control runs at the product defaults.
139
- */
140
- function productFeatureFlagOverrides(env) {
141
- return exports.PRODUCT_FEATURE_FLAGS
142
- .filter(flag => env[flag.env] !== undefined && env[flag.env] !== '')
143
- .map(flag => `${flag.env}=${env[flag.env]}`);
144
- }
145
- /** Gold-derived dataset fields that must never appear as runtime-visible inputs. */
146
- exports.GOLD_RUNTIME_FIELD_NAMES = [
147
- 'answer',
148
- 'answer_session_ids',
149
- 'question_type',
150
- 'shouldAbstain',
151
- ];
152
- /**
153
- * Research-preset truth fields for the existing runners. Research runs keep
154
- * working unchanged; their manifests are explicitly watermarked and declare
155
- * the (wider) research allowlist, so a research manifest can never be
156
- * relabeled product-public by the scorer.
157
- */
158
- function researchTruthFields(args) {
159
- return {
160
- manifestContractVersion: exports.MANIFEST_CONTRACT_VERSION,
161
- executionKind: 'research',
162
- publicEntryPoint: null,
163
- entryPointDetail: null,
164
- runtimeVisibleFieldAllowlist: [...exports.RESEARCH_RUNTIME_FIELD_ALLOWLIST],
165
- goldIsolated: false,
166
- goldIsolationBasis: 'research execution: gold-derived routing is legal and recorded, never product-labeled',
167
- productMode: null,
168
- composition: args.composition ?? null,
169
- coverage: { ...args.coverage, failedRunRecorded: false },
170
- cache: args.cache ?? null,
171
- provenance: null,
172
- models: null,
173
- watermark: exports.RESEARCH_WATERMARK,
174
- };
175
- }
176
- /** Structural type check without throwing; returns all contract violations. */
177
- function validateTruthFields(raw) {
178
- const errors = [];
179
- if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
180
- return ['truth fields missing or not an object'];
181
- const f = raw;
182
- if (f.manifestContractVersion !== exports.MANIFEST_CONTRACT_VERSION) {
183
- errors.push(`manifestContractVersion must be ${exports.MANIFEST_CONTRACT_VERSION} (got ${String(f.manifestContractVersion)})`);
184
- }
185
- if (f.executionKind !== 'research' && f.executionKind !== 'product-public') {
186
- errors.push(`executionKind must be "research" or "product-public" (got ${String(f.executionKind)})`);
187
- }
188
- if (f.executionKind === 'research') {
189
- if (f.watermark !== exports.RESEARCH_WATERMARK)
190
- errors.push(`research manifests must carry watermark "${exports.RESEARCH_WATERMARK}"`);
191
- if (f.publicEntryPoint != null)
192
- errors.push('research manifests must have publicEntryPoint null');
193
- }
194
- if (f.executionKind === 'product-public') {
195
- if (f.watermark != null)
196
- errors.push('product-public manifests must not carry the RESEARCH-ONLY watermark');
197
- if (f.publicEntryPoint !== 'mcp' && f.publicEntryPoint !== 'api' && f.publicEntryPoint !== 'cli') {
198
- errors.push(`product-public manifests must record publicEntryPoint mcp|api|cli (got ${String(f.publicEntryPoint)})`);
199
- }
200
- if (!f.entryPointDetail || typeof f.entryPointDetail.transport !== 'string' || !f.entryPointDetail.transport
201
- || typeof f.entryPointDetail.command !== 'string' || !f.entryPointDetail.command) {
202
- errors.push('product-public manifests must record entryPointDetail {transport, command}');
203
- }
204
- if (f.goldIsolated !== true)
205
- errors.push('product-public manifests must assert goldIsolated true');
206
- if (!f.productMode)
207
- errors.push('product-public manifests must record productMode');
208
- }
209
- if (Array.isArray(f.runtimeVisibleFieldAllowlist)) {
210
- const expected = f.executionKind === 'product-public'
211
- ? [...exports.PRODUCT_RUNTIME_FIELD_ALLOWLIST]
212
- : [...exports.RESEARCH_RUNTIME_FIELD_ALLOWLIST];
213
- const actual = [...f.runtimeVisibleFieldAllowlist].sort();
214
- if (JSON.stringify(actual) !== JSON.stringify([...expected].sort())) {
215
- errors.push(`runtimeVisibleFieldAllowlist mismatch: got ${JSON.stringify(f.runtimeVisibleFieldAllowlist)}`);
216
- }
217
- }
218
- else {
219
- errors.push('runtimeVisibleFieldAllowlist missing');
220
- }
221
- if (!f.coverage || typeof f.coverage !== 'object')
222
- errors.push('coverage block missing');
223
- if (f.watermark !== exports.RESEARCH_WATERMARK && f.watermark != null) {
224
- errors.push(`watermark must be "${exports.RESEARCH_WATERMARK}" or null (got ${String(f.watermark)})`);
225
- }
226
- return errors;
227
- }
228
- /**
229
- * Refuse research sidecar flags for product-public execution. Any argv
230
- * containing a research sidecar flag is rejected — sidecar facts, chronicles,
231
- * preferences, temporal tables, compiler candidates, and completion runs are
232
- * research-only context channels.
233
- */
234
- function assertNoSidecarFlags(argv) {
235
- const found = exports.SIDECAR_FLAGS.filter(flag => argv.includes(flag));
236
- if (found.length > 0) {
237
- throw new Error(`Refused for product-public execution: research sidecar flag(s) ${found.join(', ')}. ` +
238
- 'Sidecar context channels are research-only; product mechanisms must land in src/ behind public surfaces.');
239
- }
240
- }
241
- /**
242
- * Structural gold-isolation marshal check: the exact runtime inputs handed to
243
- * the public surface (query text, process argv, spawn env) must not contain
244
- * gold field names or gold field values. Content parity under gold mutation
245
- * is proven by tests/eval/product-path-contract.test.ts (poisoned fixture).
246
- */
247
- function assertGoldIsolatedRuntimeInputs(args) {
248
- const marshaled = [
249
- args.query,
250
- args.argv.join('\0'),
251
- Object.entries(args.env).map(([key, value]) => `${key}=${value}`).join('\0'),
252
- ].join('\0');
253
- for (const field of exports.GOLD_RUNTIME_FIELD_NAMES) {
254
- // Gold field NAMES must not appear as structured keys; allow ordinary
255
- // prose coincidences in the query by checking argv/env strictly and the
256
- // query only for key-like occurrences.
257
- if (args.argv.join(' ').toLowerCase().includes(field.toLowerCase())
258
- || Object.keys(args.env).some(key => key.toLowerCase().includes(field.toLowerCase()))) {
259
- throw new Error(`Gold field name "${field}" appeared in runtime argv/env — gold fields must never reach the product process`);
260
- }
261
- if (field === 'answer' || field === 'shouldAbstain')
262
- continue; // prose overlap: covered by parity fixture
263
- if (args.query.includes(field)) {
264
- throw new Error(`Gold field name "${field}" appeared in the runtime query`);
265
- }
266
- }
267
- if (marshaled.includes('"shouldAbstain"') || marshaled.includes('"question_type"') || marshaled.includes('"answer_session_ids"')) {
268
- throw new Error('Gold field JSON keys appeared in marshaled runtime inputs');
269
- }
270
- }
271
- /**
272
- * Scorer fail-closed eligibility for a product label. Collects ALL refusal
273
- * reasons and throws one combined error. A product score requires:
274
- * product-public execution, clean provenance, complete coverage (unless an
275
- * explicit failed-run record), zero promotion-arm cache reads/hits, and
276
- * complete model echoes.
277
- *
278
- * Returns a coverage note when the run is an explicitly recorded failed run.
279
- */
280
- function assertProductScoreEligibility(manifest) {
281
- const reasons = [];
282
- const truth = manifest;
283
- if (manifest.manifestContractVersion === undefined) {
284
- throw new Error('Refusing product label: manifest has no product-truth contract fields (pre-contract run). ' +
285
- 'Score it with --label research; it is watermarked RESEARCH-ONLY.');
286
- }
287
- for (const error of validateTruthFields(manifest))
288
- reasons.push(error);
289
- if (truth.executionKind !== 'product-public') {
290
- reasons.push(`executionKind is "${String(truth.executionKind)}": research runs carry only the ${exports.RESEARCH_WATERMARK} label, never a product label`);
291
- }
292
- const provenance = truth.provenance ?? {
293
- gitSha: manifest.gitSha, gitDirty: manifest.gitDirty, evaluatorSha256: manifest.evaluatorSha256,
294
- };
295
- if (!provenance || typeof provenance !== 'object') {
296
- reasons.push('provenance block missing');
297
- }
298
- else {
299
- const gitSha = String(provenance.gitSha ?? '');
300
- if (!gitSha || gitSha === 'unknown')
301
- reasons.push('provenance.gitSha missing or unknown');
302
- if (provenance.gitDirty === true)
303
- reasons.push('gitDirty: the executed code does not match the recorded SHA');
304
- if (gitDirtyLike(provenance.gitDirty))
305
- reasons.push('provenance.gitDirty missing');
306
- const evaluatorSha = provenance.evaluatorSha256;
307
- if (typeof evaluatorSha !== 'string' || !/^[0-9a-f]{64}$/.test(evaluatorSha))
308
- reasons.push('provenance.evaluatorSha256 missing or malformed');
309
- const datasetSha = provenance.datasetSha256;
310
- if (typeof datasetSha !== 'string' || !/^[0-9a-f]{64}$/.test(datasetSha))
311
- reasons.push('provenance.datasetSha256 missing or malformed');
312
- }
313
- const coverage = truth.coverage;
314
- let failedRunRecord = false;
315
- if (!coverage || typeof coverage !== 'object') {
316
- reasons.push('coverage block missing');
317
- }
318
- else {
319
- const c = coverage;
320
- if (!(c.casesTotal > 0))
321
- reasons.push('coverage.casesTotal must be > 0');
322
- if (c.casesCompleted !== c.casesTotal) {
323
- if (c.failedRunRecorded === true)
324
- failedRunRecord = true;
325
- else
326
- reasons.push(`incomplete coverage: casesCompleted ${c.casesCompleted} < casesTotal ${c.casesTotal} (record a failed-run record explicitly to score a failed run)`);
327
- }
328
- if ((c.answerErrors ?? 0) > 0) {
329
- if (c.failedRunRecorded === true)
330
- failedRunRecord = true;
331
- else
332
- reasons.push(`incomplete coverage: ${c.answerErrors} answer error(s) (record a failed-run record explicitly to score a failed run)`);
333
- }
334
- if ((c.judgeParseFailures ?? 0) > 0 && c.failedRunRecorded !== true) {
335
- reasons.push(`incomplete coverage: ${c.judgeParseFailures} judge parse failure(s)`);
336
- }
337
- }
338
- const cache = truth.cache;
339
- if (!cache || typeof cache !== 'object') {
340
- reasons.push('cache evidence missing');
341
- }
342
- else {
343
- const cc = cache;
344
- if (cc?.arm !== 'promotion' && cc?.arm !== 'iteration') {
345
- reasons.push(`cache.arm must be "promotion" or "iteration" (got ${String(cc?.arm)})`);
346
- }
347
- // Plan Task 8 semantics: "fresh isolated write-through caches and ZERO HITS".
348
- // Validity requires zero HITS (no replayed responses); read ATTEMPTS against
349
- // the verified-fresh DB are harmless by construction (nothing to hit).
350
- if (cc?.arm === 'promotion' && ((cc.hits ?? 0) > 0)) {
351
- reasons.push(`promotion arm used cache HITS (hits=${cc.hits}, reads=${cc.reads}): authoritative promotions require zero cache hits — replayed responses invalidate the run`);
352
- }
353
- }
354
- // Embedding provider: eval-hash/local are transport-smoke only. An
355
- // authoritative product score must run on a production embedding provider,
356
- // and the measured embedding configuration must be recorded in the manifest.
357
- // Embedding provider: eval-hash/local are transport-smoke only, and even a
358
- // watermarked smoke run can NEVER carry the product label — the watermark
359
- // lets smoke runs exist, it never authorizes the authoritative label.
360
- const embeddingProvider = String(manifest.embeddingProvider ?? '');
361
- const transportSmoke = manifest.transportSmoke === true;
362
- if (transportSmoke) {
363
- reasons.push('transportSmoke: transport-smoke runs (non-production embeddings) can never carry a product label — score with --label research');
364
- }
365
- else if (!embeddingProvider) {
366
- reasons.push('embeddingProvider missing from manifest: the embedding configuration of the measured product instance must be recorded');
367
- }
368
- else if (embeddingProvider === 'eval-hash' || embeddingProvider === 'local') {
369
- reasons.push(`embeddingProvider is "${embeddingProvider}": non-production embeddings can never carry a product label (--transport-smoke labels smoke runs for research, it does not authorize the product label)`);
370
- }
371
- const models = truth.models ?? {
372
- answerRequested: manifest.answerModelRequested,
373
- answerEchoes: manifest.answerModelEchoes,
374
- judgeRequested: manifest.judgeModelRequested,
375
- judgeEchoes: manifest.judgeModelEchoes,
376
- };
377
- if (!models || typeof models !== 'object') {
378
- reasons.push('model echo evidence missing');
379
- }
380
- else {
381
- const m = models;
382
- if (!m?.answerEchoes || m.answerEchoes.length === 0)
383
- reasons.push('missing answer model echo(s): provider responses were not recorded');
384
- if (!m?.judgeEchoes || m.judgeEchoes.length === 0)
385
- reasons.push('missing judge model echo(s): provider responses were not recorded');
386
- if (typeof m?.answerRequested !== 'string' || !m.answerRequested)
387
- reasons.push('missing answer model request id');
388
- if (typeof m?.judgeRequested !== 'string' || !m.judgeRequested)
389
- reasons.push('missing judge model request id');
390
- }
391
- if (reasons.length > 0) {
392
- throw new Error(`Refusing product score (${reasons.length} reason(s)):\n- ${reasons.join('\n- ')}`);
393
- }
394
- return { failedRunRecord };
395
- }
396
- function gitDirtyLike(value) {
397
- return value === undefined || value === null || typeof value !== 'boolean';
398
- }
399
- /**
400
- * Files that define the measurement system (evaluator), as opposed to the
401
- * system under test (product retrieval code). Any change to these files
402
- * changes the meaning of every score produced afterwards, so their content
403
- * hash is recorded in every run manifest and must be identical between a
404
- * baseline and a candidate for a comparison to count as a clean ablation.
405
- *
406
- * Product code (src/retrieval, src/indexer, src/embeddings, src/db, src/mcp)
407
- * is intentionally NOT listed: it is the candidate being measured.
408
- */
409
- exports.EVALUATOR_SOURCES = [
410
- 'src/eval/hashEmbedding.ts',
411
- 'src/eval/evalCache.ts',
412
- // Which memory store a case is searched against (a restored index snapshot or a cold build): it decides every page.
413
- 'src/eval/indexSnapshots.ts',
414
- // How a page dump is hashed and checked before a QA run reads it.
415
- 'src/eval/pageDump.ts',
416
- // How every runner counts a context's tokens (special-token spellings as text): it decides what fits a token cap.
417
- 'src/eval/textTokens.ts',
418
- 'scripts/eval/run-longmemeval-qa.ts',
419
- 'scripts/eval/score-longmemeval-qa.ts',
420
- 'scripts/eval/run-longmemeval-product.ts',
421
- 'src/eval/metrics.ts',
422
- 'src/eval/scoring.ts',
423
- 'src/eval/comparison.ts',
424
- 'src/eval/renorbenchBaseline.ts',
425
- 'src/eval/renorbenchProduct.ts',
426
- 'src/eval/renorbenchDocuments.ts',
427
- 'src/eval/runManifest.ts',
428
- 'src/eval/artifacts.ts',
429
- 'src/eval/longmemeval.ts',
430
- 'scripts/eval/run-renorbench.ts',
431
- 'scripts/eval/run-renorbench-product.ts',
432
- 'scripts/eval/renorbench-common.ts',
433
- 'scripts/eval/compare-runs.ts',
434
- 'scripts/eval/renorbench-baseline.ts',
435
- 'scripts/eval/score-retrieval.ts',
436
- 'scripts/eval/analyze-failures.ts',
437
- 'scripts/eval/generate-renorbench.ts',
438
- 'scripts/eval/run-longmemeval.ts',
439
- 'scripts/eval/merge-longmemeval-shards.ts',
440
- 'docs/evals/renorbench-v0.schema.json',
441
- ];
442
- function sha256(data) {
443
- return node_crypto_1.default.createHash('sha256').update(data).digest('hex');
444
- }
445
- /**
446
- * Content hash over the evaluator sources. Missing files are a hard error:
447
- * a silently truncated evaluator hash would weaken the freeze.
448
- */
449
- function evaluatorSourceHash(repoRoot) {
450
- const parts = [];
451
- for (const relative of exports.EVALUATOR_SOURCES) {
452
- const full = node_path_1.default.join(repoRoot, relative);
453
- if (!node_fs_1.default.existsSync(full)) {
454
- throw new Error(`Evaluator source missing: ${relative}`);
455
- }
456
- parts.push(`${relative}\0${sha256(node_fs_1.default.readFileSync(full))}`);
457
- }
458
- return sha256(parts.join('\n'));
459
- }
460
- /**
461
- * Git provenance for a run. `dirty === true` means the executed code does not
462
- * match the recorded SHA, which invalidates promotion-grade comparisons.
463
- */
464
- function gitState(repoRoot) {
465
- try {
466
- const sha = (0, node_child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { cwd: repoRoot, encoding: 'utf8' }).trim();
467
- const status = (0, node_child_process_1.execFileSync)('git', ['status', '--porcelain'], { cwd: repoRoot, encoding: 'utf8' });
468
- const dirty = status.trim().length > 0;
469
- return { sha, dirty, statusSha256: dirty ? sha256(status) : null };
470
- }
471
- catch {
472
- return { sha: 'unknown', dirty: true, statusSha256: null };
473
- }
474
- }
475
- function datasetSha256File(filePath) {
476
- return sha256(node_fs_1.default.readFileSync(filePath));
477
- }
478
- function packageLockSha256(repoRoot) {
479
- try {
480
- return sha256(node_fs_1.default.readFileSync(node_path_1.default.join(repoRoot, 'package-lock.json')));
481
- }
482
- catch {
483
- return null;
484
- }
485
- }