pi-mega-compact 0.20.4 → 0.20.6
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.js +24 -0
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +2 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-render.js +40 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-rollout.js +43 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex.js +2 -0
- package/dist/extensions/dashboard-server/routes.js +1 -1
- package/dist/extensions/dashboard-server/server.js +5 -1
- package/dist/extensions/mega-context/vector-cortex.js +128 -0
- package/dist/extensions/mega-runtime/vector-cortex-live.js +105 -0
- package/dist/src/config/vector-cortex.js +24 -0
- package/dist/src/config.js +1 -1
- package/dist/src/store/sqlite/global-sessions.js +16 -4
- package/dist/src/vector-cortex/provider/registry.js +112 -0
- package/dist/src/vector-cortex/provider/types.js +30 -0
- package/dist/src/vector-cortex/render/_acceptance-fixture.js +58 -0
- package/dist/src/vector-cortex/render/_acceptance-helpers.js +17 -0
- package/dist/src/vector-cortex/render/_acceptance-provider.js +29 -0
- package/dist/src/vector-cortex/render/_acceptance-scenario.js +259 -0
- package/dist/src/vector-cortex/render/renderer.js +119 -0
- package/dist/src/vector-cortex/render/types.js +29 -0
- package/dist/src/vector-cortex/render/validator.js +90 -0
- package/dist/src/vector-cortex/rollout/_acceptance-fixture.js +55 -0
- package/dist/src/vector-cortex/rollout/_acceptance-helpers.js +8 -0
- package/dist/src/vector-cortex/rollout/_acceptance-scenario.js +70 -0
- package/dist/src/vector-cortex/rollout/assign.js +56 -0
- package/dist/src/vector-cortex/rollout/emit.js +50 -0
- package/dist/src/vector-cortex/rollout/gate.js +75 -0
- package/dist/src/vector-cortex/rollout/types.js +39 -0
- package/dist/vector-cortex/provider/registry.js +112 -0
- package/dist/vector-cortex/provider/types.js +30 -0
- package/dist/vector-cortex/render/_acceptance-fixture.js +58 -0
- package/dist/vector-cortex/render/_acceptance-helpers.js +17 -0
- package/dist/vector-cortex/render/_acceptance-provider.js +29 -0
- package/dist/vector-cortex/render/_acceptance-scenario.js +259 -0
- package/dist/vector-cortex/render/renderer.js +119 -0
- package/dist/vector-cortex/render/types.js +29 -0
- package/dist/vector-cortex/render/validator.js +90 -0
- package/dist/vector-cortex/rollout/_acceptance-fixture.js +55 -0
- package/dist/vector-cortex/rollout/_acceptance-helpers.js +8 -0
- package/dist/vector-cortex/rollout/_acceptance-scenario.js +70 -0
- package/dist/vector-cortex/rollout/assign.js +56 -0
- package/dist/vector-cortex/rollout/emit.js +50 -0
- package/dist/vector-cortex/rollout/gate.js +75 -0
- package/dist/vector-cortex/rollout/types.js +39 -0
- package/extensions/dashboard-client/dist/assets/{AreaChart-Cam9-nhT.js → AreaChart-DqTbaSRA.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-Cam9-nhT.js.map → AreaChart-DqTbaSRA.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-DzIY8aM1.js → BarChart-BfNBeOvF.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-DzIY8aM1.js.map → BarChart-BfNBeOvF.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-CKIiYsG_.js → CacheTab-C9SOMYB5.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-CKIiYsG_.js.map → CacheTab-C9SOMYB5.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-xaaBJLiK.js → EventsTab-GsMKP10_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-xaaBJLiK.js.map → EventsTab-GsMKP10_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-BGtUKOqG.js → HealthTab-DAOCXwRP.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-BGtUKOqG.js.map → HealthTab-DAOCXwRP.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-ABgQnTZ9.js → MaintenanceTab-BtBeMkB5.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-ABgQnTZ9.js.map → MaintenanceTab-BtBeMkB5.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-ChR2GAN-.js → MemoryMapTab-DzndtgkZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-ChR2GAN-.js.map → MemoryMapTab-DzndtgkZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-DdCLAgcR.js → MetricsTab-DyxJ4eb8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-DdCLAgcR.js.map → MetricsTab-DyxJ4eb8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-DtemzJt6.js → OverviewTab-DCiEdVWR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-DtemzJt6.js.map → OverviewTab-DCiEdVWR.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-B9mvD9Ep.js → ReposTab-B5SIqVHA.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-B9mvD9Ep.js.map → ReposTab-B5SIqVHA.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-BcO38XLS.js → SessionsTab-DLWFJ9xI.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-BcO38XLS.js.map → SessionsTab-DLWFJ9xI.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-D_TBNP09.js → SetupTab-CvGXZyej.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SetupTab-D_TBNP09.js.map → SetupTab-CvGXZyej.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-TjHpbUOo.js → TimeSavedCard-wZuQGxLS.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-TjHpbUOo.js.map → TimeSavedCard-wZuQGxLS.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DprxndCF.js → TurnsTab-B7aOejch.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DprxndCF.js.map → TurnsTab-B7aOejch.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js +2 -0
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{WikiTab-OKgSo15G.js → WikiTab-DhWHjAtt.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-OKgSo15G.js.map → WikiTab-DhWHjAtt.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-D_Qz4q7L.js → button-BrC-W87h.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-D_Qz4q7L.js.map → button-BrC-W87h.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-CsI6Jm3p.js → card-0rgfRgr3.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-CsI6Jm3p.js.map → card-0rgfRgr3.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CvHKUdhX.js → generateCategoricalChart-DRresOQF.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CvHKUdhX.js.map → generateCategoricalChart-DRresOQF.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-0Ye_un22.js → index-DohmtZWL.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{index-0Ye_un22.js.map → index-DohmtZWL.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{switch-VQEoJl8Q.js → switch-Bs8g_zB5.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-VQEoJl8Q.js.map → switch-Bs8g_zB5.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-CAPm4HJo.js → toggle-DVVauIo8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-CAPm4HJo.js.map → toggle-DVVauIo8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-pxsNTVkh.js → useSSE-DxH1PTAR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-pxsNTVkh.js.map → useSSE-DxH1PTAR.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/api/vector-cortex.ts +18 -0
- package/extensions/dashboard-client/src/tabs/VectorCortexMetric.tsx +10 -0
- package/extensions/dashboard-client/src/tabs/VectorCortexPlansCard.tsx +39 -0
- package/extensions/dashboard-client/src/tabs/VectorCortexRenderCard.tsx +38 -0
- package/extensions/dashboard-client/src/tabs/VectorCortexRolloutCard.tsx +44 -0
- package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +19 -38
- package/extensions/dashboard-client/src/types/vector-cortex.ts +26 -0
- package/extensions/dashboard-server/api-contracts/vector-cortex.ts +52 -1
- package/extensions/dashboard-server/routes-rag-settings-helpers.ts +12 -0
- package/extensions/dashboard-server/routes-vector-cortex-render.ts +49 -0
- package/extensions/dashboard-server/routes-vector-cortex-rollout.ts +52 -0
- package/extensions/dashboard-server/routes-vector-cortex.ts +2 -0
- package/extensions/dashboard-server/routes.ts +2 -0
- package/extensions/dashboard-server/server.ts +4 -0
- package/extensions/mega-context/vector-cortex.ts +163 -0
- package/extensions/mega-runtime/vector-cortex-live.ts +165 -0
- package/package.json +1 -1
- package/src/config/vector-cortex.ts +26 -0
- package/src/config.ts +2 -0
- package/src/store/sqlite/global-sessions.ts +14 -2
- package/src/vector-cortex/provider/registry.ts +137 -0
- package/src/vector-cortex/provider/types.ts +163 -0
- package/src/vector-cortex/render/_acceptance-fixture.ts +128 -0
- package/src/vector-cortex/render/_acceptance-helpers.ts +39 -0
- package/src/vector-cortex/render/_acceptance-provider.ts +45 -0
- package/src/vector-cortex/render/_acceptance-scenario.ts +319 -0
- package/src/vector-cortex/render/renderer.ts +142 -0
- package/src/vector-cortex/render/types.ts +174 -0
- package/src/vector-cortex/render/validator.ts +120 -0
- package/src/vector-cortex/rollout/_acceptance-fixture.ts +94 -0
- package/src/vector-cortex/rollout/_acceptance-helpers.ts +24 -0
- package/src/vector-cortex/rollout/_acceptance-scenario.ts +96 -0
- package/src/vector-cortex/rollout/assign.ts +67 -0
- package/src/vector-cortex/rollout/emit.ts +81 -0
- package/src/vector-cortex/rollout/gate.ts +119 -0
- package/src/vector-cortex/rollout/types.ts +111 -0
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-Bym21yVQ.js +0 -2
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-Bym21yVQ.js.map +0 -1
|
@@ -172,6 +172,30 @@ export const VC4C_ENABLED = () => sprintFlag("MEGACOMPACT_VC4C");
|
|
|
172
172
|
* mirroring VC4A/VC4B/VC4C.
|
|
173
173
|
*/
|
|
174
174
|
export const VC5A_ENABLED = () => sprintFlag("MEGACOMPACT_VC5A");
|
|
175
|
+
/**
|
|
176
|
+
* VC5B — validated prompt renderer + provider profiles. Default ON.
|
|
177
|
+
* `MEGACOMPACT_VC5B=0` disables and is byte-identical to the predecessor
|
|
178
|
+
* (VC5A): no render manifest is produced, no canonical request is hashed, the
|
|
179
|
+
* `vector_cortex_render_validated` / `vector_cortex_provider_bypassed` events are
|
|
180
|
+
* never emitted, and the prompt continues to be built by the predecessor VC5A
|
|
181
|
+
* DAG/plan path (its goldens are unchanged). The render/validate functions are
|
|
182
|
+
* PURE — flag OFF gates the reporter + dashboard seam, never the arithmetic.
|
|
183
|
+
* This flag MUST also be a dashboard SETTINGS toggle (visible in config UI, never
|
|
184
|
+
* in EXCLUDED_SETTINGS), mirroring VC4A/VC4B/VC4C/VC5A.
|
|
185
|
+
*/
|
|
186
|
+
export const VC5B_ENABLED = () => sprintFlag("MEGACOMPACT_VC5B");
|
|
187
|
+
/**
|
|
188
|
+
* VC5C — live graduated rollout. Default ON. `MEGACOMPACT_VC5C=0` disables and
|
|
189
|
+
* is byte-identical to the predecessor (VC5B): no session is assigned a stable
|
|
190
|
+
* 10k bucket, no gate-advance decision runs, the `vector_cortex_rollout_assigned`
|
|
191
|
+
* / `vector_cortex_rollout_promotion_blocked` events are never emitted, and the
|
|
192
|
+
* prompt continues to be built by the predecessor VC5B renderer path (its goldens
|
|
193
|
+
* are unchanged). The assign/gate/emit functions are PURE — flag OFF gates the
|
|
194
|
+
* reporter + dashboard seam, never the arithmetic. This flag MUST also be a
|
|
195
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS),
|
|
196
|
+
* mirroring VC4A/VC4B/VC4C/VC5A/VC5B.
|
|
197
|
+
*/
|
|
198
|
+
export const VC5C_ENABLED = () => sprintFlag("MEGACOMPACT_VC5C");
|
|
175
199
|
// ---------------------------------------------------------------------------
|
|
176
200
|
// Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
|
|
177
201
|
// Rolled numbers for one 60s window; VC0C consumes these at its breaker seam.
|
package/dist/config.js
CHANGED
|
@@ -114,4 +114,4 @@ export const NEW_UI = () => ragEnabled("MEGACOMPACT_NEW_UI");
|
|
|
114
114
|
// default ON, `=0`/`_DISABLED` off. Re-exported from src/config/vector-cortex.ts
|
|
115
115
|
// so root consumers share one source of truth.
|
|
116
116
|
// ---------------------------------------------------------------------------
|
|
117
|
-
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
117
|
+
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
@@ -150,6 +150,8 @@ export const SETTINGS = [
|
|
|
150
150
|
boolDirect("MEGACOMPACT_VC4B", "VC4B Residual Basis Parity", "Residual codec: orthonormal DCT-II basis + int16 block quantization + block-scoped exact correction stream + (9,6) Reed-Solomon parity shards with SHA-256 corruption detection; admission gates on encodedSize <= 95% of exact-compressed size. OFF = mode C, no residual artifact produced, byte-identical predecessor.", true),
|
|
151
151
|
boolDirect("MEGACOMPACT_VC4C", "VC4C Reconstruction Fidelity", "Conservative closure + source-order assembly + reconstruction validator: recursively closes dependencies and whole tool pairs to a fixed point, resolves contradictions by retaining the later exact source resolution, assembles spans solely by source range, and rejects missing anchors / split pairs / digest mismatch / unresolved contradiction. Mandatory token estimate is content-only and handed unchanged to VC5A. OFF = mode C, no closure/validator, byte-identical predecessor (VC4B).", true),
|
|
152
152
|
boolDirect("MEGACOMPACT_VC5A", "VC5A PromptDagV1 + Budgeted Planner", "Single-session DAG (PromptDagV1) + budgeted 0/1 portfolio planner: builds a stable Kahn-ordered DAG, computes the mandatory dependency/tool/anchor closure before optional selection, returns MANDATORY_CLOSURE_OVER_BUDGET with evidence preserved on overflow, and runs a utility-per-token portfolio that never exceeds the remaining budget. Framing is owned here, not in VC4C. OFF = byte-identical predecessor (VC4C).", true),
|
|
153
|
+
boolDirect("MEGACOMPACT_VC5B", "VC5B Validated Renderer + Provider Profiles", "Validated prompt renderer: replays VC5A's stable Kahn order verbatim, preserves exact tool bytes (PREVENT-PI-002), places compacted context via the host before_agent_start prepend seam — never role:system (PREVENT-PI-003) — and SHA-256 hashes the entire canonical outbound request before provider invocation. Unknown provider/model cleanly bypasses to the predecessor prompt path. OFF = byte-identical predecessor (VC5A).", true),
|
|
154
|
+
boolDirect("MEGACOMPACT_VC5C", "VC5C Live Graduated Rollout", "Live graduated rollout: deterministically hashes each session into a stable 10,000-bucket cohort and advances the exposure gate (1/5/25/50/100%) only after a 72h monotonic residency, a powered sample, >=10,000 events, and >=200 sessions — advancing ONE gate at a time. A hard causal/tool/anchor/exact failure freezes promotion and selects the pre-VC path. OFF = byte-identical predecessor (VC5B).", true),
|
|
153
155
|
],
|
|
154
156
|
},
|
|
155
157
|
{
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-vector-cortex-render.ts — VC5B render + provider-profile
|
|
3
|
+
* dashboard route.
|
|
4
|
+
*
|
|
5
|
+
* Reader-only GET /api/vector-cortex/render returning the registered render
|
|
6
|
+
* (REN-001..020) and provider-profile (PRO-001..015) identifier counts plus the
|
|
7
|
+
* known base provider-profile keys. NEVER exposes rendered node bytes, prompt
|
|
8
|
+
* text, or the canonical outbound request (reader-only, SECURITY_PRIVACY).
|
|
9
|
+
* Flag-gated on MEGACOMPACT_VC5B: `enabled:false` when off (byte-identical to
|
|
10
|
+
* the pre-VC5B predecessor).
|
|
11
|
+
*
|
|
12
|
+
* Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
|
|
13
|
+
* `any`), reader-only aggregate (counts + profile keys only).
|
|
14
|
+
*/
|
|
15
|
+
import { VC5B_ENABLED } from "../../src/config.js";
|
|
16
|
+
import { REN_IDS } from "../../src/vector-cortex/render/types.js";
|
|
17
|
+
import { PRO_IDS } from "../../src/vector-cortex/provider/types.js";
|
|
18
|
+
import { KNOWN_PROVIDER_KEYS } from "../../src/vector-cortex/provider/registry.js";
|
|
19
|
+
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
20
|
+
/** Reader-only GET /api/vector-cortex/render (VC5B). */
|
|
21
|
+
export function handleVectorCortexRender(req, res, _ctx) {
|
|
22
|
+
const url = req.url ?? "";
|
|
23
|
+
const path = url.split("?")[0] ?? url;
|
|
24
|
+
if (path !== "/api/vector-cortex/render")
|
|
25
|
+
return false;
|
|
26
|
+
if (req.method !== "GET") {
|
|
27
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
const enabled = VC5B_ENABLED();
|
|
31
|
+
const body = {
|
|
32
|
+
enabled,
|
|
33
|
+
renderCount: enabled ? REN_IDS.length : 0,
|
|
34
|
+
providerCount: enabled ? PRO_IDS.length : 0,
|
|
35
|
+
knownProfiles: enabled ? KNOWN_PROVIDER_KEYS : [],
|
|
36
|
+
updatedAt: new Date().toISOString(),
|
|
37
|
+
};
|
|
38
|
+
sendJson(res, 200, body);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-vector-cortex-rollout.ts — VC5C live graduated-rollout
|
|
3
|
+
* dashboard route.
|
|
4
|
+
*
|
|
5
|
+
* Reader-only GET /api/vector-cortex/rollout returning the rollout aggregate:
|
|
6
|
+
* current gate, bucket count, sessions/events counts, and promotion-blocked
|
|
7
|
+
* state. NEVER exposes session payloads, prompt text, or bucket→session mappings
|
|
8
|
+
* (reader-only, SECURITY_PRIVACY). Flag-gated on MEGACOMPACT_VC5C: `enabled:false`
|
|
9
|
+
* when off (byte-identical to the pre-VC5C predecessor).
|
|
10
|
+
*
|
|
11
|
+
* Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
|
|
12
|
+
* `any`), reader-only aggregate (counts + gate state only).
|
|
13
|
+
*/
|
|
14
|
+
import { VC5C_ENABLED } from "../../src/config.js";
|
|
15
|
+
import { ROLLOUT_GATES, ROLLOUT_BUCKETS } from "../../src/vector-cortex/rollout/types.js";
|
|
16
|
+
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
17
|
+
/** Reader-only GET /api/vector-cortex/rollout (VC5C). */
|
|
18
|
+
export function handleVectorCortexRollout(req, res, _ctx) {
|
|
19
|
+
const url = req.url ?? "";
|
|
20
|
+
const path = url.split("?")[0] ?? url;
|
|
21
|
+
if (path !== "/api/vector-cortex/rollout")
|
|
22
|
+
return false;
|
|
23
|
+
if (req.method !== "GET") {
|
|
24
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
const enabled = VC5C_ENABLED();
|
|
28
|
+
const gateIndex = 0; // Ephemeral rollout state: no durable gate in this sprint.
|
|
29
|
+
const gatePct = ROLLOUT_GATES[gateIndex];
|
|
30
|
+
const body = {
|
|
31
|
+
enabled,
|
|
32
|
+
gateIndex: enabled ? gateIndex : 0,
|
|
33
|
+
gatePct: enabled ? gatePct : 0,
|
|
34
|
+
buckets: ROLLOUT_BUCKETS,
|
|
35
|
+
bucketCount: enabled ? gatePct * 100 : 0,
|
|
36
|
+
events: 0,
|
|
37
|
+
sessions: 0,
|
|
38
|
+
promotionBlocked: false,
|
|
39
|
+
updatedAt: new Date().toISOString(),
|
|
40
|
+
};
|
|
41
|
+
sendJson(res, 200, body);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
@@ -22,3 +22,5 @@ export { handleVectorCortexShards } from "./routes-vector-cortex-shards.js";
|
|
|
22
22
|
export { handleVectorCortexResidual } from "./routes-vector-cortex-residual.js";
|
|
23
23
|
export { handleVectorCortexReconstruct } from "./routes-vector-cortex-reconstruct.js";
|
|
24
24
|
export { handleVectorCortexPlans } from "./routes-vector-cortex-plans.js";
|
|
25
|
+
export { handleVectorCortexRender } from "./routes-vector-cortex-render.js";
|
|
26
|
+
export { handleVectorCortexRollout } from "./routes-vector-cortex-rollout.js";
|
|
@@ -23,4 +23,4 @@ export { handleRagSettings } from "./routes-rag-settings.js";
|
|
|
23
23
|
export { handleRagMetrics } from "./routes-rag-metrics.js";
|
|
24
24
|
export { handleModelThresholds } from "./routes-model-thresholds.js";
|
|
25
25
|
export { handleWiki } from "./routes-wiki.js";
|
|
26
|
-
export { handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, } from "./routes-vector-cortex.js";
|
|
26
|
+
export { handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, handleVectorCortexRender, handleVectorCortexRollout, } from "./routes-vector-cortex.js";
|
|
@@ -14,7 +14,7 @@ import { createRequire } from "node:module";
|
|
|
14
14
|
import { NEW_UI } from "../../src/config.js";
|
|
15
15
|
import { log, setLogPath, setDashboardServerVersion } from "./state.js";
|
|
16
16
|
import { detectTailscaleIP } from "./tailscale.js";
|
|
17
|
-
import { buildRouteContext, handleIndex, handleRepoIndex, handleEvents, handleGameState, handleGameScores, handlePerf, handlePerfSamples, handleAchievements, handleSessions, handleTopics, handleTurns, handleMaintenance, handleProviderCache, handleCacheStripes, handleMemoryStatus, handleSetupStatus, handleSetupDetect, handleSetupConfigure, handleMemoryMap, handleRaptorTree, handleRaptorBuildHistory, handleContextHealth, handleCachePoison, handleHealthSettings, handleEmbedderHealth, handleRagSettings, handleRagMetrics, handleModelThresholds, handleWiki, handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, handleStatic, } from "./routes.js";
|
|
17
|
+
import { buildRouteContext, handleIndex, handleRepoIndex, handleEvents, handleGameState, handleGameScores, handlePerf, handlePerfSamples, handleAchievements, handleSessions, handleTopics, handleTurns, handleMaintenance, handleProviderCache, handleCacheStripes, handleMemoryStatus, handleSetupStatus, handleSetupDetect, handleSetupConfigure, handleMemoryMap, handleRaptorTree, handleRaptorBuildHistory, handleContextHealth, handleCachePoison, handleHealthSettings, handleEmbedderHealth, handleRagSettings, handleRagMetrics, handleModelThresholds, handleWiki, handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, handleVectorCortexRender, handleVectorCortexRollout, handleStatic, } from "./routes.js";
|
|
18
18
|
export async function launchDashboardServer(stateDir) {
|
|
19
19
|
// Our own package version — exposed at /api/version so the launcher can
|
|
20
20
|
// detect a stale server (started by an older build) and replace it on
|
|
@@ -277,6 +277,10 @@ export async function launchDashboardServer(stateDir) {
|
|
|
277
277
|
return;
|
|
278
278
|
if (handleVectorCortexPlans(req, res, ctx))
|
|
279
279
|
return;
|
|
280
|
+
if (handleVectorCortexRender(req, res, ctx))
|
|
281
|
+
return;
|
|
282
|
+
if (handleVectorCortexRollout(req, res, ctx))
|
|
283
|
+
return;
|
|
280
284
|
handleStatic(req, res, ctx);
|
|
281
285
|
});
|
|
282
286
|
// Bind base + range are env-configurable so tests can use a private,
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mega-context/vector-cortex.ts — VC5B delegation seam (the sprint's production
|
|
3
|
+
* ownership: `extensions/mega-context/vector-cortex.ts`).
|
|
4
|
+
*
|
|
5
|
+
* This is the ONLY extension-side surface VC5B owns. It delegates to the pi-
|
|
6
|
+
* agnostic `src/vector-cortex/render` + `src/vector-cortex/provider` logic and
|
|
7
|
+
* wires the two structured events the sprint emits:
|
|
8
|
+
* - `vector_cortex_render_validated` — a render passed validation and will be
|
|
9
|
+
* prepended via the host `before_agent_start` systemPrompt seam.
|
|
10
|
+
* - `vector_cortex_provider_bypassed` — an unknown provider/profile forced a
|
|
11
|
+
* clean bypass (triad C, the predecessor prompt path).
|
|
12
|
+
*
|
|
13
|
+
* GUARDRAIL PREVENT-PI-003 (critical): the rendered compacted context is placed
|
|
14
|
+
* via the host `before_agent_start` systemPrompt PREPEND seam — it is NEVER
|
|
15
|
+
* emitted as a `role:"system"` conversation message. The renderer returns a
|
|
16
|
+
* `RenderManifestV1`, not a raw system-role payload; this seam composes the
|
|
17
|
+
* manifest's prepend into `event.systemPrompt`.
|
|
18
|
+
*
|
|
19
|
+
* The context handler (extensions/mega-events/context-handler.ts) is 228 lines
|
|
20
|
+
* (already a delegate shell) and under the extension hard limit, so NO split was
|
|
21
|
+
* required — VC5B delegates from here rather than modifying that handler.
|
|
22
|
+
*
|
|
23
|
+
* Pi runtime adapter: imports only pi runtime types + the VC5B logic. Flag-gated
|
|
24
|
+
* on `VC5B_ENABLED()`; flag OFF is byte-identical to the predecessor (VC5A state
|
|
25
|
+
* — the DAG/plan path), so this seam returns the host's unmodified systemPrompt.
|
|
26
|
+
*/
|
|
27
|
+
import { VC5B_ENABLED } from "../../src/config/vector-cortex.js";
|
|
28
|
+
import { resolveProviderProfile } from "../../src/vector-cortex/provider/registry.js";
|
|
29
|
+
import { renderPrompt } from "../../src/vector-cortex/render/renderer.js";
|
|
30
|
+
import { validateRender } from "../../src/vector-cortex/render/validator.js";
|
|
31
|
+
/**
|
|
32
|
+
* Run the full VC5B render+validate pipeline. Returns a structured outcome the
|
|
33
|
+
* `before_agent_start` handler composes into the host systemPrompt. On a clean
|
|
34
|
+
* bypass (unknown profile) it emits `vector_cortex_provider_bypassed` and the
|
|
35
|
+
* host uses the predecessor prompt path (triad C). On a validated render it
|
|
36
|
+
* emits `vector_cortex_render_validated` (triad A).
|
|
37
|
+
*
|
|
38
|
+
* All emits are best-effort and non-fatal; the flag gates zero observability
|
|
39
|
+
* writes when OFF (byte-identical to predecessor).
|
|
40
|
+
*/
|
|
41
|
+
export function runVectorCortexRender(input, emit) {
|
|
42
|
+
const fire = (event, fields) => {
|
|
43
|
+
try {
|
|
44
|
+
if (VC5B_ENABLED())
|
|
45
|
+
emit?.(event, fields);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
/* non-fatal observability — never break the agent loop */
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const rendered = renderPrompt(input);
|
|
52
|
+
if (!rendered.ok) {
|
|
53
|
+
// Clean bypass (unknown profile) or a hard order mismatch. Bypass emits the
|
|
54
|
+
// provider-bypassed event and defers to the predecessor prompt path.
|
|
55
|
+
fire("vector_cortex_provider_bypassed", {
|
|
56
|
+
code: rendered.code,
|
|
57
|
+
triad: rendered.triad,
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
validated: false,
|
|
61
|
+
bypassed: true,
|
|
62
|
+
manifest: null,
|
|
63
|
+
systemPromptPrepend: "",
|
|
64
|
+
triad: rendered.triad,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Validate the canonical request BEFORE invocation. The profile at validation
|
|
68
|
+
// time must match the manifest profile (the UNIQUE injection swaps it → C).
|
|
69
|
+
const sourceToolBytes = new Map();
|
|
70
|
+
for (const t of rendered.request.tools)
|
|
71
|
+
sourceToolBytes.set(t.id, t.bytes);
|
|
72
|
+
const pinnedToolLengths = new Map();
|
|
73
|
+
for (const t of rendered.request.tools) {
|
|
74
|
+
pinnedToolLengths.set(t.id, Buffer.byteLength(t.bytes, "utf8"));
|
|
75
|
+
}
|
|
76
|
+
const check = validateRender(rendered.manifest, rendered.request, input.profile, sourceToolBytes, pinnedToolLengths);
|
|
77
|
+
if (!check.ok) {
|
|
78
|
+
fire("vector_cortex_provider_bypassed", {
|
|
79
|
+
code: check.code,
|
|
80
|
+
triad: check.triad,
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
validated: false,
|
|
84
|
+
bypassed: true,
|
|
85
|
+
manifest: rendered.manifest,
|
|
86
|
+
systemPromptPrepend: "",
|
|
87
|
+
triad: check.triad,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
fire("vector_cortex_render_validated", {
|
|
91
|
+
profileId: rendered.manifest.profileId,
|
|
92
|
+
requestDigest: rendered.manifest.requestDigest,
|
|
93
|
+
nodeCount: rendered.manifest.nodeOrder.length,
|
|
94
|
+
triad: "A",
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
validated: true,
|
|
98
|
+
bypassed: false,
|
|
99
|
+
manifest: rendered.manifest,
|
|
100
|
+
systemPromptPrepend: rendered.request.systemPromptPrepend,
|
|
101
|
+
triad: "A",
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Register the VC5B `before_agent_start` prepend seam on the host. Flag OFF →
|
|
106
|
+
* byte-identical to the predecessor (returns the host's unmodified systemPrompt).
|
|
107
|
+
* The composed prepend is placed on the HOST systemPrompt, never as role:system.
|
|
108
|
+
*/
|
|
109
|
+
export function registerVectorCortexRender(pi, _ctx, emit) {
|
|
110
|
+
pi.on("before_agent_start", (event, ctx) => {
|
|
111
|
+
if (!VC5B_ENABLED())
|
|
112
|
+
return; // byte-identical predecessor behavior
|
|
113
|
+
// The host supplies the active (provider, model) so the seam can resolve the
|
|
114
|
+
// profile. Until the host passes a render input, the seam stays inert.
|
|
115
|
+
const pending = ctx.megaCompactVectorCortexRender;
|
|
116
|
+
if (pending === undefined)
|
|
117
|
+
return;
|
|
118
|
+
const outcome = runVectorCortexRender(pending, emit);
|
|
119
|
+
if (!outcome.validated)
|
|
120
|
+
return; // bypass / mismatch → predecessor path
|
|
121
|
+
return { systemPrompt: `${event.systemPrompt}\n\n${outcome.systemPromptPrepend}` };
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** Resolve a provider profile by (provider, model) for the host to pass in. */
|
|
125
|
+
export function resolveProfile(provider, model) {
|
|
126
|
+
const res = resolveProviderProfile(provider, model);
|
|
127
|
+
return res.ok ? res.bundle : null;
|
|
128
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex-live.ts — VC5C live graduated-rollout integration seam.
|
|
3
|
+
*
|
|
4
|
+
* This adapter composes the rollout assign + gate + emit seams into the host
|
|
5
|
+
* provider-invocation path. It runs BEFORE provider invocation and decides, for
|
|
6
|
+
* the current session, which live path is active:
|
|
7
|
+
*
|
|
8
|
+
* - on a hard causal/tool/anchor/exact failure → select mode C (pre-VC prompt
|
|
9
|
+
* path) and FREEZE promotion (promotionBlocked=true) for the remainder of the
|
|
10
|
+
* cooldown/spool/restart/clock period satisfying TRIAD_RESILIENCE;
|
|
11
|
+
* - otherwise → the active gate decides whether the VC path is exposed to this
|
|
12
|
+
* session's bucket.
|
|
13
|
+
*
|
|
14
|
+
* PREVENT-PI-003: the rollout NEVER emits a `role:"system"` message. The VC
|
|
15
|
+
* prompt context is composed into the host `before_agent_start` systemPrompt
|
|
16
|
+
* prepend seam only. PREVENT-PI-004: zero network calls (local in-process state
|
|
17
|
+
* + injected clock only). PREVENT-011: no `any`. Non-fatal: any rollout noise
|
|
18
|
+
* degrades to mode C (pre-VC continuity), never breaking the agent loop.
|
|
19
|
+
*
|
|
20
|
+
* LIVENESS HONESTY (mirrors VC0C-Q01/Q06): the rollout decision state here is
|
|
21
|
+
* PER-PROCESS / IN-MEMORY and EPHEMERAL — there is NO persistent rollout runtime
|
|
22
|
+
* and NO live producer wiring. The gate decision is recomputed from injected
|
|
23
|
+
* evidence each epoch. The assigned/blocked events are emitted for observability
|
|
24
|
+
* only.
|
|
25
|
+
*/
|
|
26
|
+
import { assignSession, bucketInGate, gatePctForIndex } from "../../src/vector-cortex/rollout/assign.js";
|
|
27
|
+
import { decideGate, selectsPreVcPath, } from "../../src/vector-cortex/rollout/gate.js";
|
|
28
|
+
import { createRolloutReporter } from "../../src/vector-cortex/rollout/emit.js";
|
|
29
|
+
import { VC5C_ENABLED } from "../../src/config/vector-cortex.js";
|
|
30
|
+
const NO_PREPEND = "";
|
|
31
|
+
/**
|
|
32
|
+
* Decide the live path for a session epoch. Pure over injected context; no
|
|
33
|
+
* I/O, no network. Flag OFF (or absent evidence/clock) degrades to mode C with
|
|
34
|
+
* the VC path inactive (pre-VC predecessor parity).
|
|
35
|
+
*/
|
|
36
|
+
export function decideLivePath(sessionId, ctx) {
|
|
37
|
+
const reporter = createRolloutReporter(ctx.emit);
|
|
38
|
+
const assignment = assignSession(sessionId);
|
|
39
|
+
if (!VC5C_ENABLED()) {
|
|
40
|
+
// Pre-VC predecessor: no rollout, no VC path. Never emit role:system.
|
|
41
|
+
return {
|
|
42
|
+
vcActive: false,
|
|
43
|
+
forcedPreVc: false,
|
|
44
|
+
mode: "C",
|
|
45
|
+
bucket: assignment.bucket,
|
|
46
|
+
gateIndex: 0,
|
|
47
|
+
promotionBlocked: false,
|
|
48
|
+
systemPromptPrepend: NO_PREPEND,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
reporter.assigned({
|
|
52
|
+
sessionId,
|
|
53
|
+
bucket: assignment.bucket,
|
|
54
|
+
gateIndex: assignment.gateIndex,
|
|
55
|
+
gatePct: gatePctForIndex(assignment.gateIndex),
|
|
56
|
+
});
|
|
57
|
+
const hardFaults = ctx.hardFaults ?? [];
|
|
58
|
+
const hardFault = hardFaults.length > 0 ? hardFaults[0] : undefined;
|
|
59
|
+
const forcedPreVc = selectsPreVcPath(hardFault);
|
|
60
|
+
if (forcedPreVc && hardFault) {
|
|
61
|
+
reporter.promotionBlocked({
|
|
62
|
+
gateIndex: ctx.currentGate ?? assignment.gateIndex,
|
|
63
|
+
kind: hardFault.kind,
|
|
64
|
+
detail: hardFault.detail,
|
|
65
|
+
});
|
|
66
|
+
// Hard failure → select C (pre-VC path) and freeze promotion.
|
|
67
|
+
return {
|
|
68
|
+
vcActive: false,
|
|
69
|
+
forcedPreVc: true,
|
|
70
|
+
mode: "C",
|
|
71
|
+
bucket: assignment.bucket,
|
|
72
|
+
gateIndex: ctx.currentGate ?? assignment.gateIndex,
|
|
73
|
+
promotionBlocked: true,
|
|
74
|
+
systemPromptPrepend: NO_PREPEND,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const clock = ctx.clock;
|
|
78
|
+
const evidence = ctx.evidence;
|
|
79
|
+
if (clock === undefined || evidence === undefined) {
|
|
80
|
+
// No live evidence/clock → pre-VC parity (no promotion, no VC exposure).
|
|
81
|
+
return {
|
|
82
|
+
vcActive: false,
|
|
83
|
+
forcedPreVc: false,
|
|
84
|
+
mode: "C",
|
|
85
|
+
bucket: assignment.bucket,
|
|
86
|
+
gateIndex: assignment.gateIndex,
|
|
87
|
+
promotionBlocked: false,
|
|
88
|
+
systemPromptPrepend: NO_PREPEND,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const outcome = decideGate(ctx.currentGate ?? assignment.gateIndex, evidence, clock);
|
|
92
|
+
const vcActive = bucketInGate(assignment.bucket, outcome.gatePct);
|
|
93
|
+
// PREVENT-PI-003: VC prompt context is composed into the host prepend seam,
|
|
94
|
+
// never as a role:system message. Empty prepend here (the actual prompt text
|
|
95
|
+
// is owned by the renderer seam); this seam only signals eligibility.
|
|
96
|
+
return {
|
|
97
|
+
vcActive,
|
|
98
|
+
forcedPreVc: false,
|
|
99
|
+
mode: vcActive ? "A" : "C",
|
|
100
|
+
bucket: assignment.bucket,
|
|
101
|
+
gateIndex: outcome.gateIndex,
|
|
102
|
+
promotionBlocked: outcome.promotionBlocked,
|
|
103
|
+
systemPromptPrepend: NO_PREPEND,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -172,6 +172,30 @@ export const VC4C_ENABLED = () => sprintFlag("MEGACOMPACT_VC4C");
|
|
|
172
172
|
* mirroring VC4A/VC4B/VC4C.
|
|
173
173
|
*/
|
|
174
174
|
export const VC5A_ENABLED = () => sprintFlag("MEGACOMPACT_VC5A");
|
|
175
|
+
/**
|
|
176
|
+
* VC5B — validated prompt renderer + provider profiles. Default ON.
|
|
177
|
+
* `MEGACOMPACT_VC5B=0` disables and is byte-identical to the predecessor
|
|
178
|
+
* (VC5A): no render manifest is produced, no canonical request is hashed, the
|
|
179
|
+
* `vector_cortex_render_validated` / `vector_cortex_provider_bypassed` events are
|
|
180
|
+
* never emitted, and the prompt continues to be built by the predecessor VC5A
|
|
181
|
+
* DAG/plan path (its goldens are unchanged). The render/validate functions are
|
|
182
|
+
* PURE — flag OFF gates the reporter + dashboard seam, never the arithmetic.
|
|
183
|
+
* This flag MUST also be a dashboard SETTINGS toggle (visible in config UI, never
|
|
184
|
+
* in EXCLUDED_SETTINGS), mirroring VC4A/VC4B/VC4C/VC5A.
|
|
185
|
+
*/
|
|
186
|
+
export const VC5B_ENABLED = () => sprintFlag("MEGACOMPACT_VC5B");
|
|
187
|
+
/**
|
|
188
|
+
* VC5C — live graduated rollout. Default ON. `MEGACOMPACT_VC5C=0` disables and
|
|
189
|
+
* is byte-identical to the predecessor (VC5B): no session is assigned a stable
|
|
190
|
+
* 10k bucket, no gate-advance decision runs, the `vector_cortex_rollout_assigned`
|
|
191
|
+
* / `vector_cortex_rollout_promotion_blocked` events are never emitted, and the
|
|
192
|
+
* prompt continues to be built by the predecessor VC5B renderer path (its goldens
|
|
193
|
+
* are unchanged). The assign/gate/emit functions are PURE — flag OFF gates the
|
|
194
|
+
* reporter + dashboard seam, never the arithmetic. This flag MUST also be a
|
|
195
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS),
|
|
196
|
+
* mirroring VC4A/VC4B/VC4C/VC5A/VC5B.
|
|
197
|
+
*/
|
|
198
|
+
export const VC5C_ENABLED = () => sprintFlag("MEGACOMPACT_VC5C");
|
|
175
199
|
// ---------------------------------------------------------------------------
|
|
176
200
|
// Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
|
|
177
201
|
// Rolled numbers for one 60s window; VC0C consumes these at its breaker seam.
|
package/dist/src/config.js
CHANGED
|
@@ -114,4 +114,4 @@ export const NEW_UI = () => ragEnabled("MEGACOMPACT_NEW_UI");
|
|
|
114
114
|
// default ON, `=0`/`_DISABLED` off. Re-exported from src/config/vector-cortex.ts
|
|
115
115
|
// so root consumers share one source of truth.
|
|
116
116
|
// ---------------------------------------------------------------------------
|
|
117
|
-
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
117
|
+
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
@@ -39,9 +39,15 @@ function sessionColor(sessionId) {
|
|
|
39
39
|
* change. PRIMARY KEY (pid, session_id) means concurrent pi processes each get
|
|
40
40
|
* their own row. Non-fatal on conflict (INSERT ... ON CONFLICT DO UPDATE).
|
|
41
41
|
*/
|
|
42
|
-
export function recordSessionHeartbeat(pid, sessionId, repoRoot, stateDir, ctxWindow, indexDir = getIndexDir()
|
|
42
|
+
export function recordSessionHeartbeat(pid, sessionId, repoRoot, stateDir, ctxWindow, indexDir = getIndexDir(),
|
|
43
|
+
// Optional clock override for deterministic tests only. Production callers
|
|
44
|
+
// omit it → Date.now(), byte-identical behavior. The S39 prune test pins
|
|
45
|
+
// heartbeats to a known-old timestamp so pruneStaleSessions' Date.now()
|
|
46
|
+
// cutoff unambiguously exceeds them (no same-millisecond last_seen ==
|
|
47
|
+
// cutoff race that made pruned !== 2).
|
|
48
|
+
nowMs = Date.now()) {
|
|
43
49
|
const db = openIndexStore(indexDir);
|
|
44
|
-
const now =
|
|
50
|
+
const now = nowMs;
|
|
45
51
|
db.prepare(`INSERT INTO session_heartbeats (pid, session_id, repo_root, state_dir, ctx_window, last_seen)
|
|
46
52
|
VALUES (@pid, @session_id, @repo_root, @state_dir, @ctx_window, @last_seen)
|
|
47
53
|
ON CONFLICT(pid, session_id) DO UPDATE SET
|
|
@@ -71,9 +77,15 @@ export function recordSessionHeartbeat(pid, sessionId, repoRoot, stateDir, ctxWi
|
|
|
71
77
|
* (for SSE real-time push via /api/events). The eventsLogPath is optional —
|
|
72
78
|
* callers without an events.log (e.g. tests) can omit it.
|
|
73
79
|
*/
|
|
74
|
-
export function appendTokenSample(sessionId, repoRoot, tokens, percent, ctxWindow, eventsLogPath, indexDir = getIndexDir()
|
|
80
|
+
export function appendTokenSample(sessionId, repoRoot, tokens, percent, ctxWindow, eventsLogPath, indexDir = getIndexDir(),
|
|
81
|
+
// Optional clock override for deterministic tests only. Production callers
|
|
82
|
+
// omit it → falls back to Date.now(), byte-identical behavior. The S39
|
|
83
|
+
// timeseries test injects distinct timestamps so the per-ts totals map is
|
|
84
|
+
// not collapsed by same-millisecond sample coincidence (the pre-existing
|
|
85
|
+
// flake where 3 samples in one ms made totals.length == 1).
|
|
86
|
+
nowMs = Date.now()) {
|
|
75
87
|
const db = openIndexStore(indexDir);
|
|
76
|
-
const now =
|
|
88
|
+
const now = nowMs;
|
|
77
89
|
db.prepare(`INSERT INTO token_samples (session_id, repo_root, tokens, percent, ctx_window, ts)
|
|
78
90
|
VALUES (@session_id, @repo_root, @tokens, @percent, @ctx_window, @ts)`).run({
|
|
79
91
|
session_id: sessionId,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/provider/registry.ts — fixture-backed base provider profile
|
|
3
|
+
* registry (VC5B, task 2).
|
|
4
|
+
*
|
|
5
|
+
* The registry resolves a `(provider, model)` pair to a `ProviderProfileBundle`
|
|
6
|
+
* (CONTRACTS §ProviderProfileV1 + role/tool/cache rules). Unknown provider/model
|
|
7
|
+
* returns `PRO_PROFILE_UNKNOWN` and the renderer CLEANLY bypasses vector-cortex
|
|
8
|
+
* rendering (NOT an error — the host uses the predecessor prompt path).
|
|
9
|
+
*
|
|
10
|
+
* Profiles are fixture-backed: each base profile is declared here as a constant
|
|
11
|
+
* and is also pinned as a conformance fixture under `conformance/vector-cortex/v2/
|
|
12
|
+
* provider/` (registered by `scripts/gen-fixtures/provider.mjs`). The registry is
|
|
13
|
+
* the REAL resolver the acceptance suite drives; the fixtures are the committed
|
|
14
|
+
* canonical corpus that proves each profile's cache-identity behavior.
|
|
15
|
+
*
|
|
16
|
+
* Pi-agnostic, dependency-free, zero network (PREVENT-PI-004 / PREVENT-011).
|
|
17
|
+
*/
|
|
18
|
+
import { PRO_PROFILE_UNKNOWN, } from "./types.js";
|
|
19
|
+
/** A registry key is `provider` + `model`. Lookup is exact-match. */
|
|
20
|
+
function key(provider, model) {
|
|
21
|
+
return `${provider}//${model}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The base role rule every VC5B profile shares: the renderer MUST use the host
|
|
25
|
+
* `before_agent_start` prepend seam and MUST NOT inject `role:"system"`
|
|
26
|
+
* (PREVENT-PI-003, critical).
|
|
27
|
+
*/
|
|
28
|
+
const BASE_ROLE = {
|
|
29
|
+
useHostPrependSeam: true,
|
|
30
|
+
forbidSystemRoleInjection: true,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The base tool rule every VC5B profile shares: exact tool bytes preserved
|
|
34
|
+
* (PREVENT-PI-002) and the renderer never reorders away from the validator order.
|
|
35
|
+
*/
|
|
36
|
+
const BASE_TOOL = {
|
|
37
|
+
preserveExactToolBytes: true,
|
|
38
|
+
forbidToolReorder: true,
|
|
39
|
+
};
|
|
40
|
+
/** Build a base cache rule (entire-canonical-request hashing by default). */
|
|
41
|
+
function baseCache(stableFields) {
|
|
42
|
+
return {
|
|
43
|
+
hashMode: "entire-canonical-request",
|
|
44
|
+
stableFields,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Build a contract-profile shape pinned as a conformance fixture too. */
|
|
48
|
+
function profile(id, version, excludedJsonPointers) {
|
|
49
|
+
return {
|
|
50
|
+
schema: "provider-profile-v1",
|
|
51
|
+
id,
|
|
52
|
+
version,
|
|
53
|
+
hashMode: "entire-canonical-request",
|
|
54
|
+
excludedJsonPointers,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The fixture-backed base profiles. Each entry is the REAL bundle the renderer
|
|
59
|
+
* resolves; the parallel conformance fixtures prove the cache-identity behavior.
|
|
60
|
+
*/
|
|
61
|
+
const BASE_PROFILES = [
|
|
62
|
+
{
|
|
63
|
+
profile: profile("anthropic-claude-opus", "v1", []),
|
|
64
|
+
role: BASE_ROLE,
|
|
65
|
+
tool: BASE_TOOL,
|
|
66
|
+
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
profile: profile("anthropic-claude-sonnet", "v1", []),
|
|
70
|
+
role: BASE_ROLE,
|
|
71
|
+
tool: BASE_TOOL,
|
|
72
|
+
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
profile: profile("openai-gpt", "v1", []),
|
|
76
|
+
role: BASE_ROLE,
|
|
77
|
+
tool: BASE_TOOL,
|
|
78
|
+
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
// A profile that proves a fixture-excluded pointer: a provider whose
|
|
82
|
+
// request-id header cannot affect cache identity. Excluded + versioned.
|
|
83
|
+
profile: profile("google-gemini", "v1", [
|
|
84
|
+
{
|
|
85
|
+
pointer: "/requestId",
|
|
86
|
+
fixtureId: "PRO-EXCLUDE-010",
|
|
87
|
+
proofDigest: "sha256:excluded-request-id-proof",
|
|
88
|
+
},
|
|
89
|
+
]),
|
|
90
|
+
role: BASE_ROLE,
|
|
91
|
+
tool: BASE_TOOL,
|
|
92
|
+
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
const REGISTRY = new Map(BASE_PROFILES.map((b) => [key(b.profile.id, b.profile.version), b]));
|
|
96
|
+
/**
|
|
97
|
+
* Resolve a `(provider, model)` pair to a `ProviderProfileBundle`. Unknown
|
|
98
|
+
* provider / model / version → a CLEAN bypass (`PRO_PROFILE_UNKNOWN`), never an
|
|
99
|
+
* error. The renderer consults this and, on `ok:false`, selects triad C (the
|
|
100
|
+
* predecessor prompt path).
|
|
101
|
+
*/
|
|
102
|
+
export function resolveProviderProfile(provider, model) {
|
|
103
|
+
const bundle = REGISTRY.get(key(provider, model));
|
|
104
|
+
if (bundle === undefined) {
|
|
105
|
+
return { ok: false, code: PRO_PROFILE_UNKNOWN };
|
|
106
|
+
}
|
|
107
|
+
return { ok: true, bundle };
|
|
108
|
+
}
|
|
109
|
+
/** The fixture-backed base profiles (exposed for tests / dashboard introspection). */
|
|
110
|
+
export const BASE_PROVIDER_PROFILES = BASE_PROFILES;
|
|
111
|
+
/** The set of known `(provider, model)` keys, for conformance registration. */
|
|
112
|
+
export const KNOWN_PROVIDER_KEYS = Array.from(REGISTRY.keys());
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/provider/types.ts — provider profile contract (VC5B, task 1).
|
|
3
|
+
*
|
|
4
|
+
* A `ProviderProfileV1` describes how a given provider/model caches and what the
|
|
5
|
+
* renderer may or may not fold into the outbound prompt without breaking the
|
|
6
|
+
* provider's KV-cache identity (CONTRACTS §ProviderProfileV1 + crystals).
|
|
7
|
+
*
|
|
8
|
+
* The renderer hashes the ENTIRE canonical outbound request by default
|
|
9
|
+
* (`hashMode: "entire-canonical-request"`). A profile may EXCLUDE a field only
|
|
10
|
+
* when a fixture proves that field cannot affect provider cache identity; every
|
|
11
|
+
* exclusion is versioned and listed in the manifest. Unknown provider / profile /
|
|
12
|
+
* version → the renderer bypasses vector-cortex rendering (a clean bypass, NOT an
|
|
13
|
+
* error) and the host falls back to the predecessor prompt path.
|
|
14
|
+
*
|
|
15
|
+
* Pure types + registered conformance IDs: no storage, no console, no network
|
|
16
|
+
* (PREVENT-PI-004 / PREVENT-011).
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The sentinel returned for an unknown provider/model. The renderer sees this as
|
|
20
|
+
* a CLEAN bypass decision, not an error, and emits `vector_cortex_provider_bypassed`.
|
|
21
|
+
*/
|
|
22
|
+
export const PRO_PROFILE_UNKNOWN = "PRO_PROFILE_UNKNOWN";
|
|
23
|
+
/**
|
|
24
|
+
* Registered PRO conformance ID range (PRO-001..015). The acceptance aggregator
|
|
25
|
+
* reads these rows from the v2 manifest and asserts each returns its manifest
|
|
26
|
+
* `ok`/`code` / pinned `requestDigest`.
|
|
27
|
+
*/
|
|
28
|
+
export const PRO_IDS = Array.from({ length: 15 }, (_v, i) => `PRO-${String(i + 1).padStart(3, "0")}`);
|
|
29
|
+
/** Named VC5B provider conformance assertions (the sprint's headline rows). */
|
|
30
|
+
export const PRO_NAMED_IDS = ["PRO-UNKNOWN-003"];
|