@totalreclaw/core 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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@totalreclaw/core",
3
3
  "description": "TotalReclaw core — E2EE crypto, reranker, wallet, UserOp, store/search pipelines. Single source of truth for all clients.",
4
- "version": "1.2.0",
4
+ "version": "1.4.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -47,6 +47,21 @@ export class WasmLshHasher {
47
47
  readonly tables: number;
48
48
  }
49
49
 
50
+ /**
51
+ * Append one feedback entry to existing JSONL content.
52
+ */
53
+ export function appendFeedbackToJsonl(existing: string, entry_json: string): string;
54
+
55
+ /**
56
+ * Apply a single counterexample to the weights; returns updated ResolutionWeights JSON.
57
+ */
58
+ export function applyFeedback(weights_json: string, counterexample_json: string): string;
59
+
60
+ /**
61
+ * Assemble a full Digest from a parsed LLM response and source claims.
62
+ */
63
+ export function assembleDigestFromLlm(parsed_json: string, claims_json: string, now_unix_seconds: bigint): string;
64
+
50
65
  /**
51
66
  * Build ABI-encoded calldata for a batch of prepared facts.
52
67
  *
@@ -62,6 +77,12 @@ export function buildBatchCalldataFromPrepared(prepared_array_json: string): Uin
62
77
  */
63
78
  export function buildDebriefPrompt(stored_facts_json: string): string;
64
79
 
80
+ /**
81
+ * Build the LLM prompt for digest compilation.
82
+ * `claims_json`: JSON array of Claim (must be non-empty).
83
+ */
84
+ export function buildDigestPrompt(claims_json: string): string;
85
+
65
86
  /**
66
87
  * Build the profiling prompt for a batch of conversation summaries.
67
88
  *
@@ -86,6 +107,12 @@ export function buildProfileMergePrompt(partials_json: string): string;
86
107
  */
87
108
  export function buildSingleCalldataFromPrepared(prepared_json: string): Uint8Array;
88
109
 
110
+ /**
111
+ * Build a template digest from an array of active claims.
112
+ * `claims_json`: JSON array of Claim. Returns JSON-serialized Digest.
113
+ */
114
+ export function buildTemplateDigest(claims_json: string, now_unix_seconds: bigint): string;
115
+
89
116
  /**
90
117
  * Build the triage prompt for classifying chunks.
91
118
  *
@@ -95,6 +122,13 @@ export function buildSingleCalldataFromPrepared(prepared_json: string): Uint8Arr
95
122
  */
96
123
  export function buildTriagePrompt(profile_json: string, summaries_json: string): string;
97
124
 
125
+ /**
126
+ * Canonicalize a Claim JSON: strict-parse as Claim, re-serialize to canonical bytes.
127
+ * Rejects legacy or malformed input. Use before encryption so TS/Python/Rust all
128
+ * produce byte-identical blobs for the same logical claim.
129
+ */
130
+ export function canonicalizeClaim(claim_json: string): string;
131
+
98
132
  /**
99
133
  * Convert conversation chunks to summaries.
100
134
  *
@@ -118,6 +152,11 @@ export function computeAuthKeyHash(auth_key_hex: string): string;
118
152
  */
119
153
  export function computeContentFingerprint(text: string, dedup_key_hex: string): string;
120
154
 
155
+ /**
156
+ * Compute a claim's score components for contradiction resolution.
157
+ */
158
+ export function computeScoreComponents(claim_json: string, now_unix_seconds: bigint, weights_json: string): string;
159
+
121
160
  /**
122
161
  * Cosine similarity between two f32 vectors.
123
162
  */
@@ -147,6 +186,16 @@ export function decrypt(encrypted_base64: string, encryption_key_hex: string): s
147
186
  */
148
187
  export function decryptAndRerank(facts_json: string, query: string, query_embedding: Float32Array, encryption_key_hex: string, top_k: number): any;
149
188
 
189
+ /**
190
+ * Default P2-3 resolution weights as JSON.
191
+ */
192
+ export function defaultResolutionWeights(): string;
193
+
194
+ /**
195
+ * Build a fresh default WeightsFile JSON with the given timestamp.
196
+ */
197
+ export function defaultWeightsFile(now_unix_seconds: bigint): string;
198
+
150
199
  /**
151
200
  * Derive an Ethereum EOA wallet from a BIP-39 mnemonic via BIP-44.
152
201
  *
@@ -185,6 +234,16 @@ export function deriveKeysFromMnemonicLenient(mnemonic: string): any;
185
234
  */
186
235
  export function deriveLshSeed(mnemonic: string, salt_hex: string): string;
187
236
 
