instar 0.28.93 → 0.28.95
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 +73 -0
- package/dist/commands/server.js.map +1 -1
- package/dist/core/DriftSpendLedger.d.ts +112 -0
- package/dist/core/DriftSpendLedger.d.ts.map +1 -0
- package/dist/core/DriftSpendLedger.js +285 -0
- package/dist/core/DriftSpendLedger.js.map +1 -0
- package/dist/core/ProjectDriftChecker.d.ts +15 -0
- package/dist/core/ProjectDriftChecker.d.ts.map +1 -1
- package/dist/core/ProjectDriftChecker.js +87 -2
- package/dist/core/ProjectDriftChecker.js.map +1 -1
- package/dist/core/ProjectDriftCheckerCache.d.ts +118 -0
- package/dist/core/ProjectDriftCheckerCache.d.ts.map +1 -0
- package/dist/core/ProjectDriftCheckerCache.js +221 -0
- package/dist/core/ProjectDriftCheckerCache.js.map +1 -0
- package/dist/monitoring/CommitmentTracker.d.ts +34 -0
- package/dist/monitoring/CommitmentTracker.d.ts.map +1 -1
- package/dist/monitoring/CommitmentTracker.js +28 -0
- package/dist/monitoring/CommitmentTracker.js.map +1 -1
- package/dist/monitoring/PromiseBeacon.d.ts +15 -0
- package/dist/monitoring/PromiseBeacon.d.ts.map +1 -1
- package/dist/monitoring/PromiseBeacon.js +86 -6
- package/dist/monitoring/PromiseBeacon.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +20 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +46 -46
- package/upgrades/0.28.94.md +60 -0
- package/upgrades/0.28.95.md +55 -0
- package/upgrades/side-effects/project-scope-phase1b-pr2.md +198 -0
- package/upgrades/side-effects/promise-beacon-ux-fixes.md +146 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Side-Effects Review — project-scope Phase 1b PR 2 (Drift cache + cost ledger)
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `project-scope-phase1b-pr2`
|
|
4
|
+
**Date:** `2026-05-11`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Second-pass reviewer:** `required (new persistent-state + cost-control surface)`
|
|
7
|
+
|
|
8
|
+
## Summary of the change
|
|
9
|
+
|
|
10
|
+
Second PR of Phase 1b. Ships the two persistent-state primitives the drift
|
|
11
|
+
checker has been operating without since PR 1:
|
|
12
|
+
|
|
13
|
+
- A verdict cache with mtime fast-path that avoids redundant LLM calls
|
|
14
|
+
when the spec and its referenced files haven't changed.
|
|
15
|
+
- A daily-rotated cost ledger that enforces the $1/day per-agent
|
|
16
|
+
spend ceiling the spec requires.
|
|
17
|
+
|
|
18
|
+
Both classes are usable on their own; `ProjectDriftChecker` now accepts
|
|
19
|
+
them as optional config and wires them in around the LLM call. When
|
|
20
|
+
neither is passed (the PR 1 contract), behavior is unchanged.
|
|
21
|
+
|
|
22
|
+
The `POST /projects/:id/drift-check` HTTP endpoint and the per-project
|
|
23
|
+
mutex around it ship in PR 3 alongside the round runner. PR 2 is the
|
|
24
|
+
data-plane piece; PR 3 is the routing.
|
|
25
|
+
|
|
26
|
+
Spec source: `docs/specs/PROJECT-SCOPE-SPEC.md` § Phase 1.4 ("Cache key",
|
|
27
|
+
mtime fast-path, "Cost ceiling").
|
|
28
|
+
|
|
29
|
+
New files:
|
|
30
|
+
- `src/core/ProjectDriftCheckerCache.ts` (~230 lines) — sha256-keyed
|
|
31
|
+
in-memory verdict cache. Mtime fast-path checks file mtimes against
|
|
32
|
+
the recorded entry before computing the cache key; full-hash path is
|
|
33
|
+
fallback. 24h TTL. Disk-backed snapshot at
|
|
34
|
+
`.instar/drift-verdict-cache.json` so the cache survives restarts
|
|
35
|
+
without a cold first-call after sleep/wake. Snapshot is corruption-
|
|
36
|
+
tolerant (corrupt file → start fresh, will be overwritten on next put).
|
|
37
|
+
- `src/core/DriftSpendLedger.ts` (~240 lines) — daily-rotated append-only
|
|
38
|
+
JSONL ledger at `.instar/drift-spend-YYYY-MM-DD.jsonl`. Each `reserve()`
|
|
39
|
+
appends a `{recordId, projectId, estimatedCost, actualCost: null,
|
|
40
|
+
timestamp}` row under an advisory file lock on
|
|
41
|
+
`.instar/local/drift-spend.lock` (proper-lockfile, same options as
|
|
42
|
+
the rest of the codebase). `reconcile(recordId, actualCost)` appends
|
|
43
|
+
a superseding row. `spentToday()` returns the de-duplicated tally.
|
|
44
|
+
`pruneOlderThan()` removes files outside the 30-day retention window
|
|
45
|
+
(via `SafeFsExecutor.safeRmSync`, NOT raw `fs.rmSync`).
|
|
46
|
+
- `tests/unit/ProjectDriftCheckerCache.test.ts` (13 cases) — hit/miss,
|
|
47
|
+
mtime fast-path (match, content-change miss, set-shrink invalidation),
|
|
48
|
+
cache-key invalidation on every input (templateVersion, modelId,
|
|
49
|
+
specBody, file content, file rename), TTL expiry, invalidate(),
|
|
50
|
+
disk persistence across instances, corrupt-snapshot tolerance,
|
|
51
|
+
`computeCacheKey` determinism + instability semantics.
|
|
52
|
+
- `tests/unit/DriftSpendLedger.test.ts` (13 cases) — default cap matches
|
|
53
|
+
spec, reserve + tally, strict-greater-than boundary at the cap
|
|
54
|
+
(equal-to-cap allowed), reconcile supersedes (no double-count),
|
|
55
|
+
idempotent reconcile, negative/non-finite rejected, JSONL row count
|
|
56
|
+
+ shape after reserve+reconcile, lock-coordinated `spentToday`,
|
|
57
|
+
concurrent reserves serialize, `pruneOlderThan` removes old files,
|
|
58
|
+
corrupt row tolerance, `OverBudgetError` exposes cap/spent/estimated.
|
|
59
|
+
|
|
60
|
+
Modified files:
|
|
61
|
+
- `src/core/ProjectDriftChecker.ts` (~+80 lines) — config accepts
|
|
62
|
+
optional `cache` and `ledger`. Order of operations inside `run()`:
|
|
63
|
+
(1) all input validation (unchanged from PR 1) → (2) cache lookup
|
|
64
|
+
(skip LLM on hit) → (3) ledger reserve (return over-budget on cap)
|
|
65
|
+
→ (4) LLM call → (5) on success, cache.put + ledger.reconcile.
|
|
66
|
+
LLM-failure verdicts (schema-fail, timeout) are NOT cached; input-
|
|
67
|
+
validation verdicts (over-budget, deleted-files, path-jail-fail) are
|
|
68
|
+
cheap to recompute and don't benefit from caching.
|
|
69
|
+
- `tests/unit/ProjectDriftChecker.test.ts` (+5 cases) — cache hit avoids
|
|
70
|
+
LLM, content change forces re-run, over-budget short-circuits before
|
|
71
|
+
the LLM, reserve+reconcile round-trip, LLM-failure not cached.
|
|
72
|
+
|
|
73
|
+
## Decision-point inventory
|
|
74
|
+
|
|
75
|
+
- **Cache hit short-circuit** (`ProjectDriftCheckerCache.lookup`) —
|
|
76
|
+
**add** — on hit, returns the cached verdict directly, bypassing
|
|
77
|
+
the LLM. Cache key is `sha256(promptTemplateVersion + modelId +
|
|
78
|
+
specBodySha + sortedFileHashes)`; mtime fast-path bypasses the hash
|
|
79
|
+
but checks `(templateVersion, modelId, all file mtimes)`. Cache
|
|
80
|
+
invariants — TTL, hash key on file content, mtime equality — are
|
|
81
|
+
exercised by 13 unit tests.
|
|
82
|
+
- **Daily cap rejection** (`DriftSpendLedger.reserve` → throws
|
|
83
|
+
`OverBudgetError`) — **add** — if `spent + estimated > cap`, throw.
|
|
84
|
+
`ProjectDriftChecker` catches it and returns
|
|
85
|
+
`manual-review-required(over-budget)`. Strict greater-than boundary
|
|
86
|
+
matches the spec (iter-2 correction).
|
|
87
|
+
- **Verdict NOT cached on LLM failure** (`run` post-call) — **add** —
|
|
88
|
+
schema-fail / timeout / failed-citation-verification all return
|
|
89
|
+
before the cache write; only `no-drift`, `minor-drift`,
|
|
90
|
+
`premise-violated` reach the put path. A second call gets a fresh
|
|
91
|
+
LLM attempt rather than the previously-cached failure verdict.
|
|
92
|
+
|
|
93
|
+
All three decisions are conservative: hit-on-content-match (never
|
|
94
|
+
hit on stale content), reject-at-strict-cap (never overshoot), no
|
|
95
|
+
cached failure (always re-try).
|
|
96
|
+
|
|
97
|
+
## Over-block vs under-block analysis
|
|
98
|
+
|
|
99
|
+
### Cache
|
|
100
|
+
|
|
101
|
+
Over-block risk: returning a stale verdict. The cache key includes the
|
|
102
|
+
full sha256 of every relevant input, so a stale verdict can only be
|
|
103
|
+
served if (a) file content is unchanged AND (b) within TTL AND (c)
|
|
104
|
+
modelId + templateVersion match. The mtime fast-path only fires when
|
|
105
|
+
the recorded mtimes match the current stat() results — `touch` without
|
|
106
|
+
content change does NOT cause a hit; it forces a full-hash fall-back
|
|
107
|
+
that then matches (correct outcome). The 24h TTL is the durable floor
|
|
108
|
+
even when nothing else moves.
|
|
109
|
+
|
|
110
|
+
Under-block risk: cache miss when it should have hit. Acceptable —
|
|
111
|
+
correctness costs an extra LLM call. The mtime fast-path is a
|
|
112
|
+
performance optimization, not a correctness invariant.
|
|
113
|
+
|
|
114
|
+
### Ledger
|
|
115
|
+
|
|
116
|
+
Over-block risk: rejecting a call that wouldn't actually exceed the
|
|
117
|
+
cap. Pre-reserve uses the `estimatedCostPerCallUsd` constant (default
|
|
118
|
+
$0.01) rather than the call's real cost; in the worst case we
|
|
119
|
+
over-reserve and over-block. Acceptable because the cap is the AGENT
|
|
120
|
+
ceiling, not a hard per-call limit. Reconcile lowers the recorded
|
|
121
|
+
spend back to actual, so subsequent calls aren't penalized.
|
|
122
|
+
|
|
123
|
+
Under-block risk: under-counting. The strict `>` boundary lets
|
|
124
|
+
`spent + estimated == cap` pass; that's the documented behavior, not
|
|
125
|
+
a bug. A reservation that's never reconciled (caller crashed) stays as
|
|
126
|
+
the pending estimate and contributes to the cap until UTC rollover —
|
|
127
|
+
fail-safe rather than fail-open.
|
|
128
|
+
|
|
129
|
+
The cap is per-machine. On multi-machine setups, the spec documents
|
|
130
|
+
the worst-case as `N × cap` per day; the true atomic cross-machine
|
|
131
|
+
cap is a same-PR tracked deferred child (`drift-spend-cross-machine`)
|
|
132
|
+
referenced in the spec. PR 2 does not change that posture.
|
|
133
|
+
|
|
134
|
+
## Signal vs authority audit
|
|
135
|
+
|
|
136
|
+
Neither primitive holds authority. They're persistence + cost-control
|
|
137
|
+
plumbing. The drift verdict is still a signal; the cache returns a
|
|
138
|
+
prior signal, the ledger throws on overshoot but the resulting verdict
|
|
139
|
+
(`manual-review-required(over-budget)`) is again just a signal. The
|
|
140
|
+
round-runner in PR 3 holds authority for round-start, combining drift
|
|
141
|
+
+ artifact checks.
|
|
142
|
+
|
|
143
|
+
## Interactions with existing systems
|
|
144
|
+
|
|
145
|
+
- **`ProjectDriftChecker`.** Both fields are optional — passing
|
|
146
|
+
neither preserves the PR 1 contract exactly. Passing one but not
|
|
147
|
+
the other is supported (cache-only / ledger-only).
|
|
148
|
+
- **`proper-lockfile`.** Already a dep (used by AgentRegistry,
|
|
149
|
+
SharedStateLedger, PlatformActivityRegistry). Same `LOCK_OPTIONS`
|
|
150
|
+
shape, same stale-detection convention.
|
|
151
|
+
- **`.instar/local/`.** Lock file lives under this machine-local
|
|
152
|
+
subdirectory by spec — same convention as `round-runner.lock` (the
|
|
153
|
+
PR 3 chokepoint). Not git-synced, so two machines don't fight over
|
|
154
|
+
a 0-byte lockfile in the sync layer.
|
|
155
|
+
- **`SafeFsExecutor`.** Used for `pruneOlderThan` rather than direct
|
|
156
|
+
`fs.rmSync`, matching the lint-no-direct-destructive contract.
|
|
157
|
+
- **Backup / snapshot.** The spec lists
|
|
158
|
+
`.instar/drift-spend-*.jsonl` in the snapshot-include set (so a
|
|
159
|
+
restore can see the prior day's spend); this PR creates the files
|
|
160
|
+
that the existing snapshot job already names — no snapshot code
|
|
161
|
+
change needed.
|
|
162
|
+
|
|
163
|
+
## Rollback cost
|
|
164
|
+
|
|
165
|
+
- **Cache.** Revert restores PR 1 behavior. The snapshot file at
|
|
166
|
+
`.instar/drift-verdict-cache.json` becomes orphaned but harmless
|
|
167
|
+
(no other code reads it).
|
|
168
|
+
- **Ledger.** Revert restores PR 1 behavior. The JSONL files at
|
|
169
|
+
`.instar/drift-spend-*.jsonl` are orphaned; the existing
|
|
170
|
+
snapshot/cleanup tooling still sweeps them via retention rules.
|
|
171
|
+
- **No schema migrations.** Both primitives are file-backed,
|
|
172
|
+
forward-compatible. Older agent versions that don't know about
|
|
173
|
+
these fields ignore them.
|
|
174
|
+
|
|
175
|
+
## What this PR explicitly defers
|
|
176
|
+
|
|
177
|
+
Per spec § Phase 1.4 and § Phase 1.5, these belong to drift but ship
|
|
178
|
+
in PR 3 (round runner) alongside the consumer that needs them:
|
|
179
|
+
|
|
180
|
+
- `POST /projects/:id/drift-check` HTTP endpoint with per-project
|
|
181
|
+
mutex. PR 2 ships the primitive; PR 3 ships the route + server
|
|
182
|
+
wiring (cache + ledger instantiation on `AgentServer` startup,
|
|
183
|
+
injection into the routes ctx, mutex map keyed by `projectId`).
|
|
184
|
+
- Integration into `ProjectRoundRunner.preflight()` step 10 ("Drift
|
|
185
|
+
check: load cached verdict if fresh + present + all hashes match;
|
|
186
|
+
otherwise run drift").
|
|
187
|
+
- Multi-machine "documented worst case is `N × cap` per day"
|
|
188
|
+
visibility — surfacing the per-machine spend in the digest or
|
|
189
|
+
dashboard.
|
|
190
|
+
|
|
191
|
+
## Verification
|
|
192
|
+
|
|
193
|
+
- `npm run lint` — passes (tsc + lint-no-direct-destructive).
|
|
194
|
+
- `npx vitest run tests/unit/ProjectDriftChecker.test.ts
|
|
195
|
+
tests/unit/DriftSpendLedger.test.ts
|
|
196
|
+
tests/unit/ProjectDriftCheckerCache.test.ts` — 76/76 pass.
|
|
197
|
+
- PR 1's 45 existing tests still green; the 5 new cache+ledger
|
|
198
|
+
integration tests assert the contract changes.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Side-Effects Review — PromiseBeacon UX fixes
|
|
3
|
+
Phase 4 artifact for /instar-dev pass on echo/promise-beacon-ux-fixes.
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
# Side-Effects Review — PromiseBeacon UX fixes
|
|
7
|
+
|
|
8
|
+
**Version / slug:** `promise-beacon-ux-fixes`
|
|
9
|
+
**Date:** `2026-05-12`
|
|
10
|
+
**Author:** `echo`
|
|
11
|
+
**Second-pass reviewer:** `pending`
|
|
12
|
+
|
|
13
|
+
## Summary of the change
|
|
14
|
+
|
|
15
|
+
PromiseBeacon's heartbeat templates ("still working — snapshot unchanged since last beat") gave the user no context about which promise was being watched, and heartbeats ran forever even when nothing was changing. Three commitments stacked on the same Telegram topic produced ~30+ context-free "no observable progress" messages over an evening with no way to stop them short of opening the dashboard. This change:
|
|
16
|
+
|
|
17
|
+
1. Includes a truncated form of the promise text in every heartbeat so the user can see what's being tracked.
|
|
18
|
+
2. Adds an auto-pause: after N consecutive unchanged-snapshot heartbeats (default N=12, ~2h at 10-min cadence), the beacon emits one final "auto-paused — reply 'keep watching' to resume" message and stops firing. Non-terminal; status stays `pending`.
|
|
19
|
+
3. Adds `POST /commitments/:id/resume` and a literal "keep watching" detector in the Telegram inbound path that calls it for any paused beacon on the originating topic.
|
|
20
|
+
|
|
21
|
+
Files touched:
|
|
22
|
+
- `src/monitoring/CommitmentTracker.ts` — new optional schema fields (`beaconPaused`, `beaconPausedReason`, `beaconPausedAt`, `beaconAutoPauseAfterUnchanged`, `consecutiveUnchanged`); `resume(id)` method.
|
|
23
|
+
- `src/monitoring/PromiseBeacon.ts` — promise-text excerpt in heartbeat composition; consecutive-unchanged counter; auto-pause flow; paused-state gate in `fire` and `schedule`.
|
|
24
|
+
- `src/server/routes.ts` — `POST /commitments/:id/resume`.
|
|
25
|
+
- `src/commands/server.ts` — extend `telegram.onMessageLogged` with literal "keep watching" detector that calls the resume endpoint.
|
|
26
|
+
- Tests: new files under `tests/unit/` and `tests/integration/`.
|
|
27
|
+
|
|
28
|
+
Decision points the change interacts with:
|
|
29
|
+
- PromiseBeacon's heartbeat composition path (template selection, LLM call gating).
|
|
30
|
+
- PromiseBeacon's scheduling path (timer arming, suppression checks).
|
|
31
|
+
- Commitment lifecycle (new non-terminal state combination: `pending + beaconPaused`).
|
|
32
|
+
- Telegram inbound path (new literal-match detector that triggers a server-side action).
|
|
33
|
+
|
|
34
|
+
## Decision-point inventory
|
|
35
|
+
|
|
36
|
+
- `PromiseBeacon.fire` heartbeat-template selection — **modify** — adds promise-text prefix to every template; adds auto-pause branch.
|
|
37
|
+
- `PromiseBeacon.schedule` arming guard — **modify** — skips arming when `beaconPaused`.
|
|
38
|
+
- `CommitmentTracker.resume(id)` — **add** — non-terminal flag clear + counter reset.
|
|
39
|
+
- `POST /commitments/:id/resume` — **add** — API entrypoint for resume.
|
|
40
|
+
- Telegram `onMessageLogged` literal-match — **add** — produces resume signal that calls the new endpoint.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 1. Over-block
|
|
45
|
+
|
|
46
|
+
**What legitimate inputs does this change reject that it shouldn't?**
|
|
47
|
+
|
|
48
|
+
The auto-pause has no block/allow surface — it stops outbound heartbeats from this agent, doesn't reject inputs. Strictly speaking it could "over-stop" if the user genuinely wanted updates on a long-running silent process. Mitigation: the final pause message tells the user how to resume; the resume path itself is idempotent.
|
|
49
|
+
|
|
50
|
+
The "keep watching" detector uses literal substring match (`/keep[\s-]?watching/i`). False positives:
|
|
51
|
+
- A user typing "I want to keep watching the build logs" while not intending to resume a beacon. Cost: a paused beacon resumes; user gets one more heartbeat and can re-pause by ignoring it (it'll auto-pause again after N cycles) or by withdrawing the commitment.
|
|
52
|
+
- Whichever paused beacons exist on the topic all resume simultaneously, not selectively. Cost: minor; same recovery path.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 2. Under-block
|
|
57
|
+
|
|
58
|
+
**What failure modes does this still miss?**
|
|
59
|
+
|
|
60
|
+
- The literal detector won't match paraphrases ("keep an eye on it", "stay on it", "don't give up"). Intentional: per signal-vs-authority, a brittle detector with blocking authority is forbidden. The detector is structurally simple by design. The final auto-pause message tells the user the exact phrase to use.
|
|
61
|
+
- If the user wants to resume one specific paused beacon out of many, this implementation resumes all paused beacons on the topic. A future iteration could accept "keep watching <commitment-id>".
|
|
62
|
+
- The auto-pause counter is per-commitment; multiple beacons on the same topic still produce N heartbeats each before pausing. The total heartbeat volume on a topic is not bounded by this change — only the per-beacon volume.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 3. Level-of-abstraction fit
|
|
67
|
+
|
|
68
|
+
The auto-pause counter belongs in PromiseBeacon — it's the only thing that knows the snapshot-hash and the consecutive-unchanged history. Putting it elsewhere would require lifting that state up.
|
|
69
|
+
|
|
70
|
+
The resume endpoint mirrors the existing `/deliver` and `/withdraw` endpoints on `/commitments/:id` — it's at the same layer as those, which is correct.
|
|
71
|
+
|
|
72
|
+
The Telegram "keep watching" detector lives in `server.ts`'s existing `onMessageLogged` extension because that's where every inbound message is observed once already (for PresenceProxy + TopicMemory). Adding a third small hook there is cheaper than building a new fan-out point. The detector itself is brittle by design (regex), but it only produces a signal — the resume endpoint is the authority for whether to act.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 4. Signal vs authority compliance
|
|
77
|
+
|
|
78
|
+
**Required reference:** [docs/signal-vs-authority.md](../../docs/signal-vs-authority.md)
|
|
79
|
+
|
|
80
|
+
- [ ] No — this change produces a signal consumed by an existing smart gate.
|
|
81
|
+
- [x] No — the brittle parts (counter, regex) hold no blocking authority over messages or behavior. The counter triggers a structural state transition (pause); the regex triggers a structural state transition (resume). Neither blocks or modifies an inbound user message.
|
|
82
|
+
- [ ] Yes — but the logic is a smart gate with full conversational context.
|
|
83
|
+
- [ ] ⚠️ Yes, with brittle logic.
|
|
84
|
+
|
|
85
|
+
The auto-pause counter is mechanics, not judgment (signal-vs-authority §"When this principle does NOT apply" — "Idempotency keys and dedup at the transport layer... not a judgment call — it's mechanics"). It counts identical snapshot hashes; that's a structural fact.
|
|
86
|
+
|
|
87
|
+
The "keep watching" detector is a brittle regex that calls a structural API. The API itself is symmetric with `/withdraw` — idempotent, no judgment, just toggles state. A false positive resumes a paused beacon, which costs one more heartbeat and re-pauses if still idle. No message is blocked, filtered, or rejected; no agent behavior is constrained beyond the toggle.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 5. Interactions
|
|
92
|
+
|
|
93
|
+
- **Shadowing:** The auto-pause check sits inside `PromiseBeacon.fire` after the existing suppression/ownership/quiet-hours checks. It runs only when those passed and templated-unchanged branch was taken. It does not shadow `beaconSuppressed` (which is for boot-cap / spend-cap, distinct semantics) — `beaconPaused` is a new orthogonal non-terminal flag with `resolved-by` `/resume` (not by the existing suppression-clear path).
|
|
94
|
+
- **Double-fire:** The "keep watching" detector lives inside the same `onMessageLogged` callback chain that already feeds PresenceProxy. Calling the resume endpoint enqueues a single mutate operation per matched commitment; no duplicate timers are created because `schedule()` clears any existing timer before arming.
|
|
95
|
+
- **Races:** Concurrent withdraw + resume on the same commitment: the existing `mutate(id, fn)` queue serializes writes; resume is rejected by `mutate` if the commitment is already terminal (withdrawn).
|
|
96
|
+
- **Feedback loops:** Resume → fire → snapshot unchanged → counter increments → re-pauses after N cycles. This is the intended steady state when a watched task is genuinely idle; the user can resume again. There is no autonomous loop that re-resumes itself.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 6. External surfaces
|
|
101
|
+
|
|
102
|
+
- **Other agents on the same machine:** No. PromiseBeacon state is per-agent.
|
|
103
|
+
- **Other users of the install base:** Yes — every instar agent ships with PromiseBeacon. After this change, every install gets the new heartbeat text format, the auto-pause behavior, and the Telegram resume detector. The new endpoint is additive (no behavior change for callers that don't use it).
|
|
104
|
+
- **External systems:** The Telegram messages emitted change format (now include promise text). Anyone tooling against the exact "still working — snapshot unchanged since last beat" string would break; we know of no such consumer outside test fixtures.
|
|
105
|
+
- **Persistent state:** Three new optional fields on the Commitment schema. Forward-compatible: missing fields default to "not paused, counter at zero, threshold default 12." Existing commitments load cleanly without migration.
|
|
106
|
+
- **Timing / runtime:** The 12-cycle threshold at default 10-min cadence yields ~2-hour silence before auto-pause. Tunable per-commitment via `beaconAutoPauseAfterUnchanged`. Quiet hours and boot-cap interactions unchanged.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 7. Rollback cost
|
|
111
|
+
|
|
112
|
+
Pure code change. Schema additions are optional. Revert the commit and ship the next patch — existing agents will continue to use whatever schema they had; new fields are simply ignored. No data migration. No agent state repair. Users see the previous (broken) UX again until a roll-forward fix; not a regression in correctness, only in UX.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Conclusion
|
|
117
|
+
|
|
118
|
+
The change addresses the user-reported spam directly: heartbeats now say what they're tracking, beacons stop themselves after extended silence, and the user can resume them from Telegram. The signal-vs-authority principle is honored: the brittle parts (counter, regex) only trigger structural state transitions, never block or judge messages. Schema additions are backward-compatible and rollback is a code revert. Clear to ship after Phase 5 second-pass review (required: change touches outbound messaging composition and commitment lifecycle).
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Second-pass review (if required)
|
|
123
|
+
|
|
124
|
+
**Reviewer:** echo (Phase-5 independent pass)
|
|
125
|
+
**Independent read of the artifact: concern → resolved**
|
|
126
|
+
|
|
127
|
+
Concerns raised, with resolutions:
|
|
128
|
+
|
|
129
|
+
- **Misleading resume ack on failure.** In `src/commands/server.ts` the "keep watching" handler `await`ed `fetch` to `/commitments/:id/resume` inside a `try`/`catch` that only `console.warn`'d on throw, never checked the HTTP response, and then unconditionally posted `⏳ resumed N watcher(s) on this topic.` to the user. A 404 (not paused / terminal), a 5xx, or a thrown fetch (server restart, partial outage) would all result in the user being told the beacon resumed when it did not.
|
|
130
|
+
**Fix applied:** the handler now inspects `response.ok` per call, counts successes, and tailors the ack: `⏳ resumed N watcher(s)` on full success, `⏳ resumed X of Y watchers — N didn't resume` on partial success, `⚠️ couldn't resume the watcher(s) on this topic — try again or open the dashboard` on total failure or fetch throw.
|
|
131
|
+
- **Cold-mirror write of `consecutiveUnchanged` had no consumer.** The cold mirror was written every fire but never consulted by `fire()` or the threshold check (which uses `hot.consecutiveUnchanged`). Write amplification on the CAS queue with no benefit and a footgun for a future reader.
|
|
132
|
+
**Fix applied:** dropped the per-cycle cold write. The field is now written only at the pause boundary (with a comment in `autoPause()`) and on resume (set to 0). The schema field carries a docstring marking it as a non-authoritative observability mirror — hot-state is authoritative during a live run.
|
|
133
|
+
|
|
134
|
+
Lower-priority observations (not blocking):
|
|
135
|
+
- Over-match on "keep watching": "I'll keep watching the build logs", "good — keep watching for the alert" both resume any paused beacons on the topic. Cost is bounded (one more heartbeat, re-pauses) and matches the artifact's analysis. Acceptable.
|
|
136
|
+
- `beaconSuppressed` × `beaconPaused` interaction: traced through — `fire()` early-exits on `beaconSuppressed` before reaching the auto-pause branch, so the two flags are mutually exclusive within a single fire. `schedule()` correctly rejects when either is set. No race.
|
|
137
|
+
- Backwards-compat for existing commitments: `hot.consecutiveUnchanged` initializes to 0 in `loadHotState`'s defaults block (not undefined/NaN), and `beaconAutoPauseAfterUnchanged ?? defaultAutoPauseAfterUnchanged` falls back cleanly. Confirmed safe.
|
|
138
|
+
- Spec line 161 ("suggest, don't auto-close"): this change is auto-PAUSE (`status` stays `pending`, resumable, no delivery semantics). Does not violate.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Evidence pointers
|
|
143
|
+
|
|
144
|
+
- Originating user report: Telegram topic 9429 ("progress update bug"), 2026-05-12.
|
|
145
|
+
- Withdrawn runaway commitments providing the live reproduction: CMT-381, CMT-382, CMT-383 on topic 9210.
|
|
146
|
+
- Spec extended (not violated): docs/specs/PROMISE-BEACON-SPEC.md (auto-pause is a new non-terminal suppression; auto-close-on-reply explicitly NOT added per spec line 161).
|