instar 1.3.330 → 1.3.331

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 (48) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +133 -17
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/core/AnthropicSubscriptionRouter.d.ts +68 -0
  5. package/dist/core/AnthropicSubscriptionRouter.d.ts.map +1 -0
  6. package/dist/core/AnthropicSubscriptionRouter.js +82 -0
  7. package/dist/core/AnthropicSubscriptionRouter.js.map +1 -0
  8. package/dist/core/InteractivePoolIntelligenceProvider.d.ts +38 -0
  9. package/dist/core/InteractivePoolIntelligenceProvider.d.ts.map +1 -0
  10. package/dist/core/InteractivePoolIntelligenceProvider.js +61 -0
  11. package/dist/core/InteractivePoolIntelligenceProvider.js.map +1 -0
  12. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  13. package/dist/core/PostUpdateMigrator.js +17 -0
  14. package/dist/core/PostUpdateMigrator.js.map +1 -1
  15. package/dist/core/intelligenceProviderFactory.d.ts +21 -0
  16. package/dist/core/intelligenceProviderFactory.d.ts.map +1 -1
  17. package/dist/core/intelligenceProviderFactory.js +24 -1
  18. package/dist/core/intelligenceProviderFactory.js.map +1 -1
  19. package/dist/core/types.d.ts +38 -0
  20. package/dist/core/types.d.ts.map +1 -1
  21. package/dist/core/types.js.map +1 -1
  22. package/dist/providers/adapters/anthropic-interactive-pool/config.d.ts +17 -0
  23. package/dist/providers/adapters/anthropic-interactive-pool/config.d.ts.map +1 -1
  24. package/dist/providers/adapters/anthropic-interactive-pool/config.js +1 -0
  25. package/dist/providers/adapters/anthropic-interactive-pool/config.js.map +1 -1
  26. package/dist/providers/adapters/anthropic-interactive-pool/pool.d.ts +16 -2
  27. package/dist/providers/adapters/anthropic-interactive-pool/pool.d.ts.map +1 -1
  28. package/dist/providers/adapters/anthropic-interactive-pool/pool.js +95 -5
  29. package/dist/providers/adapters/anthropic-interactive-pool/pool.js.map +1 -1
  30. package/dist/providers/bootRegistration.d.ts +83 -0
  31. package/dist/providers/bootRegistration.d.ts.map +1 -0
  32. package/dist/providers/bootRegistration.js +158 -0
  33. package/dist/providers/bootRegistration.js.map +1 -0
  34. package/dist/providers/costAwareRouting.d.ts +16 -0
  35. package/dist/providers/costAwareRouting.d.ts.map +1 -1
  36. package/dist/providers/costAwareRouting.js +37 -21
  37. package/dist/providers/costAwareRouting.js.map +1 -1
  38. package/dist/scaffold/templates.d.ts.map +1 -1
  39. package/dist/scaffold/templates.js +5 -0
  40. package/dist/scaffold/templates.js.map +1 -1
  41. package/dist/server/routes.d.ts.map +1 -1
  42. package/dist/server/routes.js +26 -1
  43. package/dist/server/routes.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/data/builtin-manifest.json +63 -63
  46. package/src/scaffold/templates.ts +5 -0
  47. package/upgrades/1.3.331.md +77 -0
  48. package/upgrades/side-effects/provider-substrate-live-wiring.md +145 -0
