@thehammer/template-verification 0.2.11 → 0.2.13

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/dist/types.d.ts CHANGED
@@ -91,12 +91,36 @@ export interface SourceDiscrepancy {
91
91
  /** The reconciling explanation (which values disagreed, why, and what corroborated the winner). */
92
92
  reason: string;
93
93
  }
94
+ /**
95
+ * A recorded CORRECTION — "we normalised/typo-fixed/OCR-corrected this value" — the host's
96
+ * DataExtraction identity-dedupe pass applies for every field it returns a canonical spelling
97
+ * for (SG-396), an ordinary case/spacing/punctuation normalisation included (SG-406). Same
98
+ * shape as {@link SourceDiscrepancy} but a DIFFERENT fact: this is provenance ("we corrected
99
+ * this value"), never a claim that the source documents disagreed. The two used to share one
100
+ * field (`source_discrepancy`), which fired the reviewer's genuine-conflict warning on routine
101
+ * housekeeping — SG-406 gave the correction its own home. Present on any field the block
102
+ * dedupe touched; null/undefined on every field it never corrected.
103
+ */
104
+ export interface Correction {
105
+ /** Which field was corrected — a constant naming the data point (e.g. "name"). */
106
+ field: string;
107
+ /** The literal pre-correction spelling(s) recorded before normalisation. */
108
+ conflicting_values: string[];
109
+ /** The evidence pages/sources the correction was decided from. */
110
+ evidence: SourceDiscrepancyEvidence[];
111
+ /** The canonical value that won. */
112
+ winning_value: string;
113
+ /** The correcting explanation. */
114
+ reason: string;
115
+ }
94
116
  /**
95
117
  * The extracted (pipeline) candidate — carries provenance: confidence, reasoning, citation.
96
118
  *
97
119
  * SG-392: the host's BASE render (`data.__meta`) ships only `value`/`confidence`/
98
- * `state` plus the two `_count` integers below — `reasoning`/`basis`/`sources`/
99
- * `history` are `undefined` there, and NOTHING IN THIS LIBRARY FILLS THEM IN ANY
120
+ * `state` plus the two `_count` integers below (`sources`/`history` are `undefined`
121
+ * there) — `reasoning` and `verbatim` (SG-325) ship in both light and full mode, being
122
+ * short per-field strings rather than per-attempt arrays. NOTHING IN THIS LIBRARY FILLS
123
+ * `sources`/`history` IN ANY
100
124
  * MORE. They used to be lazy-fetched by the in-letter Inspector dialog, which is
101
125
  * deleted; the embedding app reads a data point's full detail against its own
102
126
  * session instead. A real production render was shipping every field's
@@ -110,8 +134,16 @@ export interface ExtractedCandidate {
110
134
  value: unknown;
111
135
  confidence: number | null;
112
136
  reasoning?: string | null;
113
- /** verbatim | inferred — replaces the retired cited_text/cited_text_verified pair (SG-181). */
114
- basis?: "verbatim" | "inferred" | null;
137
+ /**
138
+ * What the page literally says for this field — the two-value model (SG-323/SG-324/
139
+ * SG-325), replacing the retired `basis` discriminator (`verbatim` | `inferred`) the
140
+ * model used to classify its own output with, non-deterministically. `value` above is
141
+ * the inferred/normalized reading (or this same string when inference returned null);
142
+ * `verbatim` is never a provenance flag on `value` — both are first-class and either
143
+ * (or both) may be null. Consumers show them side by side, never hide `verbatim` when
144
+ * it equals `value`, and never reintroduce a quote-vs-derived badge.
145
+ */
146
+ verbatim?: string | null;
115
147
  sources?: VerificationSource[];
116
148
  /** Cheap `sources?.length` equivalent — present even when `sources` itself is not (SG-392). */
117
149
  sources_count?: number;
@@ -140,6 +172,12 @@ export interface ExtractedCandidate {
140
172
  * none of the SG-392 payload-size risk and `hasDiscrepancy()` needs it in light mode too.
141
173
  */
142
174
  source_discrepancy?: SourceDiscrepancy | null;
175
+ /**
176
+ * Non-null when this candidate's value was NORMALISED/typo-fixed by the block dedupe
177
+ * (SG-406) — a DIFFERENT fact from `source_discrepancy` above, never folded into
178
+ * `discrepancy`. Shipped in BOTH light and full mode, same argument as `source_discrepancy`.
179
+ */
180
+ correction?: Correction | null;
143
181
  }
144
182
  /**
145
183
  * One recorded attempt in a field's extraction history (SG-190). Mirrors the extracted
@@ -150,7 +188,8 @@ export interface VerificationHistoryEntry {
150
188
  value: unknown;
151
189
  confidence: number | null;
152
190
  reasoning?: string | null;
153
- basis?: "verbatim" | "inferred" | null;
191
+ /** See {@link ExtractedCandidate.verbatim} — the same two-value model, per recorded attempt. */
192
+ verbatim?: string | null;
154
193
  state?: "present" | "absent" | "removed" | "failed" | null;
155
194
  /** True for the single live/winning attempt; false for losers/FAILED/superseded values. */
156
195
  is_chosen: boolean;
@@ -201,6 +240,13 @@ export interface DataPointMeta {
201
240
  * purposes — see {@link isSourceDiscrepancy} in `lib/discrepancy.ts`.
202
241
  */
203
242
  source_discrepancy?: SourceDiscrepancy | null;
243
+ /**
244
+ * Present (non-null) when the extracted candidate carries a `correction` (SG-406) — "we
245
+ * normalised/typo-fixed this value" provenance, distinct from `source_discrepancy` and
246
+ * deliberately NEVER folded into `discrepancy`. See {@link hasCorrection}/{@link correctionOf}
247
+ * in `lib/discrepancy.ts`.
248
+ */
249
+ correction?: Correction | null;
204
250
  }
205
251
  /** An object node in the rendered `data` tree carrying a keyed `__meta` map. */
206
252
  export type MetaCarrier = Record<string, unknown> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thehammer/template-verification",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Read-write verification overlay for rendered template apps — per-data-point confidence, discrepancy, 3-source resolution (override > extracted > claim), inline edit, and a recursive comparison page. Consumes the host's __meta sidecar; fetches nothing.",
5
5
  "license": "MIT",
6
6
  "type": "module",