instar 1.3.779 → 1.3.781

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 (54) hide show
  1. package/dashboard/index.html +161 -0
  2. package/dist/core/IntelligenceRouter.d.ts +13 -2
  3. package/dist/core/IntelligenceRouter.d.ts.map +1 -1
  4. package/dist/core/IntelligenceRouter.js +90 -2
  5. package/dist/core/IntelligenceRouter.js.map +1 -1
  6. package/dist/core/PostUpdateMigrator.d.ts +21 -0
  7. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  8. package/dist/core/PostUpdateMigrator.js +59 -0
  9. package/dist/core/PostUpdateMigrator.js.map +1 -1
  10. package/dist/core/routingPriceAuthority.d.ts +0 -0
  11. package/dist/core/routingPriceAuthority.d.ts.map +1 -0
  12. package/dist/core/routingPriceAuthority.js +0 -0
  13. package/dist/core/routingPriceAuthority.js.map +1 -0
  14. package/dist/core/routingSpendView.d.ts +172 -0
  15. package/dist/core/routingSpendView.d.ts.map +1 -0
  16. package/dist/core/routingSpendView.js +215 -0
  17. package/dist/core/routingSpendView.js.map +1 -0
  18. package/dist/core/types.d.ts +25 -0
  19. package/dist/core/types.d.ts.map +1 -1
  20. package/dist/core/types.js.map +1 -1
  21. package/dist/data/llmBenchCoverage.d.ts +20 -0
  22. package/dist/data/llmBenchCoverage.d.ts.map +1 -1
  23. package/dist/data/llmBenchCoverage.js +38 -0
  24. package/dist/data/llmBenchCoverage.js.map +1 -1
  25. package/dist/monitoring/FeatureMetricsLedger.d.ts +74 -2
  26. package/dist/monitoring/FeatureMetricsLedger.d.ts.map +1 -1
  27. package/dist/monitoring/FeatureMetricsLedger.js +233 -8
  28. package/dist/monitoring/FeatureMetricsLedger.js.map +1 -1
  29. package/dist/scaffold/templates.d.ts.map +1 -1
  30. package/dist/scaffold/templates.js +2 -1
  31. package/dist/scaffold/templates.js.map +1 -1
  32. package/dist/server/AgentServer.d.ts +1 -0
  33. package/dist/server/AgentServer.d.ts.map +1 -1
  34. package/dist/server/AgentServer.js +35 -2
  35. package/dist/server/AgentServer.js.map +1 -1
  36. package/dist/server/CapabilityIndex.d.ts.map +1 -1
  37. package/dist/server/CapabilityIndex.js +12 -0
  38. package/dist/server/CapabilityIndex.js.map +1 -1
  39. package/dist/server/routes.d.ts +3 -0
  40. package/dist/server/routes.d.ts.map +1 -1
  41. package/dist/server/routes.js +46 -0
  42. package/dist/server/routes.js.map +1 -1
  43. package/package.json +1 -1
  44. package/scripts/lint-nature-chains.mjs +210 -8
  45. package/scripts/routing-price-refresh.mjs +216 -0
  46. package/scripts/routing-prices.manifest.json +64 -0
  47. package/src/data/builtin-manifest.json +64 -64
  48. package/src/data/llmBenchCoverage.ts +41 -0
  49. package/src/scaffold/templates/jobs/instar/routing-price-refresh.md +30 -0
  50. package/src/scaffold/templates.ts +2 -1
  51. package/upgrades/1.3.780.md +28 -0
  52. package/upgrades/1.3.781.md +25 -0
  53. package/upgrades/side-effects/nature-axis-routing-fd42-rrule-lints.md +63 -0
  54. package/upgrades/side-effects/routing-spend-increment-a.md +84 -0
@@ -162,6 +162,23 @@ A durable map from each of my **doorways** (the ways I reach LLMs — Claude Cod
162
162
  - **When to use** (PROACTIVE — this is the trigger): user asks "what models can I reach?" / "is my model map current?" / "which doorways are live?" → read \`GET /doorways\`, don't guess. A \`503 registry-unavailable-no-instar-source\` just means this is a pure end-user install with no source registry.
163
163
  `;
164
164
  }