@@ -0,0 +1,145 @@
1
+ # Side-Effects Review — Provider-Substrate Live Wiring (June-15 readiness PR 1)
2
+
3
+ **Version / slug:** `provider-substrate-live-wiring`
4
+ **Date:** `2026-06-05`
5
+ **Author:** `echo (Claude Opus)`
6
+ **Second-pass reviewer:** `5-agent verification panel (build Phase 3, LARGE)`
7
+
8
+ ## Summary of the change
9
+
10
+ Wires the already-built provider substrate into production: registers both
11
+ Anthropic adapters with the providers registry at server boot (gated,
12
+ idempotent, lazy), plumbs a real TTL-cached SDK-credit reader into the
13
+ CostAwareRoutingPolicy (replacing the `() => null` stub), and adds an
14
+ opt-in `intelligence.subscriptionPath` mode (`off`/`auto`/`force`) that
15
+ routes the internal-intelligence funnel between `claude -p` (SDK-credit
16
+ path) and the interactive REPL pool (subscription floor) per spec 04
17
+ Rule 1. Files: `src/providers/bootRegistration.ts` (new),
18
+ `src/core/InteractivePoolIntelligenceProvider.ts` (new),
19
+ `src/core/AnthropicSubscriptionRouter.ts` (new),
20
+ `src/providers/costAwareRouting.ts` (decision extracted to shared pure fn),
21
+ `src/providers/adapters/anthropic-interactive-pool/{config,pool}.ts`
22
+ (model knob), `src/core/intelligenceProviderFactory.ts` (option),
23
+ `src/core/types.ts` (config type), `src/commands/server.ts` (boot+shutdown
24
+ wiring), `src/server/routes.ts` (GET /providers/registry).
25
+
26
+ ## Decision-point inventory
27
+
28
+ - `registerAnthropicAdapters` gates (claudeForbidden, enabledFrameworks) — add — refuse Claude adapters on codex-only agents
29
+ - `decideSdkVsSubscription` (extracted) — modify (refactor, semantics identical, existing tests pass) — SDK-pot vs subscription threshold
30
+ - `AnthropicSubscriptionRouter.evaluate` mode branch — add — off/auto/force routing of internal LLM calls
31
+ - `buildIntelligenceProvider` claude-code case — modify — wraps with router ONLY when the new option is passed; otherwise byte-identical
32
+ - shutdown pool dispose — add — kills pool tmux sessions at server stop
33
+ - `GET /providers/registry` — add — read-only introspection
34
+
35
+ ## 1. Over-block
36
+
37
+ **What legitimate inputs does this change reject that it shouldn't?**
38
+
39
+ In `force` mode, a pool outage (tmux missing, spawn failure) makes internal
40
+ LLM calls fail even though `claude -p` would have worked — by design (force
41
+ mode's contract is zero `claude -p` traffic), and loudly. Fleet default is
42
+ `off`, so nobody is exposed without an explicit flip. The codex-only gate
43
+ refuses registration on codex-only agents — correct, mirrors the existing
44
+ ClaudeCliIntelligenceProvider guard. No other block/allow surface.
45
+
46
+ ## 2. Under-block
47
+
48
+ **What should be rejected but passes?**
49
+
50
+ `auto` mode falls back across paths on ANY primary error, including
51
+ prompt-shaped errors (e.g. timeout from an oversized prompt) where the
52
+ retry will likely fail again — one wasted call, bounded (exactly one
53
+ fallback attempt, then a loud throw). The pool's `--dangerously-skip-
54
+ permissions` spawn means a prompt-injected judgment call could in principle
55
+ invoke tools inside the pool session; mitigated by the empty scratch
56
+ workdir and unchanged from the adapter's prototyped+parity-tested shape;
57
+ hardening is tracked in the spec (CMT-1105).
58
+
59
+ ## 3. Level-of-abstraction fit
60
+
61
+ Registration lives in `src/providers/` (substrate layer), the two
62
+ IntelligenceProvider implementations in `src/core/` next to their peers,
63
+ and the mode wiring at the composition root (server.ts) — matching the
64
+ existing layering (IntelligenceRouter precedent). The threshold logic was
65
+ EXTRACTED to one shared pure function rather than duplicated across the
66
+ two routing layers.
67
+
68
+ ## 4. Signal vs authority compliance
69
+
70
+ The router treats config (`mode`) as authority and credit snapshots as
71
+ signal: unknown signal degrades conservatively (subscription floor), never
72
+ blocks the call path. onRoute/onDegrade are observability taps with no
73
+ authority. No LLM judgment gates any decision here — all routing is
74
+ deterministic from config + credit state.
75
+
76
+ ## 5. Interactions
77
+
78
+ - **Circuit breaker**: router sits INSIDE the breaker wrap — a rate-limit
79
+ on the surviving path still trips the account-global breaker. Unchanged
80
+ for mode off.
81
+ - **Per-component IntelligenceRouter**: claude-code builds inherit the same
82
+ subscriptionPath option, so codex-default agents with claude-routed
83
+ components stay consistent.
84
+ - **/metrics/features**: pool-served calls still attribute calls+latency;
85
+ token columns read 0 (pool reports no per-call usage; onUsage is
86
+ deliberately not invoked with fake zeros).
87
+ - **SessionReaper/tmux tooling**: pool sessions are named `instar-pool-*`;
88
+ they are adapter-managed (maxIdle 30m, maxMessages 50, dispose at
89
+ shutdown). Reaper does not manage them (they are not instar sessions in
90
+ the session store).
91
+ - **QuotaTracker**: unaffected — file-based scheduler shedding stays as-is.
92
+
93
+ ## 6. External surfaces
94
+
95
+ `GET /providers/registry` (Bearer-authed like its router peers) returns
96
+ adapter ids + capability flag names + a policy-installed boolean. No prompt
97
+ content, no credentials; integration test asserts no key-material shapes in
98
+ the payload. The usage-meter call (`/api/oauth/usage`) is the EXISTING
99
+ read-only observability exception under spec 04 Rule 2, now TTL-cached
100
+ (60s) so routing volume cannot hammer it.
101
+
102
+ ## 7. Rollback cost
103
+
104
+ Mode is config-gated default-off: rollback = remove the config key (or set
105
+ `off`) + restart — no data, no state, no migration. Registration itself is
106
+ inert without the mode (lazy pool, no spawns). Worst-case orphan: pool tmux
107
+ sessions if the server dies UNgracefully mid-soak; bounded by poolSize
108
+ (default 2) and visible via `tmux ls` (`instar-pool-*`).
109
+
110
+ ## Conclusion
111
+
112
+ Ship. Default-off + pinned-argv invariance test means zero fleet behavior
113
+ change at merge; the June-15 lever becomes a config flip backed by 44 new
114
+ tests across all three tiers.
115
+
116
+ ## Second-pass review (if required)
117
+
118
+ Build Phase 3 runs the 5-agent verification panel (LARGE build) before
119
+ commit; findings folded back into code/spec before the convergence tag.
120
+
121
+ ## Evidence pointers
122
+
123
+ - Unit: `tests/unit/providers/bootRegistration.test.ts`,
124
+ `tests/unit/anthropic-subscription-router.test.ts`,
125
+ `tests/unit/intelligence-provider-factory-subscription-path.test.ts`,
126
+ `tests/unit/providers/adapters/anthropic-interactive-pool/pool-model-flag.test.ts`
127
+ - Integration: `tests/integration/providers-registry-route.test.ts`
128
+ - E2E: `tests/e2e/provider-substrate-live-wiring.test.ts`
129
+ - Spec: `docs/specs/provider-substrate-live-wiring.md` (+ `.eli16.md`)
130
+ - Live exposure measurement driving the work: /metrics/features 24h on echo
131
+ (~1,014 real internal calls, ~26.7M tokens-in).
132
+
133
+ ## CI-green follow-up (same PR)
134
+
135
+ - New side effect: a FAILED boot registration/policy install now emits a
136
+ DegradationReporter event (`serverBoot.anthropicProviderRegistration`) in
137
+ addition to the yellow boot log line — so a dark June-15 routing install is
138
+ visible in the degradation feed, not just scrollback. No behavior change on
139
+ the success path.
140
+ - Silent-fallback ratchet lowered 459 → 458 (that catch is now reporter-wired);
141
+ two non-degradation catches carry in-brace `@silent-fallback-ok`
142
+ justifications (raced tmux kill-session; HTTP 500 surfaced to caller).
143
+ - `/providers/registry` tracked in the feature-delivery-completeness guard
144
+ (read-surface class, like `/session/clock`; no framework shadow — the lever
145
+ only applies to claude-code internal traffic).