pi-mega-compact 0.20.2 → 0.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/config/vector-cortex.js +13 -0
  2. package/dist/config.js +1 -1
  3. package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +1 -0
  4. package/dist/extensions/dashboard-server/routes-vector-cortex-plans.js +49 -0
  5. package/dist/extensions/dashboard-server/routes-vector-cortex.js +1 -0
  6. package/dist/extensions/dashboard-server/routes.js +1 -1
  7. package/dist/extensions/dashboard-server/server.js +29 -22
  8. package/dist/src/config/vector-cortex.js +13 -0
  9. package/dist/src/config.js +1 -1
  10. package/dist/src/vector-cortex/planner/manifest.js +66 -0
  11. package/dist/src/vector-cortex/planner/portfolio.js +0 -0
  12. package/dist/src/vector-cortex/planner/types.js +41 -0
  13. package/dist/src/vector-cortex/prompt-dag/_acceptance-dag.js +347 -0
  14. package/dist/src/vector-cortex/prompt-dag/_acceptance-fixture.js +59 -0
  15. package/dist/src/vector-cortex/prompt-dag/_acceptance-helpers.js +17 -0
  16. package/dist/src/vector-cortex/prompt-dag/_acceptance-planner.js +153 -0
  17. package/dist/src/vector-cortex/prompt-dag/_acceptance-shuffle.js +24 -0
  18. package/dist/src/vector-cortex/prompt-dag/builder.js +171 -0
  19. package/dist/src/vector-cortex/prompt-dag/types.js +33 -0
  20. package/dist/src/vector-cortex/prompt-dag/validator.js +0 -0
  21. package/dist/vector-cortex/planner/manifest.js +66 -0
  22. package/dist/vector-cortex/planner/portfolio.js +0 -0
  23. package/dist/vector-cortex/planner/types.js +41 -0
  24. package/dist/vector-cortex/prompt-dag/_acceptance-dag.js +347 -0
  25. package/dist/vector-cortex/prompt-dag/_acceptance-fixture.js +59 -0
  26. package/dist/vector-cortex/prompt-dag/_acceptance-helpers.js +17 -0
  27. package/dist/vector-cortex/prompt-dag/_acceptance-planner.js +153 -0
  28. package/dist/vector-cortex/prompt-dag/_acceptance-shuffle.js +24 -0
  29. package/dist/vector-cortex/prompt-dag/builder.js +171 -0
  30. package/dist/vector-cortex/prompt-dag/types.js +33 -0
  31. package/dist/vector-cortex/prompt-dag/validator.js +0 -0
  32. package/extensions/dashboard-client/dist/assets/{AreaChart-XF3jPpvn.js → AreaChart-Cam9-nhT.js} +2 -2
  33. package/extensions/dashboard-client/dist/assets/{AreaChart-XF3jPpvn.js.map → AreaChart-Cam9-nhT.js.map} +1 -1
  34. package/extensions/dashboard-client/dist/assets/{BarChart-DnYYn0GF.js → BarChart-DzIY8aM1.js} +2 -2
  35. package/extensions/dashboard-client/dist/assets/{BarChart-DnYYn0GF.js.map → BarChart-DzIY8aM1.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{CacheTab-D3bVskCL.js → CacheTab-CKIiYsG_.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{CacheTab-D3bVskCL.js.map → CacheTab-CKIiYsG_.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/{EventsTab-CX_8myfc.js → EventsTab-xaaBJLiK.js} +2 -2
  39. package/extensions/dashboard-client/dist/assets/{EventsTab-CX_8myfc.js.map → EventsTab-xaaBJLiK.js.map} +1 -1
  40. package/extensions/dashboard-client/dist/assets/{HealthTab-CnVzBQvN.js → HealthTab-BGtUKOqG.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{HealthTab-CnVzBQvN.js.map → HealthTab-BGtUKOqG.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Cao--dtV.js → MaintenanceTab-ABgQnTZ9.js} +2 -2
  43. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Cao--dtV.js.map → MaintenanceTab-ABgQnTZ9.js.map} +1 -1
  44. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DZdI-9ig.js → MemoryMapTab-ChR2GAN-.js} +2 -2
  45. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DZdI-9ig.js.map → MemoryMapTab-ChR2GAN-.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{MetricsTab-SlpSmNU4.js → MetricsTab-DdCLAgcR.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{MetricsTab-SlpSmNU4.js.map → MetricsTab-DdCLAgcR.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/{OverviewTab-C_-_4au9.js → OverviewTab-DtemzJt6.js} +2 -2
  49. package/extensions/dashboard-client/dist/assets/{OverviewTab-C_-_4au9.js.map → OverviewTab-DtemzJt6.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{ReposTab-CyWedWZC.js → ReposTab-B9mvD9Ep.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{ReposTab-CyWedWZC.js.map → ReposTab-B9mvD9Ep.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{SessionsTab-wqPBMIJZ.js → SessionsTab-BcO38XLS.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{SessionsTab-wqPBMIJZ.js.map → SessionsTab-BcO38XLS.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{SetupTab-MojXmuUf.js → SetupTab-D_TBNP09.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{SetupTab-MojXmuUf.js.map → SetupTab-D_TBNP09.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-BxcplEOJ.js → TimeSavedCard-TjHpbUOo.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-BxcplEOJ.js.map → TimeSavedCard-TjHpbUOo.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{TurnsTab-D8_qWbjY.js → TurnsTab-DprxndCF.js} +2 -2
  59. package/extensions/dashboard-client/dist/assets/{TurnsTab-D8_qWbjY.js.map → TurnsTab-DprxndCF.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/VectorCortexTab-Bym21yVQ.js +2 -0
  61. package/extensions/dashboard-client/dist/assets/VectorCortexTab-Bym21yVQ.js.map +1 -0
  62. package/extensions/dashboard-client/dist/assets/{WikiTab-Cfd-QZYz.js → WikiTab-OKgSo15G.js} +2 -2
  63. package/extensions/dashboard-client/dist/assets/{WikiTab-Cfd-QZYz.js.map → WikiTab-OKgSo15G.js.map} +1 -1
  64. package/extensions/dashboard-client/dist/assets/{button-tX5ht0bb.js → button-D_Qz4q7L.js} +2 -2
  65. package/extensions/dashboard-client/dist/assets/{button-tX5ht0bb.js.map → button-D_Qz4q7L.js.map} +1 -1
  66. package/extensions/dashboard-client/dist/assets/{card-BT3Z5dDg.js → card-CsI6Jm3p.js} +2 -2
  67. package/extensions/dashboard-client/dist/assets/{card-BT3Z5dDg.js.map → card-CsI6Jm3p.js.map} +1 -1
  68. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-B6p2WnkY.js → generateCategoricalChart-CvHKUdhX.js} +2 -2
  69. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-B6p2WnkY.js.map → generateCategoricalChart-CvHKUdhX.js.map} +1 -1
  70. package/extensions/dashboard-client/dist/assets/{index-CFLekP12.js → index-0Ye_un22.js} +3 -3
  71. package/extensions/dashboard-client/dist/assets/{index-CFLekP12.js.map → index-0Ye_un22.js.map} +1 -1
  72. package/extensions/dashboard-client/dist/assets/{switch-B52oAMSw.js → switch-VQEoJl8Q.js} +2 -2
  73. package/extensions/dashboard-client/dist/assets/{switch-B52oAMSw.js.map → switch-VQEoJl8Q.js.map} +1 -1
  74. package/extensions/dashboard-client/dist/assets/{toggle-VxxVc5Tp.js → toggle-CAPm4HJo.js} +2 -2
  75. package/extensions/dashboard-client/dist/assets/{toggle-VxxVc5Tp.js.map → toggle-CAPm4HJo.js.map} +1 -1
  76. package/extensions/dashboard-client/dist/assets/{useSSE-DAVdZnG7.js → useSSE-pxsNTVkh.js} +2 -2
  77. package/extensions/dashboard-client/dist/assets/{useSSE-DAVdZnG7.js.map → useSSE-pxsNTVkh.js.map} +1 -1
  78. package/extensions/dashboard-client/dist/index.html +1 -1
  79. package/extensions/dashboard-client/src/api/vector-cortex.ts +9 -0
  80. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +35 -0
  81. package/extensions/dashboard-client/src/types/vector-cortex.ts +20 -0
  82. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +38 -0
  83. package/extensions/dashboard-server/routes-rag-settings-helpers.ts +6 -0
  84. package/extensions/dashboard-server/routes-vector-cortex-plans.ts +58 -0
  85. package/extensions/dashboard-server/routes-vector-cortex.ts +1 -0
  86. package/extensions/dashboard-server/routes.ts +1 -0
  87. package/extensions/dashboard-server/server.ts +31 -22
  88. package/package.json +1 -1
  89. package/src/config/vector-cortex.ts +14 -0
  90. package/src/config.ts +1 -0
  91. package/src/vector-cortex/planner/manifest.ts +83 -0
  92. package/src/vector-cortex/planner/portfolio.ts +0 -0
  93. package/src/vector-cortex/planner/types.ts +190 -0
  94. package/src/vector-cortex/prompt-dag/_acceptance-dag.ts +392 -0
  95. package/src/vector-cortex/prompt-dag/_acceptance-fixture.ts +132 -0
  96. package/src/vector-cortex/prompt-dag/_acceptance-helpers.ts +39 -0
  97. package/src/vector-cortex/prompt-dag/_acceptance-planner.ts +188 -0
  98. package/src/vector-cortex/prompt-dag/_acceptance-shuffle.ts +26 -0
  99. package/src/vector-cortex/prompt-dag/builder.ts +189 -0
  100. package/src/vector-cortex/prompt-dag/types.ts +151 -0
  101. package/src/vector-cortex/prompt-dag/validator.ts +0 -0
  102. package/extensions/dashboard-client/dist/assets/VectorCortexTab-B3yisAyB.js +0 -2
  103. package/extensions/dashboard-client/dist/assets/VectorCortexTab-B3yisAyB.js.map +0 -1
@@ -159,6 +159,19 @@ export const VC4B_ENABLED = () => sprintFlag("MEGACOMPACT_VC4B");
159
159
  * never in EXCLUDED_SETTINGS), mirroring VC4A/VC4B.
160
160
  */
161
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");
162
175
  // ---------------------------------------------------------------------------
163
176
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
164
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, VC4C_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";
@@ -149,6 +149,7 @@ export const SETTINGS = [
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
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),
152
153
  ],
153
154
  },
154
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
+ }
@@ -21,3 +21,4 @@ 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
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, handleVectorCortexReconstruct, } 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, handleVectorCortexReconstruct, 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
@@ -167,14 +167,16 @@ export async function launchDashboardServer(stateDir) {
167
167
  serveClientAsset,
168
168
  detectCrossRepoDrift,
169
169
  });
170
- // Bind host resolution: explicit MEGACOMPACT_DASHBOARD_HOST override wins;
171
- // otherwise auto-bind to the Tailscale interface (tailnet access); fall back
172
- // to loopback when Tailscale is absent. 0.0.0.0 means "all interfaces" and
173
- // opts into permissive CORS below.
174
- const host = process.env.MEGACOMPACT_DASHBOARD_HOST ??
175
- detectTailscaleIP() ??
176
- "127.0.0.1";
170
+ // Bind host resolution. Default: ALL interfaces (0.0.0.0) so the dashboard
171
+ // is reachable on loopback (localhost — the launcher's health check + the
172
+ // local browser), the tailnet (Tailscale), and any LAN interface. The
173
+ // network-denial gate was removed (the user opted into open access);
174
+ // MEGACOMPACT_DASHBOARD_HOST overrides for anyone who wants to restrict to
175
+ // a single interface. The tailnet IP is still detected so we can surface it
176
+ // as the remote access address. 0.0.0.0 opts into permissive CORS below.
177
+ const host = process.env.MEGACOMPACT_DASHBOARD_HOST ?? "0.0.0.0";
177
178
  const allInterfaces = host === "0.0.0.0";
179
+ const tailscaleIP = allInterfaces ? detectTailscaleIP() : null;
178
180
  // guardrails-allow PREVENT-PI-004: optional, user-triggered /dashboard server (tailnet-local via Tailscale mesh or loopback); no remote outbound calls.
179
181
  const server = createServer((req, res) => {
180
182
  // CORS for local access — restricted to loopback/same-origin tailnet
@@ -273,6 +275,8 @@ export async function launchDashboardServer(stateDir) {
273
275
  return;
274
276
  if (handleVectorCortexReconstruct(req, res, ctx))
275
277
  return;
278
+ if (handleVectorCortexPlans(req, res, ctx))
279
+ return;
276
280
  handleStatic(req, res, ctx);
277
281
  });
278
282
  // Bind base + range are env-configurable so tests can use a private,
@@ -295,25 +299,28 @@ export async function launchDashboardServer(stateDir) {
295
299
  }
296
300
  });
297
301
  server.listen(port, host, () => {
298
- // When bound to the loopback, keep the legacy localhost URL so the
299
- // user's browser (which resolves localhost ::1 or 127.0.0.1) works.
300
- // When bound to a tailnet/tailscale IP, surface that address instead.
302
+ // Surface localhost for local reach (the launcher health-checks
303
+ // localhost + the local browser uses it), and when bound to all
304
+ // interfaces with a tailnet present — also surface the tailnet
305
+ // address for remote devices on the mesh.
306
+ const localUrl = `http://localhost:${port}`; // guardrails-allow PREVENT-PI-004: dashboard URL (loopback/all-interfaces, user-opted open access)
307
+ const tailnetUrl = allInterfaces && tailscaleIP ? `http://${tailscaleIP}:${port}` : null; // guardrails-allow PREVENT-PI-004: dashboard URL (tailnet, user-opted open access)
301
308
  const url = host === "127.0.0.1"
302
- ? `http://localhost:${port}`
303
- : `http://${host}:${port}`; // guardrails-allow PREVENT-PI-004: dashboard URL (tailnet-local via Tailscale mesh or loopback)
304
- log("server running", { url, host });
309
+ ? localUrl
310
+ : tailnetUrl ?? `http://${host}:${port}`;
311
+ log("server running", { url, host, tailnetUrl });
305
312
  // eslint-disable-next-line no-console
306
- console.log(`[mega-compact] dashboard server running: ${url}`);
307
- // v0.8.2: also bind the IPv6 loopback (::1) when bound to the IPv4
308
- // loopback. On many systems `localhost` resolves to ::1 first (see
309
- // /etc/hosts), so an IPv4-only bind makes the browser hit ::1:port and
310
- // get connection refused. PREVENT-PI-004 (loopback-only) means BOTH
311
- // 127.0.0.1 and ::1. When bound to a tailscale/0.0.0.0 host, we do NOT
312
- // bind ::1 the tailnet address is what the user reaches. Non-fatal:
313
+ console.log(`[mega-compact] dashboard server running: ${url}` +
314
+ (tailnetUrl ? ` (also ${localUrl})` : ""));
315
+ // v0.8.2: also bind the IPv6 loopback (::1) when localhost must work.
316
+ // On many systems `localhost` resolves to ::1 first (see /etc/hosts),
317
+ // so an IPv4-only bind makes the browser hit ::1:port and get refused.
318
+ // Bind ::1 for the explicit loopback bind AND the all-interfaces bind
319
+ // (a browser resolving localhost ::1 must still connect). Non-fatal:
313
320
  // IPv4-only hosts or a ::1 already in use just skip the mirror.
314
321
  let v6;
315
322
  const v4Handler = server.listeners("request")[0];
316
- if (host === "127.0.0.1" && v4Handler) {
323
+ if ((host === "127.0.0.1" || allInterfaces) && v4Handler) {
317
324
  v6 = createServer((r, s) => v4Handler.call(server, r, s));
318
325
  v6.on("error", (e) => log("ipv6 loopback bind skipped", {
319
326
  port,
@@ -159,6 +159,19 @@ export const VC4B_ENABLED = () => sprintFlag("MEGACOMPACT_VC4B");
159
159
  * never in EXCLUDED_SETTINGS), mirroring VC4A/VC4B.
160
160
  */
161
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");
162
175
  // ---------------------------------------------------------------------------
163
176
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
164
177
  // Rolled numbers for one 60s window; VC0C consumes these at its breaker seam.
@@ -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, 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
+ }
@@ -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"];