instar 1.3.236 → 1.3.238

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 (62) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +35 -2
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/config/ConfigDefaults.d.ts.map +1 -1
  5. package/dist/config/ConfigDefaults.js +8 -0
  6. package/dist/config/ConfigDefaults.js.map +1 -1
  7. package/dist/core/ParallelActivityIndex.d.ts +62 -0
  8. package/dist/core/ParallelActivityIndex.d.ts.map +1 -0
  9. package/dist/core/ParallelActivityIndex.js +129 -0
  10. package/dist/core/ParallelActivityIndex.js.map +1 -0
  11. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  12. package/dist/core/PostUpdateMigrator.js +16 -0
  13. package/dist/core/PostUpdateMigrator.js.map +1 -1
  14. package/dist/core/types.d.ts +37 -0
  15. package/dist/core/types.d.ts.map +1 -1
  16. package/dist/core/types.js.map +1 -1
  17. package/dist/monitoring/GeminiLoopDriver.d.ts +112 -0
  18. package/dist/monitoring/GeminiLoopDriver.d.ts.map +1 -0
  19. package/dist/monitoring/GeminiLoopDriver.js +111 -0
  20. package/dist/monitoring/GeminiLoopDriver.js.map +1 -0
  21. package/dist/monitoring/GeminiLoopRunner.d.ts +93 -0
  22. package/dist/monitoring/GeminiLoopRunner.d.ts.map +1 -0
  23. package/dist/monitoring/GeminiLoopRunner.js +134 -0
  24. package/dist/monitoring/GeminiLoopRunner.js.map +1 -0
  25. package/dist/monitoring/ParallelWorkOverlap.d.ts +59 -0
  26. package/dist/monitoring/ParallelWorkOverlap.d.ts.map +1 -0
  27. package/dist/monitoring/ParallelWorkOverlap.js +86 -0
  28. package/dist/monitoring/ParallelWorkOverlap.js.map +1 -0
  29. package/dist/monitoring/ParallelWorkSentinel.d.ts +59 -0
  30. package/dist/monitoring/ParallelWorkSentinel.d.ts.map +1 -0
  31. package/dist/monitoring/ParallelWorkSentinel.js +79 -0
  32. package/dist/monitoring/ParallelWorkSentinel.js.map +1 -0
  33. package/dist/monitoring/geminiLoopProduction.d.ts +62 -0
  34. package/dist/monitoring/geminiLoopProduction.d.ts.map +1 -0
  35. package/dist/monitoring/geminiLoopProduction.js +124 -0
  36. package/dist/monitoring/geminiLoopProduction.js.map +1 -0
  37. package/dist/providers/adapters/gemini-cli/transport/geminiSpawn.d.ts +14 -0
  38. package/dist/providers/adapters/gemini-cli/transport/geminiSpawn.d.ts.map +1 -1
  39. package/dist/providers/adapters/gemini-cli/transport/geminiSpawn.js +16 -0
  40. package/dist/providers/adapters/gemini-cli/transport/geminiSpawn.js.map +1 -1
  41. package/dist/scaffold/templates.d.ts.map +1 -1
  42. package/dist/scaffold/templates.js +4 -0
  43. package/dist/scaffold/templates.js.map +1 -1
  44. package/dist/server/AgentServer.d.ts +9 -0
  45. package/dist/server/AgentServer.d.ts.map +1 -1
  46. package/dist/server/AgentServer.js +83 -0
  47. package/dist/server/AgentServer.js.map +1 -1
  48. package/dist/server/CapabilityIndex.d.ts.map +1 -1
  49. package/dist/server/CapabilityIndex.js +10 -0
  50. package/dist/server/CapabilityIndex.js.map +1 -1
  51. package/dist/server/routes.d.ts +5 -0
  52. package/dist/server/routes.d.ts.map +1 -1
  53. package/dist/server/routes.js +62 -0
  54. package/dist/server/routes.js.map +1 -1
  55. package/package.json +1 -1
  56. package/src/data/builtin-manifest.json +64 -64
  57. package/src/scaffold/templates.ts +4 -0
  58. package/upgrades/1.3.237.md +82 -0
  59. package/upgrades/1.3.238.md +68 -0
  60. package/upgrades/side-effects/gemini-loop-driver-wiring.md +59 -0
  61. package/upgrades/side-effects/gemini-multi-turn-loop-driver.md +56 -0
  62. package/upgrades/side-effects/parallel-activity-coherence.md +94 -0