165
+ /**
166
+ * CLAUDE.md awareness block for the Routing Control Room spend VIEW (Increment A — the
167
+ * read-only spend/caps surface). The unique heading substring `Routing Spend view` is the
168
+ * content-sniff marker used by migrateClaudeMd (Migration Parity). Read-only; the money
169
+ * controls (caps adjust, go-live, gate) are Increment B and NOT surfaced as capabilities.
170
+ */
171
+ export function ROUTING_SPEND_CLAUDEMD_SECTION(port) {
172
+ return `\n### Routing Spend view — what am I spending on routing? (\`GET /routing-spend/summary\`, \`GET /routing-spend/caps\`)
173
+
174
+ A READ-ONLY window on internal-LLM spend and the paid-door caps (docs/specs/routing-control-room-spend-alerts.md, Increment A). It turns the immutable token record (\`feature_metrics\`) into dollars by joining a reviewed price manifest ON READ — so "what did we spend, and where do the caps sit?" is a READ, not a guess. It gates NOTHING and books NOTHING (the money ledger + O(1) gate + PIN cap controls are Increment B, not built yet).
175
+ - Spend rollup (per door/model + totals): \`curl -H "Authorization: Bearer $AUTH" "http://localhost:${port}/routing-spend/summary?grain=day"\` → per-row \`{ door, modelId, doorClass, tokensIn/Out/Cached, grossUsd, subsidyUsd, netUsd, committedUsd, priceBasis, priceStale, notLiveYet, unpricedTokens* }\` + \`totals\` + \`reportingBasis\`. Grains: \`hour|day|month|total\`.
176
+ - Caps + paid-door status: \`curl -H "Authorization: Bearer $AUTH" http://localhost:${port}/routing-spend/caps\` → each metered key \`{ keyRef, provider, door, lifetimeCapUsd, dailyCapUsd, frozen, committedLifetimeUsd, committedDayUsd, goLiveState }\`. **Honest state:** no paid door is live yet, so committed spend is \`$0\` and \`goLiveState:"not-live"\` everywhere; subscription/CLI doors show \`$0 (subscription — not per-token billed)\`.
177
+ - Dashboard: the **Spend** tab renders both surfaces in plain language — point the user there rather than pasting curl output.
178
+ - Dev-gated: the routes are LIVE on a development agent, DARK on the fleet (\`503\` when off; \`routingSpend.enabled\` overrides the gate). Money caps + go-live + alerts are later, dark increments.
179
+ - **When to use** (PROACTIVE — this is the trigger): user asks "what am I spending on routing / the internal LLM calls?" / "where do my paid-door caps sit?" / "is any paid door live?" → read \`GET /routing-spend/summary\` + \`/caps\`, or send them to the Spend tab; do NOT guess.
180
+ `;
181
+ }
165
182
  /**
166
183
  * CLAUDE.md note for the second wedge-signature family (2026-06-05 EXO
167
184
  * incident) + the API fresh-respawn lever. Appended to NEW installs as part of
@@ -428,6 +445,28 @@ export function migrateConfigNatureRoutingDark(config) {
428
445
  };
429
446
  return true;
430
447
  }
448
+ /**
449
+ * Routing Control Room spend VIEW (docs/specs/routing-control-room-spend-alerts.md,
450
+ * § Migration parity): SEED the top-level `routingSpend` block DARK on existing agents so
451
+ * the update path reaches deployed agents (not only new agents via init). Added ONLY when
452
+ * ABSENT — never clobbers an operator/agent that already configured it (existence-checked,
453
+ * idempotent).
454
+ *
455
+ * CRITICAL — `enabled` is DELIBERATELY OMITTED (the #1001 pattern): the route + the ledger
456
+ * construction resolve it via `resolveDevAgentGate(routingSpend.enabled, config)`, so a
457
+ * seeded `enabled:false` would force-dark even a development agent. Only the INERT retention
458
+ * knob is seeded; NO money-authority value ever lives in config (those are Increment B's
459
+ * PIN-only store).
460
+ */
461
+ export function migrateConfigRoutingSpendDark(config) {
462
+ if (Object.prototype.hasOwnProperty.call(config, 'routingSpend'))
463
+ return false; // already present
464
+ config.routingSpend = {
465
+ // `enabled` OMITTED so resolveDevAgentGate decides (live on a dev agent, dark fleet).
466
+ tokenRollupRetentionDays: 400,
467
+ };
468
+ return true;
469
+ }
431
470
  /**
432
471
  * "Self-Unblock Before Escalating" (docs/specs/self-unblock-before-escalating.md):
433
472
  * the two nested blockerLedger sub-features — selfUnblockChecklist + durableVaultSession
@@ -4625,6 +4664,15 @@ setTimeout(() => process.exit(0), 2000);
4625
4664
  patched = true;
4626
4665
  result.upgraded.push('CLAUDE.md: added Doorway/Model Knowledge Registry section');
4627
4666
  }
4667
+ // Routing Spend view (routing-control-room-spend-alerts, Increment A) — Agent
4668
+ // Awareness Standard + Migration Parity: existing agents learn the read-only spend/caps
4669
+ // surfaces + the Spend tab via this appended section. Same text as generateClaudeMd.
4670
+ // Content-sniff on the unique heading keeps it idempotent.
4671
+ if (!content.includes('Routing Spend view')) {
4672
+ content += ROUTING_SPEND_CLAUDEMD_SECTION(port);
4673
+ patched = true;
4674
+ result.upgraded.push('CLAUDE.md: added Routing Spend view section');
4675
+ }
4628
4676
  // The Agent Carries the Loop (agent-owned-followthrough C1+C2) — agent
4629
4677
  // awareness for the owner⟂blockedOn commitment model + the probe + that the
4630
4678
  // user is never status-pinged for an agent-owned commitment. Content-sniffed.
@@ -8768,6 +8816,17 @@ Two layers keep my machine-to-machine \"ropes\" (Tailscale / LAN / Cloudflare) h
8768
8816
  else {
8769
8817
  result.skipped.push('config.json: sessions.natureRouting already present or no sessions block (no seed)');
8770
8818
  }
8819
+ // Routing Control Room spend VIEW (Increment A): SEED the top-level routingSpend block
8820
+ // DARK (tokenRollupRetentionDays only; `enabled` OMITTED so the developmentAgent gate
8821
+ // resolves it live-on-dev / dark-fleet). Existence-checked — never clobbers an operator
8822
+ // who already configured it.
8823
+ if (migrateConfigRoutingSpendDark(config)) {
8824
+ patched = true;
8825
+ result.upgraded.push('config.json: seeded dark routingSpend (tokenRollupRetentionDays:400; enabled omitted for the developmentAgent gate)');
8826
+ }
8827
+ else {
8828
+ result.skipped.push('config.json: routingSpend already present (no seed)');
8829
+ }
8771
8830
  // "Self-Unblock Before Escalating" (CMT-1519): the two nested blockerLedger
8772
8831
  // dev-gated sub-features (selfUnblockChecklist + durableVaultSession) OMIT
8773
8832
  // `enabled`. Strip a default-shaped `false` so the developmentAgent gate resolves