@mmnto/totem 1.121.0 → 1.122.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.
@@ -24,6 +24,9 @@
24
24
  import { z } from 'zod';
25
25
  /**
26
26
  * The schemaVersion WRITTEN by this code. Readers accept any 1.x (F1).
27
+ * 1.3.0 (mmnto-ai/totem#2700): `grounding` gained the optional `anchor` +
28
+ * `floor`, bundle items the optional `relevance` (which enters
29
+ * `grounding.hash`), `runMetadata` the optional `promptSource`.
27
30
  * 1.2.0 (mmnto-ai/totem#2452): `output` gained optional execution-attempt
28
31
  * evidence for fallback/configured-shell provenance. 1.1.0
29
32
  * (mmnto-ai/totem#2101): `grounding` gained the optional per-item
@@ -31,7 +34,7 @@ import { z } from 'zod';
31
34
  * to hash-of-bundle — the minor is the observable marker for that meaning
32
35
  * change; the registry stays empty because the tolerant reader parses both.
33
36
  */
34
- export declare const RUN_ARTIFACT_SCHEMA_VERSION = "1.2.0";
37
+ export declare const RUN_ARTIFACT_SCHEMA_VERSION = "1.3.0";
35
38
  /**
36
39
  * Schema version for the distinct terminal-invocation failure ledger. The
37
40
  * exact 1.0.0 literal is deliberate fail-closed behavior: before accepting a
@@ -76,6 +79,33 @@ export declare const PROVENANCE_CLASSES: readonly ["similarity-only", "structura
76
79
  * ("empty"). Honest-absent: a degraded run says so in its own record.
77
80
  */
78
81
  export declare const PROVENANCE_UNGROUNDED = "ungrounded";
82
+ /**
83
+ * What the run was ANCHORED on (mmnto-ai/totem#2700). A closed vocabulary —
84
+ * these four strings are the single spelling shared by the writer, the strict
85
+ * pre-commit evidence reader and the artifact verbs, so a gate and a producer
86
+ * can never disagree about the word.
87
+ *
88
+ * `issue` — every resolved input was an issue; `record` — a hand-authored
89
+ * design record bound with `--from` (the only kind carrying a `sha256`);
90
+ * `free-text` — every input was a topic; `mixed` — issues AND topics together.
91
+ * `mixed` is the honest fourth kind, NOT evidence: its free-text half is the
92
+ * confabulation surface.
93
+ */
94
+ export declare const GROUNDING_ANCHOR_ISSUE = "issue";
95
+ export declare const GROUNDING_ANCHOR_RECORD = "record";
96
+ export declare const GROUNDING_ANCHOR_FREE_TEXT = "free-text";
97
+ export declare const GROUNDING_ANCHOR_MIXED = "mixed";
98
+ export declare const GROUNDING_ANCHOR_KINDS: readonly ["issue", "record", "free-text", "mixed"];
99
+ /**
100
+ * Which system prompt drafted the output (mmnto-ai/totem#2700). Closed
101
+ * vocabulary, derived at the writer (`getSystemPrompt(...) === SYSTEM_PROMPT`
102
+ * → `builtin`, read BEFORE the code-blind directive is folded in). The CLI's
103
+ * `spec` command sets it and the strict pre-commit reader chooses the TEMPLATE
104
+ * or the DOCUMENT shape on it.
105
+ */
106
+ export declare const PROMPT_SOURCE_BUILTIN = "builtin";
107
+ export declare const PROMPT_SOURCE_OVERRIDE = "override";
108
+ export declare const PROMPT_SOURCES: readonly ["builtin", "override"];
79
109
  /**
80
110
  * Slice-1 admission class for both migrated callers (spec + review): factually
81
111
  * completion-only today. #2102 (backend admission contract) changes who
@@ -139,18 +169,30 @@ export declare const GroundingItemSchema: z.ZodObject<{
139
169
  filePath: z.ZodString;
140
170
  /** Linked-index name for cross-repo hits; ABSENT = the run's own repo (F1) — post-checks resolve `filePath` against the run's config root when absent. */
141
171
  sourceRepo: z.ZodOptional<z.ZodString>;
172
+ /**
173
+ * The vector-leg relevance the hit was delivered with (mmnto-ai/totem#2700):
174
+ * `1 / (1 + _distance)` ∈ [0, 1]. ABSENT iff the hit had no vector leg
175
+ * (FTS-only) — "no signal" stays distinguishable from "weak signal"
176
+ * (mmnto-ai/totem#2463 / mmnto-ai/totem#2494), so absence is the disclosure,
177
+ * never a zero. Identical bytes across stores need not give identical
178
+ * relevance (a linked store embeds with its own embedder), which is why the
179
+ * value lives on the item rather than in a hash-keyed map.
180
+ */
181
+ relevance: z.ZodOptional<z.ZodNumber>;
142
182
  }, "strip", z.ZodTypeAny, {
143
183
  filePath: string;
144
184
  contentHash: string;
145
185
  provenance: string;
146
186
  sourceType: string;
147
187
  sourceRepo?: string | undefined;
188
+ relevance?: number | undefined;
148
189
  }, {
149
190
  filePath: string;
150
191
  contentHash: string;
151
192
  provenance: string;
152
193
  sourceType: string;
153
194
  sourceRepo?: string | undefined;
195
+ relevance?: number | undefined;
154
196
  }>;
155
197
  /**
156
198
  * The per-item grounding record. No stored summary/count fields — counts are
@@ -169,18 +211,30 @@ export declare const GroundingBundleSchema: z.ZodObject<{
169
211
  filePath: z.ZodString;
170
212
  /** Linked-index name for cross-repo hits; ABSENT = the run's own repo (F1) — post-checks resolve `filePath` against the run's config root when absent. */
171
213
  sourceRepo: z.ZodOptional<z.ZodString>;