237
+ /**
238
+ * Detect contradictions between a new claim and existing claims (JSON array of {claim, id, embedding}).
239
+ */
240
+ export function detectContradictions(new_claim_json: string, new_claim_id: string, new_embedding_json: string, existing_json: string, lower_threshold: number, upper_threshold: number): string;
241
+
242
+ /**
243
+ * Deterministic entity ID from a name (first 8 bytes of SHA256 as hex).
244
+ */
245
+ export function deterministicEntityId(name: string): string;
246
+
188
247
  /**
189
248
  * Encode multiple fact submissions as SimpleAccount.executeBatch() calldata.
190
249
  *
@@ -242,6 +301,12 @@ export function encrypt(plaintext: string, encryption_key_hex: string): string;
242
301
  */
243
302
  export function enrichExtractionPrompt(profile_json: string, base_prompt: string): string;
244
303
 
304
+ /**
305
+ * Convert a feedback entry into a counterexample for weight tuning. Returns
306
+ * JSON Counterexample or the literal string "null" if the entry has no signal.
307
+ */
308
+ export function feedbackToCounterexample(entry_json: string): string;
309
+
245
310
  /**
246
311
  * WASM binding for `find_near_duplicate`.
247
312
  *
@@ -384,6 +449,11 @@ export function hashUserOp(userop_json: string, entrypoint: string, chain_id: bi
384
449
  */
385
450
  export function hexBlobToBase64(hex_blob: string): string | undefined;
386
451
 
452
+ /**
453
+ * Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
454
+ */
455
+ export function normalizeEntityName(name: string): string;
456
+
387
457
  /**
388
458
  * Normalize text (NFC, lowercase, collapse whitespace, trim).
389
459
  */
@@ -397,6 +467,12 @@ export function normalizeText(text: string): string;
397
467
  */
398
468
  export function parseBroadenedResponse(response_json: string): any;
399
469
 
470
+ /**
471
+ * Parse a decrypted blob as a Claim, falling back to legacy formats.
472
+ * Returns JSON-serialized Claim.
473
+ */
474
+ export function parseClaimOrLegacy(decrypted: string): string;
475
+
400
476
  /**
401
477
  * Parse a debrief LLM response into validated items.
402
478
  *
@@ -404,6 +480,12 @@ export function parseBroadenedResponse(response_json: string): any;
404
480
  */
405
481
  export function parseDebriefResponse(response: string): any;
406
482
 
483
+ /**
484
+ * Parse an LLM digest response.
485
+ * Returns JSON-serialized ParsedDigestResponse.
486
+ */
487
+ export function parseDigestResponse(raw: string): string;
488
+
407
489
  /**
408
490
  * Parse a batch profiling LLM response into a PartialProfile.
409
491
  *
@@ -436,6 +518,11 @@ export function parseSearchResponse(response_json: string): any;
436
518
  */
437
519
  export function parseTriageResponse(llm_output: string): any;
438
520
 
521
+ /**
522
+ * Parse a WeightsFile from JSON; rejects unknown versions and malformed input.
523
+ */
524
+ export function parseWeightsFile(content: string): string;
525
+
439
526
  /**
440
527
  * Prepare a fact for on-chain storage.
441
528
  *
@@ -466,6 +553,11 @@ export function prepareFactWithDecayScore(text: string, encryption_key_hex: stri
466
553
  */
467
554
  export function prepareTombstone(fact_id: string, owner: string): Uint8Array;
468
555
 
556
+ /**
557
+ * Parse JSONL content. Returns JSON: `{"entries": [...], "warnings": [...]}`.
558
+ */
559
+ export function readFeedbackJsonl(content: string): string;
560
+
469
561
  /**
470
562
  * Rerank candidates using BM25 + Cosine + RRF fusion.
471
563
  *
@@ -474,6 +566,21 @@ export function prepareTombstone(fact_id: string, owner: string): Uint8Array;
474
566
  */
475
567
  export function rerank(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number): any;
476
568
 
569
+ /**
570
+ * Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
571
+ */
572
+ export function resolvePair(claim_a_json: string, claim_a_id: string, claim_b_json: string, claim_b_id: string, now_unix_seconds: bigint, weights_json: string): string;
573
+
574
+ /**
575
+ * Keep only the most recent `max_lines` non-empty feedback log lines. Non-falliable.
576
+ */
577
+ export function rotateFeedbackLog(content: string, max_lines: bigint): string;
578
+
579
+ /**
580
+ * Serialize a WeightsFile JSON to pretty-printed JSON (2-space indent).
581
+ */
582
+ export function serializeWeightsFile(file_json: string): string;
583
+
477
584
  /**
478
585
  * WASM binding: determine if a new fact should supersede an existing one.
479
586
  */
