@clien-ai/mcp 0.11.0 → 0.12.1
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/CHANGELOG.md +50 -0
- package/README.md +26 -8
- package/dist/hypothesis-semantics.js +230 -0
- package/dist/hypothesis-semantics.js.map +1 -0
- package/dist/tools/collections.js +183 -68
- package/dist/tools/collections.js.map +1 -1
- package/dist/tools/hypothesis-final.js +55 -0
- package/dist/tools/hypothesis-final.js.map +1 -0
- package/dist/tools/interview-scripts.js +50 -21
- package/dist/tools/interview-scripts.js.map +1 -1
- package/dist/tools/market-signals.js +121 -0
- package/dist/tools/market-signals.js.map +1 -0
- package/dist/tools/market-sizing-proof.js +9 -3
- package/dist/tools/market-sizing-proof.js.map +1 -1
- package/dist/tools/output-schemas.js +20 -11
- package/dist/tools/output-schemas.js.map +1 -1
- package/dist/tools/registry.js +54 -40
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/report-digest.js +471 -73
- package/dist/tools/report-digest.js.map +1 -1
- package/dist/tools/research.js +28 -3
- package/dist/tools/research.js.map +1 -1
- package/dist/tools/scoped-research.js +62 -56
- package/dist/tools/scoped-research.js.map +1 -1
- package/dist/tools/status.js +46 -2
- package/dist/tools/status.js.map +1 -1
- package/dist/types/report.js +518 -22
- package/dist/types/report.js.map +1 -1
- package/dist/types/semantic-theme.js +43 -0
- package/dist/types/semantic-theme.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,56 @@ upgrade here does not imply the deployed app speaks the same shape, and the
|
|
|
13
13
|
client strips unknown fields by construction — so a field described below only
|
|
14
14
|
reaches you once both sides have shipped.
|
|
15
15
|
|
|
16
|
+
## 0.12.0
|
|
17
|
+
|
|
18
|
+
**Hypothesis confidence now means how reliable the final verdict is, not the
|
|
19
|
+
probability that the hypothesis is true.** The report and interview-script
|
|
20
|
+
tools expose the same effective verdict after robustness checks, with separate
|
|
21
|
+
evidence sufficiency and robustness outcomes. This is a minor release because
|
|
22
|
+
the `structuredContent.interviewScripts[].confidence` field changes from a
|
|
23
|
+
number to `low` / `medium` / `high`; integrations reading structured output
|
|
24
|
+
must handle the new categorical shape.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **Interview scripts rank what most needs a real answer.** Product priority,
|
|
29
|
+
lower verdict reliability, and thinner evidence replace the old distance from
|
|
30
|
+
0.5 ordering, which incorrectly treated a model-written score as a posterior
|
|
31
|
+
probability.
|
|
32
|
+
- **Every report-facing MCP reader resolves one final hypothesis result.** A
|
|
33
|
+
robustness downgrade or flip cannot retain contradictory high confidence,
|
|
34
|
+
and malformed robustness output cannot upgrade a result.
|
|
35
|
+
- **Legacy numeric confidence remains explicit and non-comparable.** In
|
|
36
|
+
`list_interview_scripts`, an older app response's 0–1 or 0–100 value moves to
|
|
37
|
+
`legacyConfidence` rather than mixing with the categorical measure. Report
|
|
38
|
+
data keeps that compatibility value at `hypothesisResults[].confidence` and
|
|
39
|
+
treats it as legacy beside `hypothesisResults[].final.confidence`.
|
|
40
|
+
- **Research tools drain every terminal event page before returning.** Full and
|
|
41
|
+
scoped runs no longer stop at the first bounded snapshot when later terminal
|
|
42
|
+
events carry the authoritative outcome.
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- **Final hypothesis semantics in structured report output:** categorical
|
|
47
|
+
verdict reliability, evidence sufficiency, robustness outcome, and preserved
|
|
48
|
+
original/final state for audit.
|
|
49
|
+
- **Literal trust states and denominators.** Successful checks that found
|
|
50
|
+
nothing now say so, while report-prose and digest claim populations are
|
|
51
|
+
labelled separately instead of appearing to contradict one another.
|
|
52
|
+
- **Bounded status-snapshot disclosure.** `clien_research_status` adds
|
|
53
|
+
`_meta.snapshot_truncated` when newer events exist beyond the returned page.
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
- **Markdown and digest readers no longer disagree with stored or visible
|
|
58
|
+
hypothesis outcomes.** Shared resolution and position-specific escaping keep
|
|
59
|
+
the final verdict coherent without corrupting receipt text.
|
|
60
|
+
- **Failed and cancelled runs surface the latest observed refund status with
|
|
61
|
+
bounded guidance.** Full and scoped research now use the drained terminal
|
|
62
|
+
events for error, refunded-credit, and refund-pending guidance.
|
|
63
|
+
`refund_pending` means the run is refund-eligible but no refund is visible
|
|
64
|
+
yet; it is not a guarantee that a refund will occur.
|
|
65
|
+
|
|
16
66
|
## 0.11.0
|
|
17
67
|
|
|
18
68
|
**A claim grounded on the second excerpt of a discussion now shows the second
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ competitors, and key findings) with a typed
|
|
|
8
8
|
[trust layer](#trust-signals) — per-claim GROUNDED/SPECULATION/NO_RECEIPT
|
|
9
9
|
classifications, source receipts, and robustness survival counts.
|
|
10
10
|
|
|
11
|
-
Alongside it, [
|
|
11
|
+
Alongside it, [the rest of the toolset](#tools) lets an agent read and edit what a project
|
|
12
12
|
already holds — projects, personas, interviews, reports, competitors, and
|
|
13
13
|
community signals — most of them free.
|
|
14
14
|
|
|
@@ -86,7 +86,24 @@ Restart Claude Code. First call triggers OAuth.
|
|
|
86
86
|
{ "name": "...", "sources": [{ "url": "...", "platform": "Hacker News", "quote": "...", "retrievedAt": "..." }] }
|
|
87
87
|
],
|
|
88
88
|
"hypothesisResults": [
|
|
89
|
-
{
|
|
89
|
+
{
|
|
90
|
+
"hypothesisId": "h1",
|
|
91
|
+
// Legacy compatibility fields: preserve, but do not rank or compare them.
|
|
92
|
+
"status": "validated", "confidence": 0.82,
|
|
93
|
+
// The authoritative effective result on current reports.
|
|
94
|
+
"final": {
|
|
95
|
+
"version": 1, "verdict": "validated", "originalVerdict": "validated",
|
|
96
|
+
"confidence": "high", "confidenceBasis": "evidence",
|
|
97
|
+
"sufficiency": "substantial", "robustness": "held", "priority": "high"
|
|
98
|
+
},
|
|
99
|
+
// Raw re-ask detail retained for audit; `final` above owns the effective result.
|
|
100
|
+
"robustness": {
|
|
101
|
+
"originalStatus": "validated", "survived": 1, "total": 1, "flipped": false,
|
|
102
|
+
"variants": [
|
|
103
|
+
{ "framing": "...", "returnedStatus": "validated", "returnedConfidence": 0.84, "agreed": true, "reasoning": "..." }
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
90
107
|
],
|
|
91
108
|
"sycophancySignals": { "lowDiscriminationCount": 0, "totalRejections": 2, "personaSignals": [...], "disagreements": [...] },
|
|
92
109
|
"openQuestions": [
|
|
@@ -184,7 +201,8 @@ a finding is, rather than taking the prose at face value:
|
|
|
184
201
|
| `personas[].sources[].receipts[]` | Present only when **one discussion yielded several excerpts**. Each child is `{ receiptId, excerpt, retrievedAt }`, and `receiptId` is content-addressed from the normalized URL plus the exact excerpt. A claim addressing one shows a second id after `·` on its digest line, and the receipt pool hangs that excerpt off the source's single row on its own `↳` line — read that, not the row's first excerpt, as what the claim was checked against. The source still counts as **one** discussion; several excerpts never inflate the breadth. A `receiptId` that does not resolve under its own source loses the receipt arrow entirely rather than falling back. |
|
|
185
202
|
| `methodology.redditRetrieval` | Present only on runs that recorded it. The frozen, code-stamped outcome of the Reddit community-evidence pass: `completed`, `completed_empty`, `completed_partial`, `failed` or `not_run`, with a bounded reason code and accepted discussion / excerpt counts. **Absent means unrecorded** — not disabled, not empty, not failed. The digest renders a sentence for the four states a reader has to act on and says nothing for `not_run` or unrecorded. |
|
|
186
203
|
| `personas[].qaFlagged` / `insufficientEvidence` / `sourcesFound` | Per-persona quality flags: `qaFlagged` means the persona failed a QA check; `insufficientEvidence` / `sourcesFound` tell you whether a `NO_RECEIPT` reflects a weak claim or just a thin evidence base. |
|
|
187
|
-
| `hypothesisResults[].
|
|
204
|
+
| `hypothesisResults[].final` | The authoritative effective result on current reports: `verdict`, categorical reliability in `confidence`, evidence coverage in `sufficiency`, and the `robustness` outcome. `confidence` may be absent when reliability was withheld; read `confidenceBasis`. Raw top-level `status` and numeric `confidence` are legacy compatibility fields and must not be ranked, trended, or compared with `final.confidence`. |
|
|
205
|
+
| `hypothesisResults[].robustness` | Raw re-ask detail retained for audit, including survival counts. Read `final.verdict` and `final.robustness` for the effective result; never independently promote `downgradedStatus` or the top-level `status`. |
|
|
188
206
|
| `sycophancySignals` | Anti-sycophancy readout: broken-persona flags (`lowDiscrimination`), per-hypothesis disagreement splits, and explicit `totalRejections`. |
|
|
189
207
|
| `openQuestions[]` | What the run did **not** settle. Each row carries the hypothesis and a `status` telling you why it's open — `never_asked`, `nobody_answered`, or `voices_disagreed` — plus `personasAsked`, how many distinct personas it was put to. Deterministically derived, never model-opined. Reaches the result text via the report's own `## Open Questions` section (see above), not via the trust digest; absent on reports from before this field shipped, an empty array means nothing was left open. |
|
|
190
208
|
|
|
@@ -196,7 +214,7 @@ simply omits them. The full Zod schema lives in
|
|
|
196
214
|
|
|
197
215
|
## Tools
|
|
198
216
|
|
|
199
|
-
|
|
217
|
+
`clien_research` is the hero — the recommended default for
|
|
200
218
|
validating an idea end to end. Everything else is either a **free read** for
|
|
201
219
|
orienting on what a project already holds, or a **targeted primitive** for a
|
|
202
220
|
narrow, cheaper probe.
|
|
@@ -267,9 +285,9 @@ name — the aliases exist for callers written before the rename.
|
|
|
267
285
|
| `list_reports` | — | free | Past `clien_research` runs, newest first. Optionally scoped to one `project_id`. |
|
|
268
286
|
| `get_report` | `job_id` | free | A past run's full report + `report_data`, same shape `clien_research` returns. Use this instead of re-running. |
|
|
269
287
|
| `list_competitors` | `project_id` | free | The project's deduped, accumulated competitor set, most-recently-seen first. Each of the four company facts carries a sibling `<fact>Grounding` — key on its `state`. |
|
|
270
|
-
| `list_community_signals` | `project_id` | free | The project's deduped, accumulated thread set, newest-**discovered** first (a stable order — a thread seen again does not move back to page one). Carries the
|
|
271
|
-
| `get_market` | `project_id` | free | The project's market snapshot
|
|
272
|
-
| `list_interview_scripts` | `project_id` | free | The interview scripts a research run wrote for the project — one per hypothesis, ranked
|
|
288
|
+
| `list_community_signals` | `project_id` | free | The project's deduped, accumulated thread set, newest-**discovered** first (a stable order — a thread seen again does not move back to page one). Carries the cached `relevantQuotes[]` excerpts captured at collection; they are user-voice evidence but are not guaranteed to preserve a speaker's exact words. |
|
|
289
|
+
| `get_market` | `project_id` | free | The project's **singleton** market snapshot. Versioned signals, sizing candidates, growth direction, trends, and positioning gaps belong to `sourceRunId`; separately labelled legacy market-size context may predate it and is never strict TAM/SAM/SOM evidence. Strict cited `marketSignals` and resolved `marketSizing` are returned separately. No snapshot is reported as "no run has produced market data", never as an empty or unmeasured market. |
|
|
290
|
+
| `list_interview_scripts` | `project_id` | free | The interview scripts a research run wrote for the project — one per hypothesis, ranked by product priority, then lower verdict reliability, then thinner evidence. Each carries its `hypothesisId`, statement, verdict, questions, categorical `confidence`, `sufficiency`, and `robustness`; older runs expose the retired numeric measure as `legacyConfidence`, which is not comparable with `low` / `medium` / `high`. **Stored output of one run, never generated on read.** Call it before `interview_persona` so the answers anchor to a hypothesis; no scripts is reported as "no run has written any", never as "nothing worth asking". |
|
|
273
291
|
|
|
274
292
|
### Account
|
|
275
293
|
|
|
@@ -325,7 +343,7 @@ same payload as `structuredContent`; see
|
|
|
325
343
|
| `job_id` | UUID | The validation job's ID |
|
|
326
344
|
| `status` | string | Terminal status: `complete`, `failed`, or `cancelled` |
|
|
327
345
|
| `project_id` | UUID \| `null` | The project this run is attached to. Pass back as `project_id` on follow-up runs. |
|
|
328
|
-
| `report_data` | object \| `null`| Structured report framing + findings, including typed `personasSynthesis`, `researchBrief`, `methodology`, safe `interviewHighlights[]`, competitors, hypotheses, and the trust layer — `claims[]`, `personas[].sources[]`, `hypothesisResults[].robustness`, `sycophancySignals`, `openQuestions[]` (see [Trust signals](#trust-signals)) |
|
|
346
|
+
| `report_data` | object \| `null`| Structured report framing + findings, including typed `personasSynthesis`, `researchBrief`, `methodology`, safe `interviewHighlights[]`, competitors, hypotheses, and the trust layer — `claims[]`, `personas[].sources[]`, authoritative `hypothesisResults[].final`, raw `hypothesisResults[].robustness`, `sycophancySignals`, `openQuestions[]` (see [Trust signals](#trust-signals)) |
|
|
329
347
|
| `total_cost_cents` | number | Optional. Total cost of the run, in cents. |
|
|
330
348
|
|
|
331
349
|
---
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure FUL-358 hypothesis semantics for the published MCP package.
|
|
3
|
+
*
|
|
4
|
+
* This module deliberately has no Zod or tool imports. Both the transport projection and the
|
|
5
|
+
* human-readable digest call the same normalizer, so a raw-drift payload cannot be trusted by one
|
|
6
|
+
* exit and rejected by another. The returned object is an allowlist: producer-private or future
|
|
7
|
+
* fields never cross the current contract boundary merely because an enclosing schema is
|
|
8
|
+
* passthrough-compatible.
|
|
9
|
+
*/
|
|
10
|
+
export const VERDICT_STATUSES = ['validated', 'invalidated', 'inconclusive'];
|
|
11
|
+
export const CONFIDENCE_LEVELS = ['low', 'medium', 'high'];
|
|
12
|
+
export const EVIDENCE_SUFFICIENCY_LEVELS = ['none', 'thin', 'moderate', 'substantial'];
|
|
13
|
+
export const ROBUSTNESS_OUTCOMES = ['held', 'flipped', 'not_retested'];
|
|
14
|
+
export const CONFIDENCE_BASES = ['evidence', 'recomputed_after_flip', 'withheld_no_evidence'];
|
|
15
|
+
export const HYPOTHESIS_PRIORITIES = ['high', 'medium', 'low'];
|
|
16
|
+
/** The semantics contract version this MCP build knows how to read. */
|
|
17
|
+
export const HYPOTHESIS_SEMANTICS_VERSION = 1;
|
|
18
|
+
const VERDICT_STRENGTH = {
|
|
19
|
+
validated: 2,
|
|
20
|
+
inconclusive: 1,
|
|
21
|
+
invalidated: 0,
|
|
22
|
+
};
|
|
23
|
+
function asRecord(value) {
|
|
24
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
25
|
+
? value
|
|
26
|
+
: null;
|
|
27
|
+
}
|
|
28
|
+
function asMember(value, members) {
|
|
29
|
+
return typeof value === 'string' && members.includes(value)
|
|
30
|
+
? value
|
|
31
|
+
: null;
|
|
32
|
+
}
|
|
33
|
+
/** The weaker of the original and candidate verdicts; an attempted upgrade is ignored. */
|
|
34
|
+
export function resolveMonotoneVerdict(rawOriginal, rawCandidate) {
|
|
35
|
+
const original = asMember(rawOriginal, VERDICT_STATUSES);
|
|
36
|
+
const candidate = asMember(rawCandidate, VERDICT_STATUSES);
|
|
37
|
+
if (!candidate)
|
|
38
|
+
return original;
|
|
39
|
+
if (!original)
|
|
40
|
+
return candidate;
|
|
41
|
+
return VERDICT_STRENGTH[candidate] < VERDICT_STRENGTH[original] ? candidate : original;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Read a rephrasing ratio only when it can describe a real finite count whose `flipped` flag
|
|
45
|
+
* agrees with whether every framing survived. A malformed ratio still cannot erase a separately
|
|
46
|
+
* readable weaker recorded verdict.
|
|
47
|
+
*/
|
|
48
|
+
export function readRobustnessCounts(value) {
|
|
49
|
+
const robustness = asRecord(value);
|
|
50
|
+
if (!robustness)
|
|
51
|
+
return null;
|
|
52
|
+
const survived = robustness.survived;
|
|
53
|
+
const total = robustness.total;
|
|
54
|
+
const flipped = robustness.flipped;
|
|
55
|
+
if (typeof survived !== 'number' ||
|
|
56
|
+
!Number.isInteger(survived) ||
|
|
57
|
+
survived < 0 ||
|
|
58
|
+
typeof total !== 'number' ||
|
|
59
|
+
!Number.isInteger(total) ||
|
|
60
|
+
total <= 0 ||
|
|
61
|
+
survived > total ||
|
|
62
|
+
typeof flipped !== 'boolean' ||
|
|
63
|
+
flipped !== (survived < total)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return { survived, total };
|
|
67
|
+
}
|
|
68
|
+
/** A typed robustness block is trustworthy only when its detailed working proves its summary. */
|
|
69
|
+
export function hasCoherentRobustnessWorking(value) {
|
|
70
|
+
const robustness = asRecord(value);
|
|
71
|
+
const counts = readRobustnessCounts(robustness);
|
|
72
|
+
const originalStatus = asMember(robustness?.originalStatus, VERDICT_STATUSES);
|
|
73
|
+
const variants = robustness?.variants;
|
|
74
|
+
if (!robustness || !counts || !originalStatus || !Array.isArray(variants))
|
|
75
|
+
return false;
|
|
76
|
+
if (variants.length !== counts.total)
|
|
77
|
+
return false;
|
|
78
|
+
let agreedCount = 0;
|
|
79
|
+
for (const raw of variants) {
|
|
80
|
+
const variant = asRecord(raw);
|
|
81
|
+
const returnedStatus = asMember(variant?.returnedStatus, VERDICT_STATUSES);
|
|
82
|
+
if (!variant || !returnedStatus || typeof variant.agreed !== 'boolean')
|
|
83
|
+
return false;
|
|
84
|
+
if (variant.agreed !== (returnedStatus === originalStatus))
|
|
85
|
+
return false;
|
|
86
|
+
if (variant.agreed)
|
|
87
|
+
agreedCount += 1;
|
|
88
|
+
}
|
|
89
|
+
return agreedCount === counts.survived;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Whether present working positively disproves its own summary. Absent working and individually
|
|
93
|
+
* unreadable variant rows do not by themselves disprove a separately valid count. A present
|
|
94
|
+
* non-array `variants` container does: it is an attempted shape that cannot authenticate dependent
|
|
95
|
+
* final semantics or cross the raw projection boundary.
|
|
96
|
+
*/
|
|
97
|
+
export function robustnessWorkingContradictsSummary(value) {
|
|
98
|
+
const robustness = asRecord(value);
|
|
99
|
+
if (!robustness)
|
|
100
|
+
return false;
|
|
101
|
+
const counts = readRobustnessCounts(robustness);
|
|
102
|
+
const originalStatus = asMember(robustness.originalStatus, VERDICT_STATUSES);
|
|
103
|
+
const variants = robustness.variants;
|
|
104
|
+
if (!Object.prototype.hasOwnProperty.call(robustness, 'variants'))
|
|
105
|
+
return false;
|
|
106
|
+
if (!Array.isArray(variants))
|
|
107
|
+
return true;
|
|
108
|
+
if (!originalStatus)
|
|
109
|
+
return true;
|
|
110
|
+
let readableCount = 0;
|
|
111
|
+
let agreedCount = 0;
|
|
112
|
+
let disagreedCount = 0;
|
|
113
|
+
for (const raw of variants) {
|
|
114
|
+
const variant = asRecord(raw);
|
|
115
|
+
const returnedStatus = asMember(variant?.returnedStatus, VERDICT_STATUSES);
|
|
116
|
+
if (!variant || !returnedStatus || typeof variant.agreed !== 'boolean')
|
|
117
|
+
continue;
|
|
118
|
+
readableCount += 1;
|
|
119
|
+
if (variant.agreed !== (returnedStatus === originalStatus))
|
|
120
|
+
return true;
|
|
121
|
+
if (variant.agreed)
|
|
122
|
+
agreedCount += 1;
|
|
123
|
+
else
|
|
124
|
+
disagreedCount += 1;
|
|
125
|
+
}
|
|
126
|
+
if (!counts)
|
|
127
|
+
return false;
|
|
128
|
+
if (variants.length > counts.total)
|
|
129
|
+
return true;
|
|
130
|
+
if (agreedCount > counts.survived || disagreedCount > counts.total - counts.survived)
|
|
131
|
+
return true;
|
|
132
|
+
return (readableCount === variants.length &&
|
|
133
|
+
variants.length === counts.total &&
|
|
134
|
+
agreedCount !== counts.survived);
|
|
135
|
+
}
|
|
136
|
+
/** Read robustness in the context of its owning row, including parent-verdict coherence. */
|
|
137
|
+
export function readRowRobustnessOutcome(rawRow) {
|
|
138
|
+
const row = asRecord(rawRow);
|
|
139
|
+
if (!row)
|
|
140
|
+
return null;
|
|
141
|
+
if (row.robustness === undefined || row.robustness === null)
|
|
142
|
+
return 'not_retested';
|
|
143
|
+
const robustness = asRecord(row.robustness);
|
|
144
|
+
if (!robustness || !readRobustnessCounts(robustness))
|
|
145
|
+
return null;
|
|
146
|
+
const rowStatus = asMember(row.status, VERDICT_STATUSES);
|
|
147
|
+
if (!rowStatus)
|
|
148
|
+
return null;
|
|
149
|
+
if (Object.prototype.hasOwnProperty.call(robustness, 'originalStatus') &&
|
|
150
|
+
asMember(robustness.originalStatus, VERDICT_STATUSES) !== rowStatus)
|
|
151
|
+
return null;
|
|
152
|
+
if (Object.prototype.hasOwnProperty.call(robustness, 'variants') &&
|
|
153
|
+
robustnessWorkingContradictsSummary(robustness))
|
|
154
|
+
return null;
|
|
155
|
+
return robustness.flipped ? 'flipped' : 'held';
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Read a legacy robustness outcome without treating a contradicted measurement as truth.
|
|
159
|
+
* Old rows may carry only `flipped`; once either count is present, the whole measured triple
|
|
160
|
+
* must agree before its outcome can be rendered.
|
|
161
|
+
*/
|
|
162
|
+
export function readLegacyRobustnessOutcome(value) {
|
|
163
|
+
if (value === undefined || value === null)
|
|
164
|
+
return 'not_retested';
|
|
165
|
+
const robustness = asRecord(value);
|
|
166
|
+
if (!robustness || typeof robustness.flipped !== 'boolean')
|
|
167
|
+
return null;
|
|
168
|
+
const carriesMeasuredCounts = Object.prototype.hasOwnProperty.call(robustness, 'survived') ||
|
|
169
|
+
Object.prototype.hasOwnProperty.call(robustness, 'total');
|
|
170
|
+
if (carriesMeasuredCounts && readRobustnessCounts(robustness) === null)
|
|
171
|
+
return null;
|
|
172
|
+
return robustness.flipped ? 'flipped' : 'held';
|
|
173
|
+
}
|
|
174
|
+
function finalAxesAreCoherent(final) {
|
|
175
|
+
const confidence = final.confidence ?? null;
|
|
176
|
+
if (final.confidenceBasis === 'withheld_no_evidence') {
|
|
177
|
+
return confidence === null && final.sufficiency === 'none';
|
|
178
|
+
}
|
|
179
|
+
if (final.confidenceBasis === 'recomputed_after_flip') {
|
|
180
|
+
return confidence === 'low' && final.sufficiency !== 'none' && final.robustness === 'flipped';
|
|
181
|
+
}
|
|
182
|
+
return confidence !== null && final.sufficiency !== 'none' && final.robustness !== 'flipped';
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Authenticate and normalize a producer-owned `final` block against its raw row.
|
|
186
|
+
*
|
|
187
|
+
* A readable row status is mandatory: it is the original verdict the code-derived block claims
|
|
188
|
+
* to reconcile. The final robustness outcome must also agree with the raw pass (or its absence),
|
|
189
|
+
* otherwise a stale pre-flip reliability block could caption a flipped row. Optional priority
|
|
190
|
+
* degrades field-locally; every unknown key is removed from the returned current-version block.
|
|
191
|
+
*/
|
|
192
|
+
export function normalizeFinalHypothesisState(rawRow) {
|
|
193
|
+
const row = asRecord(rawRow);
|
|
194
|
+
const block = asRecord(row?.final);
|
|
195
|
+
if (!row || !block || block.version !== HYPOTHESIS_SEMANTICS_VERSION)
|
|
196
|
+
return null;
|
|
197
|
+
const rowVerdict = asMember(row.status, VERDICT_STATUSES);
|
|
198
|
+
const originalVerdict = asMember(block.originalVerdict, VERDICT_STATUSES);
|
|
199
|
+
const verdict = asMember(block.verdict, VERDICT_STATUSES);
|
|
200
|
+
if (!rowVerdict || originalVerdict !== rowVerdict || !verdict)
|
|
201
|
+
return null;
|
|
202
|
+
const rawRobustness = asRecord(row.robustness);
|
|
203
|
+
const weakestRecorded = resolveMonotoneVerdict(rowVerdict, rawRobustness?.downgradedStatus);
|
|
204
|
+
if (resolveMonotoneVerdict(weakestRecorded, verdict) !== verdict)
|
|
205
|
+
return null;
|
|
206
|
+
const confidence = asMember(block.confidence, CONFIDENCE_LEVELS);
|
|
207
|
+
if (block.confidence !== undefined && confidence === null)
|
|
208
|
+
return null;
|
|
209
|
+
const confidenceBasis = asMember(block.confidenceBasis, CONFIDENCE_BASES);
|
|
210
|
+
const sufficiency = asMember(block.sufficiency, EVIDENCE_SUFFICIENCY_LEVELS);
|
|
211
|
+
const robustness = asMember(block.robustness, ROBUSTNESS_OUTCOMES);
|
|
212
|
+
if (!confidenceBasis || !sufficiency || !robustness)
|
|
213
|
+
return null;
|
|
214
|
+
if (readRowRobustnessOutcome(row) !== robustness)
|
|
215
|
+
return null;
|
|
216
|
+
const normalized = {
|
|
217
|
+
version: HYPOTHESIS_SEMANTICS_VERSION,
|
|
218
|
+
verdict,
|
|
219
|
+
originalVerdict,
|
|
220
|
+
...(confidence ? { confidence } : {}),
|
|
221
|
+
confidenceBasis,
|
|
222
|
+
sufficiency,
|
|
223
|
+
robustness,
|
|
224
|
+
};
|
|
225
|
+
const priority = asMember(block.priority, HYPOTHESIS_PRIORITIES);
|
|
226
|
+
if (priority)
|
|
227
|
+
normalized.priority = priority;
|
|
228
|
+
return finalAxesAreCoherent(normalized) ? normalized : null;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=hypothesis-semantics.js.map
|
|
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