cbrowser 20.2.2 → 21.0.0
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 +2 -2
- package/dist/analysis/accessibility-empathy.d.ts +29 -1
- package/dist/analysis/accessibility-empathy.d.ts.map +1 -1
- package/dist/analysis/accessibility-empathy.js +69 -35
- package/dist/analysis/accessibility-empathy.js.map +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +11 -7
- package/dist/browser.js.map +1 -1
- package/dist/cif-score.d.ts +56 -5
- package/dist/cif-score.d.ts.map +1 -1
- package/dist/cif-score.js +595 -346
- package/dist/cif-score.js.map +1 -1
- package/dist/cli.js +10 -8
- package/dist/cli.js.map +1 -1
- package/dist/cognitive/default-traits.d.ts +14 -0
- package/dist/cognitive/default-traits.d.ts.map +1 -0
- package/dist/cognitive/default-traits.js +36 -0
- package/dist/cognitive/default-traits.js.map +1 -0
- package/dist/cognitive/emotions.d.ts.map +1 -1
- package/dist/cognitive/emotions.js +104 -174
- package/dist/cognitive/emotions.js.map +1 -1
- package/dist/cognitive/index.d.ts +28 -0
- package/dist/cognitive/index.d.ts.map +1 -1
- package/dist/cognitive/index.js +353 -287
- package/dist/cognitive/index.js.map +1 -1
- package/dist/cognitive/temporal.d.ts +0 -24
- package/dist/cognitive/temporal.d.ts.map +1 -1
- package/dist/cognitive/temporal.js +45 -35
- package/dist/cognitive/temporal.js.map +1 -1
- package/dist/data/ctc-reference-v2-2026-10-24.d.ts +16 -0
- package/dist/data/ctc-reference-v2-2026-10-24.d.ts.map +1 -0
- package/dist/data/ctc-reference-v2-2026-10-24.js +1004 -0
- package/dist/data/ctc-reference-v2-2026-10-24.js.map +1 -0
- package/dist/ideal-profiles-gap.d.ts +1 -0
- package/dist/ideal-profiles-gap.d.ts.map +1 -1
- package/dist/ideal-profiles-gap.js +9 -1
- package/dist/ideal-profiles-gap.js.map +1 -1
- package/dist/ideal-profiles.d.ts +8 -0
- package/dist/ideal-profiles.d.ts.map +1 -1
- package/dist/ideal-profiles.js +28 -24
- package/dist/ideal-profiles.js.map +1 -1
- package/dist/mcp-server-remote.d.ts.map +1 -1
- package/dist/mcp-server-remote.js +7 -8
- package/dist/mcp-server-remote.js.map +1 -1
- package/dist/mcp-tools/account-personas.d.ts.map +1 -1
- package/dist/mcp-tools/account-personas.js +3 -1
- package/dist/mcp-tools/account-personas.js.map +1 -1
- package/dist/mcp-tools/base/answer-provenance.d.ts +28 -0
- package/dist/mcp-tools/base/answer-provenance.d.ts.map +1 -0
- package/dist/mcp-tools/base/answer-provenance.js +32 -0
- package/dist/mcp-tools/base/answer-provenance.js.map +1 -0
- package/dist/mcp-tools/base/audit-tools.d.ts +0 -3
- package/dist/mcp-tools/base/audit-tools.d.ts.map +1 -1
- package/dist/mcp-tools/base/audit-tools.js +152 -84
- package/dist/mcp-tools/base/audit-tools.js.map +1 -1
- package/dist/mcp-tools/base/capture-tools.js +1 -1
- package/dist/mcp-tools/base/capture-tools.js.map +1 -1
- package/dist/mcp-tools/base/chain-values.d.ts +38 -0
- package/dist/mcp-tools/base/chain-values.d.ts.map +1 -0
- package/dist/mcp-tools/base/chain-values.js +85 -0
- package/dist/mcp-tools/base/chain-values.js.map +1 -0
- package/dist/mcp-tools/base/cognitive-tools.d.ts.map +1 -1
- package/dist/mcp-tools/base/cognitive-tools.js +126 -120
- package/dist/mcp-tools/base/cognitive-tools.js.map +1 -1
- package/dist/mcp-tools/base/gif-tools.d.ts.map +1 -1
- package/dist/mcp-tools/base/gif-tools.js +23 -5
- package/dist/mcp-tools/base/gif-tools.js.map +1 -1
- package/dist/mcp-tools/base/persona-comparison-tools.d.ts.map +1 -1
- package/dist/mcp-tools/base/persona-comparison-tools.js +229 -172
- package/dist/mcp-tools/base/persona-comparison-tools.js.map +1 -1
- package/dist/mcp-tools/base/site-familiarity.d.ts +31 -0
- package/dist/mcp-tools/base/site-familiarity.d.ts.map +1 -0
- package/dist/mcp-tools/base/site-familiarity.js +30 -0
- package/dist/mcp-tools/base/site-familiarity.js.map +1 -0
- package/dist/mcp-tools/base/site-knowledge-tools.js +1 -1
- package/dist/mcp-tools/base/site-knowledge-tools.js.map +1 -1
- package/dist/mcp-tools/base/story-narrative.d.ts +50 -0
- package/dist/mcp-tools/base/story-narrative.d.ts.map +1 -0
- package/dist/mcp-tools/base/story-narrative.js +88 -0
- package/dist/mcp-tools/base/story-narrative.js.map +1 -0
- package/dist/mcp-tools/base/values-tools.d.ts.map +1 -1
- package/dist/mcp-tools/base/values-tools.js +19 -5
- package/dist/mcp-tools/base/values-tools.js.map +1 -1
- package/dist/mcp-tools/base/visual-testing-tools.d.ts +5 -5
- package/dist/mcp-tools/base/visual-testing-tools.d.ts.map +1 -1
- package/dist/mcp-tools/base/visual-testing-tools.js +38 -11
- package/dist/mcp-tools/base/visual-testing-tools.js.map +1 -1
- package/dist/mcp-tools/persona-creation-tools.js +6 -6
- package/dist/mcp-tools/persona-creation-tools.js.map +1 -1
- package/dist/mcp-tools/persona-lifecycle-tools.d.ts.map +1 -1
- package/dist/mcp-tools/persona-lifecycle-tools.js +5 -1
- package/dist/mcp-tools/persona-lifecycle-tools.js.map +1 -1
- package/dist/mcp-tools/tier-gate.js +1 -1
- package/dist/mcp-tools/tool-result-saver.d.ts +7 -0
- package/dist/mcp-tools/tool-result-saver.d.ts.map +1 -1
- package/dist/mcp-tools/tool-result-saver.js +11 -0
- package/dist/mcp-tools/tool-result-saver.js.map +1 -1
- package/dist/mcp-tools/trait-provenance.d.ts +109 -0
- package/dist/mcp-tools/trait-provenance.d.ts.map +1 -0
- package/dist/mcp-tools/trait-provenance.js +187 -0
- package/dist/mcp-tools/trait-provenance.js.map +1 -0
- package/dist/mcp-tools/ui-resources.d.ts +6 -7
- package/dist/mcp-tools/ui-resources.d.ts.map +1 -1
- package/dist/mcp-tools/ui-resources.js +162 -12
- package/dist/mcp-tools/ui-resources.js.map +1 -1
- package/dist/mcp-tools/widget-kit.d.ts +129 -3
- package/dist/mcp-tools/widget-kit.d.ts.map +1 -1
- package/dist/mcp-tools/widget-kit.js +507 -28
- package/dist/mcp-tools/widget-kit.js.map +1 -1
- package/dist/performance/metrics.d.ts.map +1 -1
- package/dist/performance/metrics.js +4 -1
- package/dist/performance/metrics.js.map +1 -1
- package/dist/persona-questionnaire.js +1 -1
- package/dist/persona-questionnaire.js.map +1 -1
- package/dist/personas.d.ts.map +1 -1
- package/dist/personas.js +133 -82
- package/dist/personas.js.map +1 -1
- package/dist/recording/engine.d.ts.map +1 -1
- package/dist/recording/engine.js +5 -2
- package/dist/recording/engine.js.map +1 -1
- package/dist/recording/saliency-overlay.d.ts +8 -3
- package/dist/recording/saliency-overlay.d.ts.map +1 -1
- package/dist/recording/saliency-overlay.js +14 -5
- package/dist/recording/saliency-overlay.js.map +1 -1
- package/dist/recording/types.js +1 -1
- package/dist/testing/nl-test-suite.d.ts.map +1 -1
- package/dist/testing/nl-test-suite.js +2 -1
- package/dist/testing/nl-test-suite.js.map +1 -1
- package/dist/trait-reference.d.ts +19 -2
- package/dist/trait-reference.d.ts.map +1 -1
- package/dist/trait-reference.js +19 -2
- package/dist/trait-reference.js.map +1 -1
- package/dist/types.d.ts +32 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +62 -52
- package/dist/types.js.map +1 -1
- package/dist/values/persona-completeness.js +1 -1
- package/dist/values/persona-completeness.js.map +1 -1
- package/dist/visual/ab-comparison.d.ts.map +1 -1
- package/dist/visual/ab-comparison.js +4 -1
- package/dist/visual/ab-comparison.js.map +1 -1
- package/dist/visual/attention-quality.d.ts +1 -1
- package/dist/visual/attention-quality.js +1 -1
- package/dist/visual/attention-transport.d.ts +74 -10
- package/dist/visual/attention-transport.d.ts.map +1 -1
- package/dist/visual/attention-transport.js +353 -193
- package/dist/visual/attention-transport.js.map +1 -1
- package/dist/visual/cognitive-models.d.ts +77 -55
- package/dist/visual/cognitive-models.d.ts.map +1 -1
- package/dist/visual/cognitive-models.js +231 -104
- package/dist/visual/cognitive-models.js.map +1 -1
- package/dist/visual/cognitive-transport-chain.d.ts +328 -30
- package/dist/visual/cognitive-transport-chain.d.ts.map +1 -1
- package/dist/visual/cognitive-transport-chain.js +576 -353
- package/dist/visual/cognitive-transport-chain.js.map +1 -1
- package/dist/visual/cognitive-transport.d.ts +446 -13
- package/dist/visual/cognitive-transport.d.ts.map +1 -1
- package/dist/visual/cognitive-transport.js +1085 -245
- package/dist/visual/cognitive-transport.js.map +1 -1
- package/dist/visual/cross-browser.d.ts.map +1 -1
- package/dist/visual/cross-browser.js +8 -6
- package/dist/visual/cross-browser.js.map +1 -1
- package/dist/visual/ctc-bands.d.ts +91 -0
- package/dist/visual/ctc-bands.d.ts.map +1 -0
- package/dist/visual/ctc-bands.js +117 -0
- package/dist/visual/ctc-bands.js.map +1 -0
- package/dist/visual/ctc-reference.d.ts +287 -0
- package/dist/visual/ctc-reference.d.ts.map +1 -0
- package/dist/visual/ctc-reference.js +376 -0
- package/dist/visual/ctc-reference.js.map +1 -0
- package/dist/visual/demand-laws.d.ts +145 -0
- package/dist/visual/demand-laws.d.ts.map +1 -0
- package/dist/visual/demand-laws.js +220 -0
- package/dist/visual/demand-laws.js.map +1 -0
- package/dist/visual/distance-metrics.d.ts +23 -1
- package/dist/visual/distance-metrics.d.ts.map +1 -1
- package/dist/visual/distance-metrics.js +49 -18
- package/dist/visual/distance-metrics.js.map +1 -1
- package/dist/visual/dro-bound.d.ts +220 -0
- package/dist/visual/dro-bound.d.ts.map +1 -0
- package/dist/visual/dro-bound.js +341 -0
- package/dist/visual/dro-bound.js.map +1 -0
- package/dist/visual/exact-w1.d.ts +60 -0
- package/dist/visual/exact-w1.d.ts.map +1 -0
- package/dist/visual/exact-w1.js +247 -0
- package/dist/visual/exact-w1.js.map +1 -0
- package/dist/visual/human-input.d.ts.map +1 -1
- package/dist/visual/human-input.js +45 -41
- package/dist/visual/human-input.js.map +1 -1
- package/dist/visual/index.d.ts +2 -0
- package/dist/visual/index.d.ts.map +1 -1
- package/dist/visual/index.js +2 -0
- package/dist/visual/index.js.map +1 -1
- package/dist/visual/law-times-report.d.ts +49 -0
- package/dist/visual/law-times-report.d.ts.map +1 -0
- package/dist/visual/law-times-report.js +38 -0
- package/dist/visual/law-times-report.js.map +1 -0
- package/dist/visual/model-provenance.d.ts +151 -0
- package/dist/visual/model-provenance.d.ts.map +1 -0
- package/dist/visual/model-provenance.js +334 -0
- package/dist/visual/model-provenance.js.map +1 -0
- package/dist/visual/normal-cdf.d.ts +14 -0
- package/dist/visual/normal-cdf.d.ts.map +1 -0
- package/dist/visual/normal-cdf.js +26 -0
- package/dist/visual/normal-cdf.js.map +1 -0
- package/dist/visual/perceptual-transport.d.ts +28 -4
- package/dist/visual/perceptual-transport.d.ts.map +1 -1
- package/dist/visual/perceptual-transport.js +66 -32
- package/dist/visual/perceptual-transport.js.map +1 -1
- package/dist/visual/provenance/attention.d.ts +55 -0
- package/dist/visual/provenance/attention.d.ts.map +1 -0
- package/dist/visual/provenance/attention.js +188 -0
- package/dist/visual/provenance/attention.js.map +1 -0
- package/dist/visual/provenance/chain.d.ts +41 -0
- package/dist/visual/provenance/chain.d.ts.map +1 -0
- package/dist/visual/provenance/chain.js +66 -0
- package/dist/visual/provenance/chain.js.map +1 -0
- package/dist/visual/provenance/cif.d.ts +42 -0
- package/dist/visual/provenance/cif.d.ts.map +1 -0
- package/dist/visual/provenance/cif.js +116 -0
- package/dist/visual/provenance/cif.js.map +1 -0
- package/dist/visual/provenance/ctc-reference.d.ts +36 -0
- package/dist/visual/provenance/ctc-reference.d.ts.map +1 -0
- package/dist/visual/provenance/ctc-reference.js +96 -0
- package/dist/visual/provenance/ctc-reference.js.map +1 -0
- package/dist/visual/provenance/distance.d.ts +10 -0
- package/dist/visual/provenance/distance.d.ts.map +1 -0
- package/dist/visual/provenance/distance.js +72 -0
- package/dist/visual/provenance/distance.js.map +1 -0
- package/dist/visual/provenance/dro.d.ts +10 -0
- package/dist/visual/provenance/dro.d.ts.map +1 -0
- package/dist/visual/provenance/dro.js +2 -0
- package/dist/visual/provenance/dro.js.map +1 -0
- package/dist/visual/provenance/emotion.d.ts +26 -0
- package/dist/visual/provenance/emotion.d.ts.map +1 -0
- package/dist/visual/provenance/emotion.js +99 -0
- package/dist/visual/provenance/emotion.js.map +1 -0
- package/dist/visual/provenance/human-input.d.ts +19 -0
- package/dist/visual/provenance/human-input.d.ts.map +1 -0
- package/dist/visual/provenance/human-input.js +84 -0
- package/dist/visual/provenance/human-input.js.map +1 -0
- package/dist/visual/provenance/journey-group.d.ts +15 -0
- package/dist/visual/provenance/journey-group.d.ts.map +1 -0
- package/dist/visual/provenance/journey-group.js +15 -0
- package/dist/visual/provenance/journey-group.js.map +1 -0
- package/dist/visual/provenance/journey-mcp.d.ts +24 -0
- package/dist/visual/provenance/journey-mcp.d.ts.map +1 -0
- package/dist/visual/provenance/journey-mcp.js +54 -0
- package/dist/visual/provenance/journey-mcp.js.map +1 -0
- package/dist/visual/provenance/journey.d.ts +34 -0
- package/dist/visual/provenance/journey.d.ts.map +1 -0
- package/dist/visual/provenance/journey.js +184 -0
- package/dist/visual/provenance/journey.js.map +1 -0
- package/dist/visual/provenance/laws.d.ts +38 -0
- package/dist/visual/provenance/laws.d.ts.map +1 -0
- package/dist/visual/provenance/laws.js +40 -0
- package/dist/visual/provenance/laws.js.map +1 -0
- package/dist/visual/provenance/page-metrics.d.ts +42 -0
- package/dist/visual/provenance/page-metrics.d.ts.map +1 -0
- package/dist/visual/provenance/page-metrics.js +79 -0
- package/dist/visual/provenance/page-metrics.js.map +1 -0
- package/dist/visual/provenance/perceptual.d.ts +63 -0
- package/dist/visual/provenance/perceptual.d.ts.map +1 -0
- package/dist/visual/provenance/perceptual.js +115 -0
- package/dist/visual/provenance/perceptual.js.map +1 -0
- package/dist/visual/provenance/persona-rates.d.ts +84 -0
- package/dist/visual/provenance/persona-rates.d.ts.map +1 -0
- package/dist/visual/provenance/persona-rates.js +112 -0
- package/dist/visual/provenance/persona-rates.js.map +1 -0
- package/dist/visual/provenance/personas.d.ts +122 -0
- package/dist/visual/provenance/personas.d.ts.map +1 -0
- package/dist/visual/provenance/personas.js +298 -0
- package/dist/visual/provenance/personas.js.map +1 -0
- package/dist/visual/provenance/profiles.d.ts +39 -0
- package/dist/visual/provenance/profiles.d.ts.map +1 -0
- package/dist/visual/provenance/profiles.js +37 -0
- package/dist/visual/provenance/profiles.js.map +1 -0
- package/dist/visual/provenance/temporal.d.ts +21 -0
- package/dist/visual/provenance/temporal.d.ts.map +1 -0
- package/dist/visual/provenance/temporal.js +56 -0
- package/dist/visual/provenance/temporal.js.map +1 -0
- package/dist/visual/provenance/visual-distance.d.ts +22 -0
- package/dist/visual/provenance/visual-distance.d.ts.map +1 -0
- package/dist/visual/provenance/visual-distance.js +30 -0
- package/dist/visual/provenance/visual-distance.js.map +1 -0
- package/dist/visual/regression.d.ts.map +1 -1
- package/dist/visual/regression.js +14 -9
- package/dist/visual/regression.js.map +1 -1
- package/dist/visual/responsive.d.ts.map +1 -1
- package/dist/visual/responsive.js +4 -1
- package/dist/visual/responsive.js.map +1 -1
- package/dist/visual/scope-prose.js +2 -2
- package/dist/visual/scope-prose.js.map +1 -1
- package/dist/visual/seeded-random.d.ts +16 -0
- package/dist/visual/seeded-random.d.ts.map +1 -0
- package/dist/visual/seeded-random.js +25 -0
- package/dist/visual/seeded-random.js.map +1 -0
- package/dist/visual/stored-accessibility-traits.d.ts +27 -0
- package/dist/visual/stored-accessibility-traits.d.ts.map +1 -0
- package/dist/visual/stored-accessibility-traits.js +35 -0
- package/dist/visual/stored-accessibility-traits.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where every number in the cognitive transport model comes from.
|
|
3
|
+
*
|
|
4
|
+
* A constant the model reads is either:
|
|
5
|
+
* fitted estimated from named data, with the held-out score in `source`
|
|
6
|
+
* published taken from a cited law or measurement in the literature
|
|
7
|
+
* definition a choice of units, scale or encoding that carries no empirical claim
|
|
8
|
+
* hypothesis set by hand; nothing in data or literature backs the value yet
|
|
9
|
+
*
|
|
10
|
+
* The paper and the tools report these labels instead of presenting hand-set
|
|
11
|
+
* numbers as findings. Everything the chain, the persona distance and the DRO
|
|
12
|
+
* bound read goes through `param()`, so the registry cannot drift from the code:
|
|
13
|
+
* tests record which ids a run reads and fail on an id that is read but not
|
|
14
|
+
* registered, or registered but never read.
|
|
15
|
+
*
|
|
16
|
+
* Entries live beside the code that reads them (provenance/*.ts) and are merged
|
|
17
|
+
* here, so a new constant is registered in the same file it is introduced in.
|
|
18
|
+
*
|
|
19
|
+
* @copyright 2026 Alexandria Eden alexandria.shai.eden@gmail.com https://cbrowser.ai
|
|
20
|
+
* @license MIT
|
|
21
|
+
*/
|
|
22
|
+
export type ProvenanceStatus = "fitted" | "published" | "definition" | "hypothesis";
|
|
23
|
+
export interface ProvenanceEntry {
|
|
24
|
+
/** Stable id, `<area>.<name>`, e.g. "chain.weightDeficit". */
|
|
25
|
+
id: string;
|
|
26
|
+
value: number;
|
|
27
|
+
status: ProvenanceStatus;
|
|
28
|
+
/** Data and score for fitted, citation for published, reason for definition, what would test it for hypothesis. */
|
|
29
|
+
source: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const MODEL_PROVENANCE: Readonly<Record<string, ProvenanceEntry>>;
|
|
32
|
+
/** Read a registered constant. Throws on an unregistered id, so a typo cannot fall back silently. */
|
|
33
|
+
export declare function param(id: string): number;
|
|
34
|
+
/**
|
|
35
|
+
* TEST ONLY: run `fn` with some registered constants replaced, then restore
|
|
36
|
+
* them. It exists so tests/ctc-no-dead-constants.test.ts can perturb every
|
|
37
|
+
* constant and check that the output moves; no shipped code may call it (a
|
|
38
|
+
* test asserts that). Calls nest, the innermost value winning, and an
|
|
39
|
+
* unregistered id throws exactly as param() does.
|
|
40
|
+
*/
|
|
41
|
+
export declare function withParamOverrides<T>(values: Record<string, number>, fn: () => T): T;
|
|
42
|
+
/**
|
|
43
|
+
* TEST ONLY: withParamOverrides for an async `fn`, the overrides holding
|
|
44
|
+
* until it settles. The override set is process-wide, not scoped to the async
|
|
45
|
+
* context, so anything else running meanwhile sees it too: a test awaits one
|
|
46
|
+
* override at a time (tests/journey-no-dead-constants.test.ts, which perturbs
|
|
47
|
+
* the constants a journey reads across its awaits).
|
|
48
|
+
*/
|
|
49
|
+
export declare function withParamOverridesAsync<T>(values: Record<string, number>, fn: () => Promise<T>): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* The override set in force, or null outside withParamOverrides. A new object
|
|
52
|
+
* on every override call, so a cache of anything derived from registered
|
|
53
|
+
* constants (the CTC reference curve) can key on it by identity and is never
|
|
54
|
+
* served across a change of constants. Read-only: never mutate it.
|
|
55
|
+
*/
|
|
56
|
+
export declare function activeOverrides(): Readonly<Record<string, number>> | null;
|
|
57
|
+
/** Start recording which ids `param()` reads. Returns the live set. Test and reporting use only. */
|
|
58
|
+
export declare function startProvenanceRecording(): Set<string>;
|
|
59
|
+
export declare function stopProvenanceRecording(): Set<string>;
|
|
60
|
+
export interface ProvenanceSummary {
|
|
61
|
+
counts: Record<ProvenanceStatus, number>;
|
|
62
|
+
/** Ids of the hand-set constants the computation depended on. */
|
|
63
|
+
hypotheses: string[];
|
|
64
|
+
/** What the counts cover, so "0 fitted" is not read as "nothing in cbrowser is fitted". */
|
|
65
|
+
scope: string;
|
|
66
|
+
note: string;
|
|
67
|
+
}
|
|
68
|
+
/** What a block says it covers. Tools report the score's block with the defaults below. */
|
|
69
|
+
export interface ProvenanceText {
|
|
70
|
+
scope?: string;
|
|
71
|
+
note?: string;
|
|
72
|
+
}
|
|
73
|
+
/** The text of an attention map's own block. */
|
|
74
|
+
export declare const ATTENTION_PROVENANCE_TEXT: Readonly<Required<ProvenanceText>>;
|
|
75
|
+
export declare const PERSONA_RATE_PROVENANCE_TEXT: Readonly<Required<ProvenanceText>>;
|
|
76
|
+
export interface PersonaRateProvenance extends ProvenanceSummary {
|
|
77
|
+
/** Every rate id counted, sorted, so the published ones can be named as well as counted. */
|
|
78
|
+
rates: string[];
|
|
79
|
+
}
|
|
80
|
+
/** The persona-rate section of an answer, from the ids collectPersonaReads returned for the scored persona's bridge. */
|
|
81
|
+
export declare function personaRateProvenance(ids: Iterable<string>): PersonaRateProvenance;
|
|
82
|
+
export declare function provenanceSummary(ids: Iterable<string>, text?: ProvenanceText): ProvenanceSummary;
|
|
83
|
+
/**
|
|
84
|
+
* Run `fn` and return the ids it read. Nests like withProvenance: the reads
|
|
85
|
+
* also land in any enclosing recording. Used to remember what a cached value
|
|
86
|
+
* was derived from, so a cache hit can record the same dependencies a miss
|
|
87
|
+
* would have.
|
|
88
|
+
*/
|
|
89
|
+
export declare function readsOf<T>(fn: () => T): {
|
|
90
|
+
result: T;
|
|
91
|
+
ids: ReadonlySet<string>;
|
|
92
|
+
};
|
|
93
|
+
/** Run `fn` as persona-model work: its reads go to the active collectPersonaReads set (if any) and the session, never to a score recording. */
|
|
94
|
+
export declare function personaScope<T>(fn: () => T): T;
|
|
95
|
+
/**
|
|
96
|
+
* Run `fn` as persona-model work and return the ids it read. A tool wraps the
|
|
97
|
+
* scored persona's bridge in this to report the rates that persona was scored
|
|
98
|
+
* with in a section of their own: computed from the persona, so no cache state
|
|
99
|
+
* can change it.
|
|
100
|
+
*/
|
|
101
|
+
export declare function collectPersonaReads<T>(fn: () => T): {
|
|
102
|
+
result: T;
|
|
103
|
+
ids: ReadonlySet<string>;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Run `fn` and return its result with the provenance of every constant it read.
|
|
107
|
+
*
|
|
108
|
+
* Synchronous: it records what `fn` reads before returning, so an async `fn`
|
|
109
|
+
* is recorded only up to its first await. Use withProvenanceAsync for that.
|
|
110
|
+
*/
|
|
111
|
+
export declare function withProvenance<T>(fn: () => T): {
|
|
112
|
+
result: T;
|
|
113
|
+
provenance: ProvenanceSummary;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* withProvenance for an async function: every param() read inside `fn`,
|
|
117
|
+
* before and after each await, is recorded, and nothing read by code running
|
|
118
|
+
* concurrently in another context is. Nests like withProvenance in both
|
|
119
|
+
* directions: its reads land in any enclosing recording when it settles, and
|
|
120
|
+
* withProvenance, readsOf or another withProvenanceAsync inside it land in it.
|
|
121
|
+
*
|
|
122
|
+
* Covers what `fn` awaits. Work it starts and does not await (a fire-and-forget
|
|
123
|
+
* promise) can still read into this recording after the summary is taken, and
|
|
124
|
+
* is then counted nowhere; a tool answer awaits everything it reports.
|
|
125
|
+
*/
|
|
126
|
+
export declare function withProvenanceAsync<T>(fn: () => Promise<T>): Promise<{
|
|
127
|
+
result: T;
|
|
128
|
+
provenance: ProvenanceSummary;
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* withProvenanceAsync whose reads do NOT land in an enclosing recording: a
|
|
132
|
+
* block of its own. For work a tool does beside its score, such as the
|
|
133
|
+
* attention map cognitive_effort draws as context, whose constants (fitted
|
|
134
|
+
* gaze calibration, published colour science) would otherwise be counted as
|
|
135
|
+
* the score's and make it look partly fitted. Recordings nested inside it land
|
|
136
|
+
* in it as usual. A process-wide session (startProvenanceRecording) still sees
|
|
137
|
+
* its reads, since coverage tests count every read the process makes.
|
|
138
|
+
*/
|
|
139
|
+
export declare function isolatedProvenanceAsync<T>(fn: () => Promise<T>, text?: ProvenanceText): Promise<{
|
|
140
|
+
result: T;
|
|
141
|
+
provenance: ProvenanceSummary;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* The provenance of the recording this code runs inside, as read so far, or
|
|
145
|
+
* null outside any. A tool handler running under withProvenanceAsync calls it
|
|
146
|
+
* as the last step before serialising its answer, so the block it reports is
|
|
147
|
+
* everything that answer read. Nested recordings that have finished are
|
|
148
|
+
* already merged into it; ones still running are not.
|
|
149
|
+
*/
|
|
150
|
+
export declare function activeProvenance(): ProvenanceSummary | null;
|
|
151
|
+
//# sourceMappingURL=model-provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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B,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,UAAU,EAAE,iBAAiB,CAAA;CAAE,CAS3F;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,UAAU,EAAE,iBAAiB,CAAA;CAAE,CAAC,CASxH;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,EAC7C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,UAAU,EAAE,iBAAiB,CAAA;CAAE,CAAC,CAQvD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,GAAG,IAAI,CAG3D"}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where every number in the cognitive transport model comes from.
|
|
3
|
+
*
|
|
4
|
+
* A constant the model reads is either:
|
|
5
|
+
* fitted estimated from named data, with the held-out score in `source`
|
|
6
|
+
* published taken from a cited law or measurement in the literature
|
|
7
|
+
* definition a choice of units, scale or encoding that carries no empirical claim
|
|
8
|
+
* hypothesis set by hand; nothing in data or literature backs the value yet
|
|
9
|
+
*
|
|
10
|
+
* The paper and the tools report these labels instead of presenting hand-set
|
|
11
|
+
* numbers as findings. Everything the chain, the persona distance and the DRO
|
|
12
|
+
* bound read goes through `param()`, so the registry cannot drift from the code:
|
|
13
|
+
* tests record which ids a run reads and fail on an id that is read but not
|
|
14
|
+
* registered, or registered but never read.
|
|
15
|
+
*
|
|
16
|
+
* Entries live beside the code that reads them (provenance/*.ts) and are merged
|
|
17
|
+
* here, so a new constant is registered in the same file it is introduced in.
|
|
18
|
+
*
|
|
19
|
+
* @copyright 2026 Alexandria Eden alexandria.shai.eden@gmail.com https://cbrowser.ai
|
|
20
|
+
* @license MIT
|
|
21
|
+
*/
|
|
22
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
23
|
+
import { CHAIN_PROVENANCE } from "./provenance/chain.js";
|
|
24
|
+
import { DISTANCE_PROVENANCE } from "./provenance/distance.js";
|
|
25
|
+
import { DRO_PROVENANCE } from "./provenance/dro.js";
|
|
26
|
+
import { PERSONA_PROVENANCE } from "./provenance/personas.js";
|
|
27
|
+
import { CIF_PROVENANCE } from "./provenance/cif.js";
|
|
28
|
+
import { CTC_REFERENCE_PROVENANCE } from "./provenance/ctc-reference.js";
|
|
29
|
+
import { ATTENTION_PROVENANCE } from "./provenance/attention.js";
|
|
30
|
+
import { PERCEPTUAL_PROVENANCE } from "./provenance/perceptual.js";
|
|
31
|
+
import { PAGE_METRICS_PROVENANCE } from "./provenance/page-metrics.js";
|
|
32
|
+
import { VISUAL_DISTANCE_PROVENANCE } from "./provenance/visual-distance.js";
|
|
33
|
+
import { LAW_PROVENANCE } from "./provenance/laws.js";
|
|
34
|
+
import { PROFILE_PROVENANCE } from "./provenance/profiles.js";
|
|
35
|
+
import { PERSONA_RATE_PROVENANCE, CUSTOM_RATE_PROVENANCE } from "./provenance/persona-rates.js";
|
|
36
|
+
import { JOURNEY_GROUP_PROVENANCE } from "./provenance/journey-group.js";
|
|
37
|
+
function index(...groups) {
|
|
38
|
+
const out = {};
|
|
39
|
+
for (const g of groups)
|
|
40
|
+
for (const e of g) {
|
|
41
|
+
if (out[e.id])
|
|
42
|
+
throw new Error(`duplicate provenance id ${e.id}`);
|
|
43
|
+
out[e.id] = e;
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
export const MODEL_PROVENANCE = Object.freeze(index(CHAIN_PROVENANCE, DISTANCE_PROVENANCE, DRO_PROVENANCE, PERSONA_PROVENANCE, CIF_PROVENANCE, CTC_REFERENCE_PROVENANCE, ATTENTION_PROVENANCE, PERCEPTUAL_PROVENANCE, PAGE_METRICS_PROVENANCE, VISUAL_DISTANCE_PROVENANCE, LAW_PROVENANCE, PROFILE_PROVENANCE, PERSONA_RATE_PROVENANCE, CUSTOM_RATE_PROVENANCE, JOURNEY_GROUP_PROVENANCE));
|
|
48
|
+
/**
|
|
49
|
+
* WHERE A READ IS RECORDED. Every recording (withProvenance, readsOf,
|
|
50
|
+
* withProvenanceAsync) is a set bound to the async context it runs in, so a
|
|
51
|
+
* read lands in the recording of the code that made it, across awaits, and
|
|
52
|
+
* never in a concurrent request's. Through 21.0 this was one module-level
|
|
53
|
+
* set: correct only while every recorded computation was synchronous, which
|
|
54
|
+
* is why a tool could record its chain run and not the page measurement or
|
|
55
|
+
* verdict around it (both happen across awaits). startProvenanceRecording is
|
|
56
|
+
* the one recording outside any context: a whole-process session for tests,
|
|
57
|
+
* seen by any read that no scoped recording claims.
|
|
58
|
+
*/
|
|
59
|
+
const scoped = new AsyncLocalStorage();
|
|
60
|
+
let session = null;
|
|
61
|
+
let overrides = null;
|
|
62
|
+
/** The recording a read made here lands in: the innermost scoped one, else the session, else none. */
|
|
63
|
+
function current() {
|
|
64
|
+
return scoped.getStore() ?? session;
|
|
65
|
+
}
|
|
66
|
+
/** Read a registered constant. Throws on an unregistered id, so a typo cannot fall back silently. */
|
|
67
|
+
export function param(id) {
|
|
68
|
+
const e = MODEL_PROVENANCE[id];
|
|
69
|
+
if (!e)
|
|
70
|
+
throw new Error(`unregistered model constant "${id}"`);
|
|
71
|
+
current()?.add(id);
|
|
72
|
+
if (overrides && id in overrides)
|
|
73
|
+
return overrides[id];
|
|
74
|
+
return e.value;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* TEST ONLY: run `fn` with some registered constants replaced, then restore
|
|
78
|
+
* them. It exists so tests/ctc-no-dead-constants.test.ts can perturb every
|
|
79
|
+
* constant and check that the output moves; no shipped code may call it (a
|
|
80
|
+
* test asserts that). Calls nest, the innermost value winning, and an
|
|
81
|
+
* unregistered id throws exactly as param() does.
|
|
82
|
+
*/
|
|
83
|
+
export function withParamOverrides(values, fn) {
|
|
84
|
+
for (const id of Object.keys(values)) {
|
|
85
|
+
if (!MODEL_PROVENANCE[id])
|
|
86
|
+
throw new Error(`unregistered model constant "${id}"`);
|
|
87
|
+
}
|
|
88
|
+
const outer = overrides;
|
|
89
|
+
overrides = { ...(outer ?? {}), ...values };
|
|
90
|
+
try {
|
|
91
|
+
return fn();
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
overrides = outer;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* TEST ONLY: withParamOverrides for an async `fn`, the overrides holding
|
|
99
|
+
* until it settles. The override set is process-wide, not scoped to the async
|
|
100
|
+
* context, so anything else running meanwhile sees it too: a test awaits one
|
|
101
|
+
* override at a time (tests/journey-no-dead-constants.test.ts, which perturbs
|
|
102
|
+
* the constants a journey reads across its awaits).
|
|
103
|
+
*/
|
|
104
|
+
export async function withParamOverridesAsync(values, fn) {
|
|
105
|
+
for (const id of Object.keys(values)) {
|
|
106
|
+
if (!MODEL_PROVENANCE[id])
|
|
107
|
+
throw new Error(`unregistered model constant "${id}"`);
|
|
108
|
+
}
|
|
109
|
+
const outer = overrides;
|
|
110
|
+
overrides = { ...(outer ?? {}), ...values };
|
|
111
|
+
try {
|
|
112
|
+
return await fn();
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
overrides = outer;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The override set in force, or null outside withParamOverrides. A new object
|
|
120
|
+
* on every override call, so a cache of anything derived from registered
|
|
121
|
+
* constants (the CTC reference curve) can key on it by identity and is never
|
|
122
|
+
* served across a change of constants. Read-only: never mutate it.
|
|
123
|
+
*/
|
|
124
|
+
export function activeOverrides() {
|
|
125
|
+
return overrides;
|
|
126
|
+
}
|
|
127
|
+
/** Start recording which ids `param()` reads. Returns the live set. Test and reporting use only. */
|
|
128
|
+
export function startProvenanceRecording() {
|
|
129
|
+
session = new Set();
|
|
130
|
+
return session;
|
|
131
|
+
}
|
|
132
|
+
export function stopProvenanceRecording() {
|
|
133
|
+
const r = session ?? new Set();
|
|
134
|
+
session = null;
|
|
135
|
+
return r;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The score block's scope: what a tool's `modelProvenance` counts. The
|
|
139
|
+
* attention maps a tool draws as context are recorded apart
|
|
140
|
+
* (isolatedProvenanceAsync) and carry ATTENTION_PROVENANCE_TEXT instead.
|
|
141
|
+
*/
|
|
142
|
+
const SCORE_SCOPE = "Every registered constant the score in this answer read: the page-metric extraction that measured the page (pageMetrics.*), " +
|
|
143
|
+
"the published laws that turn the page into seconds of pointing, choosing, reading and procedure for the reference user " +
|
|
144
|
+
"(law.*: Fitts, novice visual search, Brysbaert's reading rate, the keystroke-level model, and the first read of a menu label, " +
|
|
145
|
+
"law.reading.labelFirstRead, a hypothesis) and the one time budget each is a " +
|
|
146
|
+
"demand against (law.timeBudget, a hypothesis), the demand curves that turn the other page metrics into per-trait demand, " +
|
|
147
|
+
"the cognitive transport chain (with its Schwartz value modulation " +
|
|
148
|
+
"when values were applied), the reference set totalCTC is ranked against and the verdict bands cut on it (definitions), and the two " +
|
|
149
|
+
"persona-distance constants the persona profile reads. It does not count the attention model: an attention map in this answer " +
|
|
150
|
+
"(cognitive_effort's saliency overlay, visual_cognitive_story's attention analysis) is context for the page, not an input to the " +
|
|
151
|
+
"score, and carries its own block for the attention model's constants: published colour science, the gaze constants fitted on " +
|
|
152
|
+
"UEyes eye-tracking (held-out AUC 0.7367, GAZE_CALIBRATION) where a map applies them, and hand-set weights and filters.";
|
|
153
|
+
const SCORE_NOTE = "Constants labelled hypothesis are set by hand and untested against human data. This reports where each number comes from; " +
|
|
154
|
+
"it is not a validation of the score. See MODEL_PROVENANCE for each source.";
|
|
155
|
+
/** The text of an attention map's own block. */
|
|
156
|
+
export const ATTENTION_PROVENANCE_TEXT = Object.freeze({
|
|
157
|
+
scope: "Every registered constant the attention model read to draw this map. The model's constants are the colour-science conversion " +
|
|
158
|
+
"(published: sRGB, CIE XYZ and L*a*b*), the gaze blend, smoothing width and spatial prior fitted on UEyes eye-tracking (held-out " +
|
|
159
|
+
"AUC 0.7367, GAZE_CALIBRATION), and hand-set channel weights, element weights and persona filters (hypotheses); the counts say " +
|
|
160
|
+
"which of them this map read. The map is context for the page, not an input to the cognitive transport score, whose constants " +
|
|
161
|
+
"are counted in modelProvenance.",
|
|
162
|
+
note: "Constants labelled fitted were estimated from free-viewing eye-tracking pooled over many people, so they say nothing about a " +
|
|
163
|
+
"particular persona; those labelled hypothesis are set by hand. This reports where each number in the map comes from; it is " +
|
|
164
|
+
"not a validation of the map. See MODEL_PROVENANCE for each source.",
|
|
165
|
+
});
|
|
166
|
+
/** Summarise a set of ids (what one computation read) for a tool response. */
|
|
167
|
+
/** The two reference rates a capacity is a ratio against; they cancel in c = r_p / (r_p + r_ref). */
|
|
168
|
+
const REFERENCE_RATE_IDS = new Set(["law.rate.pointing.reference", "law.reading.wpm"]);
|
|
169
|
+
export const PERSONA_RATE_PROVENANCE_TEXT = Object.freeze({
|
|
170
|
+
scope: "The rates the scored persona's motor and reading capacities were computed from, counted apart from modelProvenance because " +
|
|
171
|
+
"they describe the persona, not the score's constants. A built-in persona's are registered with it (personaRate.*); a custom " +
|
|
172
|
+
"persona's are the rule it fell under (customRate.*), or, where it stated a reading profile, the fixation-model constants that " +
|
|
173
|
+
"turn that profile into a rate (profile.*). Each capacity is c = r_p / (r_p + r_ref) against the reference rates " +
|
|
174
|
+
"law.rate.pointing.reference and law.reading.wpm (published), which cancel in the ratio and are not counted here, nor is the pointing profile's endpoint dispersion (the hit-probability audit's, not a rate). The other " +
|
|
175
|
+
"personas' rates are part of the reference population totalCTC is ranked against (a definition) and are not listed.",
|
|
176
|
+
note: "A rate labelled published was measured on the persona's population against same-study controls; hypothesis rates include " +
|
|
177
|
+
"\"no measured difference\", the reference rate given where no source measures one. See MODEL_PROVENANCE for each source.",
|
|
178
|
+
});
|
|
179
|
+
/** The endpoint dispersion the bridge reads for the pointing profile it returns: the hit-probability audit's, not a rate. */
|
|
180
|
+
const DISPERSION_ID = /^profile\.pointing\.(?:[^.]+\.(?:sigma|rho)|precision\..+)$/;
|
|
181
|
+
/** The persona-rate section of an answer, from the ids collectPersonaReads returned for the scored persona's bridge. */
|
|
182
|
+
export function personaRateProvenance(ids) {
|
|
183
|
+
const rates = [...new Set(ids)].filter((id) => MODEL_PROVENANCE[id] && !REFERENCE_RATE_IDS.has(id) && !DISPERSION_ID.test(id)).sort();
|
|
184
|
+
return { ...provenanceSummary(rates, PERSONA_RATE_PROVENANCE_TEXT), rates };
|
|
185
|
+
}
|
|
186
|
+
export function provenanceSummary(ids, text = {}) {
|
|
187
|
+
const counts = { fitted: 0, published: 0, definition: 0, hypothesis: 0 };
|
|
188
|
+
const hypotheses = [];
|
|
189
|
+
for (const id of ids) {
|
|
190
|
+
const e = MODEL_PROVENANCE[id];
|
|
191
|
+
if (!e)
|
|
192
|
+
continue;
|
|
193
|
+
counts[e.status]++;
|
|
194
|
+
if (e.status === "hypothesis")
|
|
195
|
+
hypotheses.push(id);
|
|
196
|
+
}
|
|
197
|
+
hypotheses.sort();
|
|
198
|
+
return {
|
|
199
|
+
counts,
|
|
200
|
+
hypotheses,
|
|
201
|
+
scope: text.scope ?? SCORE_SCOPE,
|
|
202
|
+
note: text.note ?? SCORE_NOTE,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Run `fn` and return the ids it read. Nests like withProvenance: the reads
|
|
207
|
+
* also land in any enclosing recording. Used to remember what a cached value
|
|
208
|
+
* was derived from, so a cache hit can record the same dependencies a miss
|
|
209
|
+
* would have.
|
|
210
|
+
*/
|
|
211
|
+
export function readsOf(fn) {
|
|
212
|
+
const outer = current();
|
|
213
|
+
const mine = new Set();
|
|
214
|
+
try {
|
|
215
|
+
return { result: scoped.run(mine, fn), ids: mine };
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
if (outer)
|
|
219
|
+
for (const id of mine)
|
|
220
|
+
outer.add(id);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The persona models' own recording channel. Reads made by the persona models
|
|
225
|
+
* in cognitive-models.ts (capacity rates, pointing and reading profiles, the
|
|
226
|
+
* fixation model the readability audit shares) describe the persona or an
|
|
227
|
+
* audit, not the score, so they never land in a score's recording: a score
|
|
228
|
+
* block counts demand, chain, reference and distance. Without this, a block
|
|
229
|
+
* would also count whichever personas the CTC reference curve happened to bridge
|
|
230
|
+
* on a cache miss, and the motor and readability audits a tool runs beside its
|
|
231
|
+
* score. A process-wide session (startProvenanceRecording) still sees them, as
|
|
232
|
+
* with isolatedProvenanceAsync, since coverage tests count every read the
|
|
233
|
+
* process makes. Overrides apply as usual.
|
|
234
|
+
*/
|
|
235
|
+
const personaCollector = new AsyncLocalStorage();
|
|
236
|
+
/** Run `fn` as persona-model work: its reads go to the active collectPersonaReads set (if any) and the session, never to a score recording. */
|
|
237
|
+
export function personaScope(fn) {
|
|
238
|
+
const mine = personaCollector.getStore() ?? new Set();
|
|
239
|
+
try {
|
|
240
|
+
return scoped.run(mine, fn);
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
if (session)
|
|
244
|
+
for (const id of mine)
|
|
245
|
+
session.add(id);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Run `fn` as persona-model work and return the ids it read. A tool wraps the
|
|
250
|
+
* scored persona's bridge in this to report the rates that persona was scored
|
|
251
|
+
* with in a section of their own: computed from the persona, so no cache state
|
|
252
|
+
* can change it.
|
|
253
|
+
*/
|
|
254
|
+
export function collectPersonaReads(fn) {
|
|
255
|
+
const mine = new Set();
|
|
256
|
+
const result = personaCollector.run(mine, () => personaScope(fn));
|
|
257
|
+
return { result, ids: mine };
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Run `fn` and return its result with the provenance of every constant it read.
|
|
261
|
+
*
|
|
262
|
+
* Synchronous: it records what `fn` reads before returning, so an async `fn`
|
|
263
|
+
* is recorded only up to its first await. Use withProvenanceAsync for that.
|
|
264
|
+
*/
|
|
265
|
+
export function withProvenance(fn) {
|
|
266
|
+
const outer = current();
|
|
267
|
+
const mine = new Set();
|
|
268
|
+
try {
|
|
269
|
+
const result = scoped.run(mine, fn);
|
|
270
|
+
return { result, provenance: provenanceSummary(mine) };
|
|
271
|
+
}
|
|
272
|
+
finally {
|
|
273
|
+
if (outer)
|
|
274
|
+
for (const id of mine)
|
|
275
|
+
outer.add(id);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* withProvenance for an async function: every param() read inside `fn`,
|
|
280
|
+
* before and after each await, is recorded, and nothing read by code running
|
|
281
|
+
* concurrently in another context is. Nests like withProvenance in both
|
|
282
|
+
* directions: its reads land in any enclosing recording when it settles, and
|
|
283
|
+
* withProvenance, readsOf or another withProvenanceAsync inside it land in it.
|
|
284
|
+
*
|
|
285
|
+
* Covers what `fn` awaits. Work it starts and does not await (a fire-and-forget
|
|
286
|
+
* promise) can still read into this recording after the summary is taken, and
|
|
287
|
+
* is then counted nowhere; a tool answer awaits everything it reports.
|
|
288
|
+
*/
|
|
289
|
+
export async function withProvenanceAsync(fn) {
|
|
290
|
+
const outer = current();
|
|
291
|
+
const mine = new Set();
|
|
292
|
+
try {
|
|
293
|
+
const result = await scoped.run(mine, fn);
|
|
294
|
+
return { result, provenance: provenanceSummary(mine) };
|
|
295
|
+
}
|
|
296
|
+
finally {
|
|
297
|
+
if (outer)
|
|
298
|
+
for (const id of mine)
|
|
299
|
+
outer.add(id);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* withProvenanceAsync whose reads do NOT land in an enclosing recording: a
|
|
304
|
+
* block of its own. For work a tool does beside its score, such as the
|
|
305
|
+
* attention map cognitive_effort draws as context, whose constants (fitted
|
|
306
|
+
* gaze calibration, published colour science) would otherwise be counted as
|
|
307
|
+
* the score's and make it look partly fitted. Recordings nested inside it land
|
|
308
|
+
* in it as usual. A process-wide session (startProvenanceRecording) still sees
|
|
309
|
+
* its reads, since coverage tests count every read the process makes.
|
|
310
|
+
*/
|
|
311
|
+
export async function isolatedProvenanceAsync(fn, text = {}) {
|
|
312
|
+
const mine = new Set();
|
|
313
|
+
try {
|
|
314
|
+
const result = await scoped.run(mine, fn);
|
|
315
|
+
return { result, provenance: provenanceSummary(mine, text) };
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
if (session)
|
|
319
|
+
for (const id of mine)
|
|
320
|
+
session.add(id);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* The provenance of the recording this code runs inside, as read so far, or
|
|
325
|
+
* null outside any. A tool handler running under withProvenanceAsync calls it
|
|
326
|
+
* as the last step before serialising its answer, so the block it reports is
|
|
327
|
+
* everything that answer read. Nested recordings that have finished are
|
|
328
|
+
* already merged into it; ones still running are not.
|
|
329
|
+
*/
|
|
330
|
+
export function activeProvenance() {
|
|
331
|
+
const r = current();
|
|
332
|
+
return r ? provenanceSummary(r) : null;
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=model-provenance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-provenance.js","sourceRoot":"","sources":["../../src/visual/model-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAarD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,k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AAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,EAAoB,EACpB,OAAuB,EAAE;IAEzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;IAC/D,CAAC;YAAS,CAAC;QACT,IAAI,OAAO;YAAE,KAAK,MAAM,EAAE,IAAI,IAAI;gBAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The standard normal CDF, on its own so a module can use it without
|
|
3
|
+
* importing cognitive-models.ts (and through it model-provenance.ts); see the
|
|
4
|
+
* note where cognitive-models.ts re-exports it as _normalCDF.
|
|
5
|
+
*
|
|
6
|
+
* @copyright 2026 Alexandria Eden alexandria.shai.eden@gmail.com https://cbrowser.ai
|
|
7
|
+
* @license MIT
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Standard normal CDF (cumulative distribution function).
|
|
11
|
+
* Abramowitz and Stegun approximation (7.1.26), error < 7.5e-8.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalCDF(x: number): number;
|
|
14
|
+
//# sourceMappingURL=normal-cdf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normal-cdf.d.ts","sourceRoot":"","sources":["../../src/visual/normal-cdf.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAc3C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The standard normal CDF, on its own so a module can use it without
|
|
3
|
+
* importing cognitive-models.ts (and through it model-provenance.ts); see the
|
|
4
|
+
* note where cognitive-models.ts re-exports it as _normalCDF.
|
|
5
|
+
*
|
|
6
|
+
* @copyright 2026 Alexandria Eden alexandria.shai.eden@gmail.com https://cbrowser.ai
|
|
7
|
+
* @license MIT
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Standard normal CDF (cumulative distribution function).
|
|
11
|
+
* Abramowitz and Stegun approximation (7.1.26), error < 7.5e-8.
|
|
12
|
+
*/
|
|
13
|
+
export function normalCDF(x) {
|
|
14
|
+
const a1 = 0.254829592;
|
|
15
|
+
const a2 = -0.284496736;
|
|
16
|
+
const a3 = 1.421413741;
|
|
17
|
+
const a4 = -1.453152027;
|
|
18
|
+
const a5 = 1.061405429;
|
|
19
|
+
const p = 0.3275911;
|
|
20
|
+
const sign = x < 0 ? -1 : 1;
|
|
21
|
+
const absX = Math.abs(x) / Math.SQRT2;
|
|
22
|
+
const t = 1 / (1 + p * absX);
|
|
23
|
+
const y = 1 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * Math.exp(-absX * absX);
|
|
24
|
+
return 0.5 * (1 + sign * y);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=normal-cdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normal-cdf.js","sourceRoot":"","sources":["../../src/visual/normal-cdf.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC;IACxB,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC;IACxB,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,CAAC,GAAG,SAAS,CAAC;IAEpB,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IACtC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAE5F,OAAO,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -57,14 +57,36 @@ export interface PerceptualAnalysis {
|
|
|
57
57
|
transportDistance: number;
|
|
58
58
|
computeTimeMs: number;
|
|
59
59
|
}
|
|
60
|
+
export declare const PERCEPTUAL_PROFILES: Record<string, PerceptualProfile>;
|
|
61
|
+
export declare const DEFAULT_PROFILE: PerceptualProfile;
|
|
60
62
|
/**
|
|
61
|
-
*
|
|
63
|
+
* How a perceptual profile was found for a persona name.
|
|
64
|
+
*
|
|
65
|
+
* "builtin" the name is one of PERCEPTUAL_PROFILES
|
|
66
|
+
* "synthesized" built from the caller's accessibility traits
|
|
67
|
+
* "inferred" a built-in borrowed because of a keyword in the name
|
|
68
|
+
* "default" nothing matched; DEFAULT_PROFILE, which models no one
|
|
69
|
+
*/
|
|
70
|
+
export type PerceptualResolution = 'builtin' | 'synthesized' | 'inferred' | 'default';
|
|
71
|
+
export interface ResolvedPerceptualProfile {
|
|
72
|
+
profile: PerceptualProfile;
|
|
73
|
+
resolution: PerceptualResolution;
|
|
74
|
+
/**
|
|
75
|
+
* The profile actually used: the persona itself for builtin and synthesized,
|
|
76
|
+
* the borrowed built-in for inferred, "default" for default.
|
|
77
|
+
*/
|
|
78
|
+
resolvedProfile: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the perceptual profile for a persona, and say how it was found.
|
|
62
82
|
*
|
|
63
83
|
* For built-in personas, returns the hardcoded profile.
|
|
64
84
|
* For custom personas, synthesizes a profile from accessibility traits if provided,
|
|
65
|
-
* or infers from the persona name as a fallback.
|
|
85
|
+
* or infers from the persona name as a fallback. An unknown name never throws
|
|
86
|
+
* (custom personas rely on the inference); it resolves to "default", and the
|
|
87
|
+
* resolution is what lets a caller tell that apart from a real profile.
|
|
66
88
|
*/
|
|
67
|
-
export declare function
|
|
89
|
+
export declare function resolvePerceptualProfile(personaName: string, accessibilityTraits?: {
|
|
68
90
|
motorControl?: number;
|
|
69
91
|
tremor?: boolean;
|
|
70
92
|
visionLevel?: number;
|
|
@@ -72,7 +94,9 @@ export declare function getPerceptualProfile(personaName: string, accessibilityT
|
|
|
72
94
|
processingSpeed?: number;
|
|
73
95
|
attentionSpan?: number;
|
|
74
96
|
fatigueSusceptibility?: number;
|
|
75
|
-
}):
|
|
97
|
+
}): ResolvedPerceptualProfile;
|
|
98
|
+
/** `resolvePerceptualProfile` without the resolution. */
|
|
99
|
+
export declare function getPerceptualProfile(personaName: string, accessibilityTraits?: Parameters<typeof resolvePerceptualProfile>[1]): PerceptualProfile;
|
|
76
100
|
/**
|
|
77
101
|
* Apply persona-weighted barrier scoring.
|
|
78
102
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perceptual-transport.d.ts","sourceRoot":"","sources":["../../src/visual/perceptual-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IACnE,4FAA4F;IAC5F,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,2CAA2C;IAC3C,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,8EAA8E;IAC9E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,+DAA+D;IAC/D,aAAa,EAAE,SAAS,GAAG,cAAc,GAAG,kBAAkB,GAAG,cAAc,GAAG,gBAAgB,CAAC;IACnG,oFAAoF;IACpF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,eAAe,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,6FAA6F;IAC7F,eAAe,EAAE,MAAM,CAAC;IACxB,gHAAgH;IAChH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sGAAsG;IACtG,SAAS,EAAE,MAAM,CAAC;IAClB,+FAA+F;IAC/F,aAAa,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,eAAe,EAAE,MAAM,CAAC;IACxB,2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