214
+ /**
215
+ * The vector-leg relevance the hit was delivered with (mmnto-ai/totem#2700):
216
+ * `1 / (1 + _distance)` ∈ [0, 1]. ABSENT iff the hit had no vector leg
217
+ * (FTS-only) — "no signal" stays distinguishable from "weak signal"
218
+ * (mmnto-ai/totem#2463 / mmnto-ai/totem#2494), so absence is the disclosure,
219
+ * never a zero. Identical bytes across stores need not give identical
220
+ * relevance (a linked store embeds with its own embedder), which is why the
221
+ * value lives on the item rather than in a hash-keyed map.
222
+ */
223
+ relevance: z.ZodOptional<z.ZodNumber>;
172
224
  }, "strip", z.ZodTypeAny, {
173
225
  filePath: string;
174
226
  contentHash: string;
175
227
  provenance: string;
176
228
  sourceType: string;
177
229
  sourceRepo?: string | undefined;
230
+ relevance?: number | undefined;
178
231
  }, {
179
232
  filePath: string;
180
233
  contentHash: string;
181
234
  provenance: string;
182
235
  sourceType: string;
183
236
  sourceRepo?: string | undefined;
237
+ relevance?: number | undefined;
184
238
  }>, "many">;
185
239
  }, "strip", z.ZodTypeAny, {
186
240
  items: {
@@ -189,6 +243,7 @@ export declare const GroundingBundleSchema: z.ZodObject<{
189
243
  provenance: string;
190
244
  sourceType: string;
191
245
  sourceRepo?: string | undefined;
246
+ relevance?: number | undefined;
192
247
  }[];
193
248
  }, {
194
249
  items: {
@@ -197,16 +252,48 @@ export declare const GroundingBundleSchema: z.ZodObject<{
197
252
  provenance: string;
198
253
  sourceType: string;
199
254
  sourceRepo?: string | undefined;
255
+ relevance?: number | undefined;
200
256
  }[];
201
257
  }>;
258
+ export declare const GroundingAnchorSchema: z.ZodEffects<z.ZodObject<{
259
+ /** Closed vocabulary — the canonical spellings are {@link GROUNDING_ANCHOR_KINDS}. */
260
+ kind: z.ZodEnum<["issue", "record", "free-text", "mixed"]>;
261
+ /** `#<n>` / the input as typed for a URL or `owner/repo#N` (comma-joined for several); the repo-relative record path for `record`; the topic text for `free-text`. Never carries a control character — it is echoed by the pre-commit hook. */
262
+ ref: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
263
+ /** sha256 of the bound record's bytes — `record` anchors only. */
264
+ sha256: z.ZodOptional<z.ZodString>;
265
+ }, "strip", z.ZodTypeAny, {
266
+ kind: "record" | "issue" | "free-text" | "mixed";
267
+ ref: string;
268
+ sha256?: string | undefined;
269
+ }, {
270
+ kind: "record" | "issue" | "free-text" | "mixed";
271
+ ref: string;
272
+ sha256?: string | undefined;
273
+ }>, {
274
+ kind: "record" | "issue" | "free-text" | "mixed";
275
+ ref: string;
276
+ sha256?: string | undefined;
277
+ }, {
278
+ kind: "record" | "issue" | "free-text" | "mixed";
279
+ ref: string;
280
+ sha256?: string | undefined;
281
+ }>;
202
282
  /** What KIND of grounding the run had — day-one field, never retrofittable. */
203
283
  export declare const GroundingSchema: z.ZodObject<{
204
284
  /**
205
285
  * Deterministic hash of the grounding surface. From 1.1.0 this is
206
- * `calculateDeterministicHash(bundle)` the verifier recomputes it from
207
- * the artifact surface ALONE (one enumeration, two readers). Slice-1
208
- * artifacts (no `bundle`) carry their original hash-of-raw-context, which
209
- * is self-consistent but not recomputable offline.
286
+ * `calculateDeterministicHash(bundle)` over the canonically SORTED items
287
+ * sorted BECAUSE the hash is order-significant for arrays (the sort key
288
+ * `sourceType, sourceRepo, filePath, contentHash` is unchanged). The
289
+ * verifier recomputes it from the artifact surface ALONE (one enumeration,
290
+ * two readers) — an invariant mmnto-ai/totem#2700 leaves untouched. Each
291
+ * item's `relevance` is part of the item, so it ENTERS this hash; `anchor`
292
+ * and `floor` sit BESIDE the bundle and do NOT (they enter the artifact's
293
+ * content address like every other field, as `output.metrics.durationMs`
294
+ * already does). Slice-1 artifacts (no `bundle`) carry their original
295
+ * hash-of-raw-context, which is self-consistent but not recomputable
296
+ * offline.
210
297
  */
211
298
  hash: z.ZodString;
212
299
  /** Derived from the bundle since 1.1.0 (sorted class counts, or `ungrounded`); wholesale string in slice-1 artifacts. */
@@ -224,18 +311,30 @@ export declare const GroundingSchema: z.ZodObject<{
224
311
  filePath: z.ZodString;
225
312
  /** Linked-index name for cross-repo hits; ABSENT = the run's own repo (F1) — post-checks resolve `filePath` against the run's config root when absent. */
226
313
  sourceRepo: z.ZodOptional<z.ZodString>;
314
+ /**
315
+ * The vector-leg relevance the hit was delivered with (mmnto-ai/totem#2700):
316
+ * `1 / (1 + _distance)` ∈ [0, 1]. ABSENT iff the hit had no vector leg
317
+ * (FTS-only) — "no signal" stays distinguishable from "weak signal"
318
+ * (mmnto-ai/totem#2463 / mmnto-ai/totem#2494), so absence is the disclosure,
319
+ * never a zero. Identical bytes across stores need not give identical
320
+ * relevance (a linked store embeds with its own embedder), which is why the
321
+ * value lives on the item rather than in a hash-keyed map.
322
+ */
323
+ relevance: z.ZodOptional<z.ZodNumber>;
227
324
  }, "strip", z.ZodTypeAny, {
228
325
  filePath: string;
229
326
  contentHash: string;
230
327
  provenance: string;
231
328
  sourceType: string;
232
329
  sourceRepo?: string | undefined;
330
+ relevance?: number | undefined;
233
331
  }, {
234
332
  filePath: string;
235
333
  contentHash: string;
236
334
  provenance: string;
237
335
  sourceType: string;
238
336
  sourceRepo?: string | undefined;
337
+ relevance?: number | undefined;
239
338
  }>, "many">;
240
339
  }, "strip", z.ZodTypeAny, {
241
340
  items: {
@@ -244,6 +343,7 @@ export declare const GroundingSchema: z.ZodObject<{
244
343
  provenance: string;
245
344
  sourceType: string;
246
345
  sourceRepo?: string | undefined;
346
+ relevance?: number | undefined;
247
347
  }[];
248
348
  }, {
249
349
  items: {
@@ -252,11 +352,44 @@ export declare const GroundingSchema: z.ZodObject<{
252
352
  provenance: string;
253
353
  sourceType: string;
254
354
  sourceRepo?: string | undefined;
355
+ relevance?: number | undefined;
255
356
  }[];
256
357
  }>>;
358
+ /** What the run was anchored on (mmnto-ai/totem#2700). Optional: artifacts written before the anchored-evidence rule predate it, and the gate reads that absence as not-evidence. */
359
+ anchor: z.ZodOptional<z.ZodEffects<z.ZodObject<{
360
+ /** Closed vocabulary — the canonical spellings are {@link GROUNDING_ANCHOR_KINDS}. */
361
+ kind: z.ZodEnum<["issue", "record", "free-text", "mixed"]>;
362
+ /** `#<n>` / the input as typed for a URL or `owner/repo#N` (comma-joined for several); the repo-relative record path for `record`; the topic text for `free-text`. Never carries a control character — it is echoed by the pre-commit hook. */
363
+ ref: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
364
+ /** sha256 of the bound record's bytes — `record` anchors only. */
365
+ sha256: z.ZodOptional<z.ZodString>;
366
+ }, "strip", z.ZodTypeAny, {
367
+ kind: "record" | "issue" | "free-text" | "mixed";
368
+ ref: string;
369
+ sha256?: string | undefined;
370
+ }, {
371
+ kind: "record" | "issue" | "free-text" | "mixed";
372
+ ref: string;
373
+ sha256?: string | undefined;
374
+ }>, {
375
+ kind: "record" | "issue" | "free-text" | "mixed";
376
+ ref: string;
377
+ sha256?: string | undefined;
378
+ }, {
379
+ kind: "record" | "issue" | "free-text" | "mixed";
380
+ ref: string;
381
+ sha256?: string | undefined;
382
+ }>>;
383
+ /** The relevance floor the run was judged against (`searchRelevanceFloor`, post-parse — always a number when recorded). No config-vs-default bit is stored: it is not derivable after `TotemConfigSchema.parse`. */
384
+ floor: z.ZodOptional<z.ZodNumber>;
257
385
  }, "strip", z.ZodTypeAny, {
258
386
  hash: string;
259
387
  provenanceSummary: string;
388
+ anchor?: {
389
+ kind: "record" | "issue" | "free-text" | "mixed";
390
+ ref: string;
391
+ sha256?: string | undefined;
392
+ } | undefined;
260
393
  bundle?: {
261
394
  items: {
262
395
  filePath: string;
@@ -264,11 +397,18 @@ export declare const GroundingSchema: z.ZodObject<{
264
397
  provenance: string;
265
398
  sourceType: string;
266
399
  sourceRepo?: string | undefined;
400
+ relevance?: number | undefined;
267
401
  }[];
268
402
  } | undefined;
403
+ floor?: number | undefined;
269
404
  }, {
270
405
  hash: string;
271
406
  provenanceSummary: string;
407
+ anchor?: {
408
+ kind: "record" | "issue" | "free-text" | "mixed";
409
+ ref: string;
410
+ sha256?: string | undefined;
411
+ } | undefined;
272
412
  bundle?: {
273
413
  items: {
274
414
  filePath: string;
@@ -276,8 +416,10 @@ export declare const GroundingSchema: z.ZodObject<{
276
416
  provenance: string;
277
417
  sourceType: string;
278
418
  sourceRepo?: string | undefined;
419
+ relevance?: number | undefined;
279
420
  }[];
280
421
  } | undefined;
422
+ floor?: number | undefined;
281
423
  }>;
282
424
  /** Backend identity as RESOLVED (post quota-fallback), not as requested. */
283
425
  export declare const BackendSchema: z.ZodObject<{
@@ -1540,14 +1682,26 @@ export declare const RunMetadataSchema: z.ZodObject<{
1540
1682
  * recomputing `code.length === 0` from the grounding bundle.
1541
1683
  */
1542
1684
  codeBlind: z.ZodOptional<z.ZodBoolean>;
1685
+ /**
1686
+ * Which system prompt drafted the output (mmnto-ai/totem#2700): `builtin`
1687
+ * when `getSystemPrompt(...) === SYSTEM_PROMPT`, `override` otherwise —
1688
+ * derived at the writer, read BEFORE the code-blind directive is folded in.
1689
+ * The strict evidence reader chooses the TEMPLATE vs DOCUMENT shape on it:
1690
+ * a draft written under a custom prompt cannot be held to the built-in
1691
+ * template's headings. Absent on pre-existing artifacts (which block on the
1692
+ * missing anchor first, so the shape choice is never reached for them).
1693
+ */
1694
+ promptSource: z.ZodOptional<z.ZodEnum<["builtin", "override"]>>;
1543
1695
  }, "strip", z.ZodTypeAny, {
1544
1696
  caller?: string | undefined;
1545
1697
  command?: string | undefined;
1546
1698
  codeBlind?: boolean | undefined;
1699
+ promptSource?: "builtin" | "override" | undefined;
1547
1700
  }, {
1548
1701
  caller?: string | undefined;
1549
1702
  command?: string | undefined;
1550
1703
  codeBlind?: boolean | undefined;
1704
+ promptSource?: "builtin" | "override" | undefined;
1551
1705
  }>;
1552
1706
  /**
1553
1707
  * Token counts mirror `OrchestratorResult`: `null` means the provider did not
@@ -1600,10 +1754,17 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
1600
1754
  grounding: z.ZodObject<{
1601
1755
  /**
1602
1756
  * Deterministic hash of the grounding surface. From 1.1.0 this is
1603
- * `calculateDeterministicHash(bundle)` the verifier recomputes it from
1604
- * the artifact surface ALONE (one enumeration, two readers). Slice-1
1605
- * artifacts (no `bundle`) carry their original hash-of-raw-context, which
1606
- * is self-consistent but not recomputable offline.
1757
+ * `calculateDeterministicHash(bundle)` over the canonically SORTED items
1758
+ * sorted BECAUSE the hash is order-significant for arrays (the sort key
1759
+ * `sourceType, sourceRepo, filePath, contentHash` is unchanged). The
1760
+ * verifier recomputes it from the artifact surface ALONE (one enumeration,
1761
+ * two readers) — an invariant mmnto-ai/totem#2700 leaves untouched. Each
1762
+ * item's `relevance` is part of the item, so it ENTERS this hash; `anchor`
1763
+ * and `floor` sit BESIDE the bundle and do NOT (they enter the artifact's
1764
+ * content address like every other field, as `output.metrics.durationMs`
1765
+ * already does). Slice-1 artifacts (no `bundle`) carry their original
1766
+ * hash-of-raw-context, which is self-consistent but not recomputable
1767
+ * offline.
1607
1768
  */
1608
1769
  hash: z.ZodString;
1609
1770
  /** Derived from the bundle since 1.1.0 (sorted class counts, or `ungrounded`); wholesale string in slice-1 artifacts. */
@@ -1621,18 +1782,30 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
1621
1782
  filePath: z.ZodString;
1622
1783
  /** Linked-index name for cross-repo hits; ABSENT = the run's own repo (F1) — post-checks resolve `filePath` against the run's config root when absent. */
1623
1784
  sourceRepo: z.ZodOptional<z.ZodString>;
1785
+ /**
1786
+ * The vector-leg relevance the hit was delivered with (mmnto-ai/totem#2700):
1787
+ * `1 / (1 + _distance)` ∈ [0, 1]. ABSENT iff the hit had no vector leg
1788
+ * (FTS-only) — "no signal" stays distinguishable from "weak signal"
1789
+ * (mmnto-ai/totem#2463 / mmnto-ai/totem#2494), so absence is the disclosure,
1790
+ * never a zero. Identical bytes across stores need not give identical
1791
+ * relevance (a linked store embeds with its own embedder), which is why the
1792
+ * value lives on the item rather than in a hash-keyed map.
1793
+ */
1794
+ relevance: z.ZodOptional<z.ZodNumber>;
1624
1795
  }, "strip", z.ZodTypeAny, {
1625
1796
  filePath: string;
1626
1797
  contentHash: string;
1627
1798
  provenance: string;
1628
1799
  sourceType: string;
1629
1800
  sourceRepo?: string | undefined;
1801
+ relevance?: number | undefined;
1630
1802
  }, {
1631
1803
  filePath: string;
1632
1804
  contentHash: string;
1633
1805
  provenance: string;
1634
1806
  sourceType: string;
1635
1807
  sourceRepo?: string | undefined;
1808
+ relevance?: number | undefined;
1636
1809
  }>, "many">;
1637
1810
  }, "strip", z.ZodTypeAny, {
1638
1811
  items: {
@@ -1641,6 +1814,7 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
1641
1814
  provenance: string;
1642
1815
  sourceType: string;
1643
1816
  sourceRepo?: string | undefined;
1817
+ relevance?: number | undefined;
1644
1818
  }[];
1645
1819
  }, {
1646
1820
  items: {
@@ -1649,11 +1823,44 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
1649
1823
  provenance: string;
1650
1824
  sourceType: string;
1651
1825
  sourceRepo?: string | undefined;
1826
+ relevance?: number | undefined;
1652
1827
  }[];
1653
1828
  }>>;
1829
+ /** What the run was anchored on (mmnto-ai/totem#2700). Optional: artifacts written before the anchored-evidence rule predate it, and the gate reads that absence as not-evidence. */
1830
+ anchor: z.ZodOptional<z.ZodEffects<z.ZodObject<{
1831
+ /** Closed vocabulary — the canonical spellings are {@link GROUNDING_ANCHOR_KINDS}. */
1832
+ kind: z.ZodEnum<["issue", "record", "free-text", "mixed"]>;
1833
+ /** `#<n>` / the input as typed for a URL or `owner/repo#N` (comma-joined for several); the repo-relative record path for `record`; the topic text for `free-text`. Never carries a control character — it is echoed by the pre-commit hook. */
1834
+ ref: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
1835
+ /** sha256 of the bound record's bytes — `record` anchors only. */
1836
+ sha256: z.ZodOptional<z.ZodString>;
1837
+ }, "strip", z.ZodTypeAny, {
1838
+ kind: "record" | "issue" | "free-text" | "mixed";
1839
+ ref: string;
1840
+ sha256?: string | undefined;
1841
+ }, {
1842
+ kind: "record" | "issue" | "free-text" | "mixed";
1843
+ ref: string;
1844
+ sha256?: string | undefined;
1845
+ }>, {
1846
+ kind: "record" | "issue" | "free-text" | "mixed";
1847
+ ref: string;
1848
+ sha256?: string | undefined;
1849
+ }, {
1850
+ kind: "record" | "issue" | "free-text" | "mixed";
1851
+ ref: string;
1852
+ sha256?: string | undefined;
1853
+ }>>;
1854
+ /** The relevance floor the run was judged against (`searchRelevanceFloor`, post-parse — always a number when recorded). No config-vs-default bit is stored: it is not derivable after `TotemConfigSchema.parse`. */
1855
+ floor: z.ZodOptional<z.ZodNumber>;
1654
1856
  }, "strip", z.ZodTypeAny, {
1655
1857
  hash: string;
1656
1858
  provenanceSummary: string;
1859
+ anchor?: {
1860
+ kind: "record" | "issue" | "free-text" | "mixed";
1861
+ ref: string;
1862
+ sha256?: string | undefined;
1863
+ } | undefined;
1657
1864
  bundle?: {
1658
1865
  items: {
1659
1866
  filePath: string;
@@ -1661,11 +1868,18 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
1661
1868
  provenance: string;
1662
1869
  sourceType: string;
1663
1870
  sourceRepo?: string | undefined;
1871
+ relevance?: number | undefined;
1664
1872
  }[];
1665
1873
  } | undefined;
1874
+ floor?: number | undefined;
1666
1875
  }, {
1667
1876
  hash: string;
1668
1877
  provenanceSummary: string;
1878
+ anchor?: {
1879
+ kind: "record" | "issue" | "free-text" | "mixed";
1880
+ ref: string;
1881
+ sha256?: string | undefined;
1882
+ } | undefined;
1669
1883
  bundle?: {
1670
1884
  items: {
1671
1885
  filePath: string;
@@ -1673,8 +1887,10 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
1673
1887
  provenance: string;
1674
1888
  sourceType: string;
1675
1889
  sourceRepo?: string | undefined;
1890
+ relevance?: number | undefined;
1676
1891
  }[];
1677
1892
  } | undefined;
1893
+ floor?: number | undefined;
1678
1894
  }>;
1679
1895
  requestedBackend: z.ZodObject<{
1680
1896
  provider: z.ZodString;
@@ -2257,14 +2473,26 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2257
2473
  * recomputing `code.length === 0` from the grounding bundle.
2258
2474
  */
2259
2475
  codeBlind: z.ZodOptional<z.ZodBoolean>;
2476
+ /**
2477
+ * Which system prompt drafted the output (mmnto-ai/totem#2700): `builtin`
2478
+ * when `getSystemPrompt(...) === SYSTEM_PROMPT`, `override` otherwise —
2479
+ * derived at the writer, read BEFORE the code-blind directive is folded in.
2480
+ * The strict evidence reader chooses the TEMPLATE vs DOCUMENT shape on it:
2481
+ * a draft written under a custom prompt cannot be held to the built-in
2482
+ * template's headings. Absent on pre-existing artifacts (which block on the
2483
+ * missing anchor first, so the shape choice is never reached for them).
2484
+ */
2485
+ promptSource: z.ZodOptional<z.ZodEnum<["builtin", "override"]>>;
2260
2486
  }, "strip", z.ZodTypeAny, {
2261
2487
  caller?: string | undefined;
2262
2488
  command?: string | undefined;
2263
2489
  codeBlind?: boolean | undefined;
2490
+ promptSource?: "builtin" | "override" | undefined;
2264
2491
  }, {
2265
2492
  caller?: string | undefined;
2266
2493
  command?: string | undefined;
2267
2494
  codeBlind?: boolean | undefined;
2495
+ promptSource?: "builtin" | "override" | undefined;
2268
2496
  }>>;
2269
2497
  }, "strip", z.ZodTypeAny, {
2270
2498
  outputContract?: {
@@ -2279,6 +2507,7 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2279
2507
  caller?: string | undefined;
2280
2508
  command?: string | undefined;
2281
2509
  codeBlind?: boolean | undefined;
2510
+ promptSource?: "builtin" | "override" | undefined;
2282
2511
  } | undefined;
2283
2512
  }, {
2284
2513
  outputContract?: {
@@ -2293,6 +2522,7 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2293
2522
  caller?: string | undefined;
2294
2523
  command?: string | undefined;
2295
2524
  codeBlind?: boolean | undefined;
2525
+ promptSource?: "builtin" | "override" | undefined;
2296
2526
  } | undefined;
2297
2527
  }>>;
2298
2528
  createdAt: z.ZodString;
@@ -2346,6 +2576,11 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2346
2576
  grounding: {
2347
2577
  hash: string;
2348
2578
  provenanceSummary: string;
2579
+ anchor?: {
2580
+ kind: "record" | "issue" | "free-text" | "mixed";
2581
+ ref: string;
2582
+ sha256?: string | undefined;
2583
+ } | undefined;
2349
2584
  bundle?: {
2350
2585
  items: {
2351
2586
  filePath: string;
@@ -2353,8 +2588,10 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2353
2588
  provenance: string;
2354
2589
  sourceType: string;
2355
2590
  sourceRepo?: string | undefined;
2591
+ relevance?: number | undefined;
2356
2592
  }[];
2357
2593
  } | undefined;
2594
+ floor?: number | undefined;
2358
2595
  };
2359
2596
  requestedBackend: {
2360
2597
  model: string;
@@ -2391,6 +2628,7 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2391
2628
  caller?: string | undefined;
2392
2629
  command?: string | undefined;
2393
2630
  codeBlind?: boolean | undefined;
2631
+ promptSource?: "builtin" | "override" | undefined;
2394
2632
  } | undefined;
2395
2633
  } | undefined;
2396
2634
  }, {
@@ -2443,6 +2681,11 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2443
2681
  grounding: {
2444
2682
  hash: string;
2445
2683
  provenanceSummary: string;
2684
+ anchor?: {
2685
+ kind: "record" | "issue" | "free-text" | "mixed";
2686
+ ref: string;
2687
+ sha256?: string | undefined;
2688
+ } | undefined;
2446
2689
  bundle?: {
2447
2690
  items: {
2448
2691
  filePath: string;
@@ -2450,8 +2693,10 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2450
2693
  provenance: string;
2451
2694
  sourceType: string;
2452
2695
  sourceRepo?: string | undefined;
2696
+ relevance?: number | undefined;
2453
2697
  }[];
2454
2698
  } | undefined;
2699
+ floor?: number | undefined;
2455
2700
  };
2456
2701
  requestedBackend: {
2457
2702
  model: string;
@@ -2488,6 +2733,7 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2488
2733
  caller?: string | undefined;
2489
2734
  command?: string | undefined;
2490
2735
  codeBlind?: boolean | undefined;
2736
+ promptSource?: "builtin" | "override" | undefined;
2491
2737
  } | undefined;
2492
2738
  } | undefined;
