pi-mega-compact 0.20.45 → 0.20.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/vector-cortex-enc0d.js +39 -0
- package/dist/config/vector-cortex-enc0e.js +40 -0
- package/dist/config/vector-cortex-vc3to8.js +239 -0
- package/dist/config/vector-cortex.js +5 -227
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
- package/dist/extensions/dashboard-server/routes-setup-cortex.js +30 -1
- package/dist/extensions/dashboard-server/setup-cortex-blockers.js +2 -1
- package/dist/src/config/vector-cortex-enc0d.js +39 -0
- package/dist/src/config/vector-cortex-enc0e.js +40 -0
- package/dist/src/config/vector-cortex-vc3to8.js +239 -0
- package/dist/src/config/vector-cortex.js +5 -227
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/encoder/decision.js +17 -0
- package/dist/src/vector-cortex/encoder/promotion-emit.js +40 -0
- package/dist/src/vector-cortex/encoder/promotion.js +64 -0
- package/dist/src/vector-cortex/encoder/runtime-emit.js +8 -2
- package/dist/src/vector-cortex/encoder/runtime-select.js +35 -1
- package/dist/vector-cortex/encoder/decision.js +17 -0
- package/dist/vector-cortex/encoder/promotion-emit.js +40 -0
- package/dist/vector-cortex/encoder/promotion.js +64 -0
- package/dist/vector-cortex/encoder/runtime-emit.js +8 -2
- package/dist/vector-cortex/encoder/runtime-select.js +35 -1
- package/extensions/dashboard-client/dist/assets/{AreaChart-Cn6X7epL.js → AreaChart-COnj8FHi.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-Cn6X7epL.js.map → AreaChart-COnj8FHi.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-APy1Wc7z.js → BarChart-BYqt8c5-.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-APy1Wc7z.js.map → BarChart-BYqt8c5-.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-CEv_Ss9O.js → CacheTab-PLRjMrZV.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-CEv_Ss9O.js.map → CacheTab-PLRjMrZV.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-8jV1Pr0C.js → EventsTab-DXKSft6w.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-8jV1Pr0C.js.map → EventsTab-DXKSft6w.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-B2VgEz1j.js → HealthTab-BgVIsrde.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-B2VgEz1j.js.map → HealthTab-BgVIsrde.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-m37AlTbg.js → MaintenanceTab-DNgFC8KZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-m37AlTbg.js.map → MaintenanceTab-DNgFC8KZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-Co2jbqdT.js → MemoryMapTab-B6yY47sz.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-Co2jbqdT.js.map → MemoryMapTab-B6yY47sz.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-D0yV9X6D.js → MetricsTab-BrhJ6rkx.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-D0yV9X6D.js.map → MetricsTab-BrhJ6rkx.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-J5TjXB14.js → OverviewTab-RFHU9L4x.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-J5TjXB14.js.map → OverviewTab-RFHU9L4x.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-BadNIkWu.js → ReposTab-UFIWKkJM.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-BadNIkWu.js.map → ReposTab-UFIWKkJM.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-CdKShJuR.js → SessionsTab-BHFYsmK8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-CdKShJuR.js.map → SessionsTab-BHFYsmK8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-CPemizDx.js → SetupTab-C3dnKa8y.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{SetupTab-CPemizDx.js.map → SetupTab-C3dnKa8y.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-TvULibwW.js → TimeSavedCard-aPG5Knqn.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-TvULibwW.js.map → TimeSavedCard-aPG5Knqn.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-CglFIcYy.js → TurnsTab-fGm9n-Tk.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-CglFIcYy.js.map → TurnsTab-fGm9n-Tk.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-H2bBNhrR.js → VcStatusBadge-BtmSNH8X.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-H2bBNhrR.js.map → VcStatusBadge-BtmSNH8X.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-CXPv3sYQ.js → VectorCortexTab-meALMMOZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-CXPv3sYQ.js.map → VectorCortexTab-meALMMOZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{WikiTab-BNfN175_.js → WikiTab-0TK6q6g1.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-BNfN175_.js.map → WikiTab-0TK6q6g1.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-DjN7aqD2.js → button-CKEnMZ98.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-DjN7aqD2.js.map → button-CKEnMZ98.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-DLHA5XP8.js → card-BVVhm3sL.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-DLHA5XP8.js.map → card-BVVhm3sL.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{client-extra-ZT6mIQZS.js → client-extra-BvGxKZpm.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{client-extra-ZT6mIQZS.js.map → client-extra-BvGxKZpm.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DAl4dRVG.js → generateCategoricalChart-B1PeCct1.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DAl4dRVG.js.map → generateCategoricalChart-B1PeCct1.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-H-sfROoW.js → index-DuThOA-d.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{index-H-sfROoW.js.map → index-DuThOA-d.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{switch-BCxvJYon.js → switch-7qLS7ajc.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-BCxvJYon.js.map → switch-7qLS7ajc.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-DviUMYeg.js → toggle-D7mgOVxz.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-DviUMYeg.js.map → toggle-D7mgOVxz.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-DP2O8vHY.js → useSSE-ChpyZVeX.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-DP2O8vHY.js.map → useSSE-ChpyZVeX.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/tabs/SetupTab/CortexBlockersCard.tsx +17 -1
- package/extensions/dashboard-client/src/tabs/SetupTab/CortexSetup.tsx +1 -0
- package/extensions/dashboard-client/src/types/setup-cortex.ts +10 -0
- package/extensions/dashboard-server/api-contracts/setup-cortex.ts +11 -0
- package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
- package/extensions/dashboard-server/routes-setup-cortex.ts +35 -1
- package/extensions/dashboard-server/setup-cortex-blockers.ts +2 -1
- package/package.json +1 -1
- package/src/config/vector-cortex-enc0d.ts +41 -0
- package/src/config/vector-cortex-enc0e.ts +42 -0
- package/src/config/vector-cortex-vc3to8.ts +256 -0
- package/src/config/vector-cortex.ts +23 -245
- package/src/config.ts +2 -0
- package/src/vector-cortex/encoder/decision.ts +28 -1
- package/src/vector-cortex/encoder/promotion-emit.ts +63 -0
- package/src/vector-cortex/encoder/promotion.ts +95 -0
- package/src/vector-cortex/encoder/runtime-emit.ts +21 -4
- package/src/vector-cortex/encoder/runtime-select.ts +46 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/encoder/promotion-emit.ts — ENC-0d promotion event writers.
|
|
3
|
+
*
|
|
4
|
+
* Writes the three real-asset promotion events to the monitoring `events.log`
|
|
5
|
+
* as structured append-only JSON lines via the existing `logBenchEvent` seam
|
|
6
|
+
* (`src/monitoring.ts`):
|
|
7
|
+
*
|
|
8
|
+
* - `vector_cortex_asset_promoted` (green digest-verified swap)
|
|
9
|
+
* - `vector_cortex_asset_demoted` (red qualification / digest failure)
|
|
10
|
+
* - `vector_cortex_asset_rollback_back` (restore of a prior stack digest)
|
|
11
|
+
*
|
|
12
|
+
* Non-fatal and log-and-swallow: a write failure never breaks the agent loop
|
|
13
|
+
* (best-effort store/write contract). Each line is `{ts, event, ...fields}`
|
|
14
|
+
* shaped so the dashboard live-stream tail and evidence tooling parse it
|
|
15
|
+
* identically to every other monitoring event. Events carry digests, colors
|
|
16
|
+
* and verdicts ONLY — never message content (EVAL-REDACT-002).
|
|
17
|
+
*
|
|
18
|
+
* The path defaults to the standard state-dir events.log (mirrors
|
|
19
|
+
* defaultEventsPath). Zero network, no `any` (PREVENT-PI-004 / PREVENT-011).
|
|
20
|
+
*/
|
|
21
|
+
import { defaultEventsPath, logBenchEvent } from "../../monitoring.js";
|
|
22
|
+
import { getStateDir } from "../../store.js";
|
|
23
|
+
/** Default events.log beside the state dir (mirrors bench.ts). */
|
|
24
|
+
export function promotionEventsPath(stateDir = getStateDir()) {
|
|
25
|
+
return defaultEventsPath(stateDir);
|
|
26
|
+
}
|
|
27
|
+
const EVENT_NAME = {
|
|
28
|
+
promoted: "vector_cortex_asset_promoted",
|
|
29
|
+
demoted: "vector_cortex_asset_demoted",
|
|
30
|
+
rollback_back: "vector_cortex_asset_rollback_back",
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Append one promotion event to events.log (best-effort, non-fatal). The line
|
|
34
|
+
* is `{ts, event, ...fields}` shaped, written append-only via the monitoring
|
|
35
|
+
* logBenchEvent seam. On any write failure the event is swallowed — the agent
|
|
36
|
+
* loop is never broken.
|
|
37
|
+
*/
|
|
38
|
+
export function appendPromotionEvent(path, kind, fields) {
|
|
39
|
+
logBenchEvent(path, EVENT_NAME[kind], { ...fields });
|
|
40
|
+
}
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
* an atomic digest swap (flip the committed pointer to the prior entry's
|
|
15
15
|
* digest in one step) — no partial state is possible because the swap is a
|
|
16
16
|
* single value assignment.
|
|
17
|
+
*
|
|
18
|
+
* ENC-0d extends the ledger to the real-asset promotion path: `PromotionV1`
|
|
19
|
+
* carries `{color, assetDigestStack}` — a promotion color from gate
|
|
20
|
+
* qualification ("green" atomically swaps to the trained asset, "red" keeps
|
|
21
|
+
* the prior asset live) and a LIFO of prior shipped digest for O(1)-by-sha256
|
|
22
|
+
* rollback. The on-disk manifest byte-swap itself (write-temp-then-rename,
|
|
23
|
+
* never in-place partial) is the promotion gate script's job; these helpers
|
|
24
|
+
* stay pure and return the restorable digest + the updated manifest/stack so
|
|
25
|
+
* the script can perform the swap in one atomic step.
|
|
17
26
|
*/
|
|
18
27
|
// ---------------------------------------------------------------------------
|
|
19
28
|
// PromotionV1 — the ledger row recording one nightly training + promotion run.
|
|
@@ -42,6 +51,61 @@ export function rollbackTo(manifest, digest) {
|
|
|
42
51
|
};
|
|
43
52
|
}
|
|
44
53
|
// ---------------------------------------------------------------------------
|
|
54
|
+
// ENC-0d LIFO rollback stack + atomic swap. Pure pointer arithmetic; the
|
|
55
|
+
// on-disk write-temp-then-rename of the swapped manifest bytes is the gate
|
|
56
|
+
// script's job so no partial state can ever be observed (PREVENT-PI-004).
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
/** Push a freshly-shipped digest onto the LIFO rollback stack (top = latest
|
|
59
|
+
* prior shipped digest). Non-mutating: returns a new array. */
|
|
60
|
+
export function pushAssetDigest(stack, digest) {
|
|
61
|
+
return [...stack, digest];
|
|
62
|
+
}
|
|
63
|
+
/** Pop the top (most recent prior) digest off the LIFO rollback stack without
|
|
64
|
+
* mutating it. Returns the prior digest (null when the stack is empty) plus
|
|
65
|
+
* the remaining stack for the caller to commit (atomic card-swap fallback:
|
|
66
|
+
* a green swap pushes the incumbent digest; a rollback pops it). */
|
|
67
|
+
export function popAssetDigest(stack) {
|
|
68
|
+
if (stack.length === 0)
|
|
69
|
+
return { prior: null, rest: stack };
|
|
70
|
+
const rest = stack.slice(0, -1);
|
|
71
|
+
return { prior: stack[stack.length - 1], rest };
|
|
72
|
+
}
|
|
73
|
+
/** Atomically swap the committed manifest to a real trained asset's digest.
|
|
74
|
+
* Green: append the new entry (append-only — the incumbent stays in the
|
|
75
|
+
* ledger, never overwritten), commit to it, and record the INCUMBENT digest
|
|
76
|
+
* onto the LIFO stack for O(1) rollback (rollback restores the incumbent, so
|
|
77
|
+
* the stack must hold the pre-swap committed digest — pushing the swapped-in
|
|
78
|
+
* digest would point rollback back at the very asset being rolled back). Red
|
|
79
|
+
* (or no candidate digest): return the manifest and stack untouched — no
|
|
80
|
+
* swap, prior asset stays live. */
|
|
81
|
+
export function atomicSwap(manifest, entry, color, stack) {
|
|
82
|
+
if (color !== "green" || !entry.assetDigest) {
|
|
83
|
+
return { manifest, stack, swapped: false };
|
|
84
|
+
}
|
|
85
|
+
const incumbent = manifest.committed;
|
|
86
|
+
const next = appendAsset(manifest, entry);
|
|
87
|
+
return {
|
|
88
|
+
manifest: next,
|
|
89
|
+
stack: incumbent === null ? stack : pushAssetDigest(stack, incumbent),
|
|
90
|
+
swapped: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Roll back to the previous shipped asset by SHA-256 (O(1) via the LIFO
|
|
94
|
+
* stack): restores the most recent prior digest in the manifest and pops that
|
|
95
|
+
* entry off the stack. Returns null when no prior digest exists or the prior
|
|
96
|
+
* digest is no longer in the append-only manifest (defensive: append-only
|
|
97
|
+
* means it should always be findable). Never leaves a partial state — the
|
|
98
|
+
* committed pointer flip and the stack pop happen together or not at all. */
|
|
99
|
+
export function assetRollback(manifest, stack) {
|
|
100
|
+
const { prior, rest } = popAssetDigest(stack);
|
|
101
|
+
if (prior === null)
|
|
102
|
+
return null;
|
|
103
|
+
const restored = rollbackTo(manifest, prior);
|
|
104
|
+
if (!restored)
|
|
105
|
+
return null;
|
|
106
|
+
return { manifest: restored, stack: rest, swapped: true };
|
|
107
|
+
}
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
45
109
|
// Pure decision rules.
|
|
46
110
|
// ---------------------------------------------------------------------------
|
|
47
111
|
/** Evaluate the promotion gate: promote only when all five heads pass AND the
|
|
@@ -19,8 +19,10 @@ import { dirname } from "node:path";
|
|
|
19
19
|
import { defaultEventsPath } from "../../monitoring.js";
|
|
20
20
|
/**
|
|
21
21
|
* Emit the ML5-C `vector_cortex_runtime_selected` seller event (best-effort).
|
|
22
|
-
* The event carries ONLY the
|
|
23
|
-
* ({backend, p95Ms, budgetOk, platform})
|
|
22
|
+
* The event carries ONLY the aggregate fields the sprint specs pin
|
|
23
|
+
* ({backend, p95Ms, budgetOk, platform}) plus the ENC-0e additively-carried
|
|
24
|
+
* `demotionReason` (non-null only on a demoted platform under flag ON) —
|
|
25
|
+
* never message content. The event writer never throws.
|
|
24
26
|
*/
|
|
25
27
|
export function emitRuntimeSelected(stateDir, result) {
|
|
26
28
|
try {
|
|
@@ -33,6 +35,10 @@ export function emitRuntimeSelected(stateDir, result) {
|
|
|
33
35
|
budgetOk: result.budgetOk,
|
|
34
36
|
platform: result.platform,
|
|
35
37
|
};
|
|
38
|
+
// ENC-0e: carry the demotion reason additively, only when present.
|
|
39
|
+
if (result.demotionReason !== null && result.demotionReason !== undefined) {
|
|
40
|
+
payload.demotionReason = result.demotionReason;
|
|
41
|
+
}
|
|
36
42
|
mkdirSync(dirname(path), { recursive: true });
|
|
37
43
|
appendFileSync(path, JSON.stringify(payload) + "\n", "utf8");
|
|
38
44
|
}
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
* no fetch/HTTP). No `any` (PREVENT-011).
|
|
20
20
|
*/
|
|
21
21
|
import { ENCODER_LATENCY_P95_MS, } from "./types.js";
|
|
22
|
-
import { ML5C_ENABLED } from "../../config/vector-cortex.js";
|
|
22
|
+
import { ML5C_ENABLED, ENC_0E_ENABLED } from "../../config/vector-cortex.js";
|
|
23
|
+
import { DARWIN_X64_DEMOTION_REASON, DARWIN_X64_DEMOTION_REASON_SENTINEL, } from "./decision.js";
|
|
23
24
|
/** The 80 MiB install budget in bytes (the HG-3 ceiling, unamended). */
|
|
24
25
|
export const RUNTIME_NATIVE_INSTALL_BUDGET_MIB = 80;
|
|
25
26
|
/**
|
|
@@ -59,6 +60,7 @@ export function selectRuntimeBackend(input) {
|
|
|
59
60
|
p95Ms: null,
|
|
60
61
|
platform: input.platform,
|
|
61
62
|
rationale: "flag-off: byte-identical mode-B trigram (no selection)",
|
|
63
|
+
demotionReason: null,
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
// HG-4: Intel Mac (darwin-x64) is out-of-scope per HG-1's deferral — always demote.
|
|
@@ -69,6 +71,12 @@ export function selectRuntimeBackend(input) {
|
|
|
69
71
|
p95Ms: null,
|
|
70
72
|
platform: input.platform,
|
|
71
73
|
rationale: "darwin-x64 demoted to WASM per HG-4 (never native on this platform)",
|
|
74
|
+
// ENC-0e: the reason is the single canonical string from the ENC-0a
|
|
75
|
+
// platform matrix (decision.ts). Under flag-off the reason is stripped
|
|
76
|
+
// (null), keeping the flag-off selection byte-identical to the ENC-0d
|
|
77
|
+
// predecessor. If the matrix row ever lacks the reason, fall back to a
|
|
78
|
+
// deterministic sentinel — never throw, never fabricate a native claim.
|
|
79
|
+
demotionReason: ENC_0E_ENABLED() ? darwinX64DemotionReason(undefined) : null,
|
|
72
80
|
};
|
|
73
81
|
}
|
|
74
82
|
// Native opt-in short-circuits: operator explicitly wants the native path.
|
|
@@ -85,6 +93,7 @@ export function selectRuntimeBackend(input) {
|
|
|
85
93
|
p95Ms: input.benchRecord?.p95Ms ?? null,
|
|
86
94
|
platform: input.platform,
|
|
87
95
|
rationale: `native opt-in (MEGACOMPACT_ENCODER_NATIVE=1); shipped ${shippedMib} MiB across 5 platforms → budget amended to ${shippedMib} MiB`,
|
|
96
|
+
demotionReason: null,
|
|
88
97
|
};
|
|
89
98
|
}
|
|
90
99
|
// No bench record or degraded (gates.all:false) → WASM cannot qualify (the
|
|
@@ -99,6 +108,7 @@ export function selectRuntimeBackend(input) {
|
|
|
99
108
|
p95Ms: input.benchRecord?.p95Ms ?? null,
|
|
100
109
|
platform: input.platform,
|
|
101
110
|
rationale: `no qualifying bench record — native fallback with budget amendment (${shippedMib} MiB shipped, HG-3 amendment recorded)`,
|
|
111
|
+
demotionReason: null,
|
|
102
112
|
};
|
|
103
113
|
}
|
|
104
114
|
// The decision rule: WASM iff p95 <= 40 ms (linux-x64, 512 tokens, 4 threads) —
|
|
@@ -110,6 +120,7 @@ export function selectRuntimeBackend(input) {
|
|
|
110
120
|
p95Ms: input.benchRecord.p95Ms,
|
|
111
121
|
platform: input.platform,
|
|
112
122
|
rationale: `WASM qualifies: p95 ${input.benchRecord.p95Ms}ms <= ${ENCODER_LATENCY_P95_MS}ms`,
|
|
123
|
+
demotionReason: null,
|
|
113
124
|
};
|
|
114
125
|
}
|
|
115
126
|
return {
|
|
@@ -118,5 +129,28 @@ export function selectRuntimeBackend(input) {
|
|
|
118
129
|
p95Ms: input.benchRecord.p95Ms,
|
|
119
130
|
platform: input.platform,
|
|
120
131
|
rationale: `native required: p95 ${input.benchRecord.p95Ms}ms > ${ENCODER_LATENCY_P95_MS}ms on WASM`,
|
|
132
|
+
demotionReason: null,
|
|
121
133
|
};
|
|
122
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* ENC-0e — resolve the canonical darwin-x64 demotion reason (pure).
|
|
137
|
+
*
|
|
138
|
+
* `provider` is the ENC-0a platform-matrix row for darwin-x64 if the caller has
|
|
139
|
+
* one (the resolver owns a concrete matrix; runtime-select normally passes
|
|
140
|
+
* none and falls back to the canonical constant). Resolution order:
|
|
141
|
+
* 1. the provider row's `demotionReason` (single canonical source);
|
|
142
|
+
* 2. the canonical DARWIN_X64_DEMOTION_REASON constant;
|
|
143
|
+
* 3. the deterministic SENTINEL when a row EXISTS but lacks the reason
|
|
144
|
+
* (unique-failure injection per ENC-0e) — never a throw, never a
|
|
145
|
+
* fabricated native claim.
|
|
146
|
+
* Kept pure so tests inject the platform seam with no real Mac.
|
|
147
|
+
*/
|
|
148
|
+
export function darwinX64DemotionReason(provider) {
|
|
149
|
+
if (provider) {
|
|
150
|
+
if (provider.demotionReason && provider.demotionReason.length > 0) {
|
|
151
|
+
return provider.demotionReason;
|
|
152
|
+
}
|
|
153
|
+
return DARWIN_X64_DEMOTION_REASON_SENTINEL;
|
|
154
|
+
}
|
|
155
|
+
return DARWIN_X64_DEMOTION_REASON;
|
|
156
|
+
}
|
|
@@ -19,6 +19,23 @@
|
|
|
19
19
|
* (PREVENT-PI-004 — local computation only, never a fetch). No `any`
|
|
20
20
|
* (PREVENT-011).
|
|
21
21
|
*/
|
|
22
|
+
/**
|
|
23
|
+
* The ENC-0e canonical darwin-x64 demotion reason (HG-4 / ENC-0e).
|
|
24
|
+
*
|
|
25
|
+
* macOS Intel has no native onnxruntime-node binary upstream (arm64-only; a
|
|
26
|
+
* darwin-x64 transform-class package ships only WASM), so the runtime demotes
|
|
27
|
+
* to mode-B WASM. This is the SINGLE canonical string — consumed by
|
|
28
|
+
* runtime-select.ts (the runtime-selection event) and the Setup Cortex blockers
|
|
29
|
+
* card. No string literal for this reason survives anywhere else.
|
|
30
|
+
*/
|
|
31
|
+
export const DARWIN_X64_DEMOTION_REASON = "darwin-x64: no native binary upstream (arm64-only); mode-B WASM per HG-4";
|
|
32
|
+
/**
|
|
33
|
+
* Deterministic sentinel used when a darwin-x64 platform-matrix row is missing
|
|
34
|
+
* the `demotionReason` string (unique-failure injection per the ENC-0e spec):
|
|
35
|
+
* the selection must still choose mode-B WASM, never throw, and never fabricate
|
|
36
|
+
* a native claim — the reason just falls back to this sentinel.
|
|
37
|
+
*/
|
|
38
|
+
export const DARWIN_X64_DEMOTION_REASON_SENTINEL = "darwin-x64: demoted to WASM (reason unavailable in platform matrix)";
|
|
22
39
|
/**
|
|
23
40
|
* The normative ENC-0a budget: the 80 MiB install/asset cap (MODEL_ASSET.md
|
|
24
41
|
* §Qualification). Backend qualifies (budgetOk) iff the shipped byte-count fits.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/encoder/promotion-emit.ts — ENC-0d promotion event writers.
|
|
3
|
+
*
|
|
4
|
+
* Writes the three real-asset promotion events to the monitoring `events.log`
|
|
5
|
+
* as structured append-only JSON lines via the existing `logBenchEvent` seam
|
|
6
|
+
* (`src/monitoring.ts`):
|
|
7
|
+
*
|
|
8
|
+
* - `vector_cortex_asset_promoted` (green digest-verified swap)
|
|
9
|
+
* - `vector_cortex_asset_demoted` (red qualification / digest failure)
|
|
10
|
+
* - `vector_cortex_asset_rollback_back` (restore of a prior stack digest)
|
|
11
|
+
*
|
|
12
|
+
* Non-fatal and log-and-swallow: a write failure never breaks the agent loop
|
|
13
|
+
* (best-effort store/write contract). Each line is `{ts, event, ...fields}`
|
|
14
|
+
* shaped so the dashboard live-stream tail and evidence tooling parse it
|
|
15
|
+
* identically to every other monitoring event. Events carry digests, colors
|
|
16
|
+
* and verdicts ONLY — never message content (EVAL-REDACT-002).
|
|
17
|
+
*
|
|
18
|
+
* The path defaults to the standard state-dir events.log (mirrors
|
|
19
|
+
* defaultEventsPath). Zero network, no `any` (PREVENT-PI-004 / PREVENT-011).
|
|
20
|
+
*/
|
|
21
|
+
import { defaultEventsPath, logBenchEvent } from "../../monitoring.js";
|
|
22
|
+
import { getStateDir } from "../../store.js";
|
|
23
|
+
/** Default events.log beside the state dir (mirrors bench.ts). */
|
|
24
|
+
export function promotionEventsPath(stateDir = getStateDir()) {
|
|
25
|
+
return defaultEventsPath(stateDir);
|
|
26
|
+
}
|
|
27
|
+
const EVENT_NAME = {
|
|
28
|
+
promoted: "vector_cortex_asset_promoted",
|
|
29
|
+
demoted: "vector_cortex_asset_demoted",
|
|
30
|
+
rollback_back: "vector_cortex_asset_rollback_back",
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Append one promotion event to events.log (best-effort, non-fatal). The line
|
|
34
|
+
* is `{ts, event, ...fields}` shaped, written append-only via the monitoring
|
|
35
|
+
* logBenchEvent seam. On any write failure the event is swallowed — the agent
|
|
36
|
+
* loop is never broken.
|
|
37
|
+
*/
|
|
38
|
+
export function appendPromotionEvent(path, kind, fields) {
|
|
39
|
+
logBenchEvent(path, EVENT_NAME[kind], { ...fields });
|
|
40
|
+
}
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
* an atomic digest swap (flip the committed pointer to the prior entry's
|
|
15
15
|
* digest in one step) — no partial state is possible because the swap is a
|
|
16
16
|
* single value assignment.
|
|
17
|
+
*
|
|
18
|
+
* ENC-0d extends the ledger to the real-asset promotion path: `PromotionV1`
|
|
19
|
+
* carries `{color, assetDigestStack}` — a promotion color from gate
|
|
20
|
+
* qualification ("green" atomically swaps to the trained asset, "red" keeps
|
|
21
|
+
* the prior asset live) and a LIFO of prior shipped digest for O(1)-by-sha256
|
|
22
|
+
* rollback. The on-disk manifest byte-swap itself (write-temp-then-rename,
|
|
23
|
+
* never in-place partial) is the promotion gate script's job; these helpers
|
|
24
|
+
* stay pure and return the restorable digest + the updated manifest/stack so
|
|
25
|
+
* the script can perform the swap in one atomic step.
|
|
17
26
|
*/
|
|
18
27
|
// ---------------------------------------------------------------------------
|
|
19
28
|
// PromotionV1 — the ledger row recording one nightly training + promotion run.
|
|
@@ -42,6 +51,61 @@ export function rollbackTo(manifest, digest) {
|
|
|
42
51
|
};
|
|
43
52
|
}
|
|
44
53
|
// ---------------------------------------------------------------------------
|
|
54
|
+
// ENC-0d LIFO rollback stack + atomic swap. Pure pointer arithmetic; the
|
|
55
|
+
// on-disk write-temp-then-rename of the swapped manifest bytes is the gate
|
|
56
|
+
// script's job so no partial state can ever be observed (PREVENT-PI-004).
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
/** Push a freshly-shipped digest onto the LIFO rollback stack (top = latest
|
|
59
|
+
* prior shipped digest). Non-mutating: returns a new array. */
|
|
60
|
+
export function pushAssetDigest(stack, digest) {
|
|
61
|
+
return [...stack, digest];
|
|
62
|
+
}
|
|
63
|
+
/** Pop the top (most recent prior) digest off the LIFO rollback stack without
|
|
64
|
+
* mutating it. Returns the prior digest (null when the stack is empty) plus
|
|
65
|
+
* the remaining stack for the caller to commit (atomic card-swap fallback:
|
|
66
|
+
* a green swap pushes the incumbent digest; a rollback pops it). */
|
|
67
|
+
export function popAssetDigest(stack) {
|
|
68
|
+
if (stack.length === 0)
|
|
69
|
+
return { prior: null, rest: stack };
|
|
70
|
+
const rest = stack.slice(0, -1);
|
|
71
|
+
return { prior: stack[stack.length - 1], rest };
|
|
72
|
+
}
|
|
73
|
+
/** Atomically swap the committed manifest to a real trained asset's digest.
|
|
74
|
+
* Green: append the new entry (append-only — the incumbent stays in the
|
|
75
|
+
* ledger, never overwritten), commit to it, and record the INCUMBENT digest
|
|
76
|
+
* onto the LIFO stack for O(1) rollback (rollback restores the incumbent, so
|
|
77
|
+
* the stack must hold the pre-swap committed digest — pushing the swapped-in
|
|
78
|
+
* digest would point rollback back at the very asset being rolled back). Red
|
|
79
|
+
* (or no candidate digest): return the manifest and stack untouched — no
|
|
80
|
+
* swap, prior asset stays live. */
|
|
81
|
+
export function atomicSwap(manifest, entry, color, stack) {
|
|
82
|
+
if (color !== "green" || !entry.assetDigest) {
|
|
83
|
+
return { manifest, stack, swapped: false };
|
|
84
|
+
}
|
|
85
|
+
const incumbent = manifest.committed;
|
|
86
|
+
const next = appendAsset(manifest, entry);
|
|
87
|
+
return {
|
|
88
|
+
manifest: next,
|
|
89
|
+
stack: incumbent === null ? stack : pushAssetDigest(stack, incumbent),
|
|
90
|
+
swapped: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Roll back to the previous shipped asset by SHA-256 (O(1) via the LIFO
|
|
94
|
+
* stack): restores the most recent prior digest in the manifest and pops that
|
|
95
|
+
* entry off the stack. Returns null when no prior digest exists or the prior
|
|
96
|
+
* digest is no longer in the append-only manifest (defensive: append-only
|
|
97
|
+
* means it should always be findable). Never leaves a partial state — the
|
|
98
|
+
* committed pointer flip and the stack pop happen together or not at all. */
|
|
99
|
+
export function assetRollback(manifest, stack) {
|
|
100
|
+
const { prior, rest } = popAssetDigest(stack);
|
|
101
|
+
if (prior === null)
|
|
102
|
+
return null;
|
|
103
|
+
const restored = rollbackTo(manifest, prior);
|
|
104
|
+
if (!restored)
|
|
105
|
+
return null;
|
|
106
|
+
return { manifest: restored, stack: rest, swapped: true };
|
|
107
|
+
}
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
45
109
|
// Pure decision rules.
|
|
46
110
|
// ---------------------------------------------------------------------------
|
|
47
111
|
/** Evaluate the promotion gate: promote only when all five heads pass AND the
|
|
@@ -19,8 +19,10 @@ import { dirname } from "node:path";
|
|
|
19
19
|
import { defaultEventsPath } from "../../monitoring.js";
|
|
20
20
|
/**
|
|
21
21
|
* Emit the ML5-C `vector_cortex_runtime_selected` seller event (best-effort).
|
|
22
|
-
* The event carries ONLY the
|
|
23
|
-
* ({backend, p95Ms, budgetOk, platform})
|
|
22
|
+
* The event carries ONLY the aggregate fields the sprint specs pin
|
|
23
|
+
* ({backend, p95Ms, budgetOk, platform}) plus the ENC-0e additively-carried
|
|
24
|
+
* `demotionReason` (non-null only on a demoted platform under flag ON) —
|
|
25
|
+
* never message content. The event writer never throws.
|
|
24
26
|
*/
|
|
25
27
|
export function emitRuntimeSelected(stateDir, result) {
|
|
26
28
|
try {
|
|
@@ -33,6 +35,10 @@ export function emitRuntimeSelected(stateDir, result) {
|
|
|
33
35
|
budgetOk: result.budgetOk,
|
|
34
36
|
platform: result.platform,
|
|
35
37
|
};
|
|
38
|
+
// ENC-0e: carry the demotion reason additively, only when present.
|
|
39
|
+
if (result.demotionReason !== null && result.demotionReason !== undefined) {
|
|
40
|
+
payload.demotionReason = result.demotionReason;
|
|
41
|
+
}
|
|
36
42
|
mkdirSync(dirname(path), { recursive: true });
|
|
37
43
|
appendFileSync(path, JSON.stringify(payload) + "\n", "utf8");
|
|
38
44
|
}
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
* no fetch/HTTP). No `any` (PREVENT-011).
|
|
20
20
|
*/
|
|
21
21
|
import { ENCODER_LATENCY_P95_MS, } from "./types.js";
|
|
22
|
-
import { ML5C_ENABLED } from "../../config/vector-cortex.js";
|
|
22
|
+
import { ML5C_ENABLED, ENC_0E_ENABLED } from "../../config/vector-cortex.js";
|
|
23
|
+
import { DARWIN_X64_DEMOTION_REASON, DARWIN_X64_DEMOTION_REASON_SENTINEL, } from "./decision.js";
|
|
23
24
|
/** The 80 MiB install budget in bytes (the HG-3 ceiling, unamended). */
|
|
24
25
|
export const RUNTIME_NATIVE_INSTALL_BUDGET_MIB = 80;
|
|
25
26
|
/**
|
|
@@ -59,6 +60,7 @@ export function selectRuntimeBackend(input) {
|
|
|
59
60
|
p95Ms: null,
|
|
60
61
|
platform: input.platform,
|
|
61
62
|
rationale: "flag-off: byte-identical mode-B trigram (no selection)",
|
|
63
|
+
demotionReason: null,
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
// HG-4: Intel Mac (darwin-x64) is out-of-scope per HG-1's deferral — always demote.
|
|
@@ -69,6 +71,12 @@ export function selectRuntimeBackend(input) {
|
|
|
69
71
|
p95Ms: null,
|
|
70
72
|
platform: input.platform,
|
|
71
73
|
rationale: "darwin-x64 demoted to WASM per HG-4 (never native on this platform)",
|
|
74
|
+
// ENC-0e: the reason is the single canonical string from the ENC-0a
|
|
75
|
+
// platform matrix (decision.ts). Under flag-off the reason is stripped
|
|
76
|
+
// (null), keeping the flag-off selection byte-identical to the ENC-0d
|
|
77
|
+
// predecessor. If the matrix row ever lacks the reason, fall back to a
|
|
78
|
+
// deterministic sentinel — never throw, never fabricate a native claim.
|
|
79
|
+
demotionReason: ENC_0E_ENABLED() ? darwinX64DemotionReason(undefined) : null,
|
|
72
80
|
};
|
|
73
81
|
}
|
|
74
82
|
// Native opt-in short-circuits: operator explicitly wants the native path.
|
|
@@ -85,6 +93,7 @@ export function selectRuntimeBackend(input) {
|
|
|
85
93
|
p95Ms: input.benchRecord?.p95Ms ?? null,
|
|
86
94
|
platform: input.platform,
|
|
87
95
|
rationale: `native opt-in (MEGACOMPACT_ENCODER_NATIVE=1); shipped ${shippedMib} MiB across 5 platforms → budget amended to ${shippedMib} MiB`,
|
|
96
|
+
demotionReason: null,
|
|
88
97
|
};
|
|
89
98
|
}
|
|
90
99
|
// No bench record or degraded (gates.all:false) → WASM cannot qualify (the
|
|
@@ -99,6 +108,7 @@ export function selectRuntimeBackend(input) {
|
|
|
99
108
|
p95Ms: input.benchRecord?.p95Ms ?? null,
|
|
100
109
|
platform: input.platform,
|
|
101
110
|
rationale: `no qualifying bench record — native fallback with budget amendment (${shippedMib} MiB shipped, HG-3 amendment recorded)`,
|
|
111
|
+
demotionReason: null,
|
|
102
112
|
};
|
|
103
113
|
}
|
|
104
114
|
// The decision rule: WASM iff p95 <= 40 ms (linux-x64, 512 tokens, 4 threads) —
|
|
@@ -110,6 +120,7 @@ export function selectRuntimeBackend(input) {
|
|
|
110
120
|
p95Ms: input.benchRecord.p95Ms,
|
|
111
121
|
platform: input.platform,
|
|
112
122
|
rationale: `WASM qualifies: p95 ${input.benchRecord.p95Ms}ms <= ${ENCODER_LATENCY_P95_MS}ms`,
|
|
123
|
+
demotionReason: null,
|
|
113
124
|
};
|
|
114
125
|
}
|
|
115
126
|
return {
|
|
@@ -118,5 +129,28 @@ export function selectRuntimeBackend(input) {
|
|
|
118
129
|
p95Ms: input.benchRecord.p95Ms,
|
|
119
130
|
platform: input.platform,
|
|
120
131
|
rationale: `native required: p95 ${input.benchRecord.p95Ms}ms > ${ENCODER_LATENCY_P95_MS}ms on WASM`,
|
|
132
|
+
demotionReason: null,
|
|
121
133
|
};
|
|
122
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* ENC-0e — resolve the canonical darwin-x64 demotion reason (pure).
|
|
137
|
+
*
|
|
138
|
+
* `provider` is the ENC-0a platform-matrix row for darwin-x64 if the caller has
|
|
139
|
+
* one (the resolver owns a concrete matrix; runtime-select normally passes
|
|
140
|
+
* none and falls back to the canonical constant). Resolution order:
|
|
141
|
+
* 1. the provider row's `demotionReason` (single canonical source);
|
|
142
|
+
* 2. the canonical DARWIN_X64_DEMOTION_REASON constant;
|
|
143
|
+
* 3. the deterministic SENTINEL when a row EXISTS but lacks the reason
|
|
144
|
+
* (unique-failure injection per ENC-0e) — never a throw, never a
|
|
145
|
+
* fabricated native claim.
|
|
146
|
+
* Kept pure so tests inject the platform seam with no real Mac.
|
|
147
|
+
*/
|
|
148
|
+
export function darwinX64DemotionReason(provider) {
|
|
149
|
+
if (provider) {
|
|
150
|
+
if (provider.demotionReason && provider.demotionReason.length > 0) {
|
|
151
|
+
return provider.demotionReason;
|
|
152
|
+
}
|
|
153
|
+
return DARWIN_X64_DEMOTION_REASON_SENTINEL;
|
|
154
|
+
}
|
|
155
|
+
return DARWIN_X64_DEMOTION_REASON;
|
|
156
|
+
}
|
package/extensions/dashboard-client/dist/assets/{AreaChart-Cn6X7epL.js → AreaChart-COnj8FHi.js}
RENAMED
|
@@ -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-DAl4dRVG.js";import{R as p,A as ee,r as ve}from"./index-H-sfROoW.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-
|
|
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-B1PeCct1.js";import{R as p,A as ee,r as ve}from"./index-DuThOA-d.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-COnj8FHi.js.map
|