@tangle-network/agent-app 0.57.18 → 0.57.20
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/VaultPane-UHLJSIND.js +7 -0
- package/dist/assistant/index.js +5 -4
- package/dist/assistant/index.js.map +1 -1
- package/dist/channels/index.js +1 -1
- package/dist/chunk-3NVVBQ2U.js +131 -0
- package/dist/chunk-3NVVBQ2U.js.map +1 -0
- package/dist/{chunk-EPZYYWCT.js → chunk-6ZIC6OG5.js} +8 -2
- package/dist/{chunk-EPZYYWCT.js.map → chunk-6ZIC6OG5.js.map} +1 -1
- package/dist/{chunk-OGFDE4IR.js → chunk-E2HFIKIZ.js} +2 -2
- package/dist/{chunk-Q3ZHNN5X.js → chunk-LSUELMHY.js} +2 -2
- package/dist/chunk-LSUELMHY.js.map +1 -0
- package/dist/{chunk-IOUPOUYB.js → chunk-XADC73A7.js} +2 -2
- package/dist/chunk-XADC73A7.js.map +1 -0
- package/dist/copy-quality/index.d.ts +81 -0
- package/dist/copy-quality/index.js +283 -0
- package/dist/copy-quality/index.js.map +1 -0
- package/dist/integrations-react/index.js +1 -1
- package/dist/legibility/cli.js +1 -1
- package/dist/legibility/index.js +1 -1
- package/dist/vault/index.js +1 -1
- package/dist/vault/lazy.js +1 -1
- package/dist/web-react/async/index.js +1 -1
- package/dist/web-react/async/state.d.ts +1 -1
- package/dist/web-react/index.js +2 -2
- package/dist/work-product/index.js +12 -118
- package/dist/work-product/index.js.map +1 -1
- package/package.json +6 -1
- package/dist/VaultPane-SDNMDGFC.js +0 -7
- package/dist/chunk-IOUPOUYB.js.map +0 -1
- package/dist/chunk-Q3ZHNN5X.js.map +0 -1
- /package/dist/{VaultPane-SDNMDGFC.js.map → VaultPane-UHLJSIND.js.map} +0 -0
- /package/dist/{chunk-OGFDE4IR.js.map → chunk-E2HFIKIZ.js.map} +0 -0
package/dist/channels/index.js
CHANGED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// src/work-product/claim-support.ts
|
|
2
|
+
var CURRENCY = /[$€£¥₹]/gu;
|
|
3
|
+
var NUMBER_IN_TEXT = /[$€£¥₹]?\s*\d{1,3}(?:,\d{3})+(?:\.\d+)?|[$€£¥₹]?\s*\d+(?:\.\d+)?/gu;
|
|
4
|
+
var FIGURE_IN_PROSE = /[$€£¥₹]\s*[-+]?\d[\d,]*(?:\.\d+)?|[-+]?\d{1,3}(?:,\d{3})+(?:\.\d+)?|[-+]?\d+\.\d{2}(?!\d)/gu;
|
|
5
|
+
var WHOLE_VALUE = /^[$€£¥₹]?\s*[-+]?\s*(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?\s*%?$/u;
|
|
6
|
+
function canonicalizeValue(token) {
|
|
7
|
+
let text = token.trim();
|
|
8
|
+
if (text.length === 0) return null;
|
|
9
|
+
if (/^\(.*\)$/u.test(text)) text = text.slice(1, -1).trim();
|
|
10
|
+
text = text.replace(CURRENCY, "").trim();
|
|
11
|
+
text = text.replace(/^[-+]\s*/u, "").trim();
|
|
12
|
+
text = text.replace(/%$/u, "").trim();
|
|
13
|
+
if (!/^(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?$/u.test(text)) return null;
|
|
14
|
+
text = text.replace(/,/gu, "");
|
|
15
|
+
if (text.includes(".")) text = text.replace(/0+$/u, "").replace(/\.$/u, "");
|
|
16
|
+
text = text.replace(/^0+(?=\d)/u, "");
|
|
17
|
+
return text.length === 0 ? null : text;
|
|
18
|
+
}
|
|
19
|
+
function valuesInText(text) {
|
|
20
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21
|
+
for (const match of text.matchAll(NUMBER_IN_TEXT)) {
|
|
22
|
+
const canonical = canonicalizeValue(match[0]);
|
|
23
|
+
if (canonical !== null) seen.add(canonical);
|
|
24
|
+
}
|
|
25
|
+
return [...seen];
|
|
26
|
+
}
|
|
27
|
+
function claimValues(claim) {
|
|
28
|
+
const trimmed = claim.trim();
|
|
29
|
+
if (WHOLE_VALUE.test(trimmed)) {
|
|
30
|
+
const whole = canonicalizeValue(trimmed);
|
|
31
|
+
if (whole !== null) return [whole];
|
|
32
|
+
}
|
|
33
|
+
const seen = /* @__PURE__ */ new Set();
|
|
34
|
+
for (const match of trimmed.matchAll(FIGURE_IN_PROSE)) {
|
|
35
|
+
const canonical = canonicalizeValue(match[0]);
|
|
36
|
+
if (canonical !== null) seen.add(canonical);
|
|
37
|
+
}
|
|
38
|
+
return [...seen];
|
|
39
|
+
}
|
|
40
|
+
function verifyClaimSupport(quote, claim) {
|
|
41
|
+
if (quote.trim().length === 0) return { status: "not_applicable" };
|
|
42
|
+
const claimed = claimValues(claim);
|
|
43
|
+
if (claimed.length === 0) return { status: "not_applicable" };
|
|
44
|
+
const present = valuesInText(quote);
|
|
45
|
+
const matched = claimed.find((value) => present.includes(value));
|
|
46
|
+
if (matched !== void 0) return { status: "supported", matched };
|
|
47
|
+
return { status: "unsupported", claimed, present };
|
|
48
|
+
}
|
|
49
|
+
function excerpt(quote, limit = 120) {
|
|
50
|
+
const flat = quote.replace(/\s+/gu, " ").trim();
|
|
51
|
+
return flat.length <= limit ? flat : `${flat.slice(0, limit)}\u2026`;
|
|
52
|
+
}
|
|
53
|
+
function claimSupportErrorDetail(failure, quote) {
|
|
54
|
+
const wanted = failure.claimed.length === 1 ? failure.claimed[0] : `any of ${failure.claimed.join(", ")}`;
|
|
55
|
+
const carries = failure.present.length === 0 ? "that line carries no figure at all" : `the only figures on it are ${failure.present.join(", ")}`;
|
|
56
|
+
return `the cited text does not contain ${wanted}. It reads "${excerpt(quote)}", and ${carries}. Cite locator.find with the value exactly as it appears in the document and the platform will locate the right line for you. If this figure was COMPUTED rather than read from the document, omit the locator entirely and state the computation in claim.`;
|
|
57
|
+
}
|
|
58
|
+
function foldLabel(value) {
|
|
59
|
+
return value.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
60
|
+
}
|
|
61
|
+
function verifyTargetLabel(quote, target, groups) {
|
|
62
|
+
if (quote.trim().length === 0) return { status: "not_applicable" };
|
|
63
|
+
const group = groups.find((candidate) => Object.hasOwn(candidate.labels, target));
|
|
64
|
+
if (!group) return { status: "not_applicable" };
|
|
65
|
+
const line = ` ${foldLabel(quote)} `;
|
|
66
|
+
const own = group.labels[target] ?? [];
|
|
67
|
+
for (const label of own) {
|
|
68
|
+
const folded = foldLabel(label);
|
|
69
|
+
if (folded.length > 0 && line.includes(folded)) return { status: "identified", label };
|
|
70
|
+
}
|
|
71
|
+
for (const [rival, labels] of Object.entries(group.labels)) {
|
|
72
|
+
if (rival === target) continue;
|
|
73
|
+
for (const label of labels) {
|
|
74
|
+
const folded = foldLabel(label);
|
|
75
|
+
if (folded.length === 0 || !line.includes(folded)) continue;
|
|
76
|
+
return {
|
|
77
|
+
status: "crossed",
|
|
78
|
+
rival,
|
|
79
|
+
rivalLabel: label,
|
|
80
|
+
expected: own,
|
|
81
|
+
...group.note === void 0 ? {} : { note: group.note }
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { status: "not_applicable" };
|
|
86
|
+
}
|
|
87
|
+
function targetLabelErrorDetail(failure, target, quote) {
|
|
88
|
+
const ownLooks = failure.expected.length === 0 ? "" : ` A citation for ${target} should land on the line naming ${failure.expected.map((label) => JSON.stringify(label)).join(" or ")}.`;
|
|
89
|
+
const note = failure.note === void 0 ? "" : ` (${failure.note})`;
|
|
90
|
+
return `the line it cites reads "${excerpt(quote)}", which is the line for ${failure.rival} \u2014 it names ${JSON.stringify(failure.rivalLabel)}${note}.${ownLooks} Cite the line that belongs to this target, or attach this citation to ${failure.rival} instead. The figure is real; it is on the wrong line.`;
|
|
91
|
+
}
|
|
92
|
+
function indexArtifactValues(fields, normalizeTarget) {
|
|
93
|
+
const index = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const [key, raw] of Object.entries(fields ?? {})) {
|
|
95
|
+
const value = typeof raw === "number" && Number.isFinite(raw) ? canonicalizeValue(String(raw)) : typeof raw === "string" ? canonicalizeValue(raw) : null;
|
|
96
|
+
if (value === null) continue;
|
|
97
|
+
index.set(normalizeTarget ? normalizeTarget(key) : key, value);
|
|
98
|
+
}
|
|
99
|
+
return index;
|
|
100
|
+
}
|
|
101
|
+
function verifyArtifactAgreement(target, claim, fieldValues) {
|
|
102
|
+
const expected = fieldValues.get(target);
|
|
103
|
+
if (expected === void 0) return { status: "not_applicable" };
|
|
104
|
+
const claimed = claimValues(claim);
|
|
105
|
+
if (claimed.length === 0) return { status: "not_applicable" };
|
|
106
|
+
if (claimed.includes(expected)) return { status: "agrees", value: expected };
|
|
107
|
+
for (const value of claimed) {
|
|
108
|
+
for (const [other, otherValue] of fieldValues) {
|
|
109
|
+
if (other === target || otherValue !== value) continue;
|
|
110
|
+
return { status: "contradicts", claimed: value, expected, belongsTo: other };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { status: "not_applicable" };
|
|
114
|
+
}
|
|
115
|
+
function artifactAgreementErrorDetail(failure, target) {
|
|
116
|
+
return `the artifact reports ${failure.expected} on ${target} and ${failure.claimed} on ${failure.belongsTo}, so a citation claiming ${failure.claimed} does not support ${target} \u2014 it supports ${failure.belongsTo}. Attach this citation to ${failure.belongsTo}, or correct the artifact if ${target} really is ${failure.claimed}. The package cannot state both.`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
canonicalizeValue,
|
|
121
|
+
valuesInText,
|
|
122
|
+
claimValues,
|
|
123
|
+
verifyClaimSupport,
|
|
124
|
+
claimSupportErrorDetail,
|
|
125
|
+
verifyTargetLabel,
|
|
126
|
+
targetLabelErrorDetail,
|
|
127
|
+
indexArtifactValues,
|
|
128
|
+
verifyArtifactAgreement,
|
|
129
|
+
artifactAgreementErrorDetail
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=chunk-3NVVBQ2U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/work-product/claim-support.ts"],"sourcesContent":["/**\n * Claim support and target correctness — is this citation attached to the RIGHT\n * place, and does the text it names actually say what the entry claims?\n *\n * Three checks live here, each answering a different half of \"is this evidence\n * row honest\": {@link verifyClaimSupport} (claim ↔ cited text),\n * {@link verifyTargetLabel} (target ↔ cited line), and\n * {@link verifyArtifactAgreement} (claim ↔ the artifact field it decorates).\n * They share the numeric canonicalization below, which is why they share a\n * file — a second copy of \"what counts as the same figure\" is how two gates\n * drift into disagreeing about the same row.\n *\n * ── Check one: claim support ────────────────────────────────────────────────\n *\n * The two gates before this one answer different questions. `sourceContainsQuote`\n * asks whether the quote is really in the document; `findSourceLine` /\n * `sliceSourceSpan` make the platform produce the quote so it cannot be typed\n * wrong. Both are about the TEXT's provenance. Neither one looks at `claim`.\n *\n * Production row `7256ef49` is what that gap costs. Four evidence entries, all\n * `quoteBasis:'span'`, every quote a genuine slice of the document it named —\n * and every one landing on the employer/payer line about 200 characters above\n * the figure:\n *\n * claim 128450.00 -> \"tics LLC EIN 84-2213907\\nEmployee: Dana\"\n * claim 812.44 -> \"nt Savings Bank TIN 22-5510983\\nRecip\"\n * claim 2204.18 -> \"ndex Fund Trust TIN 47-3320115\\nRec\"\n * claim 1955.02 -> \"pient: Dana R. Whitfield\\n------------\"\n *\n * That is strictly worse than a fabricated quote. A fabricated quote fails the\n * verbatim gate; this one passes every gate, is real text from the right\n * document, and reads to a reviewer as an authoritative citation while\n * supporting nothing. `locator.find` (the platform locating a value the model\n * names) prevents the model from ADDRESSING the wrong line, and it is the right\n * primary fix. This module is the independent check underneath it: whatever\n * anchoring form produced the text, the text has to contain the figure.\n *\n * That also settles what a raw `locator.span` is worth. Hand-computed offsets\n * stay accepted, but only when they independently verify — which is exactly\n * \"the slice contains the claimed value\".\n *\n * ── The rule, and why it is drawn here ──────────────────────────────────────\n *\n * Strict on figures, silent on everything else. An unsatisfiable gate does not\n * stop a bad submit, it SELECTS for one — that is the measured mechanism behind\n * the 38 fabricated quotes on row `a68b1943`, where a coverage gate demanded\n * document lineage for computed values and got thirteen invented citations\n * forty seconds later. So the rule fires only where an honest citation can\n * always satisfy it:\n *\n * - The claim IS a value (`\"128450.00\"`, `\"$30,000\"`, `\"3\"`) — the anchored\n * text MUST contain that value. No latitude. This is the shape every tax\n * figure takes and the shape row `7256ef49` failed.\n * - The claim is prose naming figures (`\"indemnity capped at $5,000,000\"`) —\n * at least one of its currency-shaped figures must occur. Not all of them:\n * a claim may legitimately narrate a computation over several lines while\n * anchoring to the one line under discussion, and refusing that would make\n * an honest citation unrepresentable for the sake of a stricter-sounding\n * rule. One is enough to keep the anchor tethered to the claim's subject.\n * - The claim carries no figure at all (`\"Married Filing Jointly\"`,\n * `\"Dana R. Whitfield\"`, `\"2025-04-15\"`) — nothing to check, and the entry\n * passes. A filing status has no number to find, and inventing a\n * word-overlap score here would re-open the hole the verbatim gate closes.\n * - The entry has no anchored text at all — nothing to check. A computed\n * value cites its computation, not a document.\n *\n * A bare year, a form number and a box number are deliberately NOT figures:\n * `2025`, `1040` and `Box 1` have no thousands separator, no cent pair and no\n * currency symbol, so prose mentioning them does not trip the rule.\n *\n * ── Matching is value-wise, never substring ─────────────────────────────────\n *\n * `text.includes(claim)` would be the obvious implementation and it is wrong in\n * the direction that matters: it passes `\"450.00\"` against `\"128,450.00\"`, so a\n * claim citing the wrong figure survives whenever its digits happen to be a tail\n * of a real one. Both sides are tokenized into numbers and compared as VALUES,\n * so `450` and `128450` are simply different.\n */\n\n/** Currency marks stripped before a token is read as a number. */\nconst CURRENCY = /[$€£¥₹]/gu\n\n/**\n * Numbers as they occur in document text. The grouped form is tried first so\n * `128,450.00` is read as one value rather than `128` followed by `450.00` —\n * the whole point of comparing values instead of substrings.\n *\n * A leading `[$€£¥₹]?\\s*` is absorbed so `$ 1,200` tokenizes once, and the\n * dot-leaders typical of a form line (`Box 1 Wages ..... 128,450.00`) are not\n * digits, so they never join a token.\n */\nconst NUMBER_IN_TEXT = /[$€£¥₹]?\\s*\\d{1,3}(?:,\\d{3})+(?:\\.\\d+)?|[$€£¥₹]?\\s*\\d+(?:\\.\\d+)?/gu\n\n/**\n * A figure inside prose: a currency symbol, OR thousands separators, OR a cent\n * pair. Each of the three is a positive signal that the writer meant a\n * quantity rather than an identifier, which is what keeps `2025`, `1040` and\n * `Box 1` out.\n */\nconst FIGURE_IN_PROSE =\n /[$€£¥₹]\\s*[-+]?\\d[\\d,]*(?:\\.\\d+)?|[-+]?\\d{1,3}(?:,\\d{3})+(?:\\.\\d+)?|[-+]?\\d+\\.\\d{2}(?!\\d)/gu\n\n/** The whole string is one value: optional currency, sign, digits with\n * optional grouping and decimals, optional percent. Anchored, so an EIN\n * (`84-2213907`), a date (`2025-04-15`) and a range (`10-20`) are NOT values. */\nconst WHOLE_VALUE = /^[$€£¥₹]?\\s*[-+]?\\s*(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?\\s*%?$/u\n\n/**\n * Reduce a numeric token to the form both sides are compared in: no currency,\n * no grouping, no trailing zeros in the fraction, no leading zeros.\n *\n * Sign and accounting parentheses are stripped rather than preserved, so\n * `(1,234.00)`, `-1,234.00` and `1,234.00` all reduce to `1234`. A document\n * renders the same deduction all three ways depending on the form and the\n * extractor, and the sign is a property of the TARGET LINE's semantics, not of\n * the document's typography. Comparing magnitudes keeps those honest citations\n * working, and it concedes nothing to fabrication: the digits still have to be\n * the document's digits.\n *\n * Returns `null` for anything that is not a plain number.\n */\nexport function canonicalizeValue(token: string): string | null {\n let text = token.trim()\n if (text.length === 0) return null\n if (/^\\(.*\\)$/u.test(text)) text = text.slice(1, -1).trim()\n text = text.replace(CURRENCY, '').trim()\n text = text.replace(/^[-+]\\s*/u, '').trim()\n text = text.replace(/%$/u, '').trim()\n if (!/^(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?$/u.test(text)) return null\n text = text.replace(/,/gu, '')\n if (text.includes('.')) text = text.replace(/0+$/u, '').replace(/\\.$/u, '')\n text = text.replace(/^0+(?=\\d)/u, '')\n return text.length === 0 ? null : text\n}\n\n/** Every distinct value appearing in `text`, canonicalized. */\nexport function valuesInText(text: string): string[] {\n const seen = new Set<string>()\n for (const match of text.matchAll(NUMBER_IN_TEXT)) {\n const canonical = canonicalizeValue(match[0])\n if (canonical !== null) seen.add(canonical)\n }\n return [...seen]\n}\n\n/**\n * The values a claim asserts, canonicalized — empty when the claim asserts no\n * figure, which is the \"nothing to check\" case.\n *\n * A claim that is ENTIRELY one value yields that value (strict path). Otherwise\n * only currency-shaped figures inside the prose count, so an assertion that\n * merely mentions a year or a form number yields nothing.\n */\nexport function claimValues(claim: string): string[] {\n const trimmed = claim.trim()\n if (WHOLE_VALUE.test(trimmed)) {\n const whole = canonicalizeValue(trimmed)\n if (whole !== null) return [whole]\n }\n const seen = new Set<string>()\n for (const match of trimmed.matchAll(FIGURE_IN_PROSE)) {\n const canonical = canonicalizeValue(match[0])\n if (canonical !== null) seen.add(canonical)\n }\n return [...seen]\n}\n\nexport type ClaimSupport =\n /** No figure to check: a non-numeric claim, or no anchored text. */\n | { status: 'not_applicable' }\n | { status: 'supported'; matched: string }\n | { status: 'unsupported'; claimed: string[]; present: string[] }\n\n/**\n * Does `quote` carry the figure `claim` asserts?\n *\n * `supported` requires ONE claimed value to occur, which is exact for the\n * single-value claim (there is only one) and deliberate latitude for prose (see\n * the rule note at the top of the file).\n */\nexport function verifyClaimSupport(quote: string, claim: string): ClaimSupport {\n if (quote.trim().length === 0) return { status: 'not_applicable' }\n const claimed = claimValues(claim)\n if (claimed.length === 0) return { status: 'not_applicable' }\n const present = valuesInText(quote)\n const matched = claimed.find((value) => present.includes(value))\n if (matched !== undefined) return { status: 'supported', matched }\n return { status: 'unsupported', claimed, present }\n}\n\n/** Short, quotable rendering of the anchored text for an error message. */\nfunction excerpt(quote: string, limit = 120): string {\n const flat = quote.replace(/\\s+/gu, ' ').trim()\n return flat.length <= limit ? flat : `${flat.slice(0, limit)}…`\n}\n\n/**\n * The sentence a model can act on without re-reading the document: what it\n * claimed, what the line it cited actually says, what figures that line does\n * carry, and the two ways out — cite the value, or drop the locator because the\n * figure was computed. Naming both keeps the gate satisfiable, which is the\n * property that stops it manufacturing the citation it screens for.\n */\nexport function claimSupportErrorDetail(\n failure: Extract<ClaimSupport, { status: 'unsupported' }>,\n quote: string,\n): string {\n const wanted = failure.claimed.length === 1 ? failure.claimed[0]! : `any of ${failure.claimed.join(', ')}`\n const carries =\n failure.present.length === 0\n ? 'that line carries no figure at all'\n : `the only figures on it are ${failure.present.join(', ')}`\n return `the cited text does not contain ${wanted}. It reads \"${excerpt(quote)}\", and ${carries}. Cite locator.find with the value exactly as it appears in the document and the platform will locate the right line for you. If this figure was COMPUTED rather than read from the document, omit the locator entirely and state the computation in claim.`\n}\n\n// ── check two: target ↔ cited line ───────────────────────────────────────────\n\n/**\n * Does the cited line belong to the target the entry attaches it to?\n *\n * `verifyClaimSupport` asks whether the anchored text carries the claimed\n * figure. It is blind, BY CONSTRUCTION, to whether that figure belongs on that\n * line. Production row `95105c8a` is what the blindness costs — two entries,\n * both anchored to a real line of the right document, both carrying the figure\n * they claim, and both attached to the wrong form line:\n *\n * f1040.line_3b claim 1955.02 -> \"Box 1b Qualified dividends ..... 1,955.02\"\n * f1040.line_3a claim 2204.18 -> \"Box 1a Total ordinary dividends . 2,204.18\"\n *\n * Form 1040 line 3a is QUALIFIED dividends and line 3b is ORDINARY, so each\n * citation points a reviewer at the other one's line. `quote_verification`,\n * `claim_support` and `evidence_coverage` were all green on that row. A\n * citation that points at the wrong line is a wrong citation even when every\n * character of it is real, and it is the failure a reviewer is least able to\n * catch by eye, because it looks exactly like a good one.\n *\n * ── Why the domain supplies LABELS and the shell supplies the COMPARISON ────\n *\n * The shell cannot know that line 3a means qualified dividends; that is tax\n * vocabulary and baking it here would violate the one rule this package is\n * built on. So the product declares which targets are CONFUSABLE with each\n * other and what each one's line looks like in a source document — a\n * {@link ConfusableTargetGroup} — and the shell does the comparing.\n *\n * ── Why a group of labels, and not a per-target expectation ─────────────────\n *\n * The obvious shape is a per-target expectation read POSITIVELY: \"a citation\n * for line_3a must contain 'Qualified'\". It is stricter, it is easier to\n * explain, and it is the wrong shape, because it refuses honest work. A\n * consolidated broker statement writing \"Qual. div. income\", a payer writing\n * \"Dividends that are qualified\", an OCR layer dropping a word — each one turns\n * a correct citation into a refusal. And this codebase has already measured\n * what refusing honest work does: a coverage gate that demanded document\n * lineage for computed values produced 38 fabricated quotes on row `a68b1943`,\n * because a gate a model cannot satisfy honestly is a gate it satisfies\n * dishonestly. An unsatisfiable rule does not stop bad work; it SELECTS for\n * invented work.\n *\n * So the same labels are read NEGATIVELY and COMPARATIVELY. An entry is\n * refused only when the cited line positively identifies a SIBLING target and\n * says nothing that identifies its own:\n *\n * - the line carries one of the target's own labels → `identified`, pass\n * - the line carries no label from the group at all → `not_applicable`, pass\n * - the line carries a sibling's label and none of its own → `crossed`, refuse\n *\n * Silence therefore always passes. An unusually-labelled document costs\n * nothing, a target the product never grouped costs nothing, and the only way\n * to fail is for the document itself to say the line belongs to a different\n * target — which is not a phrasing accident, it is the crossed pair. The rule\n * is satisfiable by the honest citation in every case, and unsatisfiable only\n * by the wrong one.\n *\n * Matching is punctuation- and case-insensitive: a label is a semantic marker\n * for which LINE this is, not a quotation. (`sourceContainsQuote` stays exact —\n * different question, different tolerance.)\n */\n\n/** One set of targets whose source lines are mistakable for each other, with\n * the phrases that tell them apart. Every string is product vocabulary; the\n * shell reads none of them as meaning anything. */\nexport interface ConfusableTargetGroup {\n /** Named in the refusal so the model is told which distinction it missed\n * (\"Form 1099-DIV boxes 1a/1b\"). */\n note?: string\n /** Target → phrases that identify THAT target's line in a source document.\n * Targets must be spelled the way evidence targets are spelled after the\n * product's `normalizeTarget`, so one canonical name is written once. */\n labels: Record<string, readonly string[]>\n}\n\nexport type TargetLabelVerdict =\n /** No group covers this target, or the line says nothing either way. */\n | { status: 'not_applicable' }\n /** The cited line carries one of this target's own labels. */\n | { status: 'identified'; label: string }\n /** The cited line identifies a DIFFERENT target in the same group. */\n | { status: 'crossed'; rival: string; rivalLabel: string; expected: readonly string[]; note?: string }\n\n/** Fold for label matching: case- and punctuation-insensitive, whitespace\n * collapsed. `\"Box 1b Qualified dividends .....\"` and `\"qualified dividend\"`\n * meet here; nothing about the numbers on the line is touched. */\nfunction foldLabel(value: string): string {\n return value\n .normalize('NFKC')\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}]+/gu, ' ')\n .trim()\n}\n\nexport function verifyTargetLabel(\n quote: string,\n target: string,\n groups: readonly ConfusableTargetGroup[],\n): TargetLabelVerdict {\n if (quote.trim().length === 0) return { status: 'not_applicable' }\n const group = groups.find((candidate) => Object.hasOwn(candidate.labels, target))\n if (!group) return { status: 'not_applicable' }\n const line = ` ${foldLabel(quote)} `\n\n const own = group.labels[target] ?? []\n for (const label of own) {\n const folded = foldLabel(label)\n if (folded.length > 0 && line.includes(folded)) return { status: 'identified', label }\n }\n for (const [rival, labels] of Object.entries(group.labels)) {\n if (rival === target) continue\n for (const label of labels) {\n const folded = foldLabel(label)\n if (folded.length === 0 || !line.includes(folded)) continue\n return {\n status: 'crossed',\n rival,\n rivalLabel: label,\n expected: own,\n ...(group.note === undefined ? {} : { note: group.note }),\n }\n }\n }\n return { status: 'not_applicable' }\n}\n\n/** The sentence a model can act on: which line it actually cited, which target\n * that line belongs to, and what its own target's line looks like. */\nexport function targetLabelErrorDetail(\n failure: Extract<TargetLabelVerdict, { status: 'crossed' }>,\n target: string,\n quote: string,\n): string {\n const ownLooks =\n failure.expected.length === 0\n ? ''\n : ` A citation for ${target} should land on the line naming ${failure.expected.map((label) => JSON.stringify(label)).join(' or ')}.`\n const note = failure.note === undefined ? '' : ` (${failure.note})`\n return `the line it cites reads \"${excerpt(quote)}\", which is the line for ${failure.rival} — it names ${JSON.stringify(failure.rivalLabel)}${note}.${ownLooks} Cite the line that belongs to this target, or attach this citation to ${failure.rival} instead. The figure is real; it is on the wrong line.`\n}\n\n// ── check three: claim ↔ the artifact field it decorates ─────────────────────\n\n/**\n * Does the entry agree with the artifact it is evidence FOR?\n *\n * The two checks above compare evidence to the SOURCE. This one compares it to\n * the DELIVERABLE, and it needs no product vocabulary at all: when the artifact\n * states a value for a target and an evidence entry attached to that target\n * asserts a different one, the work product contradicts itself, and a reviewer\n * clicking that line is shown a figure the package does not report there.\n *\n * ── The rule, and the honest citation it must not refuse ────────────────────\n *\n * \"Claim must equal the field\" is the tempting rule and it is unsatisfiable for\n * every aggregated or derived line. Measured on production row `a68b1943`:\n * line 1a is 189,750.00 and its two evidence rows cite $128,450.00 and\n * $61,300.00 — one per W-2, which is exactly the lineage a reviewer wants.\n * Line 8 is a Schedule C net profit of 11,056.56 evidenced by gross receipts of\n * 14,750.00 and four expense lines. Refusing those would delete correct work\n * and, on this codebase's measured history, buy invented citations in its place.\n *\n * So the refusal is narrower and it is a CONTRADICTION rather than an\n * inequality: the claim asserts a figure that the artifact itself assigns to a\n * DIFFERENT target. On row `95105c8a` that is precisely the crossed pair —\n * `line_3a` is 1955.02 in the artifact and its evidence claims 2204.18, which\n * the same artifact reports on `line_3b`. There is no honest reading of that:\n * the package cannot simultaneously say the number belongs on 3b and offer it\n * as the support for 3a.\n *\n * A component that appears nowhere else in the field map (128,450.00 of a\n * 189,750.00 total) is not a contradiction and is not refused. A claim\n * narrating a computation passes as soon as one of its figures is the target's\n * own value, which is what a narration of line 9 does by definition.\n */\n\n/** Canonical target → canonical value, for the artifact fields that state a\n * figure. Non-numeric fields are dropped: a filing status or a name has no\n * numeric contradiction to detect, and inventing a string comparison here\n * would re-open the fuzzy-matching hole the quote gate closes. */\nexport function indexArtifactValues(\n fields: Readonly<Record<string, unknown>> | undefined,\n normalizeTarget?: (target: string) => string,\n): Map<string, string> {\n const index = new Map<string, string>()\n for (const [key, raw] of Object.entries(fields ?? {})) {\n const value =\n typeof raw === 'number' && Number.isFinite(raw)\n ? canonicalizeValue(String(raw))\n : typeof raw === 'string'\n ? canonicalizeValue(raw)\n : null\n if (value === null) continue\n index.set(normalizeTarget ? normalizeTarget(key) : key, value)\n }\n return index\n}\n\nexport type ArtifactAgreement =\n /** The artifact states no figure for this target, or the claim asserts none. */\n | { status: 'not_applicable' }\n | { status: 'agrees'; value: string }\n /** The claim asserts a figure the artifact reports on a different target. */\n | { status: 'contradicts'; claimed: string; expected: string; belongsTo: string }\n\nexport function verifyArtifactAgreement(\n target: string,\n claim: string,\n fieldValues: ReadonlyMap<string, string>,\n): ArtifactAgreement {\n const expected = fieldValues.get(target)\n if (expected === undefined) return { status: 'not_applicable' }\n const claimed = claimValues(claim)\n if (claimed.length === 0) return { status: 'not_applicable' }\n if (claimed.includes(expected)) return { status: 'agrees', value: expected }\n for (const value of claimed) {\n for (const [other, otherValue] of fieldValues) {\n if (other === target || otherValue !== value) continue\n return { status: 'contradicts', claimed: value, expected, belongsTo: other }\n }\n }\n return { status: 'not_applicable' }\n}\n\n/** The sentence a model can act on: both numbers, both lines, and the two ways\n * out — move the citation, or correct the artifact. */\nexport function artifactAgreementErrorDetail(\n failure: Extract<ArtifactAgreement, { status: 'contradicts' }>,\n target: string,\n): string {\n return `the artifact reports ${failure.expected} on ${target} and ${failure.claimed} on ${failure.belongsTo}, so a citation claiming ${failure.claimed} does not support ${target} — it supports ${failure.belongsTo}. Attach this citation to ${failure.belongsTo}, or correct the artifact if ${target} really is ${failure.claimed}. The package cannot state both.`\n}\n"],"mappings":";AAgFA,IAAM,WAAW;AAWjB,IAAM,iBAAiB;AAQvB,IAAM,kBACJ;AAKF,IAAM,cAAc;AAgBb,SAAS,kBAAkB,OAA8B;AAC9D,MAAI,OAAO,MAAM,KAAK;AACtB,MAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,MAAI,YAAY,KAAK,IAAI,EAAG,QAAO,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK;AAC1D,SAAO,KAAK,QAAQ,UAAU,EAAE,EAAE,KAAK;AACvC,SAAO,KAAK,QAAQ,aAAa,EAAE,EAAE,KAAK;AAC1C,SAAO,KA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,OAAW,QAAO,EAAE,QAAQ,iBAAiB;AAC9D,QAAM,UAAU,YAAY,KAAK;AACjC,MAAI,QAAQ,WAAW,EAAG,QAAO,EAAE,QAAQ,iBAAiB;AAC5D,MAAI,QAAQ,SAAS,QAAQ,EAAG,QAAO,EAAE,QAAQ,UAAU,OAAO,SAAS;AAC3E,aAAW,SAAS,SAAS;AAC3B,eAAW,CAAC,OAAO,UAAU,KAAK,aAAa;AAC7C,UAAI,UAAU,UAAU,eAAe,MAAO;AAC9C,aAAO,EAAE,QAAQ,eAAe,SAAS,OAAO,UAAU,WAAW,MAAM;AAAA,IAC7E;AAAA,EACF;AACA,SAAO,EAAE,QAAQ,iBAAiB;AACpC;AAIO,SAAS,6BACd,SACA,QACQ;AACR,SAAO,wBAAwB,QAAQ,QAAQ,OAAO,MAAM,QAAQ,QAAQ,OAAO,OAAO,QAAQ,SAAS,4BAA4B,QAAQ,OAAO,qBAAqB,MAAM,uBAAkB,QAAQ,SAAS,6BAA6B,QAAQ,SAAS,gCAAgC,MAAM,cAAc,QAAQ,OAAO;AACvU;","names":[]}
|
|
@@ -1090,7 +1090,13 @@ var DEFAULT_BANNED_TERMS = [
|
|
|
1090
1090
|
{ term: "itemKey", instead: "an internal field name \u2014 write the label the reader reads" },
|
|
1091
1091
|
{ term: "payload", instead: 'name what was sent: "your answers", "the document"' },
|
|
1092
1092
|
{ term: "null", instead: "a value the code failed to fill \u2014 render the real value or written fallback copy" },
|
|
1093
|
-
{ term: "undefined", instead: "a value the code failed to fill \u2014 render the real value or written fallback copy" }
|
|
1093
|
+
{ term: "undefined", instead: "a value the code failed to fill \u2014 render the real value or written fallback copy" },
|
|
1094
|
+
// Microcopy bans from nutlope/hallmark (MIT, revision 13ac0ec7e148655948100b6396439e481361d690,
|
|
1095
|
+
// skills/hallmark/references/copy.md). "Something went wrong" shipped as this kit's own fallback.
|
|
1096
|
+
{ term: "Oops", instead: 'say what broke and what to do: "That file is over 25 MB. Upload a smaller one."' },
|
|
1097
|
+
{ term: "Uh oh", instead: 'say what broke and what to do: "That file is over 25 MB. Upload a smaller one."' },
|
|
1098
|
+
{ term: "Something went wrong", instead: 'name the thing that broke and the next step: "The upload stopped. Try again."' },
|
|
1099
|
+
{ term: "Click here", instead: 'link text that stands alone: "View pricing plans"' }
|
|
1094
1100
|
];
|
|
1095
1101
|
var COPY_KEYS = [
|
|
1096
1102
|
"title",
|
|
@@ -1453,4 +1459,4 @@ export {
|
|
|
1453
1459
|
legibilityReportToJson,
|
|
1454
1460
|
checkLegibility
|
|
1455
1461
|
};
|
|
1456
|
-
//# sourceMappingURL=chunk-
|
|
1462
|
+
//# sourceMappingURL=chunk-6ZIC6OG5.js.map
|