@thehammer/template-verification 0.2.14 → 0.2.16
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/README.md +11 -4
- package/dist/components/VerifiedField.vue.d.ts +74 -34
- package/dist/context.d.ts +0 -9
- package/dist/index.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/template-verification.js +291 -246
- package/dist/types.d.ts +133 -31
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* A rendered object node carries a `__meta` MAP keyed by leaf field name; each
|
|
8
8
|
* entry is a {@link DataPointMeta} describing that one field's verification state.
|
|
9
9
|
*/
|
|
10
|
-
import type { PreviewFile } from "@thehammer/danx-ui";
|
|
11
10
|
/**
|
|
12
11
|
* Status bucket derived from the integer 1-5 confidence (orthogonal to discrepancy),
|
|
13
12
|
* plus 'failed' (SG-189) — a distinct extraction/citation-correction OUTCOME, not a
|
|
@@ -20,45 +19,69 @@ export type ResolvedSource = "override" | "extracted" | "claim" | "none";
|
|
|
20
19
|
/** The basis a user picked when saving an override. */
|
|
21
20
|
export type SourceChoice = "extracted" | "claim" | "custom";
|
|
22
21
|
/**
|
|
23
|
-
* One citation source for an extracted candidate
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* One citation source for an extracted candidate — `CitationSourceResource`-shaped (SG-685),
|
|
23
|
+
* the SAME shape gpt-manager's session-authed `data-point-sources`/`data-point-history`
|
|
24
|
+
* endpoints already returned before this card promoted the token-sealed detail endpoint (and
|
|
25
|
+
* `history[]`) onto it too. Replaces the earlier `file`/`original_file`/`page_number`/
|
|
26
|
+
* `source_id`/`agent_thread_message_id` shape (`TemplateDataResource::sourcesPayload()`/
|
|
27
|
+
* `sourceFilePayload()`, deleted) — one citation transport, not two.
|
|
27
28
|
*/
|
|
28
29
|
export interface VerificationSource {
|
|
29
30
|
id?: number | string;
|
|
30
31
|
source_type?: string | null;
|
|
31
|
-
source_id?: number | string | null;
|
|
32
32
|
explanation?: string | null;
|
|
33
|
-
stored_file_id?: number | string | null;
|
|
34
|
-
agent_thread_message_id?: number | string | null;
|
|
35
33
|
/**
|
|
36
34
|
* Ordered verbatim snippets cited on this source's page (SG-181 — replaces the
|
|
37
35
|
* retired attribute-level `cited_text` column). Empty only when the page has no
|
|
38
36
|
* text transcript at all (image-only).
|
|
39
37
|
*/
|
|
40
38
|
texts?: string[] | null;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
/** Whether this citation resolved to a real page (or, for a `field` citation, a real
|
|
40
|
+
* cited attribute). `false` reports WHY via `unresolved_reason` rather than a silent gap. */
|
|
41
|
+
resolved?: boolean;
|
|
42
|
+
unresolved_reason?: string | null;
|
|
43
|
+
stored_file_id?: number | string | null;
|
|
44
|
+
/** The rendered PAGE this source cites. Null when unresolved, or not a document citation. */
|
|
45
|
+
page?: {
|
|
46
|
+
id: string;
|
|
47
|
+
page_number: number | null;
|
|
48
|
+
url: string | null;
|
|
49
|
+
thumb_url: string | null;
|
|
50
|
+
mime: string | null;
|
|
51
|
+
size: number | null;
|
|
52
|
+
} | null;
|
|
53
|
+
/** The FULL document the cited page was rendered from, reached through the page's own
|
|
54
|
+
* parent. Null when `page` is null. */
|
|
55
|
+
document?: {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string | null;
|
|
58
|
+
url: string | null;
|
|
59
|
+
mime: string | null;
|
|
60
|
+
} | null;
|
|
61
|
+
/** Present only for a `field`-type citation (Generate Artifact) that resolved — the OTHER
|
|
62
|
+
* field this value was drawn from, never a document. Null for every other source_type. */
|
|
63
|
+
field?: {
|
|
64
|
+
team_object_id: number;
|
|
65
|
+
field: string;
|
|
66
|
+
value: unknown;
|
|
67
|
+
confidence: number | null;
|
|
68
|
+
reasoning: string | null;
|
|
69
|
+
state: string | null;
|
|
70
|
+
superseded: boolean;
|
|
71
|
+
record_deleted: boolean;
|
|
72
|
+
} | null;
|
|
73
|
+
/** The LLM call (ApiLog id) that produced this citation. */
|
|
74
|
+
api_log_id?: number | string | null;
|
|
75
|
+
created_at?: string | null;
|
|
54
76
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
77
|
+
* `CitationSourceResource extends` danx's `ActionResource`, which auto-prepends these three
|
|
78
|
+
* envelope keys to every `::collection()` call — a real, always-present part of the wire
|
|
79
|
+
* shape (unlike the retired `sourcesPayload()`, a plain array that never carried them), not
|
|
80
|
+
* something this library's own components read.
|
|
58
81
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
__type?: string;
|
|
83
|
+
__timestamp?: number;
|
|
84
|
+
__deleted_at?: string | null;
|
|
62
85
|
}
|
|
63
86
|
/**
|
|
64
87
|
* One piece of evidence a {@link SourceDiscrepancy} cites — the page a conflicting value
|
|
@@ -132,6 +155,14 @@ export interface Correction {
|
|
|
132
155
|
*/
|
|
133
156
|
export interface ExtractedCandidate {
|
|
134
157
|
value: unknown;
|
|
158
|
+
/**
|
|
159
|
+
* WHO authored the value standing on this field — `extraction`, `audit` or `human`
|
|
160
|
+
* (SG-428/SG-615). Shipped in BOTH light and full mode, same argument as
|
|
161
|
+
* `source_discrepancy` below: one short string per field. Not to be confused with
|
|
162
|
+
* `VerificationSource.source_type`, which names a CITATION's own kind (`file` /
|
|
163
|
+
* `api_log`), a different fact about a different object.
|
|
164
|
+
*/
|
|
165
|
+
source?: string | null;
|
|
135
166
|
confidence: number | null;
|
|
136
167
|
reasoning?: string | null;
|
|
137
168
|
/**
|
|
@@ -182,10 +213,22 @@ export interface ExtractedCandidate {
|
|
|
182
213
|
/**
|
|
183
214
|
* One recorded attempt in a field's extraction history (SG-190). Mirrors the extracted
|
|
184
215
|
* candidate's provenance plus `is_chosen` (the single live winner) and its timestamp.
|
|
216
|
+
*
|
|
217
|
+
* SG-615: caught up to the host's `fieldHistoryPayload()` (SG-450, gpt-manager
|
|
218
|
+
* `TemplateDataResource`), which this type had drifted from in both directions — it never
|
|
219
|
+
* declared `source` (WHO authored this attempt — `extraction`/`audit`/`human`) or
|
|
220
|
+
* `set_by_name` (a real display name for the `human` tier), and it declared a `page` this
|
|
221
|
+
* host method has never emitted (no source in this library reads `.page` off a history
|
|
222
|
+
* entry either — the per-source `page`/`page_number` on {@link VerificationSource} is
|
|
223
|
+
* what's real).
|
|
185
224
|
*/
|
|
186
225
|
export interface VerificationHistoryEntry {
|
|
187
226
|
id?: number | string;
|
|
188
227
|
value: unknown;
|
|
228
|
+
/** WHO authored this attempt — `extraction`, `audit` or `human`. See {@link ExtractedCandidate.source}. */
|
|
229
|
+
source?: string | null;
|
|
230
|
+
/** A real display name for the `human` tier; null for every other tier. See {@link OverrideCandidate.set_by_name}. */
|
|
231
|
+
set_by_name?: string | null;
|
|
189
232
|
confidence: number | null;
|
|
190
233
|
reasoning?: string | null;
|
|
191
234
|
/** See {@link ExtractedCandidate.verbatim} — the same two-value model, per recorded attempt. */
|
|
@@ -193,16 +236,51 @@ export interface VerificationHistoryEntry {
|
|
|
193
236
|
state?: "present" | "absent" | "removed" | "failed" | null;
|
|
194
237
|
/** True for the single live/winning attempt; false for losers/FAILED/superseded values. */
|
|
195
238
|
is_chosen: boolean;
|
|
196
|
-
page?: number | null;
|
|
197
239
|
sources?: VerificationSource[];
|
|
198
240
|
created_at?: string | null;
|
|
199
241
|
}
|
|
200
|
-
/**
|
|
242
|
+
/**
|
|
243
|
+
* One page a human cites when saving/overriding a value (SG-565, widened to a list by
|
|
244
|
+
* SG-573) — the SAME `{file_id, texts}` shape on both the write side
|
|
245
|
+
* (`SaveOverrideArgs.citation`) and the read side (`OverrideCandidate.citations`), reused
|
|
246
|
+
* rather than shaped into two types so a reopened picker round-trips through the exact
|
|
247
|
+
* shape the save endpoint takes. `file_id` is a page-level StoredFile id (danx StoredFile
|
|
248
|
+
* is UUID-keyed, never an integer); `texts` is the ordered quoted passages the person read
|
|
249
|
+
* on that page, optional even once a page is named.
|
|
250
|
+
*/
|
|
251
|
+
export interface HumanCitation {
|
|
252
|
+
file_id: string;
|
|
253
|
+
texts?: string[];
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* A user-saved override candidate — always the highest-priority resolution.
|
|
257
|
+
*
|
|
258
|
+
* `source_choice` is deliberately ABSENT here (SG-428) — it recorded whether the person
|
|
259
|
+
* pinned a candidate's value or typed their own, a fact about the gesture the host never
|
|
260
|
+
* reads back, and it is not part of the RESPONSE shape. It still rides on
|
|
261
|
+
* {@link SaveOverrideArgs} below, because both shipped clients still POST it.
|
|
262
|
+
*
|
|
263
|
+
* `state`/`set_by_name` (SG-428) and `confidence`/`reasoning`/`citations` (SG-565/SG-573)
|
|
264
|
+
* mirror the host's `humanCandidate()` (gpt-manager `TemplateDataResource`) — a person may
|
|
265
|
+
* OPTIONALLY rate their own confidence, explain their reasoning, and cite the page(s) they
|
|
266
|
+
* read the value from, the same three columns the extracted candidate carries for a
|
|
267
|
+
* machine reading. Null/absent on every override that did not opt in.
|
|
268
|
+
*/
|
|
201
269
|
export interface OverrideCandidate {
|
|
270
|
+
/**
|
|
271
|
+
* The decisive human reading's own id (SG-685) — matches this exact row's `id` in
|
|
272
|
+
* gpt-manager's `data-point-history` response, letting a consumer find this candidate's own
|
|
273
|
+
* citations there rather than re-deriving which reading is decisive.
|
|
274
|
+
*/
|
|
275
|
+
reading_id?: number;
|
|
202
276
|
value: unknown;
|
|
203
|
-
|
|
277
|
+
state?: "present" | "absent" | "removed" | null;
|
|
204
278
|
set_by?: number | string | null;
|
|
279
|
+
set_by_name?: string | null;
|
|
205
280
|
set_at?: string | null;
|
|
281
|
+
confidence?: number | null;
|
|
282
|
+
reasoning?: string | null;
|
|
283
|
+
citations?: HumanCitation[];
|
|
206
284
|
}
|
|
207
285
|
/** A claim candidate asserted by an example/reference output — lowest priority. */
|
|
208
286
|
export interface ClaimCandidate {
|
|
@@ -230,6 +308,16 @@ export interface ResolvedValue {
|
|
|
230
308
|
/** The per-data-point verification metadata (one `__meta` map entry). */
|
|
231
309
|
export interface DataPointMeta {
|
|
232
310
|
anchor: DataPointAnchor;
|
|
311
|
+
/**
|
|
312
|
+
* The field's own declared JSON-Schema `type`/`format` (e.g. `{type: 'string',
|
|
313
|
+
* format: 'date'}`) — present on every `__meta` entry the host emits, but consumed
|
|
314
|
+
* by the `views/demands` React app (a separate consumer from this library), not by
|
|
315
|
+
* anything here. Declared here for shape accuracy against the wire contract; every
|
|
316
|
+
* `it` in `verificationContract.test.ts` would otherwise have to omit a key the host
|
|
317
|
+
* genuinely sends.
|
|
318
|
+
*/
|
|
319
|
+
type?: string | null;
|
|
320
|
+
format?: string | null;
|
|
233
321
|
candidates: CandidateSet;
|
|
234
322
|
discrepancy: boolean;
|
|
235
323
|
resolved: ResolvedValue;
|
|
@@ -252,7 +340,18 @@ export interface DataPointMeta {
|
|
|
252
340
|
export type MetaCarrier = Record<string, unknown> & {
|
|
253
341
|
__meta?: Record<string, DataPointMeta>;
|
|
254
342
|
};
|
|
255
|
-
/**
|
|
343
|
+
/**
|
|
344
|
+
* Arguments the library passes to the host-injected save transport (guide §7.4).
|
|
345
|
+
*
|
|
346
|
+
* `confidence`/`reason`/`citation` (SG-565, `citation` widened to a list by SG-573) let a
|
|
347
|
+
* person OPTIONALLY carry the same evidentiary shape a machine reading does — never
|
|
348
|
+
* required, so all three are optional here exactly as the host's
|
|
349
|
+
* `DataPointValueService::validationRules()` marks them `nullable`/`sometimes`. Omitted
|
|
350
|
+
* entirely, the save is byte-identical to before these two cards. Named `citation`
|
|
351
|
+
* (singular) and `reason` on the WRITE side, `citations`/`reasoning` on the READ side
|
|
352
|
+
* ({@link OverrideCandidate}) — deliberately different names on each side of the wire, so
|
|
353
|
+
* neither field is ever confused for the other.
|
|
354
|
+
*/
|
|
256
355
|
export interface SaveOverrideArgs {
|
|
257
356
|
workflow_input_id: number | string | null | undefined;
|
|
258
357
|
object_ids: Array<number | string>;
|
|
@@ -260,6 +359,9 @@ export interface SaveOverrideArgs {
|
|
|
260
359
|
field_path: string;
|
|
261
360
|
value: string | null;
|
|
262
361
|
source_choice: SourceChoice;
|
|
362
|
+
confidence?: number | null;
|
|
363
|
+
reason?: string | null;
|
|
364
|
+
citation?: HumanCitation[];
|
|
263
365
|
}
|
|
264
366
|
/**
|
|
265
367
|
* The host-injected save transport. Backend-agnostic: the host supplies the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thehammer/template-verification",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
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",
|