pi-mega-compact 0.20.7 → 0.20.9

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 (117) hide show
  1. package/dist/config/vector-cortex.js +25 -0
  2. package/dist/config.js +1 -1
  3. package/dist/extensions/dashboard-server/api-contracts/vector-cortex-heal.js +11 -0
  4. package/dist/extensions/dashboard-server/route-dispatch.js +104 -0
  5. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
  6. package/dist/extensions/dashboard-server/routes-vector-cortex-heal.js +86 -0
  7. package/dist/extensions/dashboard-server/routes-vector-cortex.js +3 -0
  8. package/dist/extensions/dashboard-server/routes.js +1 -1
  9. package/dist/extensions/dashboard-server/server.js +3 -82
  10. package/dist/src/config/vector-cortex.js +25 -0
  11. package/dist/src/config.js +1 -1
  12. package/dist/src/vector-cortex/heal/_acceptance-fixture.js +56 -0
  13. package/dist/src/vector-cortex/heal/_restore-fixture.js +96 -0
  14. package/dist/src/vector-cortex/heal/_vc6b-helpers.js +35 -0
  15. package/dist/src/vector-cortex/heal/closure-metrics.js +66 -0
  16. package/dist/src/vector-cortex/heal/closure-opt.js +242 -0
  17. package/dist/src/vector-cortex/heal/emit.js +69 -0
  18. package/dist/src/vector-cortex/heal/proof.js +210 -0
  19. package/dist/src/vector-cortex/heal/restore-emit.js +70 -0
  20. package/dist/src/vector-cortex/heal/restore-readers.js +114 -0
  21. package/dist/src/vector-cortex/heal/restore-types.js +66 -0
  22. package/dist/src/vector-cortex/heal/restore.js +140 -0
  23. package/dist/src/vector-cortex/heal/types.js +43 -0
  24. package/dist/src/vector-cortex/heal/verify.js +75 -0
  25. package/dist/vector-cortex/heal/_acceptance-fixture.js +56 -0
  26. package/dist/vector-cortex/heal/_restore-fixture.js +96 -0
  27. package/dist/vector-cortex/heal/_vc6b-helpers.js +35 -0
  28. package/dist/vector-cortex/heal/closure-metrics.js +66 -0
  29. package/dist/vector-cortex/heal/closure-opt.js +242 -0
  30. package/dist/vector-cortex/heal/emit.js +69 -0
  31. package/dist/vector-cortex/heal/proof.js +210 -0
  32. package/dist/vector-cortex/heal/restore-emit.js +70 -0
  33. package/dist/vector-cortex/heal/restore-readers.js +114 -0
  34. package/dist/vector-cortex/heal/restore-types.js +66 -0
  35. package/dist/vector-cortex/heal/restore.js +140 -0
  36. package/dist/vector-cortex/heal/types.js +43 -0
  37. package/dist/vector-cortex/heal/verify.js +75 -0
  38. package/extensions/dashboard-client/dist/assets/{AreaChart-DqTbaSRA.js → AreaChart-fxyq2KaH.js} +2 -2
  39. package/extensions/dashboard-client/dist/assets/{AreaChart-DqTbaSRA.js.map → AreaChart-fxyq2KaH.js.map} +1 -1
  40. package/extensions/dashboard-client/dist/assets/{BarChart-BfNBeOvF.js → BarChart-D5EqAINP.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{BarChart-BfNBeOvF.js.map → BarChart-D5EqAINP.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{CacheTab-C9SOMYB5.js → CacheTab-D4UWbzLo.js} +2 -2
  43. package/extensions/dashboard-client/dist/assets/{CacheTab-C9SOMYB5.js.map → CacheTab-D4UWbzLo.js.map} +1 -1
  44. package/extensions/dashboard-client/dist/assets/{EventsTab-GsMKP10_.js → EventsTab-BiXquGrX.js} +2 -2
  45. package/extensions/dashboard-client/dist/assets/{EventsTab-GsMKP10_.js.map → EventsTab-BiXquGrX.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{HealthTab-DAOCXwRP.js → HealthTab-D5QvoTjy.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{HealthTab-DAOCXwRP.js.map → HealthTab-D5QvoTjy.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BtBeMkB5.js → MaintenanceTab-Cy_-CWgM.js} +2 -2
  49. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BtBeMkB5.js.map → MaintenanceTab-Cy_-CWgM.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DzndtgkZ.js → MemoryMapTab-DrAjgGOR.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DzndtgkZ.js.map → MemoryMapTab-DrAjgGOR.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{MetricsTab-DyxJ4eb8.js → MetricsTab-BvPHcuFN.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{MetricsTab-DyxJ4eb8.js.map → MetricsTab-BvPHcuFN.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{OverviewTab-DCiEdVWR.js → OverviewTab-DsbIigOQ.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{OverviewTab-DCiEdVWR.js.map → OverviewTab-DsbIigOQ.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{ReposTab-B5SIqVHA.js → ReposTab-7v_uZX_a.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{ReposTab-B5SIqVHA.js.map → ReposTab-7v_uZX_a.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{SessionsTab-DLWFJ9xI.js → SessionsTab-BXGrv-6C.js} +2 -2
  59. package/extensions/dashboard-client/dist/assets/{SessionsTab-DLWFJ9xI.js.map → SessionsTab-BXGrv-6C.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/{SetupTab-CvGXZyej.js → SetupTab-QRUXa65y.js} +2 -2
  61. package/extensions/dashboard-client/dist/assets/{SetupTab-CvGXZyej.js.map → SetupTab-QRUXa65y.js.map} +1 -1
  62. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-wZuQGxLS.js → TimeSavedCard-p327ZZKT.js} +2 -2
  63. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-wZuQGxLS.js.map → TimeSavedCard-p327ZZKT.js.map} +1 -1
  64. package/extensions/dashboard-client/dist/assets/{TurnsTab-B7aOejch.js → TurnsTab-BcmBSlik.js} +2 -2
  65. package/extensions/dashboard-client/dist/assets/{TurnsTab-B7aOejch.js.map → TurnsTab-BcmBSlik.js.map} +1 -1
  66. package/extensions/dashboard-client/dist/assets/VectorCortexTab-D2fjKNyT.js +2 -0
  67. package/extensions/dashboard-client/dist/assets/VectorCortexTab-D2fjKNyT.js.map +1 -0
  68. package/extensions/dashboard-client/dist/assets/{WikiTab-DhWHjAtt.js → WikiTab-DLXFMuNy.js} +2 -2
  69. package/extensions/dashboard-client/dist/assets/{WikiTab-DhWHjAtt.js.map → WikiTab-DLXFMuNy.js.map} +1 -1
  70. package/extensions/dashboard-client/dist/assets/{button-BrC-W87h.js → button-C9CghmRx.js} +2 -2
  71. package/extensions/dashboard-client/dist/assets/{button-BrC-W87h.js.map → button-C9CghmRx.js.map} +1 -1
  72. package/extensions/dashboard-client/dist/assets/{card-0rgfRgr3.js → card-DWU-1y3t.js} +2 -2
  73. package/extensions/dashboard-client/dist/assets/{card-0rgfRgr3.js.map → card-DWU-1y3t.js.map} +1 -1
  74. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DRresOQF.js → generateCategoricalChart-Dayy9dGn.js} +2 -2
  75. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DRresOQF.js.map → generateCategoricalChart-Dayy9dGn.js.map} +1 -1
  76. package/extensions/dashboard-client/dist/assets/{index-DohmtZWL.js → index-D9PsW3VZ.js} +3 -3
  77. package/extensions/dashboard-client/dist/assets/{index-DohmtZWL.js.map → index-D9PsW3VZ.js.map} +1 -1
  78. package/extensions/dashboard-client/dist/assets/{switch-Bs8g_zB5.js → switch-CnLFAmVT.js} +2 -2
  79. package/extensions/dashboard-client/dist/assets/{switch-Bs8g_zB5.js.map → switch-CnLFAmVT.js.map} +1 -1
  80. package/extensions/dashboard-client/dist/assets/{toggle-DVVauIo8.js → toggle-HN5C7_vy.js} +2 -2
  81. package/extensions/dashboard-client/dist/assets/{toggle-DVVauIo8.js.map → toggle-HN5C7_vy.js.map} +1 -1
  82. package/extensions/dashboard-client/dist/assets/{useSSE-DxH1PTAR.js → useSSE-DoJfk3Ce.js} +2 -2
  83. package/extensions/dashboard-client/dist/assets/{useSSE-DxH1PTAR.js.map → useSSE-DoJfk3Ce.js.map} +1 -1
  84. package/extensions/dashboard-client/dist/index.html +1 -1
  85. package/extensions/dashboard-client/src/api/vector-cortex.ts +18 -0
  86. package/extensions/dashboard-client/src/tabs/VectorCortexClosureCard.tsx +46 -0
  87. package/extensions/dashboard-client/src/tabs/VectorCortexLedgerCard.tsx +80 -0
  88. package/extensions/dashboard-client/src/tabs/VectorCortexRestoreCard.tsx +42 -0
  89. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +20 -164
  90. package/extensions/dashboard-client/src/tabs/VectorCortexTopologyCard.tsx +131 -0
  91. package/extensions/dashboard-client/src/types/vector-cortex.ts +30 -0
  92. package/extensions/dashboard-server/api-contracts/vector-cortex-heal.ts +73 -0
  93. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +5 -0
  94. package/extensions/dashboard-server/route-dispatch.ts +114 -0
  95. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
  96. package/extensions/dashboard-server/routes-vector-cortex-heal.ts +103 -0
  97. package/extensions/dashboard-server/routes-vector-cortex.ts +6 -0
  98. package/extensions/dashboard-server/routes.ts +2 -0
  99. package/extensions/dashboard-server/server.ts +3 -86
  100. package/package.json +1 -1
  101. package/src/config/vector-cortex.ts +27 -0
  102. package/src/config.ts +2 -0
  103. package/src/vector-cortex/heal/_acceptance-fixture.ts +108 -0
  104. package/src/vector-cortex/heal/_restore-fixture.ts +163 -0
  105. package/src/vector-cortex/heal/_vc6b-helpers.ts +55 -0
  106. package/src/vector-cortex/heal/closure-metrics.ts +73 -0
  107. package/src/vector-cortex/heal/closure-opt.ts +266 -0
  108. package/src/vector-cortex/heal/emit.ts +93 -0
  109. package/src/vector-cortex/heal/proof.ts +234 -0
  110. package/src/vector-cortex/heal/restore-emit.ts +94 -0
  111. package/src/vector-cortex/heal/restore-readers.ts +145 -0
  112. package/src/vector-cortex/heal/restore-types.ts +185 -0
  113. package/src/vector-cortex/heal/restore.ts +165 -0
  114. package/src/vector-cortex/heal/types.ts +248 -0
  115. package/src/vector-cortex/heal/verify.ts +93 -0
  116. package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js +0 -2
  117. package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js.map +0 -1
@@ -0,0 +1,114 @@
1
+ /**
2
+ * vector-cortex/heal/restore-readers.ts — the two EXACT source readers (VC6B).
3
+ *
4
+ * Split out of `restore.ts` so the orchestrator stays a short, readable policy
5
+ * file and each reader can be reasoned about on its own (PRACTICES: split at the
6
+ * 300-line soft limit, delegate-shell + impl).
7
+ *
8
+ * Both readers share one discipline: they return bytes ONLY after recomputing
9
+ * SHA-256 over the bytes they actually hold and comparing it to the digest the
10
+ * REQUEST pinned. Neither reader trusts the digest recorded alongside its own
11
+ * source — an `ExactShardV1.digest` is metadata that lives in the same file as
12
+ * the bytes, so a swapped file carries a matching (wrong) pair. Only the
13
+ * caller-supplied digest is authoritative, and only a fresh hash of the fetched
14
+ * bytes can be checked against it.
15
+ *
16
+ * Pure/deterministic/local: `node:crypto` only (a Node built-in, not a network
17
+ * call), no storage, no console (PREVENT-PI-004 / PREVENT-011).
18
+ */
19
+ import { createHash } from "node:crypto";
20
+ /**
21
+ * SHA-256 over bytes as LOWERCASE HEX with NO `sha256:` prefix — the
22
+ * `ExactShardV1.digest` / `ReconstructionSpan.digest` / `RestoreSpanRequest`
23
+ * convention. `EventV2.bytesDigest` prefixes this same value with `sha256:`.
24
+ */
25
+ export function sha256Hex(bytes) {
26
+ return createHash("sha256").update(bytes).digest("hex");
27
+ }
28
+ /**
29
+ * Strip the `sha256:` prefix from an `EventV2.bytesDigest` so it can be compared
30
+ * against a bare hex digest. A value that does not carry the prefix is returned
31
+ * unchanged rather than mangled — the comparison then simply fails, which is the
32
+ * correct outcome for a malformed record.
33
+ */
34
+ export function bareHex(digest) {
35
+ return digest.startsWith("sha256:") ? digest.slice("sha256:".length) : digest;
36
+ }
37
+ /**
38
+ * Structural range equality. All five components must match: two spans over the
39
+ * same seq window but different byte offsets are DIFFERENT spans (a re-encoded
40
+ * or re-offset stream is not the stream that was requested).
41
+ */
42
+ export function rangeEquals(a, b) {
43
+ return (a.sessionId === b.sessionId &&
44
+ a.seqStart === b.seqStart &&
45
+ a.seqEnd === b.seqEnd &&
46
+ a.byteStart === b.byteStart &&
47
+ a.byteEnd === b.byteEnd);
48
+ }
49
+ /**
50
+ * Mode A — indexed exact-shard read.
51
+ *
52
+ * Selection is by RANGE identity plus the shard's own recorded digest, which
53
+ * narrows the candidate set the way a real index lookup would. The accepted
54
+ * candidate is then re-hashed from its `originalBytes`: this second check is
55
+ * what catches a shard whose bytes were swapped AFTER the index lookup resolved
56
+ * (the sprint's unique failure injection). A candidate that matches by range but
57
+ * fails either digest check reports `digest-mismatch` — it does NOT silently fall
58
+ * through to the ledger, because a corrupt exact shard is a fact worth surfacing.
59
+ */
60
+ export function readExactShard(shards, range, digest) {
61
+ const byRange = shards.filter((s) => rangeEquals(s.range, range));
62
+ if (byRange.length === 0)
63
+ return { kind: "absent" };
64
+ const candidate = byRange.find((s) => s.digest === digest);
65
+ if (candidate === undefined)
66
+ return { kind: "digest-mismatch" };
67
+ // Defense in depth: the shard's recorded digest is metadata, the bytes are the
68
+ // authority. Re-hash what we actually hold.
69
+ const bytes = candidate.originalBytes;
70
+ if (sha256Hex(bytes) !== digest)
71
+ return { kind: "digest-mismatch" };
72
+ return { kind: "bytes", bytes };
73
+ }
74
+ /**
75
+ * Mode B — ledger range scan.
76
+ *
77
+ * An INDEPENDENT path from mode A: no shard index is consulted. The occurrence
78
+ * records covering `[seqStart..seqEnd]` are selected, sorted ascending by seq
79
+ * (the caller's array order is untrusted — a scan that concatenated records in
80
+ * arrival order would produce plausible-looking but wrong bytes), each record's
81
+ * own `bytesDigest` is verified, and the concatenation is hashed against the
82
+ * span digest.
83
+ *
84
+ * Both checks matter. Per-record verification localizes corruption to a single
85
+ * occurrence; the span-level hash catches a scan that is individually valid but
86
+ * collectively wrong — a missing record in the middle of the range, or a range
87
+ * that covers different content than the requester believed.
88
+ */
89
+ export function readLedgerSpan(events, range, digest) {
90
+ const covering = events
91
+ .filter((e) => e.sessionId === range.sessionId &&
92
+ e.seq >= range.seqStart &&
93
+ e.seq <= range.seqEnd)
94
+ .sort((a, b) => (a.seq < b.seq ? -1 : a.seq > b.seq ? 1 : 0));
95
+ if (covering.length === 0)
96
+ return { kind: "absent" };
97
+ // Per-record byte authority (VC1A): a record whose own digest disagrees with
98
+ // its bytes is corrupt, and a corrupt record can never contribute to a restore.
99
+ for (const e of covering) {
100
+ if (sha256Hex(e.originalBytes) !== bareHex(e.bytesDigest)) {
101
+ return { kind: "digest-mismatch" };
102
+ }
103
+ }
104
+ const total = covering.reduce((sum, e) => sum + e.originalBytes.length, 0);
105
+ const bytes = new Uint8Array(total);
106
+ let offset = 0;
107
+ for (const e of covering) {
108
+ bytes.set(e.originalBytes, offset);
109
+ offset += e.originalBytes.length;
110
+ }
111
+ if (sha256Hex(bytes) !== digest)
112
+ return { kind: "digest-mismatch" };
113
+ return { kind: "bytes", bytes };
114
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * vector-cortex/heal/restore-types.ts — VC6B exact source restoration contract.
3
+ *
4
+ * VC6A optimized WHICH EDGES the closure plan walks. VC6B answers the next
5
+ * question: when the plan needs a node whose bytes are no longer in the live
6
+ * window, WHERE do those bytes come from? The answer is deliberately narrow —
7
+ * an EXACT source, or nothing.
8
+ *
9
+ * THE CARDINAL RULE. Restored bytes are ONLY ever read from an exact source:
10
+ * 1. an `ExactShardV1` whose range and digest both match the request, or
11
+ * 2. a scan of the `EventV2` occurrence ledger over the requested seq range.
12
+ * Bytes are NEVER inferred from an embedding, a semantic shard, a RAPTOR
13
+ * summary, or any other derived/lossy representation. A semantic tier can tell
14
+ * you what a span was ABOUT; it cannot tell you what the span WAS. Attempting to
15
+ * "restore" from a derived source would silently fabricate transcript history,
16
+ * so VC6B has no code path that can do it: `RestoreReader` exposes exactly the
17
+ * two exact sources and nothing else.
18
+ *
19
+ * THE VERIFICATION RULE. Every restored span must hash to the SHA-256 digest the
20
+ * REQUEST pinned, checked immediately before insertion. A source that matches by
21
+ * range but not by hash is rejected (`HEAL_RESTORE_DIGEST_MISMATCH`) — never
22
+ * "close enough". This is what makes a swapped shard file, a truncated read, or a
23
+ * corrupted ledger record fail loudly instead of poisoning the reconstruction.
24
+ *
25
+ * DIGEST PINNING (three fields exist; do not confuse them).
26
+ * - `ReconstructionSpan.digest` and `ExactShardV1.digest` are SHA-256 in
27
+ * LOWERCASE HEX with NO prefix.
28
+ * - `EventV2.bytesDigest` is `sha256:<hex>`, WITH the prefix.
29
+ * `RestoreSpanRequest.digest` works at SPAN level and uses the FORMER: bare
30
+ * lowercase hex, matching `ExactShardV1.digest` / `ReconstructionSpan.digest`.
31
+ * The prefixed `EventV2.bytesDigest` is used ONLY for per-event verification
32
+ * inside the ledger-scan path and is never the request-level digest. Mixing the
33
+ * two would make every ledger restoration fail (or, worse, make a prefix-stripped
34
+ * comparison accidentally succeed against the wrong granularity).
35
+ *
36
+ * BOUNDS. A restore request is attacker-shaped input: it names spans and byte
37
+ * ranges. `RESTORE_LIMIT_SPANS` / `RESTORE_LIMIT_BYTES` bound it BEFORE any
38
+ * reader is consulted, so an oversized request cannot be used to make the
39
+ * restorer walk the whole ledger (HEAL-LIMIT-002).
40
+ *
41
+ * Pure types + registered conformance IDs: no storage, no console, no network
42
+ * (PREVENT-PI-004 / PREVENT-011).
43
+ */
44
+ /**
45
+ * Maximum spans in one request. A request naming more spans than this is
46
+ * rejected outright — the bound exists so a single call cannot be turned into an
47
+ * unbounded traversal of the ledger.
48
+ */
49
+ export const RESTORE_LIMIT_SPANS = 64;
50
+ /**
51
+ * Maximum aggregate requested bytes (4 MiB), summed from the REQUEST's ranges
52
+ * (`byteEnd - byteStart`) so the bound is enforceable without reading anything.
53
+ */
54
+ export const RESTORE_LIMIT_BYTES = 4 * 1024 * 1024;
55
+ /**
56
+ * Registered VC6B conformance ID range (HEAL-016..030), continuing VC6A's
57
+ * HEAL-001..015. The acceptance test reads these rows from the v2 manifest and
58
+ * asserts each returns its manifest `ok`/`code`.
59
+ */
60
+ export const RESTORE_IDS = Array.from({ length: 15 }, (_v, i) => `HEAL-${String(i + 16).padStart(3, "0")}`);
61
+ /** Named VC6B conformance assertions (the sprint's headline rows). */
62
+ export const RESTORE_NAMED_IDS = [
63
+ "HEAL-SPAN-001",
64
+ "HEAL-LIMIT-002",
65
+ "HEAL-DIGEST-003",
66
+ ];
@@ -0,0 +1,140 @@
1
+ /**
2
+ * vector-cortex/heal/restore.ts — VC6B exact source restoration orchestrator.
3
+ *
4
+ * Turns a `RestoreRequestV1` into a `RestoreResultV1` by consulting, per span,
5
+ * the two EXACT sources in `restore-readers.ts` — an indexed exact shard first,
6
+ * then a ledger range scan — and inserting bytes only after they hash to the
7
+ * digest the request pinned.
8
+ *
9
+ * ORDER OF OPERATIONS IS THE CONTRACT.
10
+ *
11
+ * 1. BOUNDS, BEFORE ANY READER TOUCH. The span count and the aggregate
12
+ * requested byte span are computed PURELY FROM THE REQUEST (`byteEnd -
13
+ * byteStart`, which needs no source at all) and checked first. On breach we
14
+ * return immediately, having never read `reader.exactShards` or
15
+ * `reader.ledgerEvents`. This is HEAL-LIMIT-002: an oversized request must
16
+ * not be able to make the restorer walk the ledger even once, so the check
17
+ * cannot be "inside the loop, before the read" — it must be before the loop
18
+ * exists. The acceptance corpus proves it by passing EMPTY readers with an
19
+ * over-limit request: a reader-touching implementation would still return
20
+ * "missing" rather than "limit".
21
+ *
22
+ * 2. EXACT SHARD, then LEDGER, then MISSING. Sources are tried strongest-first.
23
+ * A digest mismatch anywhere is recorded and the span is NOT restored — the
24
+ * restorer never downgrades to "closest available bytes".
25
+ *
26
+ * 3. MODE from what actually happened, not from what was attempted. A = every
27
+ * span came from a shard; B = all restored, at least one via ledger scan;
28
+ * C = something is missing, and mode C STATES its semantic loss rather than
29
+ * hiding an incomplete restoration behind a successful-looking result.
30
+ *
31
+ * PURE. No storage, no console, no clock, no network — `node:crypto` (a Node
32
+ * built-in) is the only dependency beyond types (PREVENT-PI-004 / PREVENT-011).
33
+ * The reporter seam in `restore-emit.ts` is flag-gated; THIS arithmetic is not,
34
+ * so flag-off is byte-identical.
35
+ */
36
+ import { RESTORE_LIMIT_BYTES, RESTORE_LIMIT_SPANS } from "./restore-types.js";
37
+ import { readExactShard, readLedgerSpan } from "./restore-readers.js";
38
+ /**
39
+ * Fixed code ordering so a result's `codes` array is deterministic regardless of
40
+ * which span failed first. Deterministic output is what lets the conformance
41
+ * corpus pin an exact expected value.
42
+ */
43
+ const CODE_ORDER = [
44
+ "HEAL_RESTORE_LIMIT",
45
+ "HEAL_RESTORE_DIGEST_MISMATCH",
46
+ "HEAL_RESTORE_SOURCE_MISSING",
47
+ "HEAL_RESTORE_RANGE_MISMATCH",
48
+ ];
49
+ /** Deduplicate + sort codes into the fixed priority order. */
50
+ export function orderCodes(codes) {
51
+ const seen = new Set(codes);
52
+ return CODE_ORDER.filter((c) => seen.has(c));
53
+ }
54
+ /**
55
+ * Total bytes the request ASKS for, derived from the ranges alone. Negative or
56
+ * inverted ranges contribute 0 rather than reducing the total — an inverted span
57
+ * must never be usable to smuggle a large request under the bound.
58
+ */
59
+ function requestedBytes(spans) {
60
+ let total = 0;
61
+ for (const s of spans) {
62
+ const len = s.range.byteEnd - s.range.byteStart;
63
+ total += len > 0 ? len : 0;
64
+ }
65
+ return total;
66
+ }
67
+ /** The immediate over-limit result: nothing read, everything missing. */
68
+ function limitExceeded(request) {
69
+ return {
70
+ schema: "restore-result-v1",
71
+ sessionId: request.sessionId,
72
+ mode: "C",
73
+ restored: [],
74
+ missing: request.spans.map((s) => s.nodeId),
75
+ semanticLossStated: true,
76
+ codes: ["HEAL_RESTORE_LIMIT"],
77
+ };
78
+ }
79
+ /**
80
+ * Restore the exact original bytes for every requested span.
81
+ *
82
+ * Never throws: a request naming spans no source covers yields a mode-C result
83
+ * that discloses the loss, not an exception (PRACTICES: non-fatal — a failed
84
+ * restoration must degrade the prompt, never break the agent loop).
85
+ */
86
+ export function restoreSources(request, reader) {
87
+ // (1) Bounds first — computed from the request only. `reader` is not touched
88
+ // on this path, which is exactly what HEAL-LIMIT-002 asserts.
89
+ if (request.spans.length > RESTORE_LIMIT_SPANS ||
90
+ requestedBytes(request.spans) > RESTORE_LIMIT_BYTES) {
91
+ return limitExceeded(request);
92
+ }
93
+ const restored = [];
94
+ const missing = [];
95
+ const codes = [];
96
+ let usedLedger = false;
97
+ // (2) Per span, strongest source first, in request order.
98
+ for (const span of request.spans) {
99
+ const exact = readExactShard(reader.exactShards, span.range, span.digest);
100
+ if (exact.kind === "bytes") {
101
+ restored.push({
102
+ nodeId: span.nodeId,
103
+ source: "exact-shard",
104
+ bytes: exact.bytes,
105
+ digest: span.digest,
106
+ });
107
+ continue;
108
+ }
109
+ if (exact.kind === "digest-mismatch")
110
+ codes.push("HEAL_RESTORE_DIGEST_MISMATCH");
111
+ const ledger = readLedgerSpan(reader.ledgerEvents, span.range, span.digest);
112
+ if (ledger.kind === "bytes") {
113
+ usedLedger = true;
114
+ restored.push({
115
+ nodeId: span.nodeId,
116
+ source: "ledger-scan",
117
+ bytes: ledger.bytes,
118
+ digest: span.digest,
119
+ });
120
+ continue;
121
+ }
122
+ if (ledger.kind === "digest-mismatch")
123
+ codes.push("HEAL_RESTORE_DIGEST_MISMATCH");
124
+ // (3) Neither exact source answered. Identity only — never bytes.
125
+ missing.push(span.nodeId);
126
+ codes.push("HEAL_RESTORE_SOURCE_MISSING");
127
+ }
128
+ const complete = missing.length === 0 && restored.length === request.spans.length;
129
+ const mode = !complete ? "C" : usedLedger ? "B" : "A";
130
+ return {
131
+ schema: "restore-result-v1",
132
+ sessionId: request.sessionId,
133
+ mode,
134
+ restored,
135
+ missing,
136
+ // Mode C omits spans, so it MUST disclose that the old context is gone.
137
+ semanticLossStated: mode === "C",
138
+ codes: orderCodes(codes),
139
+ };
140
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * vector-cortex/heal/types.ts — VC6A closure-optimization contract.
3
+ *
4
+ * Owns `ClosureProofV2` and `RestoreHintV1`.
5
+ *
6
+ * VC4C already performs the MANDATORY conservative closure (CONTRACTS §plan and
7
+ * closure): it recursively adds every `depends`/tool-pair predecessor to a fixed
8
+ * point, resolves contradictions, and preserves the anchor floor. VC6A does NOT
9
+ * re-close and does NOT change WHICH NODES ARE SELECTED — "VC6 only optimizes
10
+ * restoration/self-healing". It optimizes the PROOF EDGES of that already-closed
11
+ * graph by transitive reduction: an edge `a -> c` whose requirement is already
12
+ * carried by a path `a -> b -> c` is redundant and can be dropped from the
13
+ * traversal plan without changing the closed set.
14
+ *
15
+ * The optimization is therefore a claim, and a claim needs a receipt:
16
+ * `ClosureProofV2` records EVERY considered edge — retained or removed — with
17
+ * the reason. `proof.ts` replays those rows against the conservative VC4C oracle
18
+ * and rejects the optimization if the selected set diverges
19
+ * (`HEAL_PROOF_SET_MISMATCH`) or if a considered edge has no proof row
20
+ * (`HEAL_PROOF_INCOMPLETE`).
21
+ *
22
+ * PROTECTED EDGES ARE NEVER REMOVED. A tool-pair edge (PREVENT-PI-002), an edge
23
+ * touching an anchor node (PREVENT-PI-001's anchor floor), a
24
+ * contradiction-resolution edge, and a SOLE dependency edge (the only edge that
25
+ * pulls its prerequisite in) are all retained unconditionally, even when an
26
+ * alternate path exists. Only a redundant `depends` edge may go.
27
+ *
28
+ * Pure types + registered conformance IDs: no storage, no console, no network
29
+ * (PREVENT-PI-004 / PREVENT-011).
30
+ */
31
+ /**
32
+ * Registered HEAL conformance ID range (HEAL-001..015). The acceptance test
33
+ * reads these rows from the v2 manifest and asserts each returns its manifest
34
+ * `ok`/`code`.
35
+ */
36
+ export const HEAL_IDS = Array.from({ length: 15 }, (_v, i) => `HEAL-${String(i + 1).padStart(3, "0")}`);
37
+ /** Named VC6A conformance assertions (the sprint's headline rows). */
38
+ export const HEAL_NAMED_IDS = [
39
+ "HEAL-REDUCE-001",
40
+ "HEAL-PROTECT-002",
41
+ "HEAL-PROOF-003",
42
+ ];
43
+ export { RESTORE_IDS, RESTORE_NAMED_IDS, RESTORE_LIMIT_SPANS, RESTORE_LIMIT_BYTES, } from "./restore-types.js";
@@ -0,0 +1,75 @@
1
+ /**
2
+ * vector-cortex/heal/verify.ts — VC6B pre-insertion verification (task 3).
3
+ *
4
+ * `restoreSources` already hashes every span before it puts it in the result, so
5
+ * why hash again here?
6
+ *
7
+ * Because the result is a VALUE that travels. Between restoration and insertion
8
+ * it is passed across module boundaries, possibly cached, possibly assembled from
9
+ * more than one restore call, possibly reordered. `verifyRestored` is the gate
10
+ * immediately before bytes enter the reconstruction, and it re-derives its facts
11
+ * from scratch: it hashes the bytes the result ACTUALLY CARRIES and cross-checks
12
+ * them against the digest THE REQUEST asked for. A result object mutated after
13
+ * `restoreSources` returned — the classic "verified then swapped" injection —
14
+ * fails here.
15
+ *
16
+ * TWO DISTINCT INVARIANTS, TWO DISTINCT CODES.
17
+ * - `HEAL_RESTORE_DIGEST_MISMATCH` — the bytes do not hash to their OWN stated
18
+ * digest. The span is internally inconsistent (tampering or truncation).
19
+ * - `HEAL_RESTORE_RANGE_MISMATCH` — the bytes are internally consistent but do
20
+ * not answer the question that was asked: the nodeId was never requested, or
21
+ * the digest disagrees with the digest the request pinned for that nodeId.
22
+ * This is the "right bytes, wrong span" failure — substituting one real,
23
+ * correctly-hashed span for another would otherwise pass a naive check.
24
+ *
25
+ * WHOLESALE, NOT PER-SPAN. `insertable` returns the restored spans only when the
26
+ * entire result verifies. Inserting the good half of a result whose other half
27
+ * failed verification would splice a partially-corrupt transcript into the
28
+ * reconstruction without the caller ever seeing a mode-C disclosure.
29
+ *
30
+ * Pure: `node:crypto` only, no storage/console/network (PREVENT-PI-004 /
31
+ * PREVENT-011).
32
+ */
33
+ import { sha256Hex } from "./restore-readers.js";
34
+ import { orderCodes } from "./restore.js";
35
+ /**
36
+ * Re-verify every restored span against the request that asked for it.
37
+ *
38
+ * Returns `{ok:true}` only when EVERY restored span hashes to its own digest AND
39
+ * that digest is the one the request pinned for that node.
40
+ */
41
+ export function verifyRestored(result, request) {
42
+ const requestedDigests = new Map();
43
+ for (const span of request.spans)
44
+ requestedDigests.set(span.nodeId, span.digest);
45
+ const codes = [];
46
+ for (const span of result.restored) {
47
+ // (1) Internal consistency: do these bytes hash to the digest they claim?
48
+ if (sha256Hex(span.bytes) !== span.digest) {
49
+ codes.push("HEAL_RESTORE_DIGEST_MISMATCH");
50
+ // A span that fails its own digest cannot meaningfully be checked against
51
+ // the request's digest as well; one code per real defect keeps the verdict
52
+ // readable.
53
+ continue;
54
+ }
55
+ // (2) Provenance: was this node requested, and with THIS digest? An
56
+ // unrequested node or a digest swap is a range mismatch, not a hash failure.
57
+ const wanted = requestedDigests.get(span.nodeId);
58
+ if (wanted === undefined || wanted !== span.digest) {
59
+ codes.push("HEAL_RESTORE_RANGE_MISMATCH");
60
+ }
61
+ }
62
+ if (codes.length === 0)
63
+ return { ok: true };
64
+ return { ok: false, codes: orderCodes(codes) };
65
+ }
66
+ /**
67
+ * The spans that may be inserted: all of them, or none.
68
+ *
69
+ * A caller should never need to decide which half of a partially-verified result
70
+ * is safe — that decision is the whole point of the digest contract, so it is
71
+ * made here, once, in the strict direction.
72
+ */
73
+ export function insertable(result, request) {
74
+ return verifyRestored(result, request).ok ? result.restored : [];
75
+ }
@@ -1,2 +1,2 @@
1
- import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-DRresOQF.js";import{R as p,F as ee,r as ve}from"./index-DohmtZWL.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
- //# sourceMappingURL=AreaChart-DqTbaSRA.js.map
1
+ import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-Dayy9dGn.js";import{R as p,F as ee,r as ve}from"./index-D9PsW3VZ.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
+ //# sourceMappingURL=AreaChart-fxyq2KaH.js.map