instar 0.28.94 → 0.28.96
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/dashboard/index.html +249 -2
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +163 -1
- package/dist/commands/server.js.map +1 -1
- package/dist/core/MachineHeartbeat.d.ts +94 -0
- package/dist/core/MachineHeartbeat.d.ts.map +1 -0
- package/dist/core/MachineHeartbeat.js +155 -0
- package/dist/core/MachineHeartbeat.js.map +1 -0
- package/dist/core/ProjectAutoAdvancePoller.d.ts +107 -0
- package/dist/core/ProjectAutoAdvancePoller.d.ts.map +1 -0
- package/dist/core/ProjectAutoAdvancePoller.js +176 -0
- package/dist/core/ProjectAutoAdvancePoller.js.map +1 -0
- package/dist/core/ProjectRoundCompleteMessage.d.ts +158 -0
- package/dist/core/ProjectRoundCompleteMessage.d.ts.map +1 -0
- package/dist/core/ProjectRoundCompleteMessage.js +253 -0
- package/dist/core/ProjectRoundCompleteMessage.js.map +1 -0
- package/dist/core/ProjectRoundExecution.d.ts +111 -0
- package/dist/core/ProjectRoundExecution.d.ts.map +1 -0
- package/dist/core/ProjectRoundExecution.js +359 -0
- package/dist/core/ProjectRoundExecution.js.map +1 -0
- package/dist/core/ProjectRoundLock.d.ts +67 -0
- package/dist/core/ProjectRoundLock.d.ts.map +1 -0
- package/dist/core/ProjectRoundLock.js +161 -0
- package/dist/core/ProjectRoundLock.js.map +1 -0
- package/dist/core/ProjectRoundRunner.d.ts +146 -0
- package/dist/core/ProjectRoundRunner.d.ts.map +1 -0
- package/dist/core/ProjectRoundRunner.js +371 -0
- package/dist/core/ProjectRoundRunner.js.map +1 -0
- package/dist/core/ProjectRoundWorktrees.d.ts +57 -0
- package/dist/core/ProjectRoundWorktrees.d.ts.map +1 -0
- package/dist/core/ProjectRoundWorktrees.js +111 -0
- package/dist/core/ProjectRoundWorktrees.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/AgentServer.d.ts +12 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +3 -0
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/routes.d.ts +19 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +610 -7
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +47 -47
- package/upgrades/0.28.95.md +55 -0
- package/upgrades/0.28.96.md +347 -0
- package/upgrades/side-effects/project-scope-phase1b-connect-the-dots.md +184 -0
- package/upgrades/side-effects/project-scope-phase1b-pr3.md +228 -0
- package/upgrades/side-effects/project-scope-phase1b-pr4.md +198 -0
- package/upgrades/side-effects/project-scope-phase1b-pr5.md +150 -0
- package/upgrades/side-effects/project-scope-phase1b-pr6.md +136 -0
- package/upgrades/side-effects/project-scope-phase1b-pr7.md +175 -0
- package/upgrades/side-effects/promise-beacon-ux-fixes.md +146 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Side-Effects Review — project-scope Phase 1b PR 6 (Tone-gated round-complete message + delivery)
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `project-scope-phase1b-pr6`
|
|
4
|
+
**Date:** `2026-05-11`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Second-pass reviewer:** `required (new outbound-message template + new disk-backed idempotency surface)`
|
|
7
|
+
|
|
8
|
+
## Summary of the change
|
|
9
|
+
|
|
10
|
+
Sixth PR of project-scope Phase 1b. Ships the two final primitives the
|
|
11
|
+
autonomous run loop will need to emit round-complete digests safely:
|
|
12
|
+
|
|
13
|
+
- `formatRoundCompleteMessage(input)` — pure template function. Enforces
|
|
14
|
+
required-field PRESENCE (not non-emptiness, per spec § Phase 1.8 —
|
|
15
|
+
the gate "never silently rejects on a legitimate halt"). Returns
|
|
16
|
+
`{ok:true, message, idempotencyKey}` or `{ok:false, missingFields}`.
|
|
17
|
+
- `RoundCompleteDeliveryHelper` — retry + idempotency wrapper around
|
|
18
|
+
a caller-provided send function. 3-attempt exponential backoff
|
|
19
|
+
(1s, 2s, 4s defaults). Records the `(projectId, roundIndex,
|
|
20
|
+
eventKind, projectVersion)` key in `.instar/local/round-complete-sent.json`
|
|
21
|
+
after the first successful send so tone-gate retries don't produce
|
|
22
|
+
duplicates. On permanent failure (all retries exhausted, or first
|
|
23
|
+
non-transient response), the caller's `onPermanentFail` runs.
|
|
24
|
+
|
|
25
|
+
Nothing wires these up to an actual round-complete event yet — the
|
|
26
|
+
autonomous run loop is the consumer. PR 6 ships the primitives so the
|
|
27
|
+
run loop in a follow-up PR doesn't fork either of them.
|
|
28
|
+
|
|
29
|
+
Spec source: `docs/specs/PROJECT-SCOPE-SPEC.md` § Phase 1.8.
|
|
30
|
+
|
|
31
|
+
New files:
|
|
32
|
+
- `src/core/ProjectRoundCompleteMessage.ts` (~290 lines) — the
|
|
33
|
+
template + delivery helper described above. Pure ESM, no extra deps.
|
|
34
|
+
- `tests/unit/ProjectRoundCompleteMessage.test.ts` (20 cases) —
|
|
35
|
+
template required-field gate (all 9 required + halt-flavor whatHalted),
|
|
36
|
+
empty-string accepted, root-cause-default omitted, override link
|
|
37
|
+
rendered, evidence-cap honoured, idempotency-key permutations,
|
|
38
|
+
delivery first-attempt success, dedup short-circuit, transient retry
|
|
39
|
+
to success, non-transient bail with fallback, all-transient exhaust
|
|
40
|
+
with fallback, on-disk persistence across instances, no-record on
|
|
41
|
+
total failure, template-reject suppresses send.
|
|
42
|
+
|
|
43
|
+
## Decision-point inventory
|
|
44
|
+
|
|
45
|
+
- **Template required-field gate** (`formatRoundCompleteMessage`) —
|
|
46
|
+
**add** — rejects with `{ok:false, missingFields}` when any of the
|
|
47
|
+
9 required fields is undefined / null / non-array (for `evidenceCited`)
|
|
48
|
+
/ non-integer (for `roundIndex`/`projectVersion`). Halt-flavor events
|
|
49
|
+
additionally require `whatHalted` to be a string. Empty strings are
|
|
50
|
+
ACCEPTED — the spec explicitly says presence is what matters.
|
|
51
|
+
- **Idempotency-key dedup** (`RoundCompleteDeliveryHelper.sendOnce`) —
|
|
52
|
+
**add** — recorded only after a confirmed send. If all attempts
|
|
53
|
+
failed, the key is NOT recorded, so a subsequent retry with the
|
|
54
|
+
same input will be allowed to call `send` again. Bounded to 1000
|
|
55
|
+
recent keys so the dedup file doesn't grow unbounded.
|
|
56
|
+
- **Fallback firing** (`onPermanentFail`) — **add** — fires once when
|
|
57
|
+
all retries are exhausted OR a non-transient failure is reported.
|
|
58
|
+
Caller decides whether the fallback path is attention-queue,
|
|
59
|
+
audit-log, `awaitingUser` population, or all three. The PR 6
|
|
60
|
+
delivery helper just signals "we couldn't deliver — your turn."
|
|
61
|
+
|
|
62
|
+
## Over-block vs under-block analysis
|
|
63
|
+
|
|
64
|
+
### Template gate
|
|
65
|
+
Over-block: an `evidenceCited: []` (empty array) is accepted —
|
|
66
|
+
required-field PRESENCE includes "array exists, possibly empty." The
|
|
67
|
+
gate would reject `evidenceCited: undefined`. Matches spec.
|
|
68
|
+
|
|
69
|
+
Under-block: there's no length cap on individual string fields. A
|
|
70
|
+
30,000-char `whatLanded` would render in full. Acceptable: outbound
|
|
71
|
+
content quality is the tone-gate's job (MessagingToneGate already
|
|
72
|
+
flags excessive verbosity). The template just builds the string.
|
|
73
|
+
|
|
74
|
+
### Delivery helper
|
|
75
|
+
Over-block: a non-transient failure bails immediately rather than
|
|
76
|
+
retrying. Matches the spec's implicit "permanent failure → fallback"
|
|
77
|
+
semantics — retrying a 401 / 400 won't help.
|
|
78
|
+
|
|
79
|
+
Under-block: dedup is keyed on `projectVersion`. If the project record
|
|
80
|
+
is mutated between send attempts (which it normally is — the
|
|
81
|
+
post-send tracker.update bumps version), a second attempt would have
|
|
82
|
+
a different key and re-send. This is intentional — the version bump
|
|
83
|
+
is what makes "same round, different state" distinguishable from
|
|
84
|
+
"same round, same state, duplicate send."
|
|
85
|
+
|
|
86
|
+
## Signal vs authority audit
|
|
87
|
+
|
|
88
|
+
The template is a pure function — no signal/authority overlap. The
|
|
89
|
+
delivery helper has authority only over its own idempotency ring; it
|
|
90
|
+
delegates transport entirely to the caller's `send` function.
|
|
91
|
+
|
|
92
|
+
## Interactions with existing systems
|
|
93
|
+
|
|
94
|
+
- **`MessagingToneGate`.** The caller (the autonomous run loop, not
|
|
95
|
+
shipped yet) is responsible for routing the formatted message
|
|
96
|
+
through the tone gate before calling `helper.sendOnce`. The helper
|
|
97
|
+
does NOT call the tone gate directly — keeps the boundary clean
|
|
98
|
+
and the helper unit-testable.
|
|
99
|
+
- **TelegramAdapter / Slack / WhatsApp.** None used here. The caller
|
|
100
|
+
supplies the `send` function.
|
|
101
|
+
- **`.instar/local/`.** The dedup file lives at
|
|
102
|
+
`.instar/local/round-complete-sent.json` — machine-local, NOT
|
|
103
|
+
git-synced (same convention as the round-runner lock and the drift
|
|
104
|
+
ledger lock). Two machines won't dedupe each other's sends, which
|
|
105
|
+
is correct: each machine should make its own send decision and the
|
|
106
|
+
recipient platforms (Telegram, Slack) handle their own dedup.
|
|
107
|
+
- **`SafeFsExecutor`.** Used for test cleanup; the in-class
|
|
108
|
+
persistence uses tmp+rename atomic writes (matches the pattern in
|
|
109
|
+
`MachineHeartbeat`).
|
|
110
|
+
|
|
111
|
+
## Rollback cost
|
|
112
|
+
|
|
113
|
+
Revert deletes `src/core/ProjectRoundCompleteMessage.ts` and the
|
|
114
|
+
test file. The on-disk dedup file becomes orphaned but harmless.
|
|
115
|
+
No schema migrations.
|
|
116
|
+
|
|
117
|
+
## What this PR explicitly defers (to PR 7+)
|
|
118
|
+
|
|
119
|
+
- **Wiring into the autonomous run loop.** The run loop is the
|
|
120
|
+
intended consumer; it ships separately. Until then, no caller
|
|
121
|
+
invokes `formatRoundCompleteMessage` or `sendOnce`.
|
|
122
|
+
- **Attention queue / audit log / `awaitingUser` integration.** The
|
|
123
|
+
fallback callback is caller-provided; PR 6 only fires it. The
|
|
124
|
+
concrete callback that wires those three downstream channels
|
|
125
|
+
ships with the run loop.
|
|
126
|
+
- **MessagingToneGate routing.** Same — the caller threads the
|
|
127
|
+
message through the gate; the helper accepts the formatted text
|
|
128
|
+
as-is.
|
|
129
|
+
|
|
130
|
+
## Verification
|
|
131
|
+
|
|
132
|
+
- `npm run lint` — passes (tsc + lint-no-direct-destructive).
|
|
133
|
+
- `npx vitest run tests/unit/ProjectRoundCompleteMessage.test.ts` —
|
|
134
|
+
20/20 pass.
|
|
135
|
+
- Existing PR 1-5 invariants unaffected (no shared code touched
|
|
136
|
+
outside the new file).
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Side-Effects Review — project-scope Phase 1b PR 7 (Autonomous run loop)
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `project-scope-phase1b-pr7`
|
|
4
|
+
**Date:** `2026-05-11`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Second-pass reviewer:** `required (new subprocess management + process-group signaling + filesystem allocation under target repo)`
|
|
7
|
+
|
|
8
|
+
## Summary of the change
|
|
9
|
+
|
|
10
|
+
Final PR of project-scope Phase 1b. Ships the autonomous run loop the
|
|
11
|
+
spec § Phase 1.5 names (steps 1-11), wired against the lock + preflight
|
|
12
|
+
+ runner primitives that landed in PRs 3-6:
|
|
13
|
+
|
|
14
|
+
- `ProjectRoundWorktrees` — lazy worktree allocator under
|
|
15
|
+
`<targetRepoPath>/.worktrees/<projectId>/<roundIndex>/<itemId>`.
|
|
16
|
+
Appends `.worktrees/` to `.git/info/exclude` on first call so the
|
|
17
|
+
namespace doesn't pollute `git status`.
|
|
18
|
+
- `runRound(input, deps)` — the run loop. Acquires the lock, lazily
|
|
19
|
+
allocates the first worktree, spawns the autonomous child in a
|
|
20
|
+
detached process group, polls the project record every 60 seconds.
|
|
21
|
+
On mid-round mutation to `round.itemIds`, SIGTERMs the child's
|
|
22
|
+
process group (5s grace, then SIGKILL) and relaunches with the
|
|
23
|
+
new stop condition. On the child's natural exit, verifies per-item
|
|
24
|
+
artifacts via the caller-injected `verifyMergedItems` and sets
|
|
25
|
+
`round.status` to `complete` | `partially-complete`. On
|
|
26
|
+
`haltedAt` set mid-run, kills the child and returns `halted`.
|
|
27
|
+
Three-attempt resume cap on transient non-zero exits before
|
|
28
|
+
`failed`.
|
|
29
|
+
|
|
30
|
+
Spec source: `docs/specs/PROJECT-SCOPE-SPEC.md` § Phase 1.5.
|
|
31
|
+
|
|
32
|
+
New files:
|
|
33
|
+
- `src/core/ProjectRoundWorktrees.ts` (~140 lines) — pathFor,
|
|
34
|
+
allocate, prune, remove, ensureExcludeEntry helpers. `SafeGitExecutor`
|
|
35
|
+
for all git invocations.
|
|
36
|
+
- `src/core/ProjectRoundExecution.ts` (~340 lines) — the run loop
|
|
37
|
+
itself, plus `verifyMergedItemsViaGit` helper for callers that want
|
|
38
|
+
the real `git merge-base --is-ancestor` verifier instead of a stub.
|
|
39
|
+
- `tests/unit/ProjectRoundWorktrees.test.ts` (8 cases) —
|
|
40
|
+
path-shape, allocate-creates, refuse-on-existing, idempotent
|
|
41
|
+
exclude entry, prune-on-empty, remove-on-missing,
|
|
42
|
+
remove-cleans-up, allocate-with-refuseExisting-false.
|
|
43
|
+
- `tests/unit/ProjectRoundExecution.test.ts` (8 cases) —
|
|
44
|
+
lock-held-failure, first-pass-complete (no spawn), natural-exit
|
|
45
|
+
full-verification, natural-exit subset → partially-complete,
|
|
46
|
+
halt-mid-run, dynamic stop revalidation (itemIds mutation
|
|
47
|
+
triggers relaunch), worktree allocated, exclude entry written.
|
|
48
|
+
|
|
49
|
+
## Decision-point inventory
|
|
50
|
+
|
|
51
|
+
- **Spawn in detached process group** (`spawnAutonomousChild`) —
|
|
52
|
+
**add** — `detached: true` per Node `child_process.spawn`. The
|
|
53
|
+
child gets its own process group; the runner is NOT a member.
|
|
54
|
+
`process.kill(-pid, signal)` (negative PID = group target) reaps
|
|
55
|
+
the child's entire process tree (compilers, test runners spawned
|
|
56
|
+
by the autonomous skill) without reaping the runner. Spec § Phase
|
|
57
|
+
1.5 step 5 calls this out explicitly.
|
|
58
|
+
- **Worktree allocation** — **add** — lazy on first use. Refuses
|
|
59
|
+
by default if path exists (spec semantics); callers can pass
|
|
60
|
+
`refuseExisting: false` to override (used on resume paths).
|
|
61
|
+
- **Per-step halt checkpoint** — **add** — before every iteration of
|
|
62
|
+
the inner relaunch loop, re-reads `round.haltedAt` from the tracker.
|
|
63
|
+
Set → SIGTERM the child, return `halted`.
|
|
64
|
+
- **Stop-condition verifier dependency injection** — **add** —
|
|
65
|
+
`verifyMergedItems` is required input. Default (used when no
|
|
66
|
+
override) is a no-op set (returns empty set), so production callers
|
|
67
|
+
MUST pass a real verifier. Tests pass stubs. The real production
|
|
68
|
+
verifier is `verifyMergedItemsViaGit`, exported alongside the run
|
|
69
|
+
loop.
|
|
70
|
+
- **Resume cap** — **add** — 3 transient non-zero exits before
|
|
71
|
+
`failed`. Spec § Phase 1.5 step 11.
|
|
72
|
+
|
|
73
|
+
## Over-block vs under-block analysis
|
|
74
|
+
|
|
75
|
+
### Process group signaling
|
|
76
|
+
Over-block: SIGTERM-grace-then-SIGKILL of the WHOLE process group
|
|
77
|
+
will reap any descendant process the autonomous skill spawned —
|
|
78
|
+
compilers, test runners, lockfile holders. This is intentional and
|
|
79
|
+
matches the spec.
|
|
80
|
+
|
|
81
|
+
Under-block: if the autonomous child somehow detaches FURTHER
|
|
82
|
+
(creates its own grandchild group), that group escapes. Acceptable
|
|
83
|
+
edge case — the autonomous skill is in-house and doesn't do that;
|
|
84
|
+
we'd notice in observability before it becomes a leak.
|
|
85
|
+
|
|
86
|
+
### Worktree allocation
|
|
87
|
+
Over-block: a stale worktree directory under `.worktrees/` from a
|
|
88
|
+
crashed previous run causes `allocate()` to throw. Callers (the
|
|
89
|
+
runner's first-item path) pass `refuseExisting: false` so the
|
|
90
|
+
allocator returns the existing path instead. Trade-off: a crashed
|
|
91
|
+
run's stale worktree is silently reused. Acceptable: `prune()` runs
|
|
92
|
+
on every successful round completion, and `git worktree add` would
|
|
93
|
+
itself complain if the worktree is corrupt.
|
|
94
|
+
|
|
95
|
+
Under-block: `prune()` runs `git worktree prune` against the whole
|
|
96
|
+
repo, not just our namespace. Worktrees registered by OTHER tools
|
|
97
|
+
(unrelated to project-scope) that have become stale will ALSO be
|
|
98
|
+
pruned. Acceptable: `git worktree prune` only removes administrative
|
|
99
|
+
entries pointing at missing paths — it does not delete live worktree
|
|
100
|
+
directories.
|
|
101
|
+
|
|
102
|
+
### Run loop
|
|
103
|
+
Over-block: a long-running autonomous child that takes 4 hours to
|
|
104
|
+
complete isn't capped here. Acceptable — the autonomous skill has
|
|
105
|
+
its own duration cap (stop hook); the run loop just watches for exit.
|
|
106
|
+
|
|
107
|
+
Under-block: a child that hangs without exiting AND without itemIds
|
|
108
|
+
changing AND without `haltedAt` being set sits forever. Acceptable
|
|
109
|
+
for this PR — the auto-advance poller's `LOCK_HELD` rejection will
|
|
110
|
+
eventually surface the stuck round in telemetry, and the user can
|
|
111
|
+
`POST /halt`.
|
|
112
|
+
|
|
113
|
+
## Signal vs authority audit
|
|
114
|
+
|
|
115
|
+
The run loop is **authority** for round-state transitions
|
|
116
|
+
(`complete` / `partially-complete` / `failed`). The decision is
|
|
117
|
+
deterministic: the caller-provided `verifyMergedItems` (a signal
|
|
118
|
+
source) returns a set; the run loop counts matched/unmatched and
|
|
119
|
+
sets `round.status` accordingly. The runner never sets a verdict
|
|
120
|
+
the verifier didn't support.
|
|
121
|
+
|
|
122
|
+
## Interactions with existing systems
|
|
123
|
+
|
|
124
|
+
- **`ProjectRoundLock`** — acquired at step 1, released at step 8 in
|
|
125
|
+
the finally block (always releases even on throws).
|
|
126
|
+
- **`InitiativeTracker`** — single source of truth for `round.itemIds`,
|
|
127
|
+
`round.haltedAt`, `round.status`. Polled every `pollIntervalMs`;
|
|
128
|
+
mutated on outcome via `tracker.update(...)` with `ifMatch`. OCC
|
|
129
|
+
races are silently ignored at outcome-recording time (next read
|
|
130
|
+
will see the conflicting writer's state).
|
|
131
|
+
- **`SafeGitExecutor`** — every git invocation (worktree add / prune /
|
|
132
|
+
remove, merge-base --is-ancestor) routes through the safe executor.
|
|
133
|
+
No raw `execFileSync('git', ...)` anywhere.
|
|
134
|
+
- **`ProjectRoundRunner.preflight`** (PR 3) — the run loop assumes
|
|
135
|
+
preflight has passed. It does NOT re-run preflight at step 1; the
|
|
136
|
+
caller is expected to do it (auto-advance poller does; /project
|
|
137
|
+
run-round skill does).
|
|
138
|
+
- **`ProjectAutoAdvancePoller`** (PR 4) — the poller calls
|
|
139
|
+
`preflight` and then in PR 7+ can call `runRound` directly. PR 4
|
|
140
|
+
bookkeeps unacked count + clears autoAdvanceAt; the run loop is
|
|
141
|
+
the actual work-doer that follows.
|
|
142
|
+
- **`RoundCompleteDeliveryHelper`** (PR 6) — the run loop does NOT
|
|
143
|
+
invoke the delivery helper. That's a caller concern (the poller
|
|
144
|
+
or the skill consumes the run-loop result and constructs the
|
|
145
|
+
message). Keeps the run loop's responsibilities tight.
|
|
146
|
+
|
|
147
|
+
## Rollback cost
|
|
148
|
+
|
|
149
|
+
Revert deletes `src/core/ProjectRoundWorktrees.ts`,
|
|
150
|
+
`src/core/ProjectRoundExecution.ts`, the two test files. Existing
|
|
151
|
+
worktree directories under `<targetRepoPath>/.worktrees/...` become
|
|
152
|
+
orphaned but harmless. `git worktree prune` from a subsequent
|
|
153
|
+
unrelated run cleans up the administrative entries. No schema
|
|
154
|
+
changes.
|
|
155
|
+
|
|
156
|
+
## What this PR explicitly defers
|
|
157
|
+
|
|
158
|
+
- **Wiring the poller / skill to call `runRound`.** PR 4's poller
|
|
159
|
+
currently only bookkeeps; calling `runRound` is a small wiring
|
|
160
|
+
task in a follow-up PR (the runner instance is already in the
|
|
161
|
+
ctx; the poller just needs to invoke it).
|
|
162
|
+
- **`GET /projects/:id/next` real implementation.** Still 501.
|
|
163
|
+
- **Lazy merged-state reconciler on `GET /projects/:id`.** Spec
|
|
164
|
+
Phase 1.5 — the read-may-mutate behavior with the ≤3-children-per-GET
|
|
165
|
+
cap. Not implemented in PR 7; the
|
|
166
|
+
`verifyMergedItemsViaGit` helper here is the building block the
|
|
167
|
+
reconciler can call into in a follow-up.
|
|
168
|
+
|
|
169
|
+
## Verification
|
|
170
|
+
|
|
171
|
+
- `npm run lint` — passes (tsc + lint-no-direct-destructive).
|
|
172
|
+
- `npx vitest run tests/unit/ProjectRoundExecution.test.ts
|
|
173
|
+
tests/unit/ProjectRoundWorktrees.test.ts` — 16/16 pass.
|
|
174
|
+
- Existing PR 1-6 invariants unaffected (the run loop is a new
|
|
175
|
+
module; no shared-code mutations).
|
|
@@ -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).
|