@cavelang/core 0.1.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.
Files changed (62) hide show
  1. package/README.md +76 -0
  2. package/dist/src/claim.d.ts +108 -0
  3. package/dist/src/claim.d.ts.map +1 -0
  4. package/dist/src/claim.js +65 -0
  5. package/dist/src/claim.js.map +1 -0
  6. package/dist/src/confidence.d.ts +26 -0
  7. package/dist/src/confidence.d.ts.map +1 -0
  8. package/dist/src/confidence.js +34 -0
  9. package/dist/src/confidence.js.map +1 -0
  10. package/dist/src/context.d.ts +26 -0
  11. package/dist/src/context.d.ts.map +1 -0
  12. package/dist/src/context.js +31 -0
  13. package/dist/src/context.js.map +1 -0
  14. package/dist/src/entity.d.ts +26 -0
  15. package/dist/src/entity.d.ts.map +1 -0
  16. package/dist/src/entity.js +41 -0
  17. package/dist/src/entity.js.map +1 -0
  18. package/dist/src/index.d.ts +23 -0
  19. package/dist/src/index.d.ts.map +1 -0
  20. package/dist/src/index.js +23 -0
  21. package/dist/src/index.js.map +1 -0
  22. package/dist/src/key.d.ts +28 -0
  23. package/dist/src/key.d.ts.map +1 -0
  24. package/dist/src/key.js +49 -0
  25. package/dist/src/key.js.map +1 -0
  26. package/dist/src/multiplier.d.ts +17 -0
  27. package/dist/src/multiplier.d.ts.map +1 -0
  28. package/dist/src/multiplier.js +19 -0
  29. package/dist/src/multiplier.js.map +1 -0
  30. package/dist/src/tag.d.ts +29 -0
  31. package/dist/src/tag.d.ts.map +1 -0
  32. package/dist/src/tag.js +28 -0
  33. package/dist/src/tag.js.map +1 -0
  34. package/dist/src/uncertainty.d.ts +21 -0
  35. package/dist/src/uncertainty.d.ts.map +1 -0
  36. package/dist/src/uncertainty.js +26 -0
  37. package/dist/src/uncertainty.js.map +1 -0
  38. package/dist/src/uuidv7.d.ts +28 -0
  39. package/dist/src/uuidv7.d.ts.map +1 -0
  40. package/dist/src/uuidv7.js +69 -0
  41. package/dist/src/uuidv7.js.map +1 -0
  42. package/dist/src/value.d.ts +57 -0
  43. package/dist/src/value.d.ts.map +1 -0
  44. package/dist/src/value.js +104 -0
  45. package/dist/src/value.js.map +1 -0
  46. package/dist/src/verb.d.ts +47 -0
  47. package/dist/src/verb.d.ts.map +1 -0
  48. package/dist/src/verb.js +55 -0
  49. package/dist/src/verb.js.map +1 -0
  50. package/package.json +39 -0
  51. package/src/claim.ts +148 -0
  52. package/src/confidence.ts +42 -0
  53. package/src/context.ts +43 -0
  54. package/src/entity.ts +49 -0
  55. package/src/index.ts +23 -0
  56. package/src/key.ts +55 -0
  57. package/src/multiplier.ts +28 -0
  58. package/src/tag.ts +42 -0
  59. package/src/uncertainty.ts +29 -0
  60. package/src/uuidv7.ts +76 -0
  61. package/src/value.ts +138 -0
  62. package/src/verb.ts +78 -0
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @cavelang/core
2
+
3
+ The CAVE domain model — the dependency-free foundation every other package in
4
+ this monorepo builds on. Implements the model layer of the
5
+ [CAVE specification](../../README.md#the-specification): canonical claims (§2), metadata
6
+ semantics (§6), values/units/uncertainty (§7), claim keys and append-only
7
+ belief evolution primitives (§9).
8
+
9
+ Modules follow the `@prelude` convention — import a module as a namespace,
10
+ its principal type is `t`:
11
+
12
+ ```ts
13
+ import { Claim, Key, Value, Confidence, Uuidv7 } from '@cavelang/core'
14
+
15
+ const claim: Claim.t = Claim.of({
16
+ subject: Claim.entity('auth/middleware'),
17
+ verb: 'USES',
18
+ payload: Claim.relation(Claim.entity('jwt'))
19
+ })
20
+
21
+ Key.of(claim) // '["e:auth/middleware","USES",0,"r:e:jwt",[]]'
22
+ Uuidv7.next() // '01977b6e-…' — monotonic transaction id
23
+ ```
24
+
25
+ ## Modules
26
+
27
+ | Module | Spec | Purpose |
28
+ |---|---|---|
29
+ | `Claim` | §2.1, §3.1 | Canonical claim shape: subject/verb/payload/negated + metadata. Payloads: `relation`, `attribute`, `metric`. Terms: `entity`, `text` (double-quoted), `code` (backticked). |
30
+ | `Key` | §9.2 | Stable claim keys computed on the canonical form. Values excluded; contexts as a sorted set; negation included. |
31
+ | `Value` | §7.1 | Value parsing: numbers, glued units (`30ms`), multipliers (`20B` → 2×10¹⁰), compound units (`USD/yr`), `~` approximation, date-likes (`2026-H2`), atoms. Raw text always preserved. |
32
+ | `Uncertainty` | §7.2 | Aleatory `+/- Δ (kσ)` semantics: σ = Δ/k, default 2σ. |
33
+ | `Confidence` | §6.3 | Epistemic `@ N%` in [0, 1]; omitted means 1. |
34
+ | `Tag` | §6.2 | Flat `#tag` and scoped `#key:value`; flat ≡ value `undefined`. |
35
+ | `Context` | §6.1 | `@ctx` contexts and the recommended `src:`/`time:`/`loc:`/`scope:` prefixes. |
36
+ | `Entity` | §4.1 | Name normalization (whitespace → `-`, casing preserved) and advisory checks. |
37
+ | `Verb` | §5 | Standard vocabulary, qualifier verbs, `REVERSE`, lexical shape of verbs. |
38
+ | `Multiplier` | §7.1 | `T`/`B`/`M`/`K` scale factors. |
39
+ | `Uuidv7` | §9.1 | Monotonic UUIDv7 transaction ids — lexicographic order ⇒ transaction order, so `MAX(tx)` resolves current belief. |
40
+
41
+ ## Design decisions
42
+
43
+ Decisions this package pins down where the spec leaves latitude:
44
+
45
+ - **Key format** is a JSON array string —
46
+ `[subject, verb, negated, payloadPart, sortedContexts]` — deterministic,
47
+ collision-free (JSON escaping), and human-readable in the database.
48
+ `payloadPart` is `r:<object>` / `a:<attribute>` / `m` / `n`, and *every*
49
+ term is kind-prefixed (`e:` entity, `code:`, `text:`) so the three term
50
+ encodings occupy disjoint namespaces — even an entity literally named
51
+ `code:<=` cannot collide with the code literal `` `<=` ``.
52
+ - **Negation is a key component for all payload kinds.** §9.2 lists it for
53
+ relational claims; we extend it to attribute/metric claims so
54
+ `x HAS NOT a: v` and `x HAS a: v` evolve as separate facts, mirroring the
55
+ relational rule.
56
+ - **Metric claims key on the subject alone** (`m` payload part): `latency IS
57
+ 30ms` and `latency IS 800ms` are one fact whose value evolves, matching the
58
+ attribute rule "the value may change over time; the key stays about the
59
+ same property".
60
+ - **Claim classification** (relation vs metric) is the parser's job; core
61
+ only defines the shapes. `IS` + numeric/date value ⇒ metric, anything
62
+ else ⇒ relation.
63
+ - **`Value.parse` never fails** — unparseable text degrades to an `atom`
64
+ value with raw text preserved, honoring the LLM-friendliness goal (§1.6).
65
+ - **UUIDv7 monotonicity**: same-millisecond calls increment a 12-bit
66
+ sequence in `rand_a`; a backwards clock reuses the last timestamp. Strictly
67
+ increasing ids within a process, random `rand_b` across processes.
68
+
69
+ ## Tests
70
+
71
+ ```
72
+ pnpm --filter @cavelang/core test
73
+ ```
74
+
75
+ Every table and example in spec §6–§7 that concerns the model layer appears
76
+ as a test case (`test/*.test.ts`).
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Claims — the CAVE model (spec §2.1).
3
+ *
4
+ * Every CAVE line denotes a claim c = ⟨s, v, o, n, m⟩: subject, verb,
5
+ * object-or-attribute/value, negated, metadata (confidence, contexts, tags,
6
+ * value uncertainty, importance, comment, transaction identity). Claims are
7
+ * immutable — belief changes by appending (spec §9).
8
+ *
9
+ * This module defines the *canonical* claim shape: subject/verb/object are in
10
+ * primary direction (inverse forms are normalized before keying, spec §5.5),
11
+ * with the author's original text preserved in `raw`.
12
+ */
13
+ import * as Value from './value.ts';
14
+ import * as Tag from './tag.ts';
15
+ import * as Context from './context.ts';
16
+ import * as Confidence from './confidence.ts';
17
+ /** Subject or object term (spec §16: atom, literal or code literal). */
18
+ export type TermKind = 'entity' | 'text' | 'code';
19
+ export type Term = {
20
+ readonly kind: TermKind;
21
+ readonly text: string;
22
+ };
23
+ /** @returns entity term. */
24
+ export declare const entity: (text: string) => Term;
25
+ /** @returns double-quoted natural-language literal term. */
26
+ export declare const text: (value: string) => Term;
27
+ /** @returns backticked code literal term. */
28
+ export declare const code: (value: string) => Term;
29
+ /** @returns canonical text of a term with its delimiters. */
30
+ export declare const formatTerm: (term: Term) => string;
31
+ /**
32
+ * Claim payload — the canonical line shapes (spec §3.1) plus the object-less
33
+ * form used by bare existence assertions (spec §5.2 `EXISTS`):
34
+ *
35
+ * - `relation`: `subject VERB object`
36
+ * - `attribute`: `subject HAS attribute: value`
37
+ * - `metric`: `metric IS value`
38
+ * - `none`: `memory-leak EXISTS @production`
39
+ */
40
+ export type Payload = {
41
+ readonly kind: 'relation';
42
+ readonly object: Term;
43
+ } | {
44
+ readonly kind: 'attribute';
45
+ readonly attribute: string;
46
+ readonly value: Value.t;
47
+ } | {
48
+ readonly kind: 'metric';
49
+ readonly value: Value.t;
50
+ } | {
51
+ readonly kind: 'none';
52
+ };
53
+ /** Canonical (primary-direction) claim. */
54
+ export type Claim = {
55
+ readonly subject: Term;
56
+ /** Canonical primary verb, uppercase (spec §13.4 steps 1–2). */
57
+ readonly verb: string;
58
+ /** `VERB NOT` logical negation (spec §5.6). */
59
+ readonly negated: boolean;
60
+ readonly payload: Payload;
61
+ /** Contexts in author order, deduplicated. */
62
+ readonly contexts: readonly Context.t[];
63
+ readonly tags: readonly Tag.t[];
64
+ /** Epistemic confidence in [0, 1]; 1 when omitted (spec §6.3). */
65
+ readonly conf: Confidence.t;
66
+ /** `!` marker (spec §6). */
67
+ readonly importance: boolean;
68
+ /** `+/-` value uncertainty (spec §7.2). */
69
+ readonly delta?: Value.t;
70
+ /** `(Nσ)` σ-level override; semantic default is 2 (spec §7.2). */
71
+ readonly sigmaLevel?: number;
72
+ /** `;` persisted prose (spec §6.4). */
73
+ readonly comment?: string;
74
+ /** The line exactly as written, including inverse form (spec §5.5). */
75
+ readonly raw: string;
76
+ };
77
+ export type t = Claim;
78
+ export type Init = {
79
+ subject: Term;
80
+ verb: string;
81
+ payload: Payload;
82
+ negated?: boolean;
83
+ contexts?: readonly Context.t[];
84
+ tags?: readonly Tag.t[];
85
+ conf?: Confidence.t;
86
+ importance?: boolean;
87
+ delta?: Value.t;
88
+ sigmaLevel?: number;
89
+ comment?: string;
90
+ raw?: string;
91
+ };
92
+ /** @returns claim with defaults applied (spec §6: all suffixes optional). */
93
+ export declare const of: (init: Init) => Claim;
94
+ /** @returns relational claim payload. */
95
+ export declare const relation: (object: Term) => Payload;
96
+ /** @returns attribute/value claim payload. */
97
+ export declare const attribute: (attribute: string, value: Value.t) => Payload;
98
+ /** @returns metric claim payload. */
99
+ export declare const metric: (value: Value.t) => Payload;
100
+ /** Object-less payload — bare existence assertion (spec §5.2 `EXISTS`). */
101
+ export declare const none: Payload;
102
+ /**
103
+ * σ derived from the claim's `+/- Δ (kσ)` metadata: σ = Δ / k with k
104
+ * defaulting to 2 (spec §7.2). `undefined` when the claim carries no numeric
105
+ * uncertainty.
106
+ */
107
+ export declare const sigmaOf: (claim: Claim) => undefined | number;
108
+ //# sourceMappingURL=claim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../src/claim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAEjD,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,4BAA4B;AAC5B,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,KAAG,IACV,CAAA;AAE5B,4DAA4D;AAC5D,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,IACJ,CAAA;AAEjC,6CAA6C;AAC7C,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,IACJ,CAAA;AAEjC,6DAA6D;AAC7D,eAAO,MAAM,UAAU,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s, v, o, n, m⟩: subject, verb,
5
+ * object-or-attribute/value, negated, metadata (confidence, contexts, tags,
6
+ * value uncertainty, importance, comment, transaction identity). Claims are
7
+ * immutable — belief changes by appending (spec §9).
8
+ *
9
+ * This module defines the *canonical* claim shape: subject/verb/object are in
10
+ * primary direction (inverse forms are normalized before keying, spec §5.5),
11
+ * with the author's original text preserved in `raw`.
12
+ */
13
+ import * as Value from "./value.js";
14
+ import * as Tag from "./tag.js";
15
+ import * as Context from "./context.js";
16
+ import * as Confidence from "./confidence.js";
17
+ /** @returns entity term. */
18
+ export const entity = (text) => ({ kind: 'entity', text });
19
+ /** @returns double-quoted natural-language literal term. */
20
+ export const text = (value) => ({ kind: 'text', text: value });
21
+ /** @returns backticked code literal term. */
22
+ export const code = (value) => ({ kind: 'code', text: value });
23
+ /** @returns canonical text of a term with its delimiters. */
24
+ export const formatTerm = (term) => {
25
+ switch (term.kind) {
26
+ case 'text':
27
+ return `"${term.text}"`;
28
+ case 'code':
29
+ return `\`${term.text}\``;
30
+ default:
31
+ return term.text;
32
+ }
33
+ };
34
+ /** @returns claim with defaults applied (spec §6: all suffixes optional). */
35
+ export const of = (init) => ({
36
+ subject: init.subject,
37
+ verb: init.verb,
38
+ negated: init.negated ?? false,
39
+ payload: init.payload,
40
+ contexts: Context.dedupe(init.contexts ?? []),
41
+ tags: init.tags ?? [],
42
+ conf: init.conf ?? Confidence.defaultConfidence,
43
+ importance: init.importance ?? false,
44
+ ...init.delta !== undefined ? { delta: init.delta } : {},
45
+ ...init.sigmaLevel !== undefined ? { sigmaLevel: init.sigmaLevel } : {},
46
+ ...init.comment !== undefined ? { comment: init.comment } : {},
47
+ raw: init.raw ?? ''
48
+ });
49
+ /** @returns relational claim payload. */
50
+ export const relation = (object) => ({ kind: 'relation', object });
51
+ /** @returns attribute/value claim payload. */
52
+ export const attribute = (attribute, value) => ({ kind: 'attribute', attribute, value });
53
+ /** @returns metric claim payload. */
54
+ export const metric = (value) => ({ kind: 'metric', value });
55
+ /** Object-less payload — bare existence assertion (spec §5.2 `EXISTS`). */
56
+ export const none = { kind: 'none' };
57
+ /**
58
+ * σ derived from the claim's `+/- Δ (kσ)` metadata: σ = Δ / k with k
59
+ * defaulting to 2 (spec §7.2). `undefined` when the claim carries no numeric
60
+ * uncertainty.
61
+ */
62
+ export const sigmaOf = (claim) => claim.delta?.num === undefined ?
63
+ undefined :
64
+ claim.delta.num / (claim.sigmaLevel ?? 2);
65
+ //# sourceMappingURL=claim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim.js","sourceRoot":"","sources":["../../src/claim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAU7C,4BAA4B;AAC5B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAQ,EAAE,CAC3C,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;AAE5B,4DAA4D;AAC5D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAa,EAAQ,EAAE,CAC1C,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;AAEjC,6CAA6C;AAC7C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAa,EAAQ,EAAE,CAC1C,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;AAEjC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAU,EAAE;IAC/C,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,IAAI,IAAI,CAAC,IAAI,GAAG,CAAA;Q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,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,SAAiB,EAAE,KAAc,EAAW,EAAE,CACtE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;AAE3C,qCAAqC;AACrC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAW,EAAE,CAChD,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;AAE7B,2EAA2E;AAC3E,MAAM,CAAC,MAAM,IAAI,GACf,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AAElB;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAY,EAAsB,EAAE,CAC1D,KAAK,CAAC,KAAK,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC;IAC9B,SAAS,CAAC,CAAC;IACX,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Claim confidence — `@ N%` (spec §6.3).
3
+ *
4
+ * Epistemic belief in the assertion, stored as a decimal in [0, 1].
5
+ * Omitted confidence means `@ 100%` — directly observed, certain for
6
+ * practical purposes. `@ 0%` means evidentially false or fully rejected
7
+ * (retraction, spec §9.3).
8
+ */
9
+ export type Confidence = number;
10
+ export type t = Confidence;
11
+ /** Confidence of a claim with no explicit `@ N%` (spec §6.3). */
12
+ export declare const defaultConfidence = 1;
13
+ /**
14
+ * Parses a percentage token (`90%`) to a decimal clamped to [0, 1]
15
+ * (spec §13.4 step 6: `@ 90%` → `0.9`). The `%` is required — the grammar
16
+ * (spec §16) defines confidence as a percentage ending in `%`, and demanding
17
+ * it keeps a mistyped context like `@ 2026` from silently becoming
18
+ * certainty.
19
+ * @returns `undefined` when the token is not a percentage.
20
+ */
21
+ export declare const parse: (token: string) => undefined | Confidence;
22
+ /** @returns confidence clamped to [0, 1]. */
23
+ export declare const clamp: (conf: number) => Confidence;
24
+ /** @returns canonical `N%` text: `0.9` → `90%`. */
25
+ export declare const format: (conf: Confidence) => string;
26
+ //# sourceMappingURL=confidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confidence.d.ts","sourceRoot":"","sources":["../../src/confidence.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAE/B,MAAM,MAAM,CAAC,GAAG,UAAU,CAAA;AAE1B,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,SAAS,GAAG,UAMjD,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,KAAG,UACL,CAAA;AAEhC,mDAAmD;AACnD,eAAO,MAAM,MAAM,GAAI,MAAM,UAAU,KAAG,MAIzC,CAAA"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Claim confidence — `@ N%` (spec §6.3).
3
+ *
4
+ * Epistemic belief in the assertion, stored as a decimal in [0, 1].
5
+ * Omitted confidence means `@ 100%` — directly observed, certain for
6
+ * practical purposes. `@ 0%` means evidentially false or fully rejected
7
+ * (retraction, spec §9.3).
8
+ */
9
+ /** Confidence of a claim with no explicit `@ N%` (spec §6.3). */
10
+ export const defaultConfidence = 1;
11
+ /**
12
+ * Parses a percentage token (`90%`) to a decimal clamped to [0, 1]
13
+ * (spec §13.4 step 6: `@ 90%` → `0.9`). The `%` is required — the grammar
14
+ * (spec §16) defines confidence as a percentage ending in `%`, and demanding
15
+ * it keeps a mistyped context like `@ 2026` from silently becoming
16
+ * certainty.
17
+ * @returns `undefined` when the token is not a percentage.
18
+ */
19
+ export const parse = (token) => {
20
+ const match = /^(\d+(?:\.\d+)?)%$/.exec(token.trim());
21
+ if (!match || match[1] === undefined) {
22
+ return undefined;
23
+ }
24
+ return clamp(Number(match[1]) / 100);
25
+ };
26
+ /** @returns confidence clamped to [0, 1]. */
27
+ export const clamp = (conf) => Math.min(1, Math.max(0, conf));
28
+ /** @returns canonical `N%` text: `0.9` → `90%`. */
29
+ export const format = (conf) => {
30
+ const percent = conf * 100;
31
+ const rounded = Math.round(percent * 100) / 100;
32
+ return `${rounded}%`;
33
+ };
34
+ //# sourceMappingURL=confidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confidence.js","sourceRoot":"","sources":["../../src/confidence.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,iEAAiE;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAElC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAA0B,EAAE;IAC7D,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IACrD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;AACtC,CAAC,CAAA;AAED,6CAA6C;AAC7C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAc,EAAE,CAChD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;AAEhC,mDAAmD;AACnD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAgB,EAAU,EAAE;IACjD,MAAM,OAAO,GAAG,IAAI,GAAG,GAAG,CAAA;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;IAC/C,OAAO,GAAG,OAAO,GAAG,CAAA;AACtB,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Contexts — `@ctx` (spec §6.1).
3
+ *
4
+ * A context scopes a claim by time, place, source or logical scope:
5
+ * `@production`, `@2026-Q1`, `@auth.ts:42`, `@src:filing`. No space after
6
+ * `@` (with a space it is confidence, spec §6.3). Multiple contexts per
7
+ * claim are allowed and are part of the claim key (spec §9.2).
8
+ */
9
+ export type Context = string;
10
+ export type t = Context;
11
+ /** Recommended context prefixes (spec §6.1). */
12
+ export declare const prefixes: readonly ["src", "time", "loc", "scope"];
13
+ export type Prefix = (typeof prefixes)[number];
14
+ /**
15
+ * @returns the recommended prefix of a context, when it has one:
16
+ * `src:filing` → `src`, `production` → `undefined`.
17
+ */
18
+ export declare const prefix: (context: Context) => undefined | Prefix;
19
+ /** @returns canonical `@ctx` text. */
20
+ export declare const format: (context: Context) => string;
21
+ /**
22
+ * @returns deduplicated contexts in original order. Claim keys use the
23
+ * sorted form (see `Key`); emission preserves author order.
24
+ */
25
+ export declare const dedupe: (contexts: readonly Context[]) => Context[];
26
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B,MAAM,MAAM,CAAC,GAAG,OAAO,CAAA;AAEvB,gDAAgD;AAChD,eAAO,MAAM,QAAQ,0CAA2C,CAAA;AAEhE,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAA;AAI9C;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,SAAS,OAAO,KAAG,SAAS,GAAG,MAOrD,CAAA;AAED,sCAAsC;AACtC,eAAO,MAAM,MAAM,GAAI,SAAS,OAAO,KAAG,MAC3B,CAAA;AAEf;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,UAAU,SAAS,OAAO,EAAE,KAAG,OAAO,EACrC,CAAA"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Contexts — `@ctx` (spec §6.1).
3
+ *
4
+ * A context scopes a claim by time, place, source or logical scope:
5
+ * `@production`, `@2026-Q1`, `@auth.ts:42`, `@src:filing`. No space after
6
+ * `@` (with a space it is confidence, spec §6.3). Multiple contexts per
7
+ * claim are allowed and are part of the claim key (spec §9.2).
8
+ */
9
+ /** Recommended context prefixes (spec §6.1). */
10
+ export const prefixes = ['src', 'time', 'loc', 'scope'];
11
+ const prefixSet = new Set(prefixes);
12
+ /**
13
+ * @returns the recommended prefix of a context, when it has one:
14
+ * `src:filing` → `src`, `production` → `undefined`.
15
+ */
16
+ export const prefix = (context) => {
17
+ const colonAt = context.indexOf(':');
18
+ if (colonAt === -1) {
19
+ return undefined;
20
+ }
21
+ const head = context.slice(0, colonAt);
22
+ return prefixSet.has(head) ? head : undefined;
23
+ };
24
+ /** @returns canonical `@ctx` text. */
25
+ export const format = (context) => `@${context}`;
26
+ /**
27
+ * @returns deduplicated contexts in original order. Claim keys use the
28
+ * sorted form (see `Key`); emission preserves author order.
29
+ */
30
+ export const dedupe = (contexts) => [...new Set(contexts)];
31
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,gDAAgD;AAChD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAU,CAAA;AAIhE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAS,QAAQ,CAAC,CAAA;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAgB,EAAsB,EAAE;IAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACpC,IAAI,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC;QACnB,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;IACtC,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAc,CAAC,CAAC,CAAC,SAAS,CAAA;AACzD,CAAC,CAAA;AAED,sCAAsC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAgB,EAAU,EAAE,CACjD,IAAI,OAAO,EAAE,CAAA;AAEf;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,QAA4B,EAAa,EAAE,CAChE,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Entity names (spec §4.1).
3
+ *
4
+ * Entities are compact names: `auth/middleware`, `react/hooks/use-memo`,
5
+ * `PostgreSQL`, `Sarah`. `/` separates scope segments (at most 3:
6
+ * `domain/entity/aspect`), segments are kebab-case, proper nouns keep their
7
+ * casing.
8
+ */
9
+ export type Entity = string;
10
+ export type t = Entity;
11
+ /**
12
+ * Normalizes an entity name (spec §13.4 step 4): trims and collapses runs of
13
+ * internal whitespace to `-`. Casing is preserved — proper nouns keep theirs.
14
+ *
15
+ * `token expiry` → `token-expiry`, `PostgreSQL` → `PostgreSQL`.
16
+ */
17
+ export declare const normalize: (name: string) => Entity;
18
+ /** @returns scope segments of an entity name: `a/b/c` → `['a', 'b', 'c']`. */
19
+ export declare const segments: (entity: Entity) => string[];
20
+ /**
21
+ * Advisory well-formedness check (spec §4.1). Returns a list of human-readable
22
+ * problems; an empty list means the name follows every convention. Problems
23
+ * are advisories, not parse errors — CAVE tolerates messy extraction input.
24
+ */
25
+ export declare const check: (entity: Entity) => string[];
26
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/entity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,MAAM,MAAM,CAAC,GAAG,MAAM,CAAA;AAEtB;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MACP,CAAA;AAElC,8EAA8E;AAC9E,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,KAAG,MAAM,EAC7B,CAAA;AAEnB;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,KAAG,MAAM,EAiB5C,CAAA"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Entity names (spec §4.1).
3
+ *
4
+ * Entities are compact names: `auth/middleware`, `react/hooks/use-memo`,
5
+ * `PostgreSQL`, `Sarah`. `/` separates scope segments (at most 3:
6
+ * `domain/entity/aspect`), segments are kebab-case, proper nouns keep their
7
+ * casing.
8
+ */
9
+ /**
10
+ * Normalizes an entity name (spec §13.4 step 4): trims and collapses runs of
11
+ * internal whitespace to `-`. Casing is preserved — proper nouns keep theirs.
12
+ *
13
+ * `token expiry` → `token-expiry`, `PostgreSQL` → `PostgreSQL`.
14
+ */
15
+ export const normalize = (name) => name.trim().replace(/\s+/g, '-');
16
+ /** @returns scope segments of an entity name: `a/b/c` → `['a', 'b', 'c']`. */
17
+ export const segments = (entity) => entity.split('/');
18
+ /**
19
+ * Advisory well-formedness check (spec §4.1). Returns a list of human-readable
20
+ * problems; an empty list means the name follows every convention. Problems
21
+ * are advisories, not parse errors — CAVE tolerates messy extraction input.
22
+ */
23
+ export const check = (entity) => {
24
+ const problems = [];
25
+ if (entity.length === 0) {
26
+ problems.push('empty entity name');
27
+ return problems;
28
+ }
29
+ const parts = segments(entity);
30
+ if (parts.length > 3) {
31
+ problems.push(`more than 3 scope segments (${parts.length}): domain/entity/aspect is the maximum`);
32
+ }
33
+ if (parts.some(part => part.length === 0)) {
34
+ problems.push('empty scope segment');
35
+ }
36
+ if (/\s/.test(entity)) {
37
+ problems.push('whitespace in entity name (normalize to -)');
38
+ }
39
+ return problems;
40
+ };
41
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/entity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE,CAChD,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAElC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAY,EAAE,CACnD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAEnB;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAc,EAAY,EAAE;IAChD,MAAM,QAAQ,GAAa,EAAE,CAAA;IAC7B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;QAClC,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC9B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,QAAQ,CAAC,IAAI,CAAC,+BAA+B,KAAK,CAAC,MAAM,wCAAwC,CAAC,CAAA;IACpG,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1C,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;IACtC,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,QAAQ,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `@cavelang/core` — the CAVE domain model (spec §2, §6, §7, §9).
3
+ *
4
+ * Dependency-free foundation of the CAVE monorepo: canonical claim shapes,
5
+ * values/units/multipliers, uncertainty and confidence semantics, claim keys
6
+ * and UUIDv7 transaction identifiers. Higher packages (parser, canonical,
7
+ * store, query, fusion, loop, cli) build on these types.
8
+ *
9
+ * Modules follow the `@prelude` convention: `import * as Claim from ...`,
10
+ * with each module exporting its principal type as `t`.
11
+ */
12
+ export * as Claim from './claim.ts';
13
+ export * as Confidence from './confidence.ts';
14
+ export * as Context from './context.ts';
15
+ export * as Entity from './entity.ts';
16
+ export * as Key from './key.ts';
17
+ export * as Multiplier from './multiplier.ts';
18
+ export * as Tag from './tag.ts';
19
+ export * as Uncertainty from './uncertainty.ts';
20
+ export * as Uuidv7 from './uuidv7.ts';
21
+ export * as Value from './value.ts';
22
+ export * as Verb from './verb.ts';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `@cavelang/core` — the CAVE domain model (spec §2, §6, §7, §9).
3
+ *
4
+ * Dependency-free foundation of the CAVE monorepo: canonical claim shapes,
5
+ * values/units/multipliers, uncertainty and confidence semantics, claim keys
6
+ * and UUIDv7 transaction identifiers. Higher packages (parser, canonical,
7
+ * store, query, fusion, loop, cli) build on these types.
8
+ *
9
+ * Modules follow the `@prelude` convention: `import * as Claim from ...`,
10
+ * with each module exporting its principal type as `t`.
11
+ */
12
+ export * as Claim from "./claim.js";
13
+ export * as Confidence from "./confidence.js";
14
+ export * as Context from "./context.js";
15
+ export * as Entity from "./entity.js";
16
+ export * as Key from "./key.js";
17
+ export * as Multiplier from "./multiplier.js";
18
+ export * as Tag from "./tag.js";
19
+ export * as Uncertainty from "./uncertainty.js";
20
+ export * as Uuidv7 from "./uuidv7.js";
21
+ export * as Value from "./value.js";
22
+ export * as Verb from "./verb.js";
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Claim keys (spec §9.2).
3
+ *
4
+ * The claim key identifies the *fact* whose belief evolves over time: the
5
+ * latest transaction with the same key is the current belief (spec §9.1).
6
+ * Keys are computed on the canonical (primary-direction) form, so a forward
7
+ * claim and its inverse reading share one key — one fact, two names
8
+ * (spec §5.5).
9
+ *
10
+ * Key components:
11
+ *
12
+ * - relational claim: subject, verb, object, negated, context set
13
+ * - attribute/value claim: subject, verb, attribute, negated, context set
14
+ * - metric claim: subject, verb, negated, context set
15
+ *
16
+ * The value is *excluded* — it may change over time while the key stays
17
+ * about the same property. Confidence, tags, uncertainty, importance and
18
+ * comments are metadata and never key components. Contexts participate as a
19
+ * sorted, deduplicated set, which is what lets competing hypotheses
20
+ * differentiate by `@hyp:` context (spec §10.3).
21
+ *
22
+ * The key format is a JSON array — deterministic, collision-free and
23
+ * readable in the database.
24
+ */
25
+ import type * as Claim from './claim.ts';
26
+ /** @returns stable claim key of a canonical claim. */
27
+ export declare const of: (claim: Claim.t) => string;
28
+ //# sourceMappingURL=key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AAqBxC,sDAAsD;AACtD,eAAO,MAAM,EAAE,GAAI,OAAO,KAAK,CAAC,CAAC,KAAG,MAOhC,CAAA"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Claim keys (spec §9.2).
3
+ *
4
+ * The claim key identifies the *fact* whose belief evolves over time: the
5
+ * latest transaction with the same key is the current belief (spec §9.1).
6
+ * Keys are computed on the canonical (primary-direction) form, so a forward
7
+ * claim and its inverse reading share one key — one fact, two names
8
+ * (spec §5.5).
9
+ *
10
+ * Key components:
11
+ *
12
+ * - relational claim: subject, verb, object, negated, context set
13
+ * - attribute/value claim: subject, verb, attribute, negated, context set
14
+ * - metric claim: subject, verb, negated, context set
15
+ *
16
+ * The value is *excluded* — it may change over time while the key stays
17
+ * about the same property. Confidence, tags, uncertainty, importance and
18
+ * comments are metadata and never key components. Contexts participate as a
19
+ * sorted, deduplicated set, which is what lets competing hypotheses
20
+ * differentiate by `@hyp:` context (spec §10.3).
21
+ *
22
+ * The key format is a JSON array — deterministic, collision-free and
23
+ * readable in the database.
24
+ */
25
+ // Every term kind gets its own prefix so the three encodings occupy
26
+ // disjoint namespaces — an entity literally named `code:<=` must not
27
+ // collide with the backticked code literal `<=`.
28
+ const termPart = (term) => term.kind === 'entity' ? `e:${term.text}` : `${term.kind}:${term.text}`;
29
+ const payloadPart = (payload) => {
30
+ switch (payload.kind) {
31
+ case 'relation':
32
+ return `r:${termPart(payload.object)}`;
33
+ case 'attribute':
34
+ return `a:${payload.attribute}`;
35
+ case 'metric':
36
+ return 'm';
37
+ case 'none':
38
+ return 'n';
39
+ }
40
+ };
41
+ /** @returns stable claim key of a canonical claim. */
42
+ export const of = (claim) => JSON.stringify([
43
+ termPart(claim.subject),
44
+ claim.verb,
45
+ claim.negated ? 1 : 0,
46
+ payloadPart(claim.payload),
47
+ [...new Set(claim.contexts)].sort()
48
+ ]);
49
+ //# sourceMappingURL=key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../../src/key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,oEAAoE;AACpE,qEAAqE;AACrE,iDAAiD;AACjD,MAAM,QAAQ,GAAG,CAAC,IAAgB,EAAU,EAAE,CAC5C,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAA;AAEzE,MAAM,WAAW,GAAG,CAAC,OAAsB,EAAU,EAAE;IACrD,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,UAAU;YACb,OAAO,KAAK,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;QACxC,KAAK,WAAW;YACd,OAAO,KAAK,OAAO,CAAC,SAAS,EAAE,CAAA;QACjC,KAAK,QAAQ;YACX,OAAO,GAAG,CAAA;QACZ,KAAK,MAAM;YACT,OAAO,GAAG,CAAA;IACd,CAAC;AACH,CAAC,CAAA;AAED,sDAAsD;AACtD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAc,EAAU,EAAE,CAC3C,IAAI,CAAC,SAAS,CAAC;IACb,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;IACvB,KAAK,CAAC,IAAI;IACV,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC;IAC1B,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE;CACpC,CAAC,CAAA"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Numeric multipliers (spec §7.1).
3
+ *
4
+ * A multiplier is a single uppercase letter glued to a number: `20B`, `900M`,
5
+ * `1.5T`, `10K`. It scales the numeric value during canonicalization
6
+ * (spec §13.4 step 8: `20B` → `20000000000`); the raw text is preserved.
7
+ */
8
+ /** Multiplier letter. */
9
+ export type Multiplier = 'T' | 'B' | 'M' | 'K';
10
+ export type t = Multiplier;
11
+ /** Scale factor per multiplier letter. */
12
+ export declare const factors: Readonly<Record<Multiplier, number>>;
13
+ /** @returns `true` if `s` is exactly one multiplier letter. */
14
+ export declare const is: (s: string) => s is Multiplier;
15
+ /** @returns scale factor of multiplier. */
16
+ export declare const factor: (m: Multiplier) => number;
17
+ //# sourceMappingURL=multiplier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplier.d.ts","sourceRoot":"","sources":["../../src/multiplier.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yBAAyB;AACzB,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAE9C,MAAM,MAAM,CAAC,GAAG,UAAU,CAAA;AAE1B,0CAA0C;AAC1C,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAKxD,CAAA;AAED,+DAA+D;AAC/D,eAAO,MAAM,EAAE,GAAI,GAAG,MAAM,KAAG,CAAC,IAAI,UACc,CAAA;AAElD,2CAA2C;AAC3C,eAAO,MAAM,MAAM,GAAI,GAAG,UAAU,KAAG,MAC3B,CAAA"}