2493
2739
  }>, {
@@ -2540,6 +2786,11 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2540
2786
  grounding: {
2541
2787
  hash: string;
2542
2788
  provenanceSummary: string;
2789
+ anchor?: {
2790
+ kind: "record" | "issue" | "free-text" | "mixed";
2791
+ ref: string;
2792
+ sha256?: string | undefined;
2793
+ } | undefined;
2543
2794
  bundle?: {
2544
2795
  items: {
2545
2796
  filePath: string;
@@ -2547,8 +2798,10 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2547
2798
  provenance: string;
2548
2799
  sourceType: string;
2549
2800
  sourceRepo?: string | undefined;
2801
+ relevance?: number | undefined;
2550
2802
  }[];
2551
2803
  } | undefined;
2804
+ floor?: number | undefined;
2552
2805
  };
2553
2806
  requestedBackend: {
2554
2807
  model: string;
@@ -2585,6 +2838,7 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2585
2838
  caller?: string | undefined;
2586
2839
  command?: string | undefined;
2587
2840
  codeBlind?: boolean | undefined;
2841
+ promptSource?: "builtin" | "override" | undefined;
2588
2842
  } | undefined;
2589
2843
  } | undefined;
2590
2844
  }, {
@@ -2637,6 +2891,11 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2637
2891
  grounding: {
2638
2892
  hash: string;
2639
2893
  provenanceSummary: string;
2894
+ anchor?: {
2895
+ kind: "record" | "issue" | "free-text" | "mixed";
2896
+ ref: string;
2897
+ sha256?: string | undefined;
2898
+ } | undefined;
2640
2899
  bundle?: {
2641
2900
  items: {
2642
2901
  filePath: string;
@@ -2644,8 +2903,10 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2644
2903
  provenance: string;
2645
2904
  sourceType: string;
2646
2905
  sourceRepo?: string | undefined;
2906
+ relevance?: number | undefined;
2647
2907
  }[];
2648
2908
  } | undefined;
2909
+ floor?: number | undefined;
2649
2910
  };
2650
2911
  requestedBackend: {
2651
2912
  model: string;
@@ -2682,6 +2943,7 @@ export declare const InvocationFailureArtifactSchema: z.ZodEffects<z.ZodObject<{
2682
2943
  caller?: string | undefined;
2683
2944
  command?: string | undefined;
2684
2945
  codeBlind?: boolean | undefined;
2946
+ promptSource?: "builtin" | "override" | undefined;
2685
2947
  } | undefined;
2686
2948
  } | undefined;
2687
2949
  }>;
