@thehammer/template-verification 0.2.6 → 0.2.8

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.
@@ -0,0 +1,33 @@
1
+ import { type CitationEvidence } from "../lib/citations";
2
+ /**
3
+ * The evidence behind one value: why the pipeline chose it, and every source page
4
+ * it cited with that page's own verbatim quotes.
5
+ *
6
+ * Replaces the retired single-blockquote treatment, which flattened every quote
7
+ * from every page into one string joined with ellipses — page attribution, the
8
+ * one thing a citation exists to establish, was unrecoverable from it.
9
+ *
10
+ * Reused by both the Inspector's Citations tab (collapsible, full size) and each
11
+ * History attempt's panel (`dense` + flat), so a losing attempt's citations read
12
+ * exactly like the winner's.
13
+ */
14
+ type __VLS_Props = {
15
+ evidence: CitationEvidence;
16
+ /** Why the pipeline chose this value. Null renders no reasoning card. */
17
+ reasoning?: string | null;
18
+ /** verbatim = the value appears as-is in a quote; inferred = derived from it. */
19
+ basis?: "verbatim" | "inferred" | null;
20
+ /** SG-189: extraction/citation-correction failed — `reasoning` is the failure. */
21
+ failed?: boolean;
22
+ /** Collapse pages behind an accordion (off inside a History panel). */
23
+ collapsible?: boolean;
24
+ dense?: boolean;
25
+ };
26
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
27
+ failed: boolean;
28
+ collapsible: boolean;
29
+ dense: boolean;
30
+ reasoning: string | null;
31
+ basis: "verbatim" | "inferred" | null;
32
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
+ export default _default;
@@ -0,0 +1,27 @@
1
+ import type { CitationPage } from "../lib/citations";
2
+ /**
3
+ * The expanded body of one cited page: its page image on the left, its own
4
+ * ordered verbatim quotes on the right, and the page-level actions.
5
+ *
6
+ * Renders ONLY the body — the collapsed header row lives in
7
+ * {@link CitationPageList} because the disclosure's header is itself a
8
+ * `<button>`, and the view/download controls here are buttons too.
9
+ *
10
+ * The thumbnail is a `DanxFile` in `downloadable` mode: hovering it exposes
11
+ * danx-ui's own download control, and clicking it opens the full-screen viewer.
12
+ * A page whose file the host never resolved still renders its quotes; only the
13
+ * image and its actions are withheld.
14
+ */
15
+ type __VLS_Props = {
16
+ page: CitationPage;
17
+ /** Compact treatment for the History tab's per-attempt citations. */
18
+ dense?: boolean;
19
+ };
20
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
21
+ view: () => any;
22
+ document: () => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
24
+ onView?: (() => any) | undefined;
25
+ onDocument?: (() => any) | undefined;
26
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import type { CitationPage as CitationPageModel } from "../lib/citations";
2
+ /**
3
+ * The cited-page list — one collapsible section per source page, each showing that
4
+ * page's own verbatim quotes, with a full-screen viewer behind every page and
5
+ * every parent document.
6
+ *
7
+ * Progressive disclosure is the point: a data point can cite many pages, so a
8
+ * collapsed row carries only what you need to decide whether to open it (page
9
+ * number, document, quote count, and the first quote truncated). Opening a row
10
+ * reveals the page image and the full quote list.
11
+ *
12
+ * `collapsible: false` renders the same content flat, for the History tab's
13
+ * per-attempt citations where the list is short and already inside a panel.
14
+ */
15
+ type __VLS_Props = {
16
+ pages: CitationPageModel[];
17
+ /** Collapse pages behind an accordion. Off = every page always expanded. */
18
+ collapsible?: boolean;
19
+ /** Compact treatment, passed through to each page body. */
20
+ dense?: boolean;
21
+ };
22
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
23
+ collapsible: boolean;
24
+ dense: boolean;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
+ export default _default;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * A minimal, accessible collapsible-section list — the package's own, on purpose.
3
+ *
4
+ * danx-ui ships `DanxAccordion`, but a template app does NOT resolve danx-ui from
5
+ * this package's node_modules: the danxbot build marks it external and the browser
6
+ * resolves it at load time from the shell's vendor chunk, which pins
7
+ * `@thehammer/danx-ui: ^0.8.17` (see danxbot `spa-template-shell/package.json`).
8
+ * `DanxAccordion` does not exist there, and importing it fails the template's vite
9
+ * build with a Rollup "not exported" error — which is exactly what happened on the
10
+ * first attempt to ship this feature.
11
+ *
12
+ * The rule this encodes: this package must only use danx-ui surface that exists at
13
+ * the FLOOR of its declared peer range, never whatever the local install happens to
14
+ * resolve. A ~40-line disclosure is a much cheaper guarantee than a version bump
15
+ * coordinated across the shell and every template.
16
+ *
17
+ * The header is a `<button>` (its own accessible toggle), so slot content placed in
18
+ * it must not itself be interactive — put actions in the `panel` slot.
19
+ */
20
+ type __VLS_Props = {
21
+ /** Sections to render, in order. `value` is the open/closed key. */
22
+ items: Array<{
23
+ value: string;
24
+ label?: string;
25
+ }>;
26
+ /** Open section keys. Any number may be open at once. */
27
+ modelValue: string[];
28
+ /** Prefix for the generated aria ids — unique per usage on a page. */
29
+ idPrefix?: string;
30
+ };
31
+ declare var __VLS_1: {
32
+ item: {
33
+ value: string;
34
+ label?: string | undefined;
35
+ };
36
+ isOpen: boolean;
37
+ }, __VLS_3: {
38
+ item: {
39
+ value: string;
40
+ label?: string | undefined;
41
+ };
42
+ isOpen: boolean;
43
+ };
44
+ type __VLS_Slots = {} & {
45
+ header?: (props: typeof __VLS_1) => any;
46
+ } & {
47
+ panel?: (props: typeof __VLS_3) => any;
48
+ };
49
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
50
+ "update:modelValue": (value: string[]) => any;
51
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
52
+ "onUpdate:modelValue"?: ((value: string[]) => any) | undefined;
53
+ }>, {
54
+ idPrefix: string;
55
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, __VLS_Slots>;
56
+ export default _default;
57
+ type __VLS_WithSlots<T, S> = T & {
58
+ new (): {
59
+ $slots: S;
60
+ };
61
+ };
@@ -1,15 +1,19 @@
1
1
  import type { DataPointMeta, SourceChoice } from "../types";
2
2
  /**
3
3
  * The Inspector — per-data-point detail dialog. 90vw × 90vh danx-ui DanxDialog
4
- * with a hero strip (resolved value, confidence meter, source-of-truth chips,
5
- * discrepancy alert) over three tabs:
4
+ * with a hero strip (resolved value, confidence meter, source of truth,
5
+ * discrepancy alert) over four tabs:
6
6
  *
7
- * - Evidence: reasoning (readonly MarkdownEditor), cited text, and an embedded
8
- * DanxFileViewer over the cited source pages, plus per-distinct-document
9
- * "view full document" drill-downs (stacked DanxDialogs — breadcrumb back-nav
10
- * comes free from danx-ui's dialog stack).
7
+ * - Citations: why this value, then one collapsible section per cited SOURCE
8
+ * PAGE carrying that page's own verbatim quotes, each openable full screen
9
+ * (zoomable, downloadable) with the page's quotes alongside. Replaces the
10
+ * retired treatment that flattened every quote from every page into one
11
+ * blockquote, which made page attribution unrecoverable.
11
12
  * - Candidates: the resolution flow — one card per candidate with an Accept
12
13
  * action, plus custom-value entry. Saving toasts + flips the in-document pill.
14
+ * - History: the live value's confidence + reasoning above the full extraction
15
+ * history; every attempt (winner, losers, FAILED) collapses to a summary row
16
+ * and expands to its own reasoning and page-grouped citations.
13
17
  * - Audit trail: lazily fetched LLM calls (token-sealed host endpoint) rendered
14
18
  * as AuditCallCards; hidden entirely when the host minted no audit_url.
15
19
  *
package/dist/index.d.ts CHANGED
@@ -14,13 +14,16 @@ export { default as VerificationChrome } from "./components/VerificationChrome.v
14
14
  export { default as ConfidenceIcon } from "./components/ConfidenceIcon.vue";
15
15
  export { default as VerificationModal } from "./components/VerificationModal.vue";
16
16
  export { default as ComparisonPage } from "./components/ComparisonPage.vue";
17
+ export { default as CitationEvidence } from "./components/CitationEvidence.vue";
18
+ export { default as CitationPageList } from "./components/CitationPageList.vue";
19
+ export { default as CitationPage } from "./components/CitationPage.vue";
17
20
  export { bucketConfidence, STATUS_COLORS, STATUS_LABELS, } from "./lib/confidence";
18
- export { resolveDataPoint, resolveCandidates, reasoningOf, citedTextOf, RESOLUTION_PRIORITY, } from "./lib/resolveDataPoint";
21
+ export { resolveDataPoint, resolveCandidates, reasoningOf, RESOLUTION_PRIORITY, } from "./lib/resolveDataPoint";
19
22
  export { hasDiscrepancy, candidatesDisagree } from "./lib/discrepancy";
20
23
  export { walkDataPoints } from "./lib/walk";
21
24
  export type { WalkedDataPoint } from "./lib/walk";
22
- export { groupSources, sourceRowLabel } from "./lib/sources";
23
- export type { SourceGroup } from "./lib/sources";
25
+ export { citationEvidence, citationSummary } from "./lib/citations";
26
+ export type { CitationPage as CitationPageModel, CitationEvidence as CitationEvidenceModel } from "./lib/citations";
24
27
  export { computeProgress } from "./lib/progress";
25
28
  export type { VerificationProgress } from "./lib/progress";
26
29
  export { fetchDataPointAudit } from "./lib/audit";
@@ -0,0 +1,84 @@
1
+ import type { PreviewFile } from "@thehammer/danx-ui";
2
+ import type { VerificationSource } from "../types";
3
+ /**
4
+ * One cited PAGE of a source document, with the verbatim quotes taken from it.
5
+ *
6
+ * This is the unit the extraction pipeline actually records: `sources[]` holds one
7
+ * row per cited page, and that row carries its OWN ordered `texts[]` (SG-181). The
8
+ * retired `groupSources()` model grouped by "file identity" and left the quotes
9
+ * flattened across the whole candidate, so a reviewer could never tell which page a
10
+ * given quote came from — the defect this model exists to remove.
11
+ *
12
+ * Two source rows that cite the SAME page image merge into one page, their quotes
13
+ * concatenated in source order.
14
+ */
15
+ export interface CitationPage {
16
+ /** Stable merge/render key — same page image ⇒ same key. */
17
+ key: string;
18
+ /** Page position inside the parent document, when the host resolved one. */
19
+ pageNumber: number | null;
20
+ /** Human label: "Page 4", else the file name, else a neutral fallback. */
21
+ label: string;
22
+ /** The parent document's name, when known — shown as the page's context. */
23
+ documentName: string | null;
24
+ /**
25
+ * The page image itself, danx-ui `PreviewFile`-shaped, carrying `page_number`
26
+ * so the viewer's own `sortByPageNumber()` orders a multi-page citation
27
+ * correctly. Null when the host did not resolve a file for this source — the
28
+ * quotes still render, the view/download affordances do not.
29
+ */
30
+ file: PreviewFile | null;
31
+ /**
32
+ * A direct URL to this page, from either host shape (`file.url`, else the
33
+ * idealized `file_url`). Null when the host resolved neither — a plain-text
34
+ * listing then names the page without linking it.
35
+ */
36
+ url: string | null;
37
+ /** The FULL parent document (the whole PDF), when this page is a transcode child. */
38
+ document: PreviewFile | null;
39
+ /** This page's ordered verbatim quotes, duplicates removed. */
40
+ quotes: string[];
41
+ /** Any non-empty `explanation` recorded against this page. */
42
+ explanations: string[];
43
+ /** The source row ids that merged into this page. */
44
+ sourceIds: Array<number | string>;
45
+ }
46
+ /** The full citation picture for one candidate (or one history attempt). */
47
+ export interface CitationEvidence {
48
+ /** Cited pages, ordered by page number, then by input order. */
49
+ pages: CitationPage[];
50
+ /** Distinct parent documents across every cited page. */
51
+ documents: PreviewFile[];
52
+ /** The LLM calls that produced this citation — the audit-trail anchor. */
53
+ apiLogIds: Array<number | string>;
54
+ /**
55
+ * Citation sources the correction loop could never resolve to a real page
56
+ * (`source_type: 'failed_file'`). Surfaced rather than dropped — recording
57
+ * them instead of discarding them is the whole point of that source type.
58
+ */
59
+ unresolved: VerificationSource[];
60
+ pageCount: number;
61
+ quoteCount: number;
62
+ /** True when there is nothing at all to show — no page, no unresolved citation. */
63
+ isEmpty: boolean;
64
+ }
65
+ /**
66
+ * Build the citation picture for a candidate's `sources[]`.
67
+ *
68
+ * Sources are classified by kind before anything is grouped, so provenance rows
69
+ * never masquerade as evidence:
70
+ *
71
+ * - `failed_file` → `unresolved` (an unresolvable citation, shown as a warning)
72
+ * - `api_log` → `apiLogIds` (the LLM call behind the citation)
73
+ * - `user` → dropped (a human override is not a citation)
74
+ * - anything else → a cited page, merged by page identity
75
+ *
76
+ * A source with quotes but no resolvable file still becomes a page, so a quote is
77
+ * never silently discarded for want of a thumbnail.
78
+ *
79
+ * Tolerates both host shapes: the live gpt-manager payload (`file` + `page_number`)
80
+ * and the idealized document-page shape (`file_url` / `file_name` / `page`).
81
+ */
82
+ export declare function citationEvidence(sources?: VerificationSource[] | null): CitationEvidence;
83
+ /** "2 pages · 5 quotes" — the one-line summary used in tab badges and headers. */
84
+ export declare function citationSummary(evidence: CitationEvidence): string;
@@ -22,8 +22,3 @@ export declare function resolveCandidates(candidates?: CandidateSet | null): Res
22
22
  * Reasoning is frequently `""`/null — callers render a quiet empty state, never throw.
23
23
  */
24
24
  export declare function reasoningOf(meta?: DataPointMeta | null): string | null;
25
- /**
26
- * The extracted candidate's cited text, normalized to a non-empty string or null.
27
- * Like reasoning, cited_text is graceful-empty.
28
- */
29
- export declare function citedTextOf(meta?: DataPointMeta | null): string | null;