instar 1.2.3 → 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/package.json +1 -1
- package/src/data/builtin-manifest.json +2 -2
- package/upgrades/1.2.4.md +69 -0
- package/upgrades/side-effects/worktree-detector-attention-wireup.md +194 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./builtin-manifest.schema.json",
|
|
3
3
|
"schemaVersion": 1,
|
|
4
|
-
"generatedAt": "2026-05-
|
|
5
|
-
"instarVersion": "1.2.
|
|
4
|
+
"generatedAt": "2026-05-21T15:35:55.916Z",
|
|
5
|
+
"instarVersion": "1.2.4",
|
|
6
6
|
"entryCount": 190,
|
|
7
7
|
"entries": {
|
|
8
8
|
"hook:session-start": {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Upgrade Guide — v1.2.4 (worktree detector → Telegram alerts)
|
|
2
|
+
|
|
3
|
+
<!-- bump: patch -->
|
|
4
|
+
|
|
5
|
+
## What Changed
|
|
6
|
+
|
|
7
|
+
**Layer 4 detector now surfaces misplaced worktrees through the Telegram
|
|
8
|
+
attention queue, not just the JSONL fallback.** The agent worktree
|
|
9
|
+
convention's lifeline detector — added in v1.1.0 (PR #278) — has been
|
|
10
|
+
running on every agent server boot and dutifully appending detected
|
|
11
|
+
violations to `<stateDir>/audit/worktree-detector.jsonl`, but the
|
|
12
|
+
emissions never reached the operator's Telegram. That was a known
|
|
13
|
+
follow-up tracked in v1.1.0's Deferred list.
|
|
14
|
+
|
|
15
|
+
This release closes that gap by moving the detector invocation from
|
|
16
|
+
its old position before `TelegramAdapter` was initialized to a new
|
|
17
|
+
position immediately after both TelegramAdapter setup blocks (the
|
|
18
|
+
send-only and full-mode paths in `src/commands/server.ts`). When the
|
|
19
|
+
agent has Telegram configured, the detector now passes
|
|
20
|
+
`telegram.createAttentionItem` as its emit-attention callback;
|
|
21
|
+
otherwise it falls back to the JSONL append exactly as before.
|
|
22
|
+
|
|
23
|
+
The detector remains **signal-only** — every emission goes through
|
|
24
|
+
the existing `AttentionItem.id` dedupe contract, the JSONL fallback
|
|
25
|
+
keeps its O_NOFOLLOW + fstat + 24h rolling-window dedupe, and the
|
|
26
|
+
detector still never blocks, moves, or deletes anything. The only
|
|
27
|
+
behavioral change visible to the operator is: misplaced-worktree
|
|
28
|
+
alerts now arrive as Telegram attention topics on the next agent
|
|
29
|
+
restart, instead of being silently written to a log file the
|
|
30
|
+
operator was unlikely to discover.
|
|
31
|
+
|
|
32
|
+
## Evidence
|
|
33
|
+
|
|
34
|
+
Reproduction prior: an agent running v1.1.0–v1.2.3 with one or more
|
|
35
|
+
worktrees of the shared instar repo outside any registered agent's
|
|
36
|
+
`.worktrees/` safe area would, on every server boot, emit zero
|
|
37
|
+
Telegram alerts and silently append JSONL lines under
|
|
38
|
+
`<stateDir>/audit/worktree-detector.jsonl`. Verified by inspecting
|
|
39
|
+
the server-start log on echo's machine after each release —
|
|
40
|
+
"Worktree detector: N misplaced worktree(s) flagged" appeared in
|
|
41
|
+
console output but no attention topic was ever created.
|
|
42
|
+
|
|
43
|
+
After this PR: the same configuration produces the same JSONL line
|
|
44
|
+
PLUS a Telegram attention topic per misplaced worktree, deduped by
|
|
45
|
+
the same `worktree-misplaced:sha256(path)` id the JSONL already
|
|
46
|
+
used. The console line gains a `via Telegram` / `via JSONL fallback`
|
|
47
|
+
suffix so the operator can tell which channel ran. Verified by
|
|
48
|
+
three new wireup tests in
|
|
49
|
+
`tests/unit/AgentWorktreeDetector-attention-wireup.test.ts`:
|
|
50
|
+
shape-compatibility between detector output and adapter input,
|
|
51
|
+
async-callback await safety (the detector awaits the emit so a
|
|
52
|
+
Telegram API roundtrip latency is honored), and JSONL fallback
|
|
53
|
+
preservation when `emitAttention` is undefined.
|
|
54
|
+
|
|
55
|
+
## What to Tell Your User
|
|
56
|
+
|
|
57
|
+
- "Your agents now actually tell you when they spot a worktree in the unsafe location. Before this release, the warning was being written to a log file in the background — the agent saw it, but you never did. Now it shows up as an attention topic in Telegram the next time the agent starts up. Same dedupe rules as before, so you won't get pinged twice for the same one within a day."
|
|
58
|
+
|
|
59
|
+
## Summary of New Capabilities
|
|
60
|
+
|
|
61
|
+
| Capability | How to Use |
|
|
62
|
+
|-----------|-----------|
|
|
63
|
+
| Worktree detector emits to Telegram | Automatic on every agent server boot. When the agent has Telegram configured, misplaced-worktree detections create attention topics; otherwise the JSONL fallback at `<stateDir>/audit/worktree-detector.jsonl` continues as before. Dedupe is path-hash-based via the same `worktree-misplaced:sha256(path)` id the JSONL has always used. |
|
|
64
|
+
| Console reports the channel | The startup log line now reads `Worktree detector: N misplaced worktree(s) flagged via Telegram` (or `via JSONL fallback`) so the operator can confirm which channel ran without grepping the audit file. |
|
|
65
|
+
|
|
66
|
+
## Deferred (Tracked Follow-ups)
|
|
67
|
+
|
|
68
|
+
- The 24h rolling-window JSONL dedupe runs only on the fallback path. The Telegram path leans on `AttentionItem.id` collision in TelegramAdapter's existing `attentionItems` Map — that lookup is per-process and is reset on agent restart, so two boots within 24h on a Telegram-configured agent could theoretically emit twice for the same misplaced worktree. In practice agent restarts are infrequent enough that this isn't a real source of noise; if it ever becomes one, the fix is to consult the JSONL dedupe state from the Telegram path too.
|
|
69
|
+
- The detector's first-run burst on machines with many pre-existing misplaced worktrees (echo's machine has ~30 from before the convention shipped) is now Telegram-visible for the first time. Operators may want to bulk-acknowledge them with `/done` rather than processing each individually.
|
|
@@ -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).
|