instar 1.2.2 → 1.2.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.
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +64 -33
- package/dist/commands/server.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +72 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +46 -46
- package/upgrades/1.2.3.md +43 -0
- package/upgrades/1.2.4.md +69 -0
- package/upgrades/side-effects/capabilities-discoverability.md +116 -0
- package/upgrades/side-effects/worktree-detector-attention-wireup.md +194 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Side-Effects Review — Layer 4 detector → AttentionQueue wireup
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `worktree-detector-attention-wireup`
|
|
4
|
+
**Date:** `2026-05-21`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Second-pass reviewer:** `not required` (see §"Phase 5 trigger check")
|
|
7
|
+
|
|
8
|
+
## Summary of the change
|
|
9
|
+
|
|
10
|
+
The Layer 4 lifeline detector (from the agent worktree convention,
|
|
11
|
+
shipped in v1.1.0 via PR #278) was running on every agent server boot
|
|
12
|
+
and emitting to its JSONL fallback only — the Telegram AttentionQueue
|
|
13
|
+
wireup was deferred because, in `startServer()`, the detector was
|
|
14
|
+
invoked at line ~2208 while `TelegramAdapter` doesn't initialize until
|
|
15
|
+
line ~2810/2897. The deferred state is documented in the v1.1.0 NEXT.md
|
|
16
|
+
and in `upgrades/side-effects/agent-worktree-convention-layer-3-4.md`.
|
|
17
|
+
|
|
18
|
+
This PR closes the gap by moving the detector invocation to **after**
|
|
19
|
+
both `TelegramAdapter` setup blocks. When Telegram is configured, the
|
|
20
|
+
detector now passes `telegram.createAttentionItem` as its
|
|
21
|
+
`emitAttention` callback; when it isn't, the JSONL fallback fires
|
|
22
|
+
exactly as before. The detector remains signal-only — no blocking,
|
|
23
|
+
no moves, no deletes.
|
|
24
|
+
|
|
25
|
+
**Files touched:**
|
|
26
|
+
- `src/commands/server.ts` (+62 / -29 lines: removed the old early invocation, replaced with a one-paragraph stub comment; added the new conditional invocation after the full-mode Telegram block).
|
|
27
|
+
- `tests/unit/AgentWorktreeDetector-attention-wireup.test.ts` (new, 3 cases — shape-compat, async-await safety, JSONL-fallback preservation).
|
|
28
|
+
- `upgrades/NEXT.md` (new — fresh v1.2.4 release).
|
|
29
|
+
- `package.json` (1.2.3 → 1.2.4).
|
|
30
|
+
|
|
31
|
+
## Decision-point inventory
|
|
32
|
+
|
|
33
|
+
- **Detector emission target selection** — *modify*. Was unconditional
|
|
34
|
+
JSONL; is now Telegram-when-configured-else-JSONL. The selection
|
|
35
|
+
rule is a pure presence check (`telegram ? emitToTelegram : undefined`),
|
|
36
|
+
no judgment. Both paths exist in the spec.
|
|
37
|
+
- **AttentionItem.id dedupe** — *pass-through*. The detector already
|
|
38
|
+
produces `worktree-misplaced:sha256(path)` ids; TelegramAdapter's
|
|
39
|
+
existing `attentionItems` Map collapses repeats. No new dedupe logic.
|
|
40
|
+
- **JSONL fallback rolling-window** — *unchanged*. Same 24h, same
|
|
41
|
+
O_NOFOLLOW + fstat owner/mode gate on the fallback file.
|
|
42
|
+
|
|
43
|
+
No new authorities introduced. No new detectors. Just a wiring change
|
|
44
|
+
that connects an existing signal producer (detector) to an existing
|
|
45
|
+
authority surface (AttentionQueue).
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 1. Over-block
|
|
50
|
+
|
|
51
|
+
No block/allow surface — over-block not applicable. The detector emits
|
|
52
|
+
attention items; AttentionQueue is the authority that decides what to
|
|
53
|
+
do with them. Neither side rejects the user/operator from anything.
|
|
54
|
+
|
|
55
|
+
## 2. Under-block
|
|
56
|
+
|
|
57
|
+
No block/allow surface — under-block not applicable.
|
|
58
|
+
|
|
59
|
+
A related coverage gap worth naming (and tracked in NEXT.md Deferred):
|
|
60
|
+
the 24h JSONL dedupe is per-file. The Telegram path leans on
|
|
61
|
+
`AttentionItem.id` collision in TelegramAdapter's in-memory
|
|
62
|
+
`attentionItems` Map, which is reset on every agent restart. Two
|
|
63
|
+
agent restarts within 24h on a Telegram-configured agent could
|
|
64
|
+
theoretically re-emit for the same misplaced worktree path. In
|
|
65
|
+
practice, agent restarts are infrequent; if noise becomes a problem,
|
|
66
|
+
the fix is to consult the JSONL dedupe state from the Telegram path
|
|
67
|
+
too. Acceptable for v1.
|
|
68
|
+
|
|
69
|
+
## 3. Level-of-abstraction fit
|
|
70
|
+
|
|
71
|
+
Right layer. The detector lives where every other lifecycle observer
|
|
72
|
+
lives (`src/core/`), invoked from the agent boot path
|
|
73
|
+
(`src/commands/server.ts`), feeding the existing AttentionQueue
|
|
74
|
+
surface in TelegramAdapter. The move from "before TelegramAdapter
|
|
75
|
+
init" to "after TelegramAdapter init" is the only change; everything
|
|
76
|
+
else reuses primitives that have been in production since v1.1.0.
|
|
77
|
+
|
|
78
|
+
A smarter gate (the AttentionQueue) already exists; this PR feeds it
|
|
79
|
+
the signal it was always intended to consume.
|
|
80
|
+
|
|
81
|
+
## 4. Signal vs authority compliance
|
|
82
|
+
|
|
83
|
+
**Required reference:** [docs/signal-vs-authority.md](../../docs/signal-vs-authority.md)
|
|
84
|
+
|
|
85
|
+
**Does this change hold blocking authority with brittle logic?**
|
|
86
|
+
|
|
87
|
+
- [x] **No — this change produces a signal consumed by an existing smart gate.** The detector remains signal-only. AttentionQueue (TelegramAdapter's `attentionItems` registry) is the authority that owns dedupe, topic creation, and operator routing. The detector's only authoritative decision is the path-based "is this worktree under a registered safe root" filter, which is hard-invariant validation (carve-out in `docs/signal-vs-authority.md`).
|
|
88
|
+
|
|
89
|
+
The detector's invariant that the audit ledger is **never** consumed
|
|
90
|
+
as an allowlist remains in force — the path-based rule is the
|
|
91
|
+
detector's only authority surface, and that rule is restated in
|
|
92
|
+
`src/core/AgentWorktreeDetector.ts`'s file-level comment.
|
|
93
|
+
|
|
94
|
+
## 5. Interactions
|
|
95
|
+
|
|
96
|
+
- **Shadowing:** the detector now runs AFTER `telegram.start()` and
|
|
97
|
+
after the Telegram routing/callback wireup (`wireTelegramRouting`
|
|
98
|
+
+ `wireTelegramCallbacks`). It still runs BEFORE the AgentServer
|
|
99
|
+
HTTP listener (line 7037), so no inbound traffic is missed during
|
|
100
|
+
the detection sweep.
|
|
101
|
+
- **Double-fire:** dedupe is owned by AttentionQueue (`item.id`
|
|
102
|
+
collision) for the Telegram path and by the JSONL rolling-window
|
|
103
|
+
scan for the fallback path. Two concurrent agent boots against the
|
|
104
|
+
same instar repo would each emit; the AttentionQueue collapse
|
|
105
|
+
protects the Telegram side, and the JSONL state-dir is per-agent
|
|
106
|
+
so cross-agent file contention is impossible.
|
|
107
|
+
- **Races:** the detector awaits each `emitAttention` call (verified
|
|
108
|
+
by the async-await test in
|
|
109
|
+
`tests/unit/AgentWorktreeDetector-attention-wireup.test.ts`). The
|
|
110
|
+
TelegramAdapter's `createAttentionItem` does a network roundtrip
|
|
111
|
+
(`createForumTopic`); awaiting it keeps the detector's
|
|
112
|
+
`result.emitted` counter accurate.
|
|
113
|
+
- **Feedback loops:** the detector reads `git worktree list` and
|
|
114
|
+
emits attention items. AttentionQueue creates Telegram topics. No
|
|
115
|
+
loop back into `git worktree`.
|
|
116
|
+
- **Startup ordering:** moving the detector down ~700 lines in
|
|
117
|
+
`startServer()` lengthens the time between `registerAgent` and
|
|
118
|
+
the first detection by the duration of TelegramAdapter init. On
|
|
119
|
+
echo's machine that's typically <500ms (the Telegram
|
|
120
|
+
`start()` call awaits a long-poll handshake). No user-visible
|
|
121
|
+
latency change.
|
|
122
|
+
|
|
123
|
+
## 6. External surfaces
|
|
124
|
+
|
|
125
|
+
- **Other agents on the same machine:** none. Each agent's
|
|
126
|
+
detection emits to its own TelegramAdapter / JSONL.
|
|
127
|
+
- **Other users of the install base:** purely additive — for any
|
|
128
|
+
agent that wasn't already configured for Telegram, behavior is
|
|
129
|
+
byte-identical to v1.2.3 (JSONL only). For Telegram-configured
|
|
130
|
+
agents, attention topics will appear on next agent restart per
|
|
131
|
+
misplaced worktree.
|
|
132
|
+
- **External systems:** Telegram (additional topic creates via
|
|
133
|
+
`createForumTopic`). Rate-limited by Telegram's API; one topic
|
|
134
|
+
per detection emission per misplaced path per process. Real-world
|
|
135
|
+
impact on echo's machine: ~30 attention topics on first boot
|
|
136
|
+
after this release, then near-zero per subsequent boot (all
|
|
137
|
+
deduped via item.id).
|
|
138
|
+
- **Persistent state:** the existing
|
|
139
|
+
`<stateDir>/audit/worktree-detector.jsonl` fallback file is
|
|
140
|
+
unchanged. Telegram attention topic registrations land in the
|
|
141
|
+
existing TelegramAdapter state (`<stateDir>/state/attention-items.json`,
|
|
142
|
+
managed by the adapter itself).
|
|
143
|
+
- **Timing:** detector still uses the existing 2-second timeout
|
|
144
|
+
on `git worktree list --porcelain`. Unchanged.
|
|
145
|
+
|
|
146
|
+
## 7. Rollback cost
|
|
147
|
+
|
|
148
|
+
- **Code:** revert this commit. The detector returns to its pre-PR
|
|
149
|
+
position (early in `startServer()` with `emitAttention` always
|
|
150
|
+
undefined), and the JSONL fallback resumes as the only emission
|
|
151
|
+
channel. No data migration. Attention topics already created on
|
|
152
|
+
Telegram remain — they're operator-managed and don't depend on
|
|
153
|
+
this PR's wiring.
|
|
154
|
+
- **Persistent state:** no schema change. The
|
|
155
|
+
`<stateDir>/state/attention-items.json` registry is the same one
|
|
156
|
+
TelegramAdapter has owned since v0.10.x.
|
|
157
|
+
- **Agent state repair:** none required.
|
|
158
|
+
- **User visibility during rollback:** new attention topics stop
|
|
159
|
+
appearing; existing ones stay until the operator `/done`s or
|
|
160
|
+
`/wontdo`s them. The JSONL trail continues unchanged.
|
|
161
|
+
|
|
162
|
+
Total rollback time: under 2 minutes (one revert).
|
|
163
|
+
|
|
164
|
+
## Conclusion
|
|
165
|
+
|
|
166
|
+
Pure wireup change. The detector and AttentionQueue have both been
|
|
167
|
+
in production since v1.1.0; this PR connects them. Signal-only
|
|
168
|
+
contract is preserved. Three new tests pin the shape-compat,
|
|
169
|
+
async-await safety, and JSONL-fallback-preservation invariants.
|
|
170
|
+
Pre-push gate green.
|
|
171
|
+
|
|
172
|
+
Phase 5 trigger check: the change does **not** touch outbound or
|
|
173
|
+
inbound messaging *dispatch* (the detector emits a category that
|
|
174
|
+
AttentionQueue already handles), session lifecycle, compaction,
|
|
175
|
+
coherence gates, idempotency at transport, trust levels, or anything
|
|
176
|
+
named sentinel/guard/gate/watchdog. The detector is signal-only and
|
|
177
|
+
AttentionQueue is the long-existing authority. No second-pass
|
|
178
|
+
reviewer required.
|
|
179
|
+
|
|
180
|
+
Clear to ship.
|
|
181
|
+
|
|
182
|
+
## Evidence pointers
|
|
183
|
+
|
|
184
|
+
- **Wireup tests:** `tests/unit/AgentWorktreeDetector-attention-wireup.test.ts`
|
|
185
|
+
(3 cases: shape-compat between detector output and adapter input,
|
|
186
|
+
async-callback await safety, JSONL fallback preservation).
|
|
187
|
+
- **Spec:** `docs/specs/AGENT-WORKTREE-CONVENTION-SPEC.md` (approved
|
|
188
|
+
2026-05-17 22:35 UTC).
|
|
189
|
+
- **Sibling artifacts:**
|
|
190
|
+
- `upgrades/side-effects/agent-worktree-convention-layer-1-2-5.md`
|
|
191
|
+
(Layer 1+2+5, merged in PR #277 as `bdf8508f`).
|
|
192
|
+
- `upgrades/side-effects/agent-worktree-convention-layer-3-4.md`
|
|
193
|
+
(Layer 3+4, merged in PR #278 as `c7e8e08b`; documented this
|
|
194
|
+
wireup as deferred follow-up).
|