@@ -0,0 +1,68 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ Wires the Gemini multi-turn loop-driver engine (`need-gem-002`, increment 1,
9
+ already merged) into a real, budget-gated, **dark** capability — so the Gemini
10
+ mentee can be handed a goal it works across turns instead of one reply.
11
+
12
+ - `geminiLoopProduction.ts` — the production dependencies: a subscription-auth
13
+ spawn (routes through the billing-env-stripping gemini transport, so no run can
14
+ introduce an API key), a `gemini --list-sessions` handle parser that picks the
15
+ freshest session by age, and a budget gate that reuses the existing QuotaTracker
16
+ spawn-admission signal (fails open if no tracker).
17
+ - `GeminiLoopRunner` — a multi-turn run can take minutes, so `POST` ADMITS a run
18
+ (enabled? under the concurrency cap? budget open?) and returns a `runId`
19
+ immediately; the loop runs in the background and the result lands in a bounded
20
+ in-memory registry.
21
+ - Routes `POST /gemini-loop/runs` + `GET /gemini-loop/runs[/:id]`.
22
+ - Config `autonomousSessions.geminiLoopDriver` (`enabled`, `model`, `maxTurns`
23
+ default 12, `minTurnIntervalMs`, `maxConcurrent` default 1, `turnTimeoutMs`).
24
+
25
+ Ships **dark** behind `autonomousSessions.geminiLoopDriver.enabled` (default
26
+ `false`); the `developmentAgent` gate turns it on for development agents only.
27
+ Rollback = set the flag `false` (instant, no redeploy). Subscription auth is
28
+ structural. 21 new tests across all three tiers (unit + integration route + e2e
29
+ alive + wired-source check). Spec: `docs/specs/gemini-multi-turn-loop-driver.md`.
30
+
31
+ **The Parallel-Work overlap councilor can now actually run.** The previous change shipped the
32
+ detector and the sentinel as tested library code; this wires the `ParallelWorkSentinel` into
33
+ the server so it ticks on a cadence over the cross-topic activity index, spots when two of
34
+ your topics are working on the same thing, and nudges you once — with a cooldown so it never
35
+ re-nags. It is signal-only and never gates.
36
+
37
+ It ships **dark**: off by default behind `monitoring.parallelWorkSentinel.enabled`. A
38
+ false-positive nudge is worse than silence, so it graduates only after it is shown to be
39
+ quiet. When on, it scans every ~15 minutes, audits every transition to
40
+ `logs/sentinel-events.jsonl`, and the timer is unref'd + cleaned up on shutdown.
41
+
42
+ ## What to Tell Your User
43
+
44
+ On development agents I can now be handed a multi-step task for the Gemini side
45
+ and work it across several turns on my own — on subscription login, never an API
46
+ key — with a hard turn cap and a spend gate so it can't run away. On every other
47
+ agent it ships turned off, so nothing changes there. This is the capability the
48
+ apprenticeship program needed so the Gemini mentee can do real multi-step work
49
+ instead of stopping after one reply.
50
+
51
+ Optional: if your agent works across many topics and you want it to proactively notice when
52
+ two topics are doing the same work, you can turn on the overlap councilor in your monitoring
53
+ config. It is off by default and only ever sends a gentle heads-up -- it never blocks anything.
54
+
55
+ ## Summary of New Capabilities
56
+
57
+ - `monitoring.parallelWorkSentinel.enabled` (default false, ships dark) +
58
+ `cadenceMinutes` (default 15) — turns on and tunes the proactive overlap councilor.
59
+ - The `ParallelWorkSentinel` is now constructed + cadenced in the server when enabled, with
60
+ every transition audited to `logs/sentinel-events.jsonl`.
61
+
62
+ ## Evidence
63
+
64
+ - Wiring-integrity test (Testing Integrity Standard): boots the real AgentServer and asserts
65
+ the sentinel is NOT constructed when the flag is off (ships dark) and IS constructed +
66
+ ticks when the flag is on. tsc clean.
67
+ - The detector + sentinel logic is already covered by 17 unit tests (shipped with the
68
+ prior change); this change only turns them on.
@@ -0,0 +1,59 @@
1
+ # Side-Effects Review — Gemini loop-driver wiring (need-gem-002, increment 2)
2
+
3
+ **Version / slug:** `gemini-loop-driver-wiring`
4
+ **Date:** `2026-06-04`
5
+ **Author:** `echo`
6
+ **Second-pass reviewer:** `not required` (ships DARK behind
7
+ `autonomousSessions.geminiLoopDriver.enabled`; the developmentAgent gate turns it
8
+ on for dev agents only; rollback = flag false, instant)
9
+
10
+ ## Summary of the change
11
+
12
+ Wires the (already-merged, increment 1) `GeminiLoopDriver` engine into a real,
13
+ budget-gated, dark capability:
14
+ - `geminiLoopProduction.ts` — production deps: the subscription-auth spawn
15
+ (`createGeminiLoopSpawn` → the billing-env-stripping transport), the
16
+ `--list-sessions` handle parser (`parseLatestGeminiSessionHandle`, min-age), and
17
+ the QuotaTracker-backed budget gate (`createQuotaBudgetGate`).
18
+ - `GeminiLoopRunner.ts` — admits + launches runs async (a loop can take minutes,
19
+ so a run returns a `runId` immediately) into a bounded in-memory registry.
20
+ - Routes `POST /gemini-loop/runs` (admit) + `GET /gemini-loop/runs[/:id]` (poll).
21
+ - `server.ts` constructs it under the developmentAgent gate; `types.ts` adds
22
+ `autonomousSessions.geminiLoopDriver`.
23
+
24
+ ## Decision-point inventory
25
+
26
+ Admission has four refusal boundaries (disabled / at-capacity / budget / invalid)
27
+ plus the OK path; the handle parser picks min-age or null; the budget gate maps
28
+ the QuotaTracker signal (fail-open with no tracker). All covered both-sides
29
+ across the unit/integration suites.
30
+
31
+ ## 1. Over-block
32
+
33
+ **What legitimate inputs does this change reject?** Nothing on the fleet — it
34
+ ships dark (disabled → POST returns 409 'disabled'). When enabled: a closed budget
35
+ gate refuses to start (intended — the overspend guard), `maxConcurrent: 1` refuses
36
+ a 2nd concurrent run (intended — keeps shared-cwd handle capture unambiguous), and
37
+ an empty goal is 400. A requested `maxTurns` is clamped DOWN to the config cap, never
38
+ up. These are all the guardrails, not false rejections.
39
+
40
+ ## 2. Under-block
41
+
42
+ **What does this still miss?** Handle capture uses the shared process cwd, so it is
43
+ only unambiguous at `maxConcurrent: 1` (a per-loop cwd needs a transport `cwd`
44
+ option — deferred; documented in the spec risks). The runner does not persist runs
45
+ across a restart (in-memory registry — acceptable for a dev dark feature; a SQLite
46
+ store is a later increment if it graduates). A 429/capacity wall ends a turn via
47
+ the engine's spawn-failure path rather than a graceful gemini-capacity-policy
48
+ pause (noted as a refinement). A mentee that finishes silently (no sentinel) runs
49
+ to the turn cap rather than an LLM-judge early-exit (judge = a later increment).
50
+
51
+ ## 3. Level-of-abstraction fit
52
+
53
+ **Right layer?** Yes. Production deps live in `monitoring/` beside the engine and
54
+ depend only on the gemini transport (subscription-auth guarantee stays in the
55
+ transport, reused not re-implemented). The runner is constructed beside the other
56
+ dark monitoring features in `server.ts` under the same `developmentAgent` gate
57
+ pattern, and threads through the existing `AgentServer` options → `RouteContext`
58
+ plumbing (mirrors `mcpProcessReaper`). The budget gate reuses the existing
59
+ QuotaTracker spawn-admission decision rather than inventing new accounting.
@@ -0,0 +1,56 @@
1
+ # Side-Effects Review — Gemini multi-turn loop-driver (engine increment)
2
+
3
+ **Version / slug:** `gemini-multi-turn-loop-driver`
4
+ **Date:** `2026-06-04`
5
+ **Author:** `echo`
6
+ **Second-pass reviewer:** `not required` (dark + unwired engine increment; the
7
+ spendable surface — the invoking route/wiring — is a separate later increment
8
+ that will carry its own review)
9
+
10
+ ## Summary of the change
11
+
12
+ Adds `GeminiLoopDriver` (`src/monitoring/GeminiLoopDriver.ts`), a dependency-
13
+ injected engine that drives a gemini task across turns via the native
14
+ `gemini -r <handle>` resume path (turn 1 one-shot establishes the session; later
15
+ turns resume by a stable handle, re-prompting with only the next instruction so
16
+ no transcript is re-sent). Adds the `buildGeminiResumeArgv` transport helper. The
17
+ engine is NOT invoked anywhere yet (dark + unwired); only its 14 unit tests
18
+ exercise it.
19
+
20
+ ## Decision-point inventory
21
+
22
+ The engine makes five terminal decisions per run: done-sentinel detected,
23
+ turn-cap reached, budget-gate closed, spawn failure (non-zero exit), and
24
+ handle-capture failure. Each is covered both-sides in the unit suite.
25
+
26
+ ## 1. Over-block
27
+
28
+ **What legitimate inputs does this change reject?** Nothing in production today —
29
+ the engine is unwired, so no caller is gated by it. Within a run: a closed budget
30
+ gate halts before spawning (intended — that IS the overspend guard), and a
31
+ `null` handle-capture aborts the loop after turn 1 rather than resuming (intended
32
+ — resuming `latest` could hijack a foreign session; aborting is the safe choice).
33
+ The `maxTurns` clamp floors at 1, so a 0/negative cap still runs exactly one turn
34
+ rather than zero or infinite.
35
+
36
+ ## 2. Under-block
37
+
38
+ **What does this still miss?** The engine does not itself enforce a token budget —
39
+ it delegates to the injected `budgetGate`, which is wired to the real
40
+ QuotaTracker only in the (later) invocation increment; an integrator that injects
41
+ a permissive gate gets no budget protection. It does not detect a wedged turn
42
+ mid-spawn (it relies on the injected spawn's own timeout, which the real
43
+ `spawnGeminiAndWait` provides). It does not yet verify the empirically-noted 3+
44
+ turn resume-accumulation (a live-verify gate recorded in the spec before any
45
+ enable). Completion relies on the mentee emitting the sentinel OR (later) a judge;
46
+ a mentee that finishes silently without the sentinel runs to the turn cap.
47
+
48
+ ## 3. Level-of-abstraction fit
49
+
50
+ **Right layer?** Yes. The engine sits in `src/monitoring/` beside the other
51
+ driver/lifecycle components and depends only on the gemini transport's pure argv
52
+ builders (`buildGeminiOneShotArgv` / `buildGeminiResumeArgv`); all I/O is
53
+ injected, so the subscription-auth guarantee stays in the transport
54
+ (`buildGeminiChildEnv` strips billing env) and is reused, not re-implemented. The
55
+ resume argv helper lives in the transport module next to the one-shot builder,
56
+ keeping the gemini-cli invocation surface in one place.
@@ -0,0 +1,94 @@
1
+ # Side-Effects Review — Parallel-Work Awareness, Phase A core (cross-topic index)
2
+
3
+ **Version / slug:** `parallel-activity-coherence`
4
+ **Date:** `2026-06-03`
5
+ **Author:** `Echo (instar-dev agent)`
6
+ **Tier:** `2` (new capability; converged + approved spec: docs/specs/parallel-activity-coherence.md)
7
+ **Second-pass reviewer:** `not required (the converged spec carries a 2-reviewer adversarial+integration pass that reshaped it)`
8
+
9
+ ## Summary of the change
10
+ Phase A CORE of the Parallel-Work Awareness feature: `ParallelActivityIndex` — a thin
11
+ CROSS-topic read aggregator over the EXISTING Topic-Intent Layer. It does NOT add a new
12
+ per-topic store (convergence: that would duplicate `TopicIntentStore`); it only READS the
13
+ existing per-topic intent files and presents the cross-topic view ("all my topics + what
14
+ each is working on") that genuinely did not exist. Plus `extractTags` — high-specificity
15
+ token extraction (drops generic boilerplate so two "fix the test" topics don't false-match).
16
+
17
+ New:
18
+ - `src/core/ParallelActivityIndex.ts` — enumerate `{stateDir}/topic-intent/*.json`; per
19
+ topic derive `focus` (latest goal > latest decision > purpose), `tags` (high-specificity
20
+ tokens), `refCount`, `updatedAt`, `running`. Read-only; an injectable `getRefs` seam for
21
+ testability (production uses the real `TopicIntentStore.getRefsAtOrAbove`).
22
+ - `tests/unit/parallel-activity-index.test.ts` — 7 tests.
23
+
24
+ Phase A is now COMPLETE: `GET /parallel-work/activities` route + CapabilityIndex entry
25
+ (`parallelWork`, prefixes `['/parallel-work']`) + server wiring (constructed in AgentServer
26
+ in its OWN try/catch, injected into routeCtx, `running` enriched from the live session list)
27
+ + integration/e2e tests + CLAUDE.md template + migrateClaudeMd agent-awareness. The overlap
28
+ ParallelWorkSentinel is Phase B (ships dark), a separate PR.
29
+
30
+ ## Phase B (overlap sentinel core — added to this PR)
31
+ - `src/monitoring/ParallelWorkOverlap.ts` — the PURE cross-topic overlap detector: activity
32
+ gate (only recently-worked topics), IDF/specificity weighting over the already-boilerplate-
33
+ filtered tags, ≥1 shared high-specificity tag required, self-exclusion, signature = sorted
34
+ shared-tag set, + `signatureChangedMaterially` (hysteresis) and `pairKey`. No I/O, no real
35
+ time (injected nowMs) ⇒ exhaustively unit-tested (11 tests).
36
+ - `src/monitoring/ParallelWorkSentinel.ts` — the stateful councilor: `tick(nowMs)` reads the
37
+ activities, runs the detector, and emits ONE `overlap` nudge per genuinely-fresh overlap.
38
+ Containment: PAIR-KEYED cooldown (survives focus edits), signature hysteresis (no re-nag on
39
+ a one-token tweak), audit sink for every transition. SIGNAL-ONLY (emits an event; never
40
+ gates/mutates). 6 tests. The cadence + lease-gating + server wiring + config (ships dark) +
41
+ the nudge→Telegram/sentinel-events routing are the remaining wiring on this branch.
42
+
43
+ ## Phase B wiring (the on-switch)
44
+ - `src/config/ConfigDefaults.ts` — `monitoring.parallelWorkSentinel: { enabled: false }` — ships
45
+ DARK (false-positive nudge worse than silence; graduate after proven quiet). Add-missing-only
46
+ via applyDefaults ⇒ free migration; never a destructive sub-flag default.
47
+ - `src/core/types.ts` — `MonitoringConfig.parallelWorkSentinel?: { enabled, cadenceMinutes? }`.
48
+ - `src/server/AgentServer.ts` — when enabled, construct `ParallelWorkSentinel` over the index in
49
+ its OWN try/catch (cascade isolation), tick on an unref'd cadence (default 15min), audit each
50
+ transition to `logs/sentinel-events.jsonl`; cleared on `stop()`. Signal-only.
51
+
52
+ ## Decision-point inventory
53
+ - `ParallelActivityIndex` read aggregation — **add** — pure read over existing state; no
54
+ block/allow surface, no mutation.
55
+ - `ParallelWorkOverlap` / `ParallelWorkSentinel` — **add** — pure detector + a signal-only
56
+ EventEmitter; no block/allow surface, no mutation. The nudge informs; the agent decides.
57
+
58
+ ## 1./2. Over/Under-block
59
+ No block/allow surface. Signal-only observability over existing data.
60
+
61
+ ## 3. Level-of-abstraction fit
62
+ Correct — it reads the Topic-Intent layer (the right source for "what each topic intends")
63
+ and presents a cross-topic view; it does not re-implement intent capture or storage.
64
+
65
+ ## 4. Signal vs authority
66
+ **Reference:** docs/signal-vs-authority.md. [x] No block/allow surface. A read aggregator.
67
+
68
+ ## 5. Interactions
69
+ - **No new store / no new write path** — reuses `TopicIntentStore` (which already has the
70
+ structural per-turn write path via TopicIntentCapture). No duplication, no second decay engine.
71
+ - **False-positive containment starts here:** `extractTags` strips generic boilerplate +
72
+ requires specificity (compound/identifier tokens, or rare ≥4-char words), so the Phase B
73
+ overlap comparison rests on genuine shared entities, not coincidental generic words.
74
+ - **Robustness:** missing intent dir ⇒ empty list; a corrupt/again topic file ⇒ that topic
75
+ contributes no refs (swallowed), never throws.
76
+
77
+ ## 6. External surfaces
78
+ - (Remaining) `GET /parallel-work/activities` + CapabilityIndex classification (the #727
79
+ lesson). No persistent state of its own (reads existing topic-intent files). Config flag
80
+ (`monitoring.parallelWorkSentinel`) lands with the sentinel (Phase B), ships dark.
81
+
82
+ ## 7. Rollback cost
83
+ Pure additive read code. Revert ⇒ gone, no state, no migration.
84
+
85
+ ## Conclusion
86
+ Phase A core complete + unit-tested (7 tests, tsc clean): the cross-topic index over the
87
+ existing Topic-Intent layer + specificity-aware tag extraction. Non-duplicative (the
88
+ convergence-mandated reshape). Route + wiring + integration/e2e + agent-awareness follow on
89
+ this branch; the overlap ParallelWorkSentinel is Phase B (ships dark).
90
+
91
+ ## Evidence pointers
92
+ - `tsc --noEmit` clean; `vitest run tests/unit/parallel-activity-index.test.ts` → 7/7
93
+ (extractTags specificity boundary incl. the cpu vs cpu-sampling case; focus derivation
94
+ goal>decision>purpose; tags; running/nickname; empty-dir ⇒ []).