@thehammer/template-verification 0.2.1 → 0.2.3

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 CHANGED
@@ -2,12 +2,27 @@
2
2
 
3
3
  A read-write **verification overlay** for rendered template apps. It overlays a
4
4
  trust layer on top of an already-rendered document template: per-data-point
5
- confidence/status icons, discrepancy indicators, a click-through detail modal,
6
- inline editing, and a recursive comparison page.
7
-
8
- The library **fetches nothing** — the host passes in the rendered `data` (with an
9
- embedded `__meta` sidecar) and a `saveOverride` transport via a single
10
- `initVerification()` call. It is backend-agnostic and unit-testable standalone.
5
+ confidence pills + verified check chips, discrepancy indicators, and a
6
+ click-through **Inspector** dialog — a hero strip (resolved value, gradient
7
+ confidence meter, discrepancy alert) over three tabs:
8
+
9
+ - **Evidence** — readonly-markdown reasoning, cited-text quote, an embedded
10
+ `DanxFileViewer` over the cited source pages, and per-document drill-down
11
+ to the FULL parent PDF in a stacked dialog.
12
+ - **Candidates** — the resolution flow: one card per candidate
13
+ (override/extracted/claim) with Accept actions + custom-value entry;
14
+ saves toast and flip the in-document pill to a verified chip.
15
+ - **Audit trail** — the LLM calls behind the data point (model, status,
16
+ timing, collapsible JSON request/response), lazy-fetched from the host's
17
+ token-sealed `audit_url`. Tab hidden when the host mints none.
18
+
19
+ `VerificationChrome` adds a review-progress meter (X of Y human-verified),
20
+ a needs-review jump button, and completion celebration.
21
+
22
+ Render data + `__meta` arrive via a single `initVerification()` call — the
23
+ only network the library touches is the host-supplied `saveOverride`
24
+ transport and the optional `auditUrl` endpoint. Backend-agnostic and
25
+ unit-testable standalone.
11
26
 
12
27
  ## Install
13
28
 
@@ -51,7 +66,9 @@ async function saveOverride(args) {
51
66
  initVerification({
52
67
  data: props.data,
53
68
  saveOverride,
54
- workflowInputId: props.data.workflow_input_id
69
+ workflowInputId: props.data.__verification?.workflow_input_id,
70
+ // Token-sealed audit endpoint (optional) — enables the Inspector's Audit tab.
71
+ auditUrl: props.data.__verification?.audit_url ?? null
55
72
  })
56
73
  </script>
57
74
 
@@ -14,6 +14,13 @@ export interface AuditLlmCall {
14
14
  started_at?: string | null;
15
15
  request?: unknown;
16
16
  response?: unknown;
17
+ /**
18
+ * Which pipeline stage this call belongs to (e.g. "Data Extraction Directive") —
19
+ * the TaskOrchestrator name the host resolved this call's TaskWorker back to.
20
+ * Null when the host could not attribute a stage (see gpt-manager's
21
+ * DataPointAuditService for the current Extraction-only attribution scope).
22
+ */
23
+ stage?: string | null;
17
24
  }
18
25
  /**
19
26
  * Lazy-fetch the LLM-call trace for one data point. The anchor's NEAREST object
@@ -1,3 +1,4 @@
1
+ import type { DataPointMeta } from "../types";
1
2
  /** Review-progress summary over a rendered data tree. */
2
3
  export interface VerificationProgress {
3
4
  /** Anchored data points (have a __meta entry) — the reviewable universe. */
@@ -9,6 +10,18 @@ export interface VerificationProgress {
9
10
  /** 0-100 integer percent (100 when total is 0 — nothing to review is "done"). */
10
11
  percent: number;
11
12
  }
13
+ /**
14
+ * One data point's "needs review" predicate — the SAME criteria
15
+ * {@link computeProgress} tallies, exported so a single point can be classified
16
+ * outside a full-tree walk (e.g. {@link ../components/VerifiedField.vue} tags its
17
+ * own rendered DOM node so `VerificationChrome`'s jump-to-next-flagged button can
18
+ * find it via a plain `.tv-needs-review` query, without duplicating this logic).
19
+ *
20
+ * Unverified (no override candidate) AND (disagreeing OR extracted confidence is
21
+ * low (≤2) or absent — which includes a data point with NO extracted candidate
22
+ * at all, e.g. a field never covered by any extraction directive).
23
+ */
24
+ export declare function pointNeedsReview(meta: DataPointMeta): boolean;
12
25
  /**
13
26
  * Compute review progress by walking the data tree ({@link walkDataPoints}).
14
27
  * "Verified" = an override candidate exists (a human explicitly locked a value —
@@ -18,8 +18,10 @@ export interface SourceGroup {
18
18
  }
19
19
  /**
20
20
  * Group an extracted candidate's sources by file identity so the modal can render
21
- * one block per file with its pages beneath. Links a group only when a `file_url`
22
- * is present on any of its sources.
21
+ * one block per file with its pages beneath. Links a group when a `file_url` (the
22
+ * idealized shape) is present on any of its sources, falling back to the resolved
23
+ * `file.url` (the live gpt-manager backend shape — `TemplateDataResource` never
24
+ * emits `file_url`, only `file: {id,name,url,mime,size,thumb}`).
23
25
  */
24
26
  export declare function groupSources(sources?: VerificationSource[] | null): SourceGroup[];
25
27
  /** Human page/citation label for a single source row. */