instar 1.3.549 → 1.3.550

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.
@@ -39,6 +39,23 @@ export interface SlotMapOptions {
39
39
  /** One ledger assignment → the policy's SlotState. */
40
40
  export declare function mapSlot(a: CredentialAssignment, opts: SlotMapOptions): SlotState;
41
41
  export declare function mapSlots(assignments: readonly CredentialAssignment[], opts: SlotMapOptions): SlotState[];
42
+ /** A session snapshot the busyness computation reads — only these three fields. */
43
+ export interface BusynessSession {
44
+ status: string;
45
+ framework?: string;
46
+ /** The pool account this session launched under (→ its current slot via the ledger). */
47
+ subscriptionAccountId?: string;
48
+ }
49
+ /**
50
+ * Per-slot busyness = count of RUNNING claude-code sessions on each slot (the drain
51
+ * "busiest slot" signal, §2.4 — the balancer drains toward the busiest slot so an
52
+ * expiring weekly window is spent where the work actually is). A session's slot is its
53
+ * account's CURRENT slot (`slotOf(subscriptionAccountId)`); an UNTAGGED session (no pool
54
+ * account — the default interactive session) counts toward the default slot. Non-running
55
+ * or non-claude-code sessions don't count (only claude-code sessions read the credential
56
+ * store the balancer steers). Pure; the live wiring passes `state.listSessions()`.
57
+ */
58
+ export declare function computeBusynessBySlot(sessions: readonly BusynessSession[], slotOf: (accountId: string) => string | null, defaultSlot: string): Record<string, number>;
42
59
  /** The raw balancer config block (subscriptionPool.credentialRepointing.balancer + siblings). */
43
60
  export interface RawRebalancerConfig {
44
61
  passIntervalMs?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"CredentialRebalancerSnapshot.d.ts","sourceRoot":"","sources":["../../src/core/CredentialRebalancerSnapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBAAyB,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AE,MAAM,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,mBAAmB,GAAG,wBAAwB,CAsB1F"}
@@ -76,6 +76,30 @@ export function mapSlot(a, opts) {
76
76
  export function mapSlots(assignments, opts) {
77
77
  return assignments.map((a) => mapSlot(a, opts));
78
78
  }
79
+ /**
80
+ * Per-slot busyness = count of RUNNING claude-code sessions on each slot (the drain
81
+ * "busiest slot" signal, §2.4 — the balancer drains toward the busiest slot so an
82
+ * expiring weekly window is spent where the work actually is). A session's slot is its
83
+ * account's CURRENT slot (`slotOf(subscriptionAccountId)`); an UNTAGGED session (no pool
84
+ * account — the default interactive session) counts toward the default slot. Non-running
85
+ * or non-claude-code sessions don't count (only claude-code sessions read the credential
86
+ * store the balancer steers). Pure; the live wiring passes `state.listSessions()`.
87
+ */
88
+ export function computeBusynessBySlot(sessions, slotOf, defaultSlot) {
89
+ const busy = {};
90
+ for (const s of sessions) {
91
+ if (s.status !== 'running')
92
+ continue;
93
+ // Undefined framework = a legacy record (pre-framework-tag) — treat as claude-code (the
94
+ // default); only an EXPLICIT non-claude framework is excluded.
95
+ if (s.framework !== undefined && s.framework !== 'claude-code')
96
+ continue;
97
+ const slot = s.subscriptionAccountId ? slotOf(s.subscriptionAccountId) : defaultSlot;
98
+ if (slot)
99
+ busy[slot] = (busy[slot] ?? 0) + 1;
100
+ }
101
+ return busy;
102
+ }
79
103
  function clamp(v, lo, hi, dflt) {
80
104
  const n = typeof v === 'number' && Number.isFinite(v) ? v : dflt;
81
105
  return Math.min(hi, Math.max(lo, n));
@@ -1 +1 @@
1
- {"version":3,"file":"CredentialRebalancerSnapshot.js","sourceRoot":"","sources":["../../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AE,KAAK,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;SAC1D;QACD,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;QAC7E,uBAAuB,EAAE,GAAG,CAAC,uBAAuB,IAAI,IAAI;QAC5D,2BAA2B,EAAE,KAAK,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9E,gBAAgB,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;KACxD,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.549",
3
+ "version": "1.3.550",
4
4
  "description": "Coherence infrastructure for self-evolving AI agents — on the Claude Code or Codex subscription you already have.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-06-14T00:20:22.976Z",
5
- "instarVersion": "1.3.549",
4
+ "generatedAt": "2026-06-14T00:25:10.461Z",
5
+ "instarVersion": "1.3.550",
6
6
  "entryCount": 201,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -0,0 +1,23 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ Makes the autonomous balancer's dry-run dogfooding produce meaningful drain decisions: the drain objective now targets the actually-busiest slot (real session-count signal) instead of an arbitrary one.
9
+
10
+ - **`computeBusynessBySlot`** (src/core/CredentialRebalancerSnapshot.ts) — a pure helper: per-slot busyness = count of RUNNING claude-code sessions on each slot. A session's slot is its account's current slot (`ledger.slotOf`); an untagged session counts toward the default slot; non-running and explicit-non-claude sessions don't count.
11
+ - **Wired into the balancer** — the server's `listSlots` provider now feeds this real busyness from the live session list, so the §2.4 drain objective deals an expiring weekly window to the slot where the work actually is. Read-only; dry-run on a dev agent (zero writes), dark on the fleet.
12
+
13
+ ## What to Tell Your User
14
+
15
+ A small sharpening of the (still off-by-default, dry-run) account-balancer so what you watch is actually meaningful: when it considers draining an account whose weekly allowance is about to expire, it now sends that work to whichever of your config slots is genuinely busiest right now, instead of picking one arbitrarily. Nothing moves — it's still dry-run, still observation only — but the decisions you'd watch at the rebalancer status endpoint now reflect real activity, which is exactly the signal that builds confidence before you decide whether to turn on real moves.
16
+
17
+ ## Summary of New Capabilities
18
+
19
+ No new runtime capability — a read-only refinement to the Increment-B balancer's dry-run decisions. New internal helper `computeBusynessBySlot` feeds real per-slot busyness (count of running claude-code sessions) into the balancer's drain-target selection. No route, no config flag, no credential write path; dry-run on dev, dark on fleet.
20
+
21
+ ## Evidence
22
+
23
+ - `tests/unit/credential-rebalancer-snapshot.test.ts` (+5 = 15) — counts running claude-code sessions per slot via the account→slot map; untagged session → default slot; non-running excluded; explicit-non-claude excluded but legacy (undefined framework) counted; a tagged session whose account has no current slot is dropped. tsc + full lint clean.
@@ -0,0 +1,38 @@
1
+ # Side-Effects Review — WS5.2 balancer busyness signal (drain-target refinement)
2
+
3
+ **Version / slug:** `ws52-busyness`
4
+ **Date:** 2026-06-13
5
+ **Author:** echo
6
+ **Second-pass reviewer:** not required (a pure read-only data-signal helper + thin wiring; no gate/sentinel/lifecycle/write surface; the balancer it feeds is already dry-run-gated + B3a-reviewed)
7
+
8
+ ## Summary of the change
9
+
10
+ Resolves the tracked busyness follow-up for the autonomous balancer (Increment B). Adds a pure `computeBusynessBySlot(sessions, slotOf, defaultSlot)` to `CredentialRebalancerSnapshot.ts` — per-slot busyness = count of RUNNING claude-code sessions on each slot (a session's slot is its account's current slot via `ledger.slotOf`; an untagged session counts toward the default slot; non-running / explicit-non-claude sessions don't count). Wires it into the server's `listSlots` provider so the balancer's drain objective targets the actually-busiest slot (real signal) instead of uniform-0. Read-only; affects only the §2.4 drain TARGET selection, and only in dry-run on a dev agent (zero credential writes).
11
+
12
+ ## Decision-point inventory
13
+
14
+ - `CredentialRebalancerPolicy` drain-target selection (objective 2) — now fed a real busyness signal instead of uniform 0. No new decision point; it sharpens an existing one (which busy slot a drain deals to). No authority change; the balancer remains dry-run-gated.
15
+
16
+ ---
17
+
18
+ ## 1. Over-block / ## 2. Under-block
19
+ No block/allow surface. The signal only orders drain TARGET candidates; a wrong count would at worst pick a sub-optimal busy slot to drain to (still a valid eligible slot), and only in dry-run.
20
+
21
+ ## 3. Level-of-abstraction fit
22
+ Correct: the busyness computation is a pure mapper in the snapshot module (alongside mapSlot/mapAccount), kept out of server.ts so a counting bug is unit-testable. The server wiring is a one-line provider change passing `state.listSessions()` + the ledger's `slotOf`.
23
+
24
+ ## 4. Signal vs authority compliance
25
+ - [x] No — a read-only data-signal helper; no block/allow surface, no authority. (Ref: docs/signal-vs-authority.md.)
26
+
27
+ ## 5. Interactions
28
+ - Feeds only the policy's drain `busyness` field (already consumed; previously always 0). No shadowing/race — pure, computed fresh each pass from the live session list.
29
+ - The untagged-session-→-default-slot attribution is a deliberate choice (the default interactive session runs on the default account); documented.
30
+
31
+ ## 6. External surfaces
32
+ - None directly. The balancer's `GET /credentials/rebalancer` status (and its dry-run audit) will now reflect drain decisions that target the busiest slot — observably better dogfooding signal, still zero writes (dry-run on dev; dark on fleet).
33
+
34
+ ## 7. Multi-machine posture (Cross-Machine Coherence)
35
+ - **Machine-local BY DESIGN.** Busyness is computed from THIS machine's live session list + THIS machine's ledger; per-machine. No cross-machine input.
36
+
37
+ ## 8. Rollback cost
38
+ Trivial. Revert → the balancer falls back to uniform busyness (drain picks the first eligible busy slot). No state, no migration, no credential touch.