@@ -2710,10 +2972,17 @@ export declare const RunArtifactSchema: z.ZodObject<{
2710
2972
  grounding: z.ZodObject<{
2711
2973
  /**
2712
2974
  * Deterministic hash of the grounding surface. From 1.1.0 this is
2713
- * `calculateDeterministicHash(bundle)` the verifier recomputes it from
2714
- * the artifact surface ALONE (one enumeration, two readers). Slice-1
2715
- * artifacts (no `bundle`) carry their original hash-of-raw-context, which
2716
- * is self-consistent but not recomputable offline.
2975
+ * `calculateDeterministicHash(bundle)` over the canonically SORTED items
2976
+ * sorted BECAUSE the hash is order-significant for arrays (the sort key
2977
+ * `sourceType, sourceRepo, filePath, contentHash` is unchanged). The
2978
+ * verifier recomputes it from the artifact surface ALONE (one enumeration,
2979
+ * two readers) — an invariant mmnto-ai/totem#2700 leaves untouched. Each
2980
+ * item's `relevance` is part of the item, so it ENTERS this hash; `anchor`
2981
+ * and `floor` sit BESIDE the bundle and do NOT (they enter the artifact's
2982
+ * content address like every other field, as `output.metrics.durationMs`
2983
+ * already does). Slice-1 artifacts (no `bundle`) carry their original
2984
+ * hash-of-raw-context, which is self-consistent but not recomputable
2985
+ * offline.
2717
2986
  */
2718
2987
  hash: z.ZodString;
2719
2988
  /** Derived from the bundle since 1.1.0 (sorted class counts, or `ungrounded`); wholesale string in slice-1 artifacts. */
@@ -2731,18 +3000,30 @@ export declare const RunArtifactSchema: z.ZodObject<{
2731
3000
  filePath: z.ZodString;
2732
3001
  /** Linked-index name for cross-repo hits; ABSENT = the run's own repo (F1) — post-checks resolve `filePath` against the run's config root when absent. */
2733
3002
  sourceRepo: z.ZodOptional<z.ZodString>;
3003
+ /**
3004
+ * The vector-leg relevance the hit was delivered with (mmnto-ai/totem#2700):
3005
+ * `1 / (1 + _distance)` ∈ [0, 1]. ABSENT iff the hit had no vector leg
3006
+ * (FTS-only) — "no signal" stays distinguishable from "weak signal"
3007
+ * (mmnto-ai/totem#2463 / mmnto-ai/totem#2494), so absence is the disclosure,
3008
+ * never a zero. Identical bytes across stores need not give identical
3009
+ * relevance (a linked store embeds with its own embedder), which is why the
3010
+ * value lives on the item rather than in a hash-keyed map.
3011
+ */
3012
+ relevance: z.ZodOptional<z.ZodNumber>;
2734
3013
  }, "strip", z.ZodTypeAny, {
2735
3014
  filePath: string;
2736
3015
  contentHash: string;
2737
3016
  provenance: string;
2738
3017
  sourceType: string;
2739
3018
  sourceRepo?: string | undefined;
3019
+ relevance?: number | undefined;
2740
3020
  }, {
2741
3021
  filePath: string;
2742
3022
  contentHash: string;
2743
3023
  provenance: string;
2744
3024
  sourceType: string;
2745
3025
  sourceRepo?: string | undefined;
3026
+ relevance?: number | undefined;
2746
3027
  }>, "many">;
2747
3028
  }, "strip", z.ZodTypeAny, {
2748
3029
  items: {
@@ -2751,6 +3032,7 @@ export declare const RunArtifactSchema: z.ZodObject<{
2751
3032
  provenance: string;
2752
3033
  sourceType: string;
2753
3034
  sourceRepo?: string | undefined;
3035
+ relevance?: number | undefined;
2754
3036
  }[];
2755
3037
  }, {
2756
3038
  items: {
@@ -2759,11 +3041,44 @@ export declare const RunArtifactSchema: z.ZodObject<{
2759
3041
  provenance: string;
2760
3042
  sourceType: string;
2761
3043
  sourceRepo?: string | undefined;
3044
+ relevance?: number | undefined;
2762
3045
  }[];
2763
3046
  }>>;
3047
+ /** What the run was anchored on (mmnto-ai/totem#2700). Optional: artifacts written before the anchored-evidence rule predate it, and the gate reads that absence as not-evidence. */
3048
+ anchor: z.ZodOptional<z.ZodEffects<z.ZodObject<{
3049
+ /** Closed vocabulary — the canonical spellings are {@link GROUNDING_ANCHOR_KINDS}. */
3050
+ kind: z.ZodEnum<["issue", "record", "free-text", "mixed"]>;
3051
+ /** `#<n>` / the input as typed for a URL or `owner/repo#N` (comma-joined for several); the repo-relative record path for `record`; the topic text for `free-text`. Never carries a control character — it is echoed by the pre-commit hook. */
3052
+ ref: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
3053
+ /** sha256 of the bound record's bytes — `record` anchors only. */
3054
+ sha256: z.ZodOptional<z.ZodString>;
3055
+ }, "strip", z.ZodTypeAny, {
3056
+ kind: "record" | "issue" | "free-text" | "mixed";
3057
+ ref: string;
3058
+ sha256?: string | undefined;
3059
+ }, {
3060
+ kind: "record" | "issue" | "free-text" | "mixed";
3061
+ ref: string;
3062
+ sha256?: string | undefined;
3063
+ }>, {
3064
+ kind: "record" | "issue" | "free-text" | "mixed";
3065
+ ref: string;
3066
+ sha256?: string | undefined;
3067
+ }, {
3068
+ kind: "record" | "issue" | "free-text" | "mixed";
3069
+ ref: string;
3070
+ sha256?: string | undefined;
3071
+ }>>;
3072
+ /** The relevance floor the run was judged against (`searchRelevanceFloor`, post-parse — always a number when recorded). No config-vs-default bit is stored: it is not derivable after `TotemConfigSchema.parse`. */
3073
+ floor: z.ZodOptional<z.ZodNumber>;
2764
3074
  }, "strip", z.ZodTypeAny, {
2765
3075
  hash: string;
2766
3076
  provenanceSummary: string;
3077
+ anchor?: {
3078
+ kind: "record" | "issue" | "free-text" | "mixed";
3079
+ ref: string;
3080
+ sha256?: string | undefined;
3081
+ } | undefined;
2767
3082
  bundle?: {
2768
3083
  items: {
2769
3084
  filePath: string;
@@ -2771,11 +3086,18 @@ export declare const RunArtifactSchema: z.ZodObject<{
2771
3086
  provenance: string;
2772
3087
  sourceType: string;
2773
3088
  sourceRepo?: string | undefined;
3089
+ relevance?: number | undefined;
2774
3090
  }[];
2775
3091
  } | undefined;
3092
+ floor?: number | undefined;
2776
3093
  }, {
2777
3094
  hash: string;
2778
3095
  provenanceSummary: string;
3096
+ anchor?: {
3097
+ kind: "record" | "issue" | "free-text" | "mixed";
3098
+ ref: string;
3099
+ sha256?: string | undefined;
3100
+ } | undefined;
2779
3101
  bundle?: {
2780
3102
  items: {
2781
3103
  filePath: string;
@@ -2783,8 +3105,10 @@ export declare const RunArtifactSchema: z.ZodObject<{
2783
3105
  provenance: string;
2784
3106
  sourceType: string;
2785
3107
  sourceRepo?: string | undefined;
3108
+ relevance?: number | undefined;
2786
3109
  }[];
2787
3110
  } | undefined;
3111
+ floor?: number | undefined;
2788
3112
  }>;
2789
3113
  backend: z.ZodObject<{
2790
3114
  provider: z.ZodString;
@@ -3547,14 +3871,26 @@ export declare const RunArtifactSchema: z.ZodObject<{
3547
3871
  * recomputing `code.length === 0` from the grounding bundle.
3548
3872
  */
3549
3873
  codeBlind: z.ZodOptional<z.ZodBoolean>;
3874
+ /**
3875
+ * Which system prompt drafted the output (mmnto-ai/totem#2700): `builtin`
3876
+ * when `getSystemPrompt(...) === SYSTEM_PROMPT`, `override` otherwise —
3877
+ * derived at the writer, read BEFORE the code-blind directive is folded in.
3878
+ * The strict evidence reader chooses the TEMPLATE vs DOCUMENT shape on it:
3879
+ * a draft written under a custom prompt cannot be held to the built-in
3880
+ * template's headings. Absent on pre-existing artifacts (which block on the
3881
+ * missing anchor first, so the shape choice is never reached for them).
3882
+ */
3883
+ promptSource: z.ZodOptional<z.ZodEnum<["builtin", "override"]>>;
3550
3884
  }, "strip", z.ZodTypeAny, {
3551
3885
  caller?: string | undefined;
3552
3886
  command?: string | undefined;
3553
3887
  codeBlind?: boolean | undefined;
3888
+ promptSource?: "builtin" | "override" | undefined;
3554
3889
  }, {
3555
3890
  caller?: string | undefined;
3556
3891
  command?: string | undefined;
3557
3892
  codeBlind?: boolean | undefined;
3893
+ promptSource?: "builtin" | "override" | undefined;
3558
3894
  }>>;
3559
3895
  }, "strip", z.ZodTypeAny, {
3560
3896
  outputContract?: {
@@ -3569,6 +3905,7 @@ export declare const RunArtifactSchema: z.ZodObject<{
3569
3905
  caller?: string | undefined;
3570
3906
  command?: string | undefined;
3571
3907
  codeBlind?: boolean | undefined;
3908
+ promptSource?: "builtin" | "override" | undefined;
3572
3909
  } | undefined;
3573
3910
  }, {
3574
3911
  outputContract?: {
@@ -3583,6 +3920,7 @@ export declare const RunArtifactSchema: z.ZodObject<{
3583
3920
  caller?: string | undefined;
3584
3921
  command?: string | undefined;
3585
3922
  codeBlind?: boolean | undefined;
3923
+ promptSource?: "builtin" | "override" | undefined;
3586
3924
  } | undefined;
3587
3925
  }>>;
3588
3926
  /**
@@ -3603,6 +3941,11 @@ export declare const RunArtifactSchema: z.ZodObject<{
3603
3941
  grounding: {
3604
3942
  hash: string;
3605
3943
  provenanceSummary: string;
3944
+ anchor?: {
3945
+ kind: "record" | "issue" | "free-text" | "mixed";
3946
+ ref: string;
3947
+ sha256?: string | undefined;
3948
+ } | undefined;
3606
3949
  bundle?: {
3607
3950
  items: {
3608
3951
  filePath: string;
@@ -3610,8 +3953,10 @@ export declare const RunArtifactSchema: z.ZodObject<{
3610
3953
  provenance: string;
3611
3954
  sourceType: string;
3612
3955
  sourceRepo?: string | undefined;
3956
+ relevance?: number | undefined;
3613
3957
  }[];
3614
3958
  } | undefined;
3959
+ floor?: number | undefined;
3615
3960
  };
3616
3961
  backend: {
3617
3962
  model: string;
@@ -3683,6 +4028,7 @@ export declare const RunArtifactSchema: z.ZodObject<{
3683
4028
  caller?: string | undefined;
3684
4029
  command?: string | undefined;
3685
4030
  codeBlind?: boolean | undefined;
4031
+ promptSource?: "builtin" | "override" | undefined;
3686
4032
  } | undefined;
3687
4033
  } | undefined;
3688
4034
  }, {
@@ -3698,6 +4044,11 @@ export declare const RunArtifactSchema: z.ZodObject<{
3698
4044
  grounding: {
3699
4045
  hash: string;
3700
4046
  provenanceSummary: string;
4047
+ anchor?: {
4048
+ kind: "record" | "issue" | "free-text" | "mixed";
4049
+ ref: string;
4050
+ sha256?: string | undefined;
4051
+ } | undefined;
3701
4052
  bundle?: {
3702
4053
  items: {
3703
4054
  filePath: string;
@@ -3705,8 +4056,10 @@ export declare const RunArtifactSchema: z.ZodObject<{
3705
4056
  provenance: string;
3706
4057
  sourceType: string;
3707
4058
  sourceRepo?: string | undefined;
4059
+ relevance?: number | undefined;
3708
4060
  }[];
3709
4061
  } | undefined;
4062
+ floor?: number | undefined;
3710
4063
  };
3711
4064
  backend: {
3712
4065
  model: string;
@@ -3778,6 +4131,7 @@ export declare const RunArtifactSchema: z.ZodObject<{
3778
4131
  caller?: string | undefined;
3779
4132
  command?: string | undefined;
3780
4133
  codeBlind?: boolean | undefined;
4134
+ promptSource?: "builtin" | "override" | undefined;
3781
4135
  } | undefined;
3782
4136
  } | undefined;
3783
4137
  }>;
@@ -3791,6 +4145,11 @@ export type InvocationFailureArtifact = z.infer<typeof InvocationFailureArtifact
3791
4145
  export type InputBundle = z.infer<typeof InputBundleSchema>;
3792
4146
  export type GroundingItem = z.infer<typeof GroundingItemSchema>;
3793
4147
  export type GroundingBundle = z.infer<typeof GroundingBundleSchema>;
4148
+ export type GroundingAnchor = z.infer<typeof GroundingAnchorSchema>;
4149
+ /** Inferred from the anchor schema's enum — the canonical anchor-kind union (mmnto-ai/totem#2700). */
4150
+ export type GroundingAnchorKind = GroundingAnchor['kind'];
4151
+ /** Inferred from the tuple the `RunMetadataSchema.promptSource` enum is built from — the canonical prompt-source union (mmnto-ai/totem#2700). */
4152
+ export type PromptSource = (typeof PROMPT_SOURCES)[number];
3794
4153
  export type OutputContract = z.infer<typeof OutputContractSchema>;
3795
4154
  export type ContextPolicy = z.infer<typeof ContextPolicySchema>;
3796
4155
  export type RunMetadata = z.infer<typeof RunMetadataSchema>;