pi-mega-compact 0.20.1 → 0.20.3
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 +26 -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-plans.js +49 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-reconstruct.js +33 -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/src/config/vector-cortex.js +26 -0
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/planner/manifest.js +66 -0
- package/dist/src/vector-cortex/planner/portfolio.js +0 -0
- package/dist/src/vector-cortex/planner/types.js +41 -0
- package/dist/src/vector-cortex/prompt-dag/_acceptance-dag.js +347 -0
- package/dist/src/vector-cortex/prompt-dag/_acceptance-fixture.js +59 -0
- package/dist/src/vector-cortex/prompt-dag/_acceptance-helpers.js +17 -0
- package/dist/src/vector-cortex/prompt-dag/_acceptance-planner.js +153 -0
- package/dist/src/vector-cortex/prompt-dag/_acceptance-shuffle.js +24 -0
- package/dist/src/vector-cortex/prompt-dag/builder.js +171 -0
- package/dist/src/vector-cortex/prompt-dag/types.js +33 -0
- package/dist/src/vector-cortex/prompt-dag/validator.js +0 -0
- package/dist/src/vector-cortex/reconstruct/_acceptance-helpers.js +365 -0
- package/dist/src/vector-cortex/reconstruct/assemble.js +137 -0
- package/dist/src/vector-cortex/reconstruct/closure.js +268 -0
- package/dist/src/vector-cortex/reconstruct/types.js +46 -0
- package/dist/src/vector-cortex/reconstruct/validate.js +152 -0
- package/dist/vector-cortex/planner/manifest.js +66 -0
- package/dist/vector-cortex/planner/portfolio.js +0 -0
- package/dist/vector-cortex/planner/types.js +41 -0
- package/dist/vector-cortex/prompt-dag/_acceptance-dag.js +347 -0
- package/dist/vector-cortex/prompt-dag/_acceptance-fixture.js +59 -0
- package/dist/vector-cortex/prompt-dag/_acceptance-helpers.js +17 -0
- package/dist/vector-cortex/prompt-dag/_acceptance-planner.js +153 -0
- package/dist/vector-cortex/prompt-dag/_acceptance-shuffle.js +24 -0
- package/dist/vector-cortex/prompt-dag/builder.js +171 -0
- package/dist/vector-cortex/prompt-dag/types.js +33 -0
- package/dist/vector-cortex/prompt-dag/validator.js +0 -0
- package/dist/vector-cortex/reconstruct/_acceptance-helpers.js +365 -0
- package/dist/vector-cortex/reconstruct/assemble.js +137 -0
- package/dist/vector-cortex/reconstruct/closure.js +268 -0
- package/dist/vector-cortex/reconstruct/types.js +46 -0
- package/dist/vector-cortex/reconstruct/validate.js +152 -0
- package/extensions/dashboard-client/dist/assets/{AreaChart-n4z5w9Ox.js → AreaChart-Cam9-nhT.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-n4z5w9Ox.js.map → AreaChart-Cam9-nhT.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-BLGjWWBr.js → BarChart-DzIY8aM1.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-BLGjWWBr.js.map → BarChart-DzIY8aM1.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-CAnrKKVK.js → CacheTab-CKIiYsG_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-CAnrKKVK.js.map → CacheTab-CKIiYsG_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-D-GL7Ngq.js → EventsTab-xaaBJLiK.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-D-GL7Ngq.js.map → EventsTab-xaaBJLiK.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-C4x5qQ8s.js → HealthTab-BGtUKOqG.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-C4x5qQ8s.js.map → HealthTab-BGtUKOqG.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BSPs0eq5.js → MaintenanceTab-ABgQnTZ9.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BSPs0eq5.js.map → MaintenanceTab-ABgQnTZ9.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-BWEUtTSu.js → MemoryMapTab-ChR2GAN-.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-BWEUtTSu.js.map → MemoryMapTab-ChR2GAN-.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Dhm1c3Cx.js → MetricsTab-DdCLAgcR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Dhm1c3Cx.js.map → MetricsTab-DdCLAgcR.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-Cm6cySiQ.js → OverviewTab-DtemzJt6.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-Cm6cySiQ.js.map → OverviewTab-DtemzJt6.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-DxLN1N4K.js → ReposTab-B9mvD9Ep.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-DxLN1N4K.js.map → ReposTab-B9mvD9Ep.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-CZuI4ISW.js → SessionsTab-BcO38XLS.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-CZuI4ISW.js.map → SessionsTab-BcO38XLS.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-C_0VOomm.js → SetupTab-D_TBNP09.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SetupTab-C_0VOomm.js.map → SetupTab-D_TBNP09.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-BhbaRLmi.js → TimeSavedCard-TjHpbUOo.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-BhbaRLmi.js.map → TimeSavedCard-TjHpbUOo.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-CXJmbjje.js → TurnsTab-DprxndCF.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-CXJmbjje.js.map → TurnsTab-DprxndCF.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-Bym21yVQ.js +2 -0
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-Bym21yVQ.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{WikiTab-C5uvMCzp.js → WikiTab-OKgSo15G.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-C5uvMCzp.js.map → WikiTab-OKgSo15G.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-Cl_fxJcg.js → button-D_Qz4q7L.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-Cl_fxJcg.js.map → button-D_Qz4q7L.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-BH8Le5YM.js → card-CsI6Jm3p.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-BH8Le5YM.js.map → card-CsI6Jm3p.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-sZ6ZNtBi.js → generateCategoricalChart-CvHKUdhX.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-sZ6ZNtBi.js.map → generateCategoricalChart-CvHKUdhX.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-CX9zv8cJ.js → index-0Ye_un22.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{index-CX9zv8cJ.js.map → index-0Ye_un22.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{switch-CXJhcjhM.js → switch-VQEoJl8Q.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-CXJhcjhM.js.map → switch-VQEoJl8Q.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-CoLtIc6y.js → toggle-CAPm4HJo.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-CoLtIc6y.js.map → toggle-CAPm4HJo.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-fSXho606.js → useSSE-pxsNTVkh.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-fSXho606.js.map → useSSE-pxsNTVkh.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/VectorCortexTab.tsx +72 -0
- package/extensions/dashboard-client/src/types/vector-cortex.ts +36 -0
- package/extensions/dashboard-server/api-contracts/vector-cortex.ts +66 -0
- package/extensions/dashboard-server/routes-rag-settings-helpers.ts +12 -0
- package/extensions/dashboard-server/routes-vector-cortex-plans.ts +58 -0
- package/extensions/dashboard-server/routes-vector-cortex-reconstruct.ts +41 -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/package.json +1 -1
- package/src/config/vector-cortex.ts +28 -0
- package/src/config.ts +2 -0
- package/src/vector-cortex/planner/manifest.ts +83 -0
- package/src/vector-cortex/planner/portfolio.ts +0 -0
- package/src/vector-cortex/planner/types.ts +190 -0
- package/src/vector-cortex/prompt-dag/_acceptance-dag.ts +392 -0
- package/src/vector-cortex/prompt-dag/_acceptance-fixture.ts +132 -0
- package/src/vector-cortex/prompt-dag/_acceptance-helpers.ts +39 -0
- package/src/vector-cortex/prompt-dag/_acceptance-planner.ts +188 -0
- package/src/vector-cortex/prompt-dag/_acceptance-shuffle.ts +26 -0
- package/src/vector-cortex/prompt-dag/builder.ts +189 -0
- package/src/vector-cortex/prompt-dag/types.ts +151 -0
- package/src/vector-cortex/prompt-dag/validator.ts +0 -0
- package/src/vector-cortex/reconstruct/_acceptance-helpers.ts +455 -0
- package/src/vector-cortex/reconstruct/assemble.ts +170 -0
- package/src/vector-cortex/reconstruct/closure.ts +299 -0
- package/src/vector-cortex/reconstruct/types.ts +330 -0
- package/src/vector-cortex/reconstruct/validate.ts +184 -0
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-BGe9hu3r.js +0 -2
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-BGe9hu3r.js.map +0 -1
|
@@ -146,6 +146,32 @@ export const VC4A_ENABLED = () => sprintFlag("MEGACOMPACT_VC4A");
|
|
|
146
146
|
* gates the reporter/admission seam, never the arithmetic.
|
|
147
147
|
*/
|
|
148
148
|
export const VC4B_ENABLED = () => sprintFlag("MEGACOMPACT_VC4B");
|
|
149
|
+
/**
|
|
150
|
+
* VC4C — reconstruction fidelity (closure + assemble + validate). Default ON.
|
|
151
|
+
* `MEGACOMPACT_VC4C=0` disables and is byte-identical to the predecessor
|
|
152
|
+
* (VC4B): no conservative closure is computed, the reconstruction validator's
|
|
153
|
+
* `vector_cortex_reconstruction_validated` / `vector_cortex_closure_rejected`
|
|
154
|
+
* events are never emitted, and the assembled reconstruction is never produced
|
|
155
|
+
* (the prompt continues to be built by the legacy VC4B exact/residual path and
|
|
156
|
+
* the VC4A shard goldens are unchanged). The closure/assemble/validate
|
|
157
|
+
* functions are PURE — flag OFF gates the reporter seam, never the arithmetic.
|
|
158
|
+
* This flag MUST also be a dashboard SETTINGS toggle (visible in config UI,
|
|
159
|
+
* never in EXCLUDED_SETTINGS), mirroring VC4A/VC4B.
|
|
160
|
+
*/
|
|
161
|
+
export const VC4C_ENABLED = () => sprintFlag("MEGACOMPACT_VC4C");
|
|
162
|
+
/**
|
|
163
|
+
* VC5A — PromptDagV1 + budgeted portfolio planner. Default ON.
|
|
164
|
+
* `MEGACOMPACT_VC5A=0` disables and is byte-identical to the predecessor
|
|
165
|
+
* (VC4C): no prompt DAG is built or validated, no budgeted plan is selected,
|
|
166
|
+
* the `vector_cortex_plan_selected` / `vector_cortex_plan_mandatory_overflow`
|
|
167
|
+
* events are never emitted, and the prompt continues to be built by the
|
|
168
|
+
* predecessor VC4C closure/reconstruction path (its goldens are unchanged).
|
|
169
|
+
* The builder/validator/portfolio functions are PURE — flag OFF gates the
|
|
170
|
+
* reporter + dashboard seam, never the arithmetic. This flag MUST also be a
|
|
171
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS),
|
|
172
|
+
* mirroring VC4A/VC4B/VC4C.
|
|
173
|
+
*/
|
|
174
|
+
export const VC5A_ENABLED = () => sprintFlag("MEGACOMPACT_VC5A");
|
|
149
175
|
// ---------------------------------------------------------------------------
|
|
150
176
|
// Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
|
|
151
177
|
// 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, 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, 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";
|
|
@@ -148,6 +148,8 @@ export const SETTINGS = [
|
|
|
148
148
|
boolDirect("MEGACOMPACT_VC3C", "VC3C Topology Query + Router Invalidation", "TopologyQueryV1/RouterKeyV2 structured keys (length-delimited, unsigned-byte order, no prefix ambiguity), exact (session,generation) invalidation, stale-generation rejection (TOP_GENERATION_STALE), and the M6 router-generation-v2 copy/validate/switch migration. OFF = mode C, no structured router key / generation invalidation, byte-identical predecessor.", true),
|
|
149
149
|
boolDirect("MEGACOMPACT_VC4A", "VC4A Dual-Tier Shards", "SemanticShardV1/ExactShardV1/ShardManifestV1: partition a session ONLY at complete EventV2 boundaries; exact shards preserve every tool call/result pair, anchor and invalid UTF-8 event as original bytes (pairs never split across exact shards); manifest enforces disjoint sorted ranges + complete protected-span coverage. OFF = mode C, exact anchors/current transcript only, byte-identical predecessor.", true),
|
|
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
|
+
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
|
+
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),
|
|
151
153
|
],
|
|
152
154
|
},
|
|
153
155
|
{
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-vector-cortex-plans.ts — VC5A PromptDagV1 + budgeted
|
|
3
|
+
* planner dashboard route.
|
|
4
|
+
*
|
|
5
|
+
* Reader-only GET /api/vector-cortex/plans returning ONLY plan manifests — the
|
|
6
|
+
* registered PromptDagV1 (DAG-001..030) and budgeted-planner (PLN-001..020)
|
|
7
|
+
* identifier counts, plus a reader-only plans array. NEVER exposes session
|
|
8
|
+
* payloads, prompt text, byte spans, or source bytes (reader-only,
|
|
9
|
+
* SECURITY_PRIVACY). Flag-gated on MEGACOMPACT_VC5A: `enabled:false` when off
|
|
10
|
+
* (byte-identical to the pre-VC5A predecessor).
|
|
11
|
+
*
|
|
12
|
+
* The VC5A planner is PURE IN-MEMORY logic in this sprint (it has no durable plan
|
|
13
|
+
* store yet), so the per-run plan outputs are not persisted. The route reports
|
|
14
|
+
* the registered manifest layout truthfully: `enabled` reflects the flag, the
|
|
15
|
+
* dag/planner counts come from the registered conformance ID range, and `plans`
|
|
16
|
+
* is empty until a future sprint persists selected plans. Non-fatal: an internal
|
|
17
|
+
* error degrades to `enabled:false` with empty arrays.
|
|
18
|
+
*
|
|
19
|
+
* Guardrails: PREVENT-PI-004 (local filesystem / in-process state only),
|
|
20
|
+
* PREVENT-011 (no `any`), reader-only aggregate (counts + manifests only).
|
|
21
|
+
*/
|
|
22
|
+
import { VC5A_ENABLED } from "../../src/config.js";
|
|
23
|
+
import { DAG_IDS } from "../../src/vector-cortex/prompt-dag/types.js";
|
|
24
|
+
import { PLN_IDS } from "../../src/vector-cortex/planner/types.js";
|
|
25
|
+
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
26
|
+
/**
|
|
27
|
+
* Reader-only GET /api/vector-cortex/plans (VC5A).
|
|
28
|
+
*/
|
|
29
|
+
export function handleVectorCortexPlans(req, res, _ctx) {
|
|
30
|
+
const url = req.url ?? "";
|
|
31
|
+
const path = url.split("?")[0] ?? url;
|
|
32
|
+
if (path !== "/api/vector-cortex/plans")
|
|
33
|
+
return false;
|
|
34
|
+
if (req.method !== "GET") {
|
|
35
|
+
// Reader-only path: cannot be "off" without a GET; it is genuinely read-only.
|
|
36
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const enabled = VC5A_ENABLED();
|
|
40
|
+
const body = {
|
|
41
|
+
enabled,
|
|
42
|
+
dagCount: enabled ? DAG_IDS.length : 0,
|
|
43
|
+
plannerCount: enabled ? PLN_IDS.length : 0,
|
|
44
|
+
plans: [],
|
|
45
|
+
updatedAt: new Date().toISOString(),
|
|
46
|
+
};
|
|
47
|
+
sendJson(res, 200, body);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard handler: GET /api/vector-cortex/reconstruct (VC4C).
|
|
3
|
+
*
|
|
4
|
+
* Reader-only reconstruction-fidelity aggregate. Mirrors the VC4B residual
|
|
5
|
+
* handler: path guard + 405 on non-GET, gated on the sprint flag, returns a
|
|
6
|
+
* zero-valued view when disabled (byte-identical predecessor contract). Never
|
|
7
|
+
* returns reconstructed spans, exact bytes, or prompt text.
|
|
8
|
+
*/
|
|
9
|
+
import { VC4C_ENABLED } from "../../src/config.js";
|
|
10
|
+
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
11
|
+
export function handleVectorCortexReconstruct(req, res, _ctx) {
|
|
12
|
+
const url = req.url ?? "";
|
|
13
|
+
const path = url.split("?")[0] ?? url;
|
|
14
|
+
if (path !== "/api/vector-cortex/reconstruct")
|
|
15
|
+
return false;
|
|
16
|
+
if (req.method !== "GET") {
|
|
17
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
const enabled = VC4C_ENABLED();
|
|
21
|
+
const body = {
|
|
22
|
+
enabled,
|
|
23
|
+
closureAttempts: 0,
|
|
24
|
+
closureRejections: 0,
|
|
25
|
+
validatedCount: 0,
|
|
26
|
+
invalidatedCount: 0,
|
|
27
|
+
spanTotal: 0,
|
|
28
|
+
byteTotal: 0,
|
|
29
|
+
updatedAt: new Date().toISOString(),
|
|
30
|
+
};
|
|
31
|
+
sendJson(res, 200, body);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
@@ -20,3 +20,5 @@ export { handleVectorCortexTopology } from "./routes-vector-cortex-topology.js";
|
|
|
20
20
|
export { handleVectorCortexQuery } from "./routes-vector-cortex-query.js";
|
|
21
21
|
export { handleVectorCortexShards } from "./routes-vector-cortex-shards.js";
|
|
22
22
|
export { handleVectorCortexResidual } from "./routes-vector-cortex-residual.js";
|
|
23
|
+
export { handleVectorCortexReconstruct } from "./routes-vector-cortex-reconstruct.js";
|
|
24
|
+
export { handleVectorCortexPlans } from "./routes-vector-cortex-plans.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, } from "./routes-vector-cortex.js";
|
|
26
|
+
export { handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, } 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, 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, 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
|
|
@@ -271,6 +271,10 @@ export async function launchDashboardServer(stateDir) {
|
|
|
271
271
|
return;
|
|
272
272
|
if (handleVectorCortexResidual(req, res, ctx))
|
|
273
273
|
return;
|
|
274
|
+
if (handleVectorCortexReconstruct(req, res, ctx))
|
|
275
|
+
return;
|
|
276
|
+
if (handleVectorCortexPlans(req, res, ctx))
|
|
277
|
+
return;
|
|
274
278
|
handleStatic(req, res, ctx);
|
|
275
279
|
});
|
|
276
280
|
// Bind base + range are env-configurable so tests can use a private,
|
|
@@ -146,6 +146,32 @@ export const VC4A_ENABLED = () => sprintFlag("MEGACOMPACT_VC4A");
|
|
|
146
146
|
* gates the reporter/admission seam, never the arithmetic.
|
|
147
147
|
*/
|
|
148
148
|
export const VC4B_ENABLED = () => sprintFlag("MEGACOMPACT_VC4B");
|
|
149
|
+
/**
|
|
150
|
+
* VC4C — reconstruction fidelity (closure + assemble + validate). Default ON.
|
|
151
|
+
* `MEGACOMPACT_VC4C=0` disables and is byte-identical to the predecessor
|
|
152
|
+
* (VC4B): no conservative closure is computed, the reconstruction validator's
|
|
153
|
+
* `vector_cortex_reconstruction_validated` / `vector_cortex_closure_rejected`
|
|
154
|
+
* events are never emitted, and the assembled reconstruction is never produced
|
|
155
|
+
* (the prompt continues to be built by the legacy VC4B exact/residual path and
|
|
156
|
+
* the VC4A shard goldens are unchanged). The closure/assemble/validate
|
|
157
|
+
* functions are PURE — flag OFF gates the reporter seam, never the arithmetic.
|
|
158
|
+
* This flag MUST also be a dashboard SETTINGS toggle (visible in config UI,
|
|
159
|
+
* never in EXCLUDED_SETTINGS), mirroring VC4A/VC4B.
|
|
160
|
+
*/
|
|
161
|
+
export const VC4C_ENABLED = () => sprintFlag("MEGACOMPACT_VC4C");
|
|
162
|
+
/**
|
|
163
|
+
* VC5A — PromptDagV1 + budgeted portfolio planner. Default ON.
|
|
164
|
+
* `MEGACOMPACT_VC5A=0` disables and is byte-identical to the predecessor
|
|
165
|
+
* (VC4C): no prompt DAG is built or validated, no budgeted plan is selected,
|
|
166
|
+
* the `vector_cortex_plan_selected` / `vector_cortex_plan_mandatory_overflow`
|
|
167
|
+
* events are never emitted, and the prompt continues to be built by the
|
|
168
|
+
* predecessor VC4C closure/reconstruction path (its goldens are unchanged).
|
|
169
|
+
* The builder/validator/portfolio functions are PURE — flag OFF gates the
|
|
170
|
+
* reporter + dashboard seam, never the arithmetic. This flag MUST also be a
|
|
171
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS),
|
|
172
|
+
* mirroring VC4A/VC4B/VC4C.
|
|
173
|
+
*/
|
|
174
|
+
export const VC5A_ENABLED = () => sprintFlag("MEGACOMPACT_VC5A");
|
|
149
175
|
// ---------------------------------------------------------------------------
|
|
150
176
|
// Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
|
|
151
177
|
// 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, 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, 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";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/planner/manifest.ts — plan manifest identity + pre-provider
|
|
3
|
+
* revalidation (VC5A).
|
|
4
|
+
*
|
|
5
|
+
* Split from `portfolio.ts` (which owns SELECTION) so each file keeps one
|
|
6
|
+
* concern and stays under the 300-line soft limit: this module owns the plan's
|
|
7
|
+
* IDENTITY and the last gate before a provider call.
|
|
8
|
+
*
|
|
9
|
+
* The manifest digest deliberately covers PER-NODE TOKEN COUNTS, which the DAG
|
|
10
|
+
* digest does not: token counts are a planner input rather than DAG structure.
|
|
11
|
+
* That is exactly what makes the sprint's unique failure injection detectable —
|
|
12
|
+
* mutating a node's token count after planning but before validation changes the
|
|
13
|
+
* recomputed manifest digest, so `validatePlanManifest` returns
|
|
14
|
+
* `PLN_MANIFEST_DIGEST_MISMATCH` and the plan never reaches the provider.
|
|
15
|
+
*
|
|
16
|
+
* Pure/deterministic: no storage, no console, no network (PREVENT-PI-004).
|
|
17
|
+
*/
|
|
18
|
+
import { createHash } from "node:crypto";
|
|
19
|
+
/**
|
|
20
|
+
* Deterministic digest over a plan AND the token counts/utilities it was
|
|
21
|
+
* selected with. Hashing walks `selectedNodeIds` in its stored (sorted) order,
|
|
22
|
+
* so the digest is a pure function of the plan and the candidate facts.
|
|
23
|
+
*
|
|
24
|
+
* A node missing from `candidates` hashes as `-1`, so dropping a candidate is
|
|
25
|
+
* itself a detectable mutation rather than a silently-skipped field.
|
|
26
|
+
*/
|
|
27
|
+
export function planManifestDigest(plan, candidates) {
|
|
28
|
+
const h = createHash("sha256");
|
|
29
|
+
h.update(plan.schema);
|
|
30
|
+
h.update(" ");
|
|
31
|
+
h.update(plan.dagDigest);
|
|
32
|
+
h.update(" ");
|
|
33
|
+
h.update(String(plan.tokenBudget));
|
|
34
|
+
h.update(" ");
|
|
35
|
+
h.update(String(plan.tokenTotal));
|
|
36
|
+
h.update(" ");
|
|
37
|
+
h.update(String(plan.dependencyHighWater));
|
|
38
|
+
const byId = new Map(candidates.map((c) => [c.nodeId, c]));
|
|
39
|
+
for (const id of plan.selectedNodeIds) {
|
|
40
|
+
const c = byId.get(id);
|
|
41
|
+
h.update("");
|
|
42
|
+
h.update(id);
|
|
43
|
+
h.update(" ");
|
|
44
|
+
// Token count is part of the identity — a post-plan mutation breaks it.
|
|
45
|
+
h.update(String(c?.tokenEstimate ?? -1));
|
|
46
|
+
h.update(" ");
|
|
47
|
+
h.update(String(c?.utility ?? -1));
|
|
48
|
+
}
|
|
49
|
+
return h.digest("hex");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Re-validate a plan against the candidates AS THEY STAND NOW, immediately
|
|
53
|
+
* before a provider call. Returns `PLN_MANIFEST_DIGEST_MISMATCH` when the
|
|
54
|
+
* recomputed manifest digest disagrees with the digest pinned at planning time.
|
|
55
|
+
*
|
|
56
|
+
* This is the sprint's unique failure injection: a node token count mutated
|
|
57
|
+
* after planning but before validation is caught here, BEFORE the provider is
|
|
58
|
+
* invoked, rather than producing a prompt whose real cost differs from the
|
|
59
|
+
* admitted budget.
|
|
60
|
+
*/
|
|
61
|
+
export function validatePlanManifest(plan, candidates, pinnedDigest) {
|
|
62
|
+
if (planManifestDigest(plan, candidates) !== pinnedDigest) {
|
|
63
|
+
return { ok: false, code: "PLN_MANIFEST_DIGEST_MISMATCH" };
|
|
64
|
+
}
|
|
65
|
+
return { ok: true };
|
|
66
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/planner/types.ts — `PlanV1` + the budget admission contract
|
|
3
|
+
* (VC5A, task 1).
|
|
4
|
+
*
|
|
5
|
+
* VC5A EXCLUSIVELY OWNS FRAMING + BUDGET ADMISSION (CONTRACTS §plan and
|
|
6
|
+
* closure). VC4C hands over `ClosureResult.mandatoryTokenEstimate`, a
|
|
7
|
+
* CONTENT-ONLY count with no prompt framing, no role tags and no separators, and
|
|
8
|
+
* VC4C never truncates a mandatory node nor reasons about a budget. This module
|
|
9
|
+
* adds the framing cost on top of that content estimate and decides admission:
|
|
10
|
+
*
|
|
11
|
+
* framed(node) = tokenEstimate + framingPerNode
|
|
12
|
+
* mandatoryCost = mandatoryTokenEstimate + framingPerNode * |mandatory|
|
|
13
|
+
* + framingOverhead
|
|
14
|
+
*
|
|
15
|
+
* If `mandatoryCost > tokenBudget` the planner returns
|
|
16
|
+
* `MANDATORY_CLOSURE_OVER_BUDGET` and the adapter demotes to C. Crucially it
|
|
17
|
+
* does so WITHOUT DROPPING EVIDENCE: the mandatory set is returned intact on the
|
|
18
|
+
* failure so the caller can report exactly what did not fit (the sprint bar:
|
|
19
|
+
* "over-budget mandatory closure never drops evidence and always demotes").
|
|
20
|
+
*
|
|
21
|
+
* The framing constants are CONFIGURABLE, never invented magic numbers: a caller
|
|
22
|
+
* supplies the profile it is actually rendering with, and the defaults below are
|
|
23
|
+
* documented as a conservative baseline rather than a measured provider fact.
|
|
24
|
+
*
|
|
25
|
+
* Pure types + registered conformance IDs: no storage, no console, no network
|
|
26
|
+
* (PREVENT-PI-004 / PREVENT-011).
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Conservative default framing baseline. Documented as a BASELINE, not a
|
|
30
|
+
* measured provider constant: a real provider profile (VC5B) overrides it. Kept
|
|
31
|
+
* small and explicit so a default-driven plan is never silently over-optimistic.
|
|
32
|
+
*/
|
|
33
|
+
export const DEFAULT_FRAMING = { perNode: 4, overhead: 8 };
|
|
34
|
+
/**
|
|
35
|
+
* Registered PLN conformance ID range (PLN-001..020). The acceptance aggregator
|
|
36
|
+
* reads these rows from the v2 manifest and asserts each returns its manifest
|
|
37
|
+
* `ok`/`code`.
|
|
38
|
+
*/
|
|
39
|
+
export const PLN_IDS = Array.from({ length: 20 }, (_v, i) => `PLN-${String(i + 1).padStart(3, "0")}`);
|
|
40
|
+
/** Named VC5A planner conformance assertions (the sprint's headline rows). */
|
|
41
|
+
export const PLAN_NAMED_IDS = ["PLN-MANDATORY-002", "PLN-TIE-003"];
|