@@ -110,6 +110,97 @@ class WasmLshHasher {
110
110
  if (Symbol.dispose) WasmLshHasher.prototype[Symbol.dispose] = WasmLshHasher.prototype.free;
111
111
  exports.WasmLshHasher = WasmLshHasher;
112
112
 
113
+ /**
114
+ * Append one feedback entry to existing JSONL content.
115
+ * @param {string} existing
116
+ * @param {string} entry_json
117
+ * @returns {string}
118
+ */
119
+ function appendFeedbackToJsonl(existing, entry_json) {
120
+ let deferred4_0;
121
+ let deferred4_1;
122
+ try {
123
+ const ptr0 = passStringToWasm0(existing, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
124
+ const len0 = WASM_VECTOR_LEN;
125
+ const ptr1 = passStringToWasm0(entry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
126
+ const len1 = WASM_VECTOR_LEN;
127
+ const ret = wasm.appendFeedbackToJsonl(ptr0, len0, ptr1, len1);
128
+ var ptr3 = ret[0];
129
+ var len3 = ret[1];
130
+ if (ret[3]) {
131
+ ptr3 = 0; len3 = 0;
132
+ throw takeFromExternrefTable0(ret[2]);
133
+ }
134
+ deferred4_0 = ptr3;
135
+ deferred4_1 = len3;
136
+ return getStringFromWasm0(ptr3, len3);
137
+ } finally {
138
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
139
+ }
140
+ }
141
+ exports.appendFeedbackToJsonl = appendFeedbackToJsonl;
142
+
143
+ /**
144
+ * Apply a single counterexample to the weights; returns updated ResolutionWeights JSON.
145
+ * @param {string} weights_json
146
+ * @param {string} counterexample_json
147
+ * @returns {string}
148
+ */
149
+ function applyFeedback(weights_json, counterexample_json) {
150
+ let deferred4_0;
151
+ let deferred4_1;
152
+ try {
153
+ const ptr0 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
154
+ const len0 = WASM_VECTOR_LEN;
155
+ const ptr1 = passStringToWasm0(counterexample_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
156
+ const len1 = WASM_VECTOR_LEN;
157
+ const ret = wasm.applyFeedback(ptr0, len0, ptr1, len1);
158
+ var ptr3 = ret[0];
159
+ var len3 = ret[1];
160
+ if (ret[3]) {
161
+ ptr3 = 0; len3 = 0;
162
+ throw takeFromExternrefTable0(ret[2]);
163
+ }
164
+ deferred4_0 = ptr3;
165
+ deferred4_1 = len3;
166
+ return getStringFromWasm0(ptr3, len3);
167
+ } finally {
168
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
169
+ }
170
+ }
171
+ exports.applyFeedback = applyFeedback;
172
+
173
+ /**
174
+ * Assemble a full Digest from a parsed LLM response and source claims.
175
+ * @param {string} parsed_json
176
+ * @param {string} claims_json
177
+ * @param {bigint} now_unix_seconds
178
+ * @returns {string}
179
+ */
180
+ function assembleDigestFromLlm(parsed_json, claims_json, now_unix_seconds) {
181
+ let deferred4_0;
182
+ let deferred4_1;
183
+ try {
184
+ const ptr0 = passStringToWasm0(parsed_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
185
+ const len0 = WASM_VECTOR_LEN;
186
+ const ptr1 = passStringToWasm0(claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
187
+ const len1 = WASM_VECTOR_LEN;
188
+ const ret = wasm.assembleDigestFromLlm(ptr0, len0, ptr1, len1, now_unix_seconds);
189
+ var ptr3 = ret[0];
190
+ var len3 = ret[1];
191
+ if (ret[3]) {
192
+ ptr3 = 0; len3 = 0;
193
+ throw takeFromExternrefTable0(ret[2]);
194
+ }
195
+ deferred4_0 = ptr3;
196
+ deferred4_1 = len3;
197
+ return getStringFromWasm0(ptr3, len3);
198
+ } finally {
199
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
200
+ }
201
+ }
202
+ exports.assembleDigestFromLlm = assembleDigestFromLlm;
203
+
113
204
  /**
114
205
  * Build ABI-encoded calldata for a batch of prepared facts.
115
206
  *
@@ -160,6 +251,34 @@ function buildDebriefPrompt(stored_facts_json) {
160
251
  }
161
252
  exports.buildDebriefPrompt = buildDebriefPrompt;
162
253
 
254
+ /**
255
+ * Build the LLM prompt for digest compilation.
256
+ * `claims_json`: JSON array of Claim (must be non-empty).
257
+ * @param {string} claims_json
258
+ * @returns {string}
259
+ */
260
+ function buildDigestPrompt(claims_json) {
261
+ let deferred3_0;
262
+ let deferred3_1;
263
+ try {
264
+ const ptr0 = passStringToWasm0(claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
265
+ const len0 = WASM_VECTOR_LEN;
266
+ const ret = wasm.buildDigestPrompt(ptr0, len0);
267
+ var ptr2 = ret[0];
268
+ var len2 = ret[1];
269
+ if (ret[3]) {
270
+ ptr2 = 0; len2 = 0;
271
+ throw takeFromExternrefTable0(ret[2]);
272
+ }
273
+ deferred3_0 = ptr2;
274
+ deferred3_1 = len2;
275
+ return getStringFromWasm0(ptr2, len2);
276
+ } finally {
277
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
278
+ }
279
+ }
280
+ exports.buildDigestPrompt = buildDigestPrompt;
281
+
163
282
  /**
164
283
  * Build the profiling prompt for a batch of conversation summaries.
165
284
  *
@@ -241,6 +360,35 @@ function buildSingleCalldataFromPrepared(prepared_json) {
241
360
  }
242
361
  exports.buildSingleCalldataFromPrepared = buildSingleCalldataFromPrepared;
243
362
 
363
+ /**
364
+ * Build a template digest from an array of active claims.
365
+ * `claims_json`: JSON array of Claim. Returns JSON-serialized Digest.
366
+ * @param {string} claims_json
367
+ * @param {bigint} now_unix_seconds
368
+ * @returns {string}
369
+ */
370
+ function buildTemplateDigest(claims_json, now_unix_seconds) {
371
+ let deferred3_0;
372
+ let deferred3_1;
373
+ try {
374
+ const ptr0 = passStringToWasm0(claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
375
+ const len0 = WASM_VECTOR_LEN;
376
+ const ret = wasm.buildTemplateDigest(ptr0, len0, now_unix_seconds);
377
+ var ptr2 = ret[0];
378
+ var len2 = ret[1];
379
+ if (ret[3]) {
380
+ ptr2 = 0; len2 = 0;
381
+ throw takeFromExternrefTable0(ret[2]);
382
+ }
383
+ deferred3_0 = ptr2;
384
+ deferred3_1 = len2;
385
+ return getStringFromWasm0(ptr2, len2);
386
+ } finally {
387
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
388
+ }
389
+ }
390
+ exports.buildTemplateDigest = buildTemplateDigest;
391
+
244
392
  /**
245
393
  * Build the triage prompt for classifying chunks.
246
394
  *
@@ -275,6 +423,35 @@ function buildTriagePrompt(profile_json, summaries_json) {
275
423
  }
276
424
  exports.buildTriagePrompt = buildTriagePrompt;
277
425
 
426
+ /**
427
+ * Canonicalize a Claim JSON: strict-parse as Claim, re-serialize to canonical bytes.
428
+ * Rejects legacy or malformed input. Use before encryption so TS/Python/Rust all
429
+ * produce byte-identical blobs for the same logical claim.
430
+ * @param {string} claim_json
431
+ * @returns {string}
432
+ */
433
+ function canonicalizeClaim(claim_json) {
434
+ let deferred3_0;
435
+ let deferred3_1;
436
+ try {
437
+ const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
438
+ const len0 = WASM_VECTOR_LEN;
439
+ const ret = wasm.canonicalizeClaim(ptr0, len0);
440
+ var ptr2 = ret[0];
441
+ var len2 = ret[1];
442
+ if (ret[3]) {
443
+ ptr2 = 0; len2 = 0;
444
+ throw takeFromExternrefTable0(ret[2]);
445
+ }
446
+ deferred3_0 = ptr2;
447
+ deferred3_1 = len2;
448
+ return getStringFromWasm0(ptr2, len2);
449
+ } finally {
450
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
451
+ }
452
+ }
453
+ exports.canonicalizeClaim = canonicalizeClaim;
454
+
278
455
  /**
279
456
  * Convert conversation chunks to summaries.
280
457
  *
@@ -356,6 +533,37 @@ function computeContentFingerprint(text, dedup_key_hex) {
356
533
  }
357
534
  exports.computeContentFingerprint = computeContentFingerprint;
358
535
 
536
+ /**
537
+ * Compute a claim's score components for contradiction resolution.
538
+ * @param {string} claim_json
539
+ * @param {bigint} now_unix_seconds
540
+ * @param {string} weights_json
541
+ * @returns {string}
542
+ */
543
+ function computeScoreComponents(claim_json, now_unix_seconds, weights_json) {
544
+ let deferred4_0;
545
+ let deferred4_1;
546
+ try {
547
+ const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
548
+ const len0 = WASM_VECTOR_LEN;
549
+ const ptr1 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
550
+ const len1 = WASM_VECTOR_LEN;
551
+ const ret = wasm.computeScoreComponents(ptr0, len0, now_unix_seconds, ptr1, len1);
552
+ var ptr3 = ret[0];
553
+ var len3 = ret[1];
554
+ if (ret[3]) {
555
+ ptr3 = 0; len3 = 0;
556
+ throw takeFromExternrefTable0(ret[2]);
557
+ }
558
+ deferred4_0 = ptr3;
559
+ deferred4_1 = len3;
560
+ return getStringFromWasm0(ptr3, len3);
561
+ } finally {
562
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
563
+ }
564
+ }
565
+ exports.computeScoreComponents = computeScoreComponents;
566
+
359
567
  /**
360
568
  * Cosine similarity between two f32 vectors.
361
569
  * @param {Float32Array} a
@@ -442,6 +650,55 @@ function decryptAndRerank(facts_json, query, query_embedding, encryption_key_hex
442
650
  }
443
651
  exports.decryptAndRerank = decryptAndRerank;
444
652
 
653
+ /**
654
+ * Default P2-3 resolution weights as JSON.
655
+ * @returns {string}
656
+ */
657
+ function defaultResolutionWeights() {
658
+ let deferred2_0;
659
+ let deferred2_1;
660
+ try {
661
+ const ret = wasm.defaultResolutionWeights();
662
+ var ptr1 = ret[0];
663
+ var len1 = ret[1];
664
+ if (ret[3]) {
665
+ ptr1 = 0; len1 = 0;
666
+ throw takeFromExternrefTable0(ret[2]);
667
+ }
668
+ deferred2_0 = ptr1;
669
+ deferred2_1 = len1;
670
+ return getStringFromWasm0(ptr1, len1);
671
+ } finally {
672
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
673
+ }
674
+ }
675
+ exports.defaultResolutionWeights = defaultResolutionWeights;
676
+
677
+ /**
678
+ * Build a fresh default WeightsFile JSON with the given timestamp.
679
+ * @param {bigint} now_unix_seconds
680
+ * @returns {string}
681
+ */
682
+ function defaultWeightsFile(now_unix_seconds) {
683
+ let deferred2_0;
684
+ let deferred2_1;
685
+ try {
686
+ const ret = wasm.defaultWeightsFile(now_unix_seconds);
687
+ var ptr1 = ret[0];
688
+ var len1 = ret[1];
689
+ if (ret[3]) {
690
+ ptr1 = 0; len1 = 0;
691
+ throw takeFromExternrefTable0(ret[2]);
692
+ }
693
+ deferred2_0 = ptr1;
694
+ deferred2_1 = len1;
695
+ return getStringFromWasm0(ptr1, len1);
696
+ } finally {
697
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
698
+ }
699
+ }
700
+ exports.defaultWeightsFile = defaultWeightsFile;
701
+
445
702
  /**
446
703
  * Derive an Ethereum EOA wallet from a BIP-39 mnemonic via BIP-44.
447
704
  *
@@ -560,6 +817,65 @@ function deriveLshSeed(mnemonic, salt_hex) {
560
817
  }
561
818
  exports.deriveLshSeed = deriveLshSeed;
562
819
 
820
+ /**
821
+ * Detect contradictions between a new claim and existing claims (JSON array of {claim, id, embedding}).
822
+ * @param {string} new_claim_json
823
+ * @param {string} new_claim_id
824
+ * @param {string} new_embedding_json
825
+ * @param {string} existing_json
826
+ * @param {number} lower_threshold
827
+ * @param {number} upper_threshold
828
+ * @returns {string}
829
+ */
830
+ function detectContradictions(new_claim_json, new_claim_id, new_embedding_json, existing_json, lower_threshold, upper_threshold) {
831
+ let deferred6_0;
832
+ let deferred6_1;
833
+ try {
834
+ const ptr0 = passStringToWasm0(new_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
835
+ const len0 = WASM_VECTOR_LEN;
836
+ const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
837
+ const len1 = WASM_VECTOR_LEN;
838
+ const ptr2 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
839
+ const len2 = WASM_VECTOR_LEN;
840
+ const ptr3 = passStringToWasm0(existing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
841
+ const len3 = WASM_VECTOR_LEN;
842
+ const ret = wasm.detectContradictions(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, lower_threshold, upper_threshold);
843
+ var ptr5 = ret[0];
844
+ var len5 = ret[1];
845
+ if (ret[3]) {
846
+ ptr5 = 0; len5 = 0;
847
+ throw takeFromExternrefTable0(ret[2]);
848
+ }
849
+ deferred6_0 = ptr5;
850
+ deferred6_1 = len5;
851
+ return getStringFromWasm0(ptr5, len5);
852
+ } finally {
853
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
854
+ }
855
+ }
856
+ exports.detectContradictions = detectContradictions;
857
+
858
+ /**
859
+ * Deterministic entity ID from a name (first 8 bytes of SHA256 as hex).
860
+ * @param {string} name
861
+ * @returns {string}
862
+ */
863
+ function deterministicEntityId(name) {
864
+ let deferred2_0;
865
+ let deferred2_1;
866
+ try {
867
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
868
+ const len0 = WASM_VECTOR_LEN;
869
+ const ret = wasm.deterministicEntityId(ptr0, len0);
870
+ deferred2_0 = ret[0];
871
+ deferred2_1 = ret[1];
872
+ return getStringFromWasm0(ret[0], ret[1]);
873
+ } finally {
874
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
875
+ }
876
+ }
877
+ exports.deterministicEntityId = deterministicEntityId;
878
+
563
879
  /**
564
880
  * Encode multiple fact submissions as SimpleAccount.executeBatch() calldata.
565
881
  *
@@ -716,6 +1032,34 @@ function enrichExtractionPrompt(profile_json, base_prompt) {
716
1032
  }
717
1033
  exports.enrichExtractionPrompt = enrichExtractionPrompt;
718
1034
 
1035
+ /**
1036
+ * Convert a feedback entry into a counterexample for weight tuning. Returns
1037
+ * JSON Counterexample or the literal string "null" if the entry has no signal.
1038
+ * @param {string} entry_json
1039
+ * @returns {string}
1040
+ */
1041
+ function feedbackToCounterexample(entry_json) {
1042
+ let deferred3_0;
1043
+ let deferred3_1;
1044
+ try {
1045
+ const ptr0 = passStringToWasm0(entry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1046
+ const len0 = WASM_VECTOR_LEN;
1047
+ const ret = wasm.feedbackToCounterexample(ptr0, len0);
1048
+ var ptr2 = ret[0];
1049
+ var len2 = ret[1];
1050
+ if (ret[3]) {
1051
+ ptr2 = 0; len2 = 0;
1052
+ throw takeFromExternrefTable0(ret[2]);
1053
+ }
1054
+ deferred3_0 = ptr2;
1055
+ deferred3_1 = len2;
1056
+ return getStringFromWasm0(ptr2, len2);
1057
+ } finally {
1058
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1059
+ }
1060
+ }
1061
+ exports.feedbackToCounterexample = feedbackToCounterexample;
1062
+
719
1063
  /**
720
1064
  * WASM binding for `find_near_duplicate`.
721
1065
  *
@@ -1121,6 +1465,27 @@ function hexBlobToBase64(hex_blob) {
1121
1465
  }
1122
1466
  exports.hexBlobToBase64 = hexBlobToBase64;
1123
1467
 
1468
+ /**
1469
+ * Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
1470
+ * @param {string} name
1471
+ * @returns {string}
1472
+ */
1473
+ function normalizeEntityName(name) {
1474
+ let deferred2_0;
1475
+ let deferred2_1;
1476
+ try {
1477
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1478
+ const len0 = WASM_VECTOR_LEN;
1479
+ const ret = wasm.normalizeEntityName(ptr0, len0);
1480
+ deferred2_0 = ret[0];
1481
+ deferred2_1 = ret[1];
1482
+ return getStringFromWasm0(ret[0], ret[1]);
1483
+ } finally {
1484
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1485
+ }
1486
+ }
1487
+ exports.normalizeEntityName = normalizeEntityName;
1488
+
1124
1489
  /**
1125
1490
  * Normalize text (NFC, lowercase, collapse whitespace, trim).
1126
1491
  * @param {string} text
@@ -1161,6 +1526,34 @@ function parseBroadenedResponse(response_json) {
1161
1526
  }
1162
1527
  exports.parseBroadenedResponse = parseBroadenedResponse;
1163
1528
 
1529
+ /**
1530
+ * Parse a decrypted blob as a Claim, falling back to legacy formats.
1531
+ * Returns JSON-serialized Claim.
1532
+ * @param {string} decrypted
1533
+ * @returns {string}
1534
+ */
1535
+ function parseClaimOrLegacy(decrypted) {
1536
+ let deferred3_0;
1537
+ let deferred3_1;
1538
+ try {
1539
+ const ptr0 = passStringToWasm0(decrypted, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1540
+ const len0 = WASM_VECTOR_LEN;
1541
+ const ret = wasm.parseClaimOrLegacy(ptr0, len0);
1542
+ var ptr2 = ret[0];
1543
+ var len2 = ret[1];
1544
+ if (ret[3]) {
1545
+ ptr2 = 0; len2 = 0;
1546
+ throw takeFromExternrefTable0(ret[2]);
1547
+ }
1548
+ deferred3_0 = ptr2;
1549
+ deferred3_1 = len2;
1550
+ return getStringFromWasm0(ptr2, len2);
1551
+ } finally {
1552
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1553
+ }
1554
+ }
1555
+ exports.parseClaimOrLegacy = parseClaimOrLegacy;
1556
+
1164
1557
  /**
1165
1558
  * Parse a debrief LLM response into validated items.
1166
1559
  *
@@ -1179,6 +1572,34 @@ function parseDebriefResponse(response) {
1179
1572
  }
1180
1573
  exports.parseDebriefResponse = parseDebriefResponse;
1181
1574
 
1575
+ /**
1576
+ * Parse an LLM digest response.
1577
+ * Returns JSON-serialized ParsedDigestResponse.
1578
+ * @param {string} raw
1579
+ * @returns {string}
1580
+ */
1581
+ function parseDigestResponse(raw) {
1582
+ let deferred3_0;
1583
+ let deferred3_1;
1584
+ try {
1585
+ const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1586
+ const len0 = WASM_VECTOR_LEN;
1587
+ const ret = wasm.parseDigestResponse(ptr0, len0);
1588
+ var ptr2 = ret[0];
1589
+ var len2 = ret[1];
1590
+ if (ret[3]) {
1591
+ ptr2 = 0; len2 = 0;
1592
+ throw takeFromExternrefTable0(ret[2]);
1593
+ }
1594
+ deferred3_0 = ptr2;
1595
+ deferred3_1 = len2;
1596
+ return getStringFromWasm0(ptr2, len2);
1597
+ } finally {
1598
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1599
+ }
1600
+ }
1601
+ exports.parseDigestResponse = parseDigestResponse;
1602
+
1182
1603
  /**
1183
1604
  * Parse a batch profiling LLM response into a PartialProfile.
1184
1605
  *
@@ -1255,6 +1676,33 @@ function parseTriageResponse(llm_output) {
1255
1676
  }
1256
1677
  exports.parseTriageResponse = parseTriageResponse;
1257
1678
 
1679
+ /**
1680
+ * Parse a WeightsFile from JSON; rejects unknown versions and malformed input.
1681
+ * @param {string} content
1682
+ * @returns {string}
1683
+ */
1684
+ function parseWeightsFile(content) {
1685
+ let deferred3_0;
1686
+ let deferred3_1;
1687
+ try {
1688
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1689
+ const len0 = WASM_VECTOR_LEN;
1690
+ const ret = wasm.parseWeightsFile(ptr0, len0);
1691
+ var ptr2 = ret[0];
1692
+ var len2 = ret[1];
1693
+ if (ret[3]) {
1694
+ ptr2 = 0; len2 = 0;
1695
+ throw takeFromExternrefTable0(ret[2]);
1696
+ }
1697
+ deferred3_0 = ptr2;
1698
+ deferred3_1 = len2;
1699
+ return getStringFromWasm0(ptr2, len2);
1700
+ } finally {
1701
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1702
+ }
1703
+ }
1704
+ exports.parseWeightsFile = parseWeightsFile;
1705
+
1258
1706
  /**
1259
1707
  * Prepare a fact for on-chain storage.
1260
1708
  *
@@ -1362,6 +1810,33 @@ function prepareTombstone(fact_id, owner) {
1362
1810
  }
1363
1811
  exports.prepareTombstone = prepareTombstone;
1364
1812
 
1813
+ /**
1814
+ * Parse JSONL content. Returns JSON: `{"entries": [...], "warnings": [...]}`.
1815
+ * @param {string} content
1816
+ * @returns {string}
1817
+ */
1818
+ function readFeedbackJsonl(content) {
1819
+ let deferred3_0;
1820
+ let deferred3_1;
1821
+ try {
1822
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1823
+ const len0 = WASM_VECTOR_LEN;
1824
+ const ret = wasm.readFeedbackJsonl(ptr0, len0);
1825
+ var ptr2 = ret[0];
1826
+ var len2 = ret[1];
1827
+ if (ret[3]) {
1828
+ ptr2 = 0; len2 = 0;
1829
+ throw takeFromExternrefTable0(ret[2]);
1830
+ }
1831
+ deferred3_0 = ptr2;
1832
+ deferred3_1 = len2;
1833
+ return getStringFromWasm0(ptr2, len2);
1834
+ } finally {
1835
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1836
+ }
1837
+ }
1838
+ exports.readFeedbackJsonl = readFeedbackJsonl;
1839
+
1365
1840
  /**
1366
1841
  * Rerank candidates using BM25 + Cosine + RRF fusion.
1367
1842
  *
@@ -1388,6 +1863,95 @@ function rerank(query, query_embedding, candidates_json, top_k) {
1388
1863
  }
1389
1864
  exports.rerank = rerank;
1390
1865
 
1866
+ /**
1867
+ * Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
1868
+ * @param {string} claim_a_json
1869
+ * @param {string} claim_a_id
1870
+ * @param {string} claim_b_json
1871
+ * @param {string} claim_b_id
1872
+ * @param {bigint} now_unix_seconds
1873
+ * @param {string} weights_json
1874
+ * @returns {string}
1875
+ */
1876
+ function resolvePair(claim_a_json, claim_a_id, claim_b_json, claim_b_id, now_unix_seconds, weights_json) {
1877
+ let deferred7_0;
1878
+ let deferred7_1;
1879
+ try {
1880
+ const ptr0 = passStringToWasm0(claim_a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1881
+ const len0 = WASM_VECTOR_LEN;
1882
+ const ptr1 = passStringToWasm0(claim_a_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1883
+ const len1 = WASM_VECTOR_LEN;
1884
+ const ptr2 = passStringToWasm0(claim_b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1885
+ const len2 = WASM_VECTOR_LEN;
1886
+ const ptr3 = passStringToWasm0(claim_b_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1887
+ const len3 = WASM_VECTOR_LEN;
1888
+ const ptr4 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1889
+ const len4 = WASM_VECTOR_LEN;
1890
+ const ret = wasm.resolvePair(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, now_unix_seconds, ptr4, len4);
1891
+ var ptr6 = ret[0];
1892
+ var len6 = ret[1];
1893
+ if (ret[3]) {
1894
+ ptr6 = 0; len6 = 0;
1895
+ throw takeFromExternrefTable0(ret[2]);
1896
+ }
1897
+ deferred7_0 = ptr6;
1898
+ deferred7_1 = len6;
1899
+ return getStringFromWasm0(ptr6, len6);
1900
+ } finally {
1901
+ wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
1902
+ }
1903
+ }
1904
+ exports.resolvePair = resolvePair;
1905
+
1906
+ /**
1907
+ * Keep only the most recent `max_lines` non-empty feedback log lines. Non-falliable.
1908
+ * @param {string} content
1909
+ * @param {bigint} max_lines
1910
+ * @returns {string}
1911
+ */
1912
+ function rotateFeedbackLog(content, max_lines) {
1913
+ let deferred2_0;
1914
+ let deferred2_1;
1915
+ try {
1916
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1917
+ const len0 = WASM_VECTOR_LEN;
1918
+ const ret = wasm.rotateFeedbackLog(ptr0, len0, max_lines);
1919
+ deferred2_0 = ret[0];
1920
+ deferred2_1 = ret[1];
1921
+ return getStringFromWasm0(ret[0], ret[1]);
1922
+ } finally {
1923
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1924
+ }
1925
+ }
1926
+ exports.rotateFeedbackLog = rotateFeedbackLog;
1927
+
1928
+ /**
1929
+ * Serialize a WeightsFile JSON to pretty-printed JSON (2-space indent).
1930
+ * @param {string} file_json
1931
+ * @returns {string}
1932
+ */
1933
+ function serializeWeightsFile(file_json) {
1934
+ let deferred3_0;
1935
+ let deferred3_1;
1936
+ try {
1937
+ const ptr0 = passStringToWasm0(file_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1938
+ const len0 = WASM_VECTOR_LEN;
1939
+ const ret = wasm.serializeWeightsFile(ptr0, len0);
1940
+ var ptr2 = ret[0];
1941
+ var len2 = ret[1];
1942
+ if (ret[3]) {
1943
+ ptr2 = 0; len2 = 0;
1944
+ throw takeFromExternrefTable0(ret[2]);
1945
+ }
1946
+ deferred3_0 = ptr2;
1947
+ deferred3_1 = len2;
1948
+ return getStringFromWasm0(ptr2, len2);
1949
+ } finally {
1950
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1951
+ }
1952
+ }
1953
+ exports.serializeWeightsFile = serializeWeightsFile;
1954
+
1391
1955
  /**
1392
1956
  * WASM binding: determine if a new fact should supersede an existing one.
1393
1957
  * @param {number} new_importance
Binary file