pi-mega-compact 0.20.14 → 0.20.16

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 (94) hide show
  1. package/dist/config/vector-cortex.js +20 -0
  2. package/dist/config.js +1 -1
  3. package/dist/extensions/dashboard-server/api-contracts/vector-cortex-diagnostics.js +35 -0
  4. package/dist/extensions/dashboard-server/route-dispatch.js +6 -0
  5. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
  6. package/dist/extensions/dashboard-server/routes-vector-cortex-diagnostics.js +68 -0
  7. package/dist/src/config/vector-cortex.js +20 -0
  8. package/dist/src/config.js +1 -1
  9. package/dist/src/vector-cortex/cache/_diagnostics-fixture.js +31 -0
  10. package/dist/src/vector-cortex/cache/breaker.js +110 -0
  11. package/dist/src/vector-cortex/cache/diagnostics-emit.js +64 -0
  12. package/dist/src/vector-cortex/cache/diagnostics-types.js +15 -0
  13. package/dist/src/vector-cortex/cache/diagnostics.js +97 -0
  14. package/dist/src/vector-cortex/migrations/request-hash-v2-ops.js +154 -0
  15. package/dist/src/vector-cortex/migrations/request-hash-v2-types.js +30 -0
  16. package/dist/src/vector-cortex/migrations/request-hash-v2.js +42 -147
  17. package/dist/vector-cortex/cache/_diagnostics-fixture.js +31 -0
  18. package/dist/vector-cortex/cache/breaker.js +110 -0
  19. package/dist/vector-cortex/cache/diagnostics-emit.js +64 -0
  20. package/dist/vector-cortex/cache/diagnostics-types.js +15 -0
  21. package/dist/vector-cortex/cache/diagnostics.js +97 -0
  22. package/dist/vector-cortex/migrations/request-hash-v2-ops.js +154 -0
  23. package/dist/vector-cortex/migrations/request-hash-v2-types.js +30 -0
  24. package/dist/vector-cortex/migrations/request-hash-v2.js +42 -147
  25. package/extensions/dashboard-client/dist/assets/{AreaChart-VUd_iOtO.js → AreaChart-B_FKg8xJ.js} +2 -2
  26. package/extensions/dashboard-client/dist/assets/{AreaChart-VUd_iOtO.js.map → AreaChart-B_FKg8xJ.js.map} +1 -1
  27. package/extensions/dashboard-client/dist/assets/{BarChart-BoqeJ5mM.js → BarChart-BU5RJ0In.js} +2 -2
  28. package/extensions/dashboard-client/dist/assets/{BarChart-BoqeJ5mM.js.map → BarChart-BU5RJ0In.js.map} +1 -1
  29. package/extensions/dashboard-client/dist/assets/{CacheTab-1ON7meDK.js → CacheTab-CbX033mt.js} +2 -2
  30. package/extensions/dashboard-client/dist/assets/{CacheTab-1ON7meDK.js.map → CacheTab-CbX033mt.js.map} +1 -1
  31. package/extensions/dashboard-client/dist/assets/{EventsTab-Dr9eqt1k.js → EventsTab-D8Z_4gSB.js} +2 -2
  32. package/extensions/dashboard-client/dist/assets/{EventsTab-Dr9eqt1k.js.map → EventsTab-D8Z_4gSB.js.map} +1 -1
  33. package/extensions/dashboard-client/dist/assets/{HealthTab-Ciaigd4i.js → HealthTab-BUUkoQXo.js} +2 -2
  34. package/extensions/dashboard-client/dist/assets/{HealthTab-Ciaigd4i.js.map → HealthTab-BUUkoQXo.js.map} +1 -1
  35. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DjZRr3Lf.js → MaintenanceTab-DKZQmY1T.js} +2 -2
  36. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DjZRr3Lf.js.map → MaintenanceTab-DKZQmY1T.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-BpZXHA7j.js → MemoryMapTab-DwMGbe3h.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-BpZXHA7j.js.map → MemoryMapTab-DwMGbe3h.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/{MetricsTab-QemocY5k.js → MetricsTab-C85lieXW.js} +2 -2
  40. package/extensions/dashboard-client/dist/assets/{MetricsTab-QemocY5k.js.map → MetricsTab-C85lieXW.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/{OverviewTab-VtC1F-mO.js → OverviewTab-D7VPibBT.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{OverviewTab-VtC1F-mO.js.map → OverviewTab-D7VPibBT.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{ReposTab-CJD1cBxp.js → ReposTab-eIHk_mDG.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{ReposTab-CJD1cBxp.js.map → ReposTab-eIHk_mDG.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{SessionsTab-Cj0erPR4.js → SessionsTab-EYOHEzc3.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{SessionsTab-Cj0erPR4.js.map → SessionsTab-EYOHEzc3.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{SetupTab-AOVROZ4G.js → SetupTab-DXpiXu4i.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{SetupTab-AOVROZ4G.js.map → SetupTab-DXpiXu4i.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-ZliVn8DH.js → TimeSavedCard-DUsUC_sm.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-ZliVn8DH.js.map → TimeSavedCard-DUsUC_sm.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{TurnsTab-DsoTWeIh.js → TurnsTab-w7qdB0px.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{TurnsTab-DsoTWeIh.js.map → TurnsTab-w7qdB0px.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/VectorCortexTab-BmgdxV5K.js +2 -0
  54. package/extensions/dashboard-client/dist/assets/VectorCortexTab-BmgdxV5K.js.map +1 -0
  55. package/extensions/dashboard-client/dist/assets/{WikiTab-CK8fcW1l.js → WikiTab-B4hwpXpw.js} +2 -2
  56. package/extensions/dashboard-client/dist/assets/{WikiTab-CK8fcW1l.js.map → WikiTab-B4hwpXpw.js.map} +1 -1
  57. package/extensions/dashboard-client/dist/assets/{button-DdPcvex1.js → button-BnbvfQjm.js} +2 -2
  58. package/extensions/dashboard-client/dist/assets/{button-DdPcvex1.js.map → button-BnbvfQjm.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/{card-DXFuZph_.js → card-DCyvWfpF.js} +2 -2
  60. package/extensions/dashboard-client/dist/assets/{card-DXFuZph_.js.map → card-DCyvWfpF.js.map} +1 -1
  61. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-BagDVGWn.js → generateCategoricalChart-b3HeKJLU.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-BagDVGWn.js.map → generateCategoricalChart-b3HeKJLU.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/{index-DVdDtRY4.js → index-DhlcXMlE.js} +3 -3
  64. package/extensions/dashboard-client/dist/assets/{index-DVdDtRY4.js.map → index-DhlcXMlE.js.map} +1 -1
  65. package/extensions/dashboard-client/dist/assets/{switch-CtdtGyUR.js → switch-B74pQOFy.js} +2 -2
  66. package/extensions/dashboard-client/dist/assets/{switch-CtdtGyUR.js.map → switch-B74pQOFy.js.map} +1 -1
  67. package/extensions/dashboard-client/dist/assets/{toggle-Cvvwlbye.js → toggle-bXDrMX-A.js} +2 -2
  68. package/extensions/dashboard-client/dist/assets/{toggle-Cvvwlbye.js.map → toggle-bXDrMX-A.js.map} +1 -1
  69. package/extensions/dashboard-client/dist/assets/{useSSE-DvlceHjV.js → useSSE-Yq86SUA0.js} +2 -2
  70. package/extensions/dashboard-client/dist/assets/{useSSE-DvlceHjV.js.map → useSSE-Yq86SUA0.js.map} +1 -1
  71. package/extensions/dashboard-client/dist/index.html +1 -1
  72. package/extensions/dashboard-client/src/api/vector-cortex.ts +9 -0
  73. package/extensions/dashboard-client/src/tabs/VectorCortexDiagnosticsCard.tsx +46 -0
  74. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +25 -121
  75. package/extensions/dashboard-client/src/tabs/useVectorCortexPoll.ts +123 -0
  76. package/extensions/dashboard-client/src/types/vector-cortex-vc7.ts +63 -0
  77. package/extensions/dashboard-client/src/types/vector-cortex.ts +5 -33
  78. package/extensions/dashboard-server/api-contracts/vector-cortex-diagnostics.ts +76 -0
  79. package/extensions/dashboard-server/route-dispatch.ts +5 -0
  80. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
  81. package/extensions/dashboard-server/routes-vector-cortex-diagnostics.ts +77 -0
  82. package/package.json +1 -1
  83. package/src/config/vector-cortex.ts +21 -0
  84. package/src/config.ts +1 -0
  85. package/src/vector-cortex/cache/_diagnostics-fixture.ts +32 -0
  86. package/src/vector-cortex/cache/breaker.ts +124 -0
  87. package/src/vector-cortex/cache/diagnostics-emit.ts +90 -0
  88. package/src/vector-cortex/cache/diagnostics-types.ts +87 -0
  89. package/src/vector-cortex/cache/diagnostics.ts +119 -0
  90. package/src/vector-cortex/migrations/request-hash-v2-ops.ts +201 -0
  91. package/src/vector-cortex/migrations/request-hash-v2-types.ts +87 -0
  92. package/src/vector-cortex/migrations/request-hash-v2.ts +65 -213
  93. package/extensions/dashboard-client/dist/assets/VectorCortexTab-BBa7rp6C.js +0 -2
  94. package/extensions/dashboard-client/dist/assets/VectorCortexTab-BBa7rp6C.js.map +0 -1
@@ -0,0 +1,97 @@
1
+ /**
2
+ * cache/diagnostics.ts — VC7C pure miss classification (flag-independent).
3
+ *
4
+ * The classifier is PURE arithmetic: given a `MissObservation` it returns
5
+ * exactly ONE `MissClass` and the payload-free `MissEvidence`. It is NOT gated by
6
+ * MEGACOMPACT_VC7C — flag-off must be byte-identical to the predecessor, so the
7
+ * SAME class a user sees today, they see tomorrow. The flag gates only the
8
+ * reporter/dashboard seam (see `diagnostics-emit.ts`).
9
+ *
10
+ * Exclusive ranking: profile -> range -> dependency -> request -> generation ->
11
+ * unknown. First match wins; the ranking itself is the contract and is pinned by
12
+ * CACHE-016..030. "Absence is not a mismatch": a cold key (null cached fields)
13
+ * classifies `unknown`, never `profile`. PREVENT-002/011/PI-004 honored.
14
+ */
15
+ /** A cached field is present iff it is non-null. */
16
+ function isPresent(value) {
17
+ return value !== null;
18
+ }
19
+ /**
20
+ * Clamp the dependency delta to a non-negative, safe-integer count. A request
21
+ * BEHIND the cached frontier is not an advance (delta 0); a huge advance
22
+ * saturates rather than losing precision.
23
+ */
24
+ function advanceDelta(request, cached) {
25
+ if (cached === null)
26
+ return { advanced: false, delta: 0 };
27
+ if (request <= cached)
28
+ return { advanced: false, delta: 0 };
29
+ const diff = request - cached;
30
+ if (diff > BigInt(Number.MAX_SAFE_INTEGER)) {
31
+ return { advanced: true, delta: Number.MAX_SAFE_INTEGER };
32
+ }
33
+ return { advanced: true, delta: Number(diff) };
34
+ }
35
+ /** Collect the payload-free evidence from one observation. */
36
+ export function collectEvidence(o) {
37
+ const profileMismatch = isPresent(o.cachedProfileId) &&
38
+ isPresent(o.cachedProfileVersion) &&
39
+ (o.cachedProfileId !== o.requestProfileId ||
40
+ o.cachedProfileVersion !== o.requestProfileVersion);
41
+ const rangeMismatch = (isPresent(o.cachedCoveredDigest) &&
42
+ o.cachedCoveredDigest !== o.requestCoveredDigest) ||
43
+ (isPresent(o.cachedRangeCount) &&
44
+ o.cachedRangeCount !== o.requestedRangeCount);
45
+ const dep = advanceDelta(o.requestDependencyHighWater, o.cachedDependencyHighWater);
46
+ const requestMismatch = isPresent(o.cachedRequestDigest) &&
47
+ o.cachedRequestDigest !== o.requestDigest;
48
+ const absent = !isPresent(o.cachedProfileId) &&
49
+ !isPresent(o.cachedCoveredDigest) &&
50
+ !isPresent(o.cachedRequestDigest) &&
51
+ !isPresent(o.cachedDependencyHighWater);
52
+ return {
53
+ profileMismatch,
54
+ rangeMismatch,
55
+ dependencyAdvanced: dep.advanced,
56
+ requestMismatch,
57
+ generationInvalidated: o.generationInvalidated,
58
+ requestedRangeCount: o.requestedRangeCount,
59
+ // Nothing was cached when the observation is absent, so a stale
60
+ // cachedRangeCount on the observation is not real — report 0.
61
+ cachedRangeCount: o.cachedRangeCount === null || absent ? 0 : o.cachedRangeCount,
62
+ dependencyDelta: dep.delta,
63
+ absent,
64
+ };
65
+ }
66
+ /** The exclusive ranking: first true cause wins. */
67
+ export function classFor(e) {
68
+ if (e.profileMismatch)
69
+ return "profile";
70
+ if (e.rangeMismatch)
71
+ return "range";
72
+ if (e.dependencyAdvanced)
73
+ return "dependency";
74
+ if (e.requestMismatch)
75
+ return "request";
76
+ if (e.generationInvalidated)
77
+ return "generation";
78
+ return "unknown";
79
+ }
80
+ /** Classify one observation: exactly one deterministic class. */
81
+ export function classifyMiss(o) {
82
+ const evidence = collectEvidence(o);
83
+ return {
84
+ schema: "cache-diagnostic-v1",
85
+ missClass: classFor(evidence),
86
+ evidence,
87
+ };
88
+ }
89
+ /**
90
+ * A miss a caller can self-heal on the next turn (re-fetch under a fresh
91
+ * profile / a new generation), so a triad recovery path may treat it as
92
+ * transient. Only profile + generation qualify; the rest are hard mismatches.
93
+ * An `unknown` miss is NEVER transient.
94
+ */
95
+ export function isTransientMiss(d) {
96
+ return d.missClass === "profile" || d.missClass === "generation";
97
+ }
@@ -0,0 +1,154 @@
1
+ /**
2
+ * request-hash-v2-ops.ts — M5 migration operational logic (copy/verify/switch).
3
+ *
4
+ * Extracted from request-hash-v2.ts to keep the parent file under the 300-line
5
+ * soft limit (soft-as-hard gate). Pure logic over an injected M5Host;
6
+ * deterministic + testable; no console. PREVENT-002/011/PI-004 honored.
7
+ */
8
+ import { createHash } from "node:crypto";
9
+ import { invalidationKey } from "../topology/query.js";
10
+ import { M5_FAIL, REQUEST_HASH_LEGACY_VERSION, } from "./request-hash-v2-types.js";
11
+ /** Length-prefixed framing so the folded fields cannot alias. */
12
+ function field(value) {
13
+ return `${Buffer.byteLength(value, "utf8")}:${value}`;
14
+ }
15
+ const identity = (profileId, requestDigest) => `${profileId}::${requestDigest}`;
16
+ /**
17
+ * The authoritative v2 hash: SHA-256 over the version tag, profile, request
18
+ * digest, and economics version. Length-prefixed for injectivity, exactly as the
19
+ * crystal key encoder frames its fields.
20
+ */
21
+ export function deriveRequestHashV2(profileId, requestDigest, economicsVersion) {
22
+ return createHash("sha256")
23
+ .update(field("request-hash-v2") +
24
+ field(profileId) +
25
+ field(requestDigest) +
26
+ field(economicsVersion), "utf8")
27
+ .digest("hex");
28
+ }
29
+ /** Derive the v2 row for one v1 row. */
30
+ export function deriveRequestHashRow(host, v1) {
31
+ const economicsVersion = host.economicsVersionOf(v1.profileId);
32
+ return {
33
+ profileId: v1.profileId,
34
+ // IDENTITY-PRESERVING: carried through verbatim, never re-derived.
35
+ requestDigest: v1.requestDigest,
36
+ economicsVersion,
37
+ hash: deriveRequestHashV2(v1.profileId, v1.requestDigest, economicsVersion),
38
+ };
39
+ }
40
+ /**
41
+ * Economics versions encode the generation they were minted under. We treat the
42
+ * trailing numeric segment as the generation; if it is not numeric the row is
43
+ * considered tied to generation 0 (always live unless explicitly invalidated).
44
+ */
45
+ function generationFromEconomics(economicsVersion) {
46
+ const match = /(\d+)$/.exec(economicsVersion);
47
+ return match ? BigInt(match[1]) : 0n;
48
+ }
49
+ export function detectCollision(host) {
50
+ const byHash = new Map();
51
+ const seenIdentities = new Set();
52
+ for (const v1 of host.v1Rows()) {
53
+ const row = deriveRequestHashRow(host, v1);
54
+ const id = identity(v1.profileId, v1.requestDigest);
55
+ // Two distinct v1 rows (different v1 hash) with the same v2 hash collide,
56
+ // even if they share an identity — the v2 table cannot distinguish them.
57
+ if (seenIdentities.has(id))
58
+ return true;
59
+ seenIdentities.add(id);
60
+ const prior = byHash.get(row.hash);
61
+ if (prior !== undefined && prior !== id)
62
+ return true;
63
+ byHash.set(row.hash, id);
64
+ }
65
+ return false;
66
+ }
67
+ export function isGenerationInvalidated(host, row) {
68
+ const session = host.sessionOf(row.profileId);
69
+ const live = host.liveGenerationOf(session);
70
+ const keyForLive = invalidationKey(session, live);
71
+ const keyForRow = invalidationKey(session, generationFromEconomics(row.economicsVersion));
72
+ return keyForLive !== keyForRow;
73
+ }
74
+ export function m5Copy(host) {
75
+ const existing = new Map(host.existingV2().map((r) => [identity(r.profileId, r.requestDigest), r]));
76
+ const wanted = [];
77
+ for (const v1 of host.v1Rows()) {
78
+ const fresh = deriveRequestHashRow(host, v1);
79
+ if (isGenerationInvalidated(host, fresh))
80
+ continue;
81
+ const stored = existing.get(identity(v1.profileId, v1.requestDigest));
82
+ if (stored !== undefined &&
83
+ stored.hash === fresh.hash &&
84
+ stored.economicsVersion === fresh.economicsVersion) {
85
+ continue;
86
+ }
87
+ wanted.push(fresh);
88
+ }
89
+ if (wanted.length > 0)
90
+ host.putV2(wanted);
91
+ return { written: wanted, all: [...host.existingV2()] };
92
+ }
93
+ function dedupe(codes) {
94
+ const out = [];
95
+ for (const c of codes)
96
+ if (!out.includes(c))
97
+ out.push(c);
98
+ return out;
99
+ }
100
+ export function m5Verify(host) {
101
+ const codes = [];
102
+ const stored = host.existingV2();
103
+ const v1Rows = host.v1Rows();
104
+ const counts = new Map();
105
+ for (const r of stored) {
106
+ const id = identity(r.profileId, r.requestDigest);
107
+ counts.set(id, (counts.get(id) ?? 0) + 1);
108
+ }
109
+ const expected = new Set();
110
+ for (const v1 of v1Rows) {
111
+ const id = identity(v1.profileId, v1.requestDigest);
112
+ // Dead-generation rows are intentionally skipped by copy; do not flag.
113
+ const fresh = deriveRequestHashRow(host, v1);
114
+ if (isGenerationInvalidated(host, fresh))
115
+ continue;
116
+ expected.add(id);
117
+ const n = counts.get(id) ?? 0;
118
+ if (n === 0)
119
+ codes.push(M5_FAIL.COPY_PARTIAL);
120
+ if (n > 1)
121
+ codes.push(M5_FAIL.COUNT_MISMATCH);
122
+ }
123
+ const v1Digests = new Set(v1Rows.map((r) => identity(r.profileId, r.requestDigest)));
124
+ for (const r of stored) {
125
+ const fresh = deriveRequestHashV2(r.profileId, r.requestDigest, r.economicsVersion);
126
+ if (r.hash !== fresh)
127
+ codes.push(M5_FAIL.DIGEST_MISMATCH);
128
+ const id = identity(r.profileId, r.requestDigest);
129
+ if (!v1Digests.has(id)) {
130
+ codes.push(expected.size > 0 ? M5_FAIL.IDENTITY_DRIFT : M5_FAIL.COUNT_MISMATCH);
131
+ }
132
+ }
133
+ if (detectCollision(host))
134
+ codes.push(M5_FAIL.REQUEST_HASH_COLLISION);
135
+ return { ok: codes.length === 0, codes: dedupe(codes) };
136
+ }
137
+ export function m5Switch(host) {
138
+ if (host.activeVersion() !== REQUEST_HASH_LEGACY_VERSION) {
139
+ return { ok: false, codes: [M5_FAIL.NOT_ON_LEGACY] };
140
+ }
141
+ // Collision check runs before copy-completeness verify: a structural
142
+ // collision is a switch-blocker regardless of copy state.
143
+ if (detectCollision(host))
144
+ return { ok: false, codes: [M5_FAIL.REQUEST_HASH_COLLISION] };
145
+ const verify = m5Verify(host);
146
+ if (!verify.ok)
147
+ return verify;
148
+ host.switchToV2();
149
+ return { ok: true, codes: [] };
150
+ }
151
+ export function migrateRequestHashV2(host) {
152
+ m5Copy(host);
153
+ return m5Switch(host);
154
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * request-hash-v2-types.ts — M5 request-hash-v2 migration types.
3
+ *
4
+ * Extracted from request-hash-v2.ts to keep the parent file under the 300-line
5
+ * soft limit (soft-as-hard gate). Pure type + constant definitions; no logic.
6
+ * PREVENT-002/011/PI-004 honored.
7
+ */
8
+ /** The active-version value the v2 pointer is switched to. */
9
+ export const REQUEST_HASH_V2_VERSION = 2;
10
+ /** The legacy (predecessor) active version. */
11
+ export const REQUEST_HASH_LEGACY_VERSION = 1;
12
+ /** M5 failure codes. */
13
+ export const M5_FAIL = {
14
+ COPY_PARTIAL: "M5_COPY_PARTIAL",
15
+ COUNT_MISMATCH: "M5_COUNT_MISMATCH",
16
+ DIGEST_MISMATCH: "M5_DIGEST_MISMATCH",
17
+ IDENTITY_DRIFT: "M5_IDENTITY_DRIFT",
18
+ /** Two distinct v1 rows map to the same v2 hash — blocks the switch. (VC7C) */
19
+ REQUEST_HASH_COLLISION: "M5_REQUEST_HASH_COLLISION",
20
+ /** The active pointer is not on v1; switching would be a no-op or a regression. */
21
+ NOT_ON_LEGACY: "M5_NOT_ON_LEGACY",
22
+ };
23
+ /**
24
+ * Registered M5 conformance IDs (M5-001..020). The acceptance test reads these
25
+ * rows from the v2 `migrations/` domain and asserts each returns its manifest
26
+ * bytes or exactly its listed failure code. Mirrors M6_IDS / M4_IDS.
27
+ */
28
+ export const M5_IDS = Array.from({ length: 20 }, (_v, i) => `M5-${String(i + 1).padStart(3, "0")}`);
29
+ /** Named M5 rows surfaced by the conformance corpus (mirrors M6_NAMED_IDS). */
30
+ export const M5_NAMED_IDS = ["M5-COLLIDE-002"];
@@ -1,161 +1,56 @@
1
1
  /**
2
- * vector-cortex/migrations/request-hash-v2.ts — M5 request-hash-v2, COPY +
3
- * VALIDATE ONLY (VC7B). The switch lands in VC7C.
2
+ * vector-cortex/migrations/request-hash-v2.ts — M5 request-hash-v2 migration
3
+ * (COPY + VALIDATE + SWITCH).
4
+ *
5
+ * Delegate-shell: types + constants live in request-hash-v2-types.ts and the
6
+ * operational logic (copy/verify/switch/collision) lives in
7
+ * request-hash-v2-ops.ts. This file re-exports the public surface so callers
8
+ * import from a single module. Split to keep under the 300-line soft limit
9
+ * (soft-as-hard gate).
4
10
  *
5
11
  * M5 versions the canonical request hash: the predecessor hashed the outbound
6
12
  * request under the v1 scheme; v2 folds in the provider profile's ECONOMICS
7
13
  * version so a pricing/TTL/exclusion change cannot silently reuse a cache
8
14
  * identity minted under different economics. Like M4/M6 it follows the
9
- * copy/validate/switch contract — but VC7B deliberately stops after validate:
15
+ * copy/validate/switch contract:
10
16
  *
11
17
  * - copy: resumable per (profile, request) — an interrupted run resumes
12
18
  * without duplicate rows or active-pointer drift.
13
19
  * - validate: every v1 row has exactly one v2 row, every v2 digest re-hashes
14
- * from its own declared fields, and the M5-specific invariant —
15
- * the migration is IDENTITY-PRESERVING: a v2 row must carry the
16
- * same `requestDigest` as the v1 row it came from. v2 changes how
17
- * a CACHE KEY is derived, never what the request IS. A row whose
18
- * request digest drifted is rejected (`M5_IDENTITY_DRIFT`).
19
- * - switch: NOT IMPLEMENTED IN VC7B. `m5Switch` exists so the shape of the
20
- * lifecycle is reviewable, but it always refuses with
21
- * `M5_SWITCH_DEFERRED` and leaves the active pointer on v1.
20
+ * from its own declared fields, the migration is IDENTITY-PRESERVING
21
+ * (a v2 row carries the same `requestDigest` as its v1 source v2
22
+ * changes how a CACHE KEY is derived, never what the request IS), and
23
+ * the M5-specific invariant ADDED in VC7C there are ZERO
24
+ * collisions: no two distinct v1 rows may map to one v2 hash. A
25
+ * collision (`M5_REQUEST_HASH_COLLISION`) means two different
26
+ * conversations would share a cache key, the most dangerous outcome
27
+ * in the subsystem, so it blocks the switch outright.
28
+ * - switch: ATOMICALLY flip the active pointer to v2 via `host.switchToV2()`.
29
+ * VC7B deferred this; VC7C performs it — but ONLY after re-validating
30
+ * against freshly-read host state at switch time.
22
31
  *
23
- * WHY THE SWITCH IS WITHHELD. Flipping the request-hash version invalidates
24
- * every crystal minted under v1 in one step. VC7C first runs the shadow
25
- * comparison (v1 vs v2 digests over live traffic) so the blast radius is
26
- * measured before it is taken. Shipping the switch here would mean flipping it
27
- * on evidence that does not exist yet so the function is present, refuses, and
28
- * says why, rather than being a TODO comment someone later mistakes for done.
29
- * Old-binary protocol: a reader that predates v2 keeps reading v1 rows, which
30
- * remain untouched and authoritative for the whole of VC7B.
32
+ * WHY THE COLLISION CHECK RUNS AT SWITCH TIME, NOT VALIDATE TIME. The brief's
33
+ * failure-injection contract is explicit: crash after M5 validation, inject a
34
+ * collision into host state, then resume and the RESUMED run must detect
35
+ * `M5_REQUEST_HASH_COLLISION`. If the collision were detected only from the result
36
+ * of an earlier `m5Verify` call, the cached result would be replayed and the
37
+ * injected collision would be invisible. So `m5Switch` RE-READS the host (`v1Rows`,
38
+ * `existingV2`, `activeVersion`) and RE-RUNS the collision check against that live
39
+ * state. Validation is a precondition; the switch is the only place that proves the
40
+ * hazard is absent *right now*. This is the same resume-after-crash discipline as
41
+ * M4/M6: a migration that trusts a stale verification is a migration that loses
42
+ * data on restart.
31
43
  *
32
- * Pure logic over an injected M5Host (deterministic + testable; no console).
33
- * PREVENT-002/011/PI-004 honored.
34
- */
35
- import { createHash } from "node:crypto";
36
- /** The active-version value the v2 pointer will be switched to in VC7C. */
37
- export const REQUEST_HASH_V2_VERSION = 2;
38
- /** The legacy (predecessor) active version; VC7B never leaves this. */
39
- export const REQUEST_HASH_LEGACY_VERSION = 1;
40
- /** M5 failure codes. */
41
- export const M5_FAIL = {
42
- COPY_PARTIAL: "M5_COPY_PARTIAL",
43
- COUNT_MISMATCH: "M5_COUNT_MISMATCH",
44
- DIGEST_MISMATCH: "M5_DIGEST_MISMATCH",
45
- IDENTITY_DRIFT: "M5_IDENTITY_DRIFT",
46
- SWITCH_DEFERRED: "M5_SWITCH_DEFERRED",
47
- };
48
- /** Length-prefixed framing so the folded fields cannot alias. */
49
- function field(value) {
50
- return `${Buffer.byteLength(value, "utf8")}:${value}`;
51
- }
52
- /**
53
- * The authoritative v2 hash: SHA-256 over the version tag, profile, request
54
- * digest, and economics version. Length-prefixed for injectivity, exactly as the
55
- * crystal key encoder frames its fields.
56
- */
57
- export function deriveRequestHashV2(profileId, requestDigest, economicsVersion) {
58
- return createHash("sha256")
59
- .update(field("request-hash-v2") + field(profileId) + field(requestDigest) + field(economicsVersion), "utf8")
60
- .digest("hex");
61
- }
62
- /** Derive the v2 row for one v1 row. */
63
- export function deriveRequestHashRow(host, v1) {
64
- const economicsVersion = host.economicsVersionOf(v1.profileId);
65
- return {
66
- profileId: v1.profileId,
67
- // IDENTITY-PRESERVING: carried through verbatim, never re-derived.
68
- requestDigest: v1.requestDigest,
69
- economicsVersion,
70
- hash: deriveRequestHashV2(v1.profileId, v1.requestDigest, economicsVersion),
71
- };
72
- }
73
- const identity = (profileId, requestDigest) => `${profileId}::${requestDigest}`;
74
- /**
75
- * Copy every v1 row into a v2 row BESIDE it (resumable, idempotent). Rows already
76
- * persisted with a matching derivation are left untouched; absent or stale rows
77
- * are (re)written from the authoritative derivation. The active pointer is never
78
- * touched — v1 remains authoritative throughout VC7B.
79
- */
80
- export function m5Copy(host) {
81
- const existing = new Map(host.existingV2().map((r) => [identity(r.profileId, r.requestDigest), r]));
82
- const wanted = [];
83
- for (const v1 of host.v1Rows()) {
84
- const fresh = deriveRequestHashRow(host, v1);
85
- const stored = existing.get(identity(v1.profileId, v1.requestDigest));
86
- if (stored !== undefined &&
87
- stored.hash === fresh.hash &&
88
- stored.economicsVersion === fresh.economicsVersion) {
89
- continue; // healthy, already copied
90
- }
91
- wanted.push(fresh);
92
- }
93
- if (wanted.length > 0)
94
- host.putV2(wanted);
95
- return { written: wanted, all: [...host.existingV2()] };
96
- }
97
- /**
98
- * Validate the copied set: exactly one v2 row per v1 row, every v2 hash
99
- * re-derives from its own declared fields, no orphan v2 rows, and every v2 row's
100
- * request digest equals its v1 source's (identity preservation). Never mutates.
101
- */
102
- export function m5Verify(host) {
103
- const codes = [];
104
- const stored = host.existingV2();
105
- const v1Rows = host.v1Rows();
106
- const counts = new Map();
107
- for (const r of stored) {
108
- const id = identity(r.profileId, r.requestDigest);
109
- counts.set(id, (counts.get(id) ?? 0) + 1);
110
- }
111
- const expected = new Set();
112
- for (const v1 of v1Rows) {
113
- const id = identity(v1.profileId, v1.requestDigest);
114
- expected.add(id);
115
- const n = counts.get(id) ?? 0;
116
- if (n === 0)
117
- codes.push(M5_FAIL.COPY_PARTIAL);
118
- if (n > 1)
119
- codes.push(M5_FAIL.COUNT_MISMATCH);
120
- }
121
- // Every v1 request digest that must survive the migration unchanged.
122
- const v1Digests = new Set(v1Rows.map((r) => identity(r.profileId, r.requestDigest)));
123
- for (const r of stored) {
124
- const fresh = deriveRequestHashV2(r.profileId, r.requestDigest, r.economicsVersion);
125
- if (r.hash !== fresh)
126
- codes.push(M5_FAIL.DIGEST_MISMATCH);
127
- const id = identity(r.profileId, r.requestDigest);
128
- // A v2 row whose identity has no v1 source either drifted or is an orphan.
129
- if (!v1Digests.has(id)) {
130
- codes.push(expected.size > 0 ? M5_FAIL.IDENTITY_DRIFT : M5_FAIL.COUNT_MISMATCH);
131
- }
132
- }
133
- return { ok: codes.length === 0, codes: dedupe(codes) };
134
- }
135
- /**
136
- * The switch — DEFERRED TO VC7C BY DESIGN.
44
+ * M6 INVALIDATION CONSUMPTION. A v2 request hash is only as trustworthy as the
45
+ * generation it was minted under. The switch consumes M6's structured invalidation
46
+ * keys via the REAL API (`invalidationKey` from `../topology/query.js`) rather than
47
+ * inventing one: when a v2 row's economics version maps to an invalidated router
48
+ * generation, that row cannot be promoted to active. We do not re-derive a
49
+ * generation here — topology is the authority on what generation is live — we only
50
+ * refuse to switch a row whose generation is dead. This keeps M5 from resurrecting
51
+ * cache identities tied to a generation the router has already invalidated.
137
52
  *
138
- * Always refuses and always leaves the active pointer on v1. It exists so the
139
- * lifecycle is complete and reviewable, and so a caller that tries to switch
140
- * early gets an explicit `M5_SWITCH_DEFERRED` instead of silence.
141
- */
142
- export function m5Switch(host) {
143
- void host;
144
- return { ok: false, codes: [M5_FAIL.SWITCH_DEFERRED] };
145
- }
146
- /**
147
- * The VC7B M5 lifecycle: copy -> verify. NO SWITCH. Returns the verify result;
148
- * the active version pointer is guaranteed to still be
149
- * `REQUEST_HASH_LEGACY_VERSION` on return.
53
+ * PREVENT-002/011/PI-004 honored.
150
54
  */
151
- export function migrateRequestHashV2CopyValidate(host) {
152
- m5Copy(host);
153
- return m5Verify(host);
154
- }
155
- function dedupe(codes) {
156
- const out = [];
157
- for (const c of codes)
158
- if (!out.includes(c))
159
- out.push(c);
160
- return out;
161
- }
55
+ export { REQUEST_HASH_V2_VERSION, REQUEST_HASH_LEGACY_VERSION, M5_FAIL, M5_IDS, M5_NAMED_IDS, } from "./request-hash-v2-types.js";
56
+ export { deriveRequestHashV2, deriveRequestHashRow, detectCollision, isGenerationInvalidated, m5Copy, m5Verify, m5Switch, migrateRequestHashV2, } from "./request-hash-v2-ops.js";
@@ -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-BagDVGWn.js";import{R as p,F as ee,r as ve}from"./index-DVdDtRY4.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-VUd_iOtO.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-b3HeKJLU.js";import{R as p,F as ee,r as ve}from"./index-DhlcXMlE.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-B_FKg8xJ.js.map