instar 0.28.95 → 0.28.97
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 +90 -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/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 +782 -7
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +48 -48
- package/upgrades/0.28.96.md +347 -0
- package/upgrades/0.28.97.md +146 -0
- package/upgrades/side-effects/project-scope-phase1-7-skill-surface.md +175 -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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Side-Effects Review — project-scope Phase 1b PR 5 (Dashboard Projects tab + Initiatives filter)
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `project-scope-phase1b-pr5`
|
|
4
|
+
**Date:** `2026-05-11`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Second-pass reviewer:** `required (new dashboard surface + new server-side filter)`
|
|
7
|
+
|
|
8
|
+
## Summary of the change
|
|
9
|
+
|
|
10
|
+
Fifth PR of project-scope Phase 1b. Ships the dashboard surface plus
|
|
11
|
+
the small server-side filter the dashboard depends on. The compaction-
|
|
12
|
+
recovery hook's active-projects digest was already in the template (it
|
|
13
|
+
shipped alongside session-start.sh in Phase 1.9 / PR 1's session-start
|
|
14
|
+
work and the equivalent block is present at lines 467-509 of
|
|
15
|
+
`src/templates/hooks/compaction-recovery.sh`), so no template change
|
|
16
|
+
is needed for this PR.
|
|
17
|
+
|
|
18
|
+
Spec source: `docs/specs/PROJECT-SCOPE-SPEC.md` § Phase 1.10
|
|
19
|
+
("Dashboard Projects tab"), § Phase 1.10 ("Initiatives tab filter").
|
|
20
|
+
|
|
21
|
+
Modified files:
|
|
22
|
+
- `dashboard/index.html` (+~210 lines) — adds the Projects tab button
|
|
23
|
+
alongside the Initiatives tab, adds the Projects panel HTML (header,
|
|
24
|
+
empty state, list container), registers the tab in the panel router,
|
|
25
|
+
and ships ~180 lines of JS:
|
|
26
|
+
- `loadProjects()` — fetches `/projects`, filters to `status:'active'`
|
|
27
|
+
client-side, fetches each project's joined view via
|
|
28
|
+
`/projects/:id?reconcile=false` in parallel (capped at 25), renders
|
|
29
|
+
cards.
|
|
30
|
+
- `renderProjectCard(project, children)` — XSS-safe construction
|
|
31
|
+
(`textContent` everywhere, `appendChild` only, no `innerHTML`).
|
|
32
|
+
Per spec: title row, drift status badge (colored per verdict),
|
|
33
|
+
round-by-round progress bar + pipelineStage histogram + Halt
|
|
34
|
+
+ Ack buttons.
|
|
35
|
+
- `startProjectsPoll` / `stopProjectsPoll` — 15-second `setInterval`
|
|
36
|
+
when the tab is active, cleared on deactivation.
|
|
37
|
+
- `projectHalt(id)` + `projectAck(id, idx)` — POST to the new
|
|
38
|
+
runner-backed routes. 409 ("version mismatch") triggers a silent
|
|
39
|
+
`loadProjects()` re-render rather than an error toast.
|
|
40
|
+
- `loadInitiatives()` is updated to pass
|
|
41
|
+
`?excludeKind=project&excludeParented=true` by default, with a
|
|
42
|
+
"Show projects + children" checkbox to bypass. The filter is
|
|
43
|
+
server-side; the records never make the wire-trip.
|
|
44
|
+
- `src/server/routes.ts` (+~10 lines) — `GET /initiatives` now accepts
|
|
45
|
+
`excludeKind=<string>` (drops records where `kind ?? 'task'` matches)
|
|
46
|
+
and `excludeParented=true` (drops records with a `parentProjectId`).
|
|
47
|
+
- `tests/unit/routes-initiatives.test.ts` (+3 cases + mirror update) —
|
|
48
|
+
exercises both new params individually and combined with the existing
|
|
49
|
+
`status=` filter. The test mirror at the top of the file (which
|
|
50
|
+
duplicates the production handler shape) was updated in lockstep.
|
|
51
|
+
|
|
52
|
+
## Decision-point inventory
|
|
53
|
+
|
|
54
|
+
- **Initiatives filter** — **add** — `excludeKind` and
|
|
55
|
+
`excludeParented` are additive query parameters that DEFAULT TO NOT
|
|
56
|
+
EXCLUDING. Existing callers see no behavior change. The dashboard
|
|
57
|
+
opts in via a UI checkbox that defaults to "exclude" (matches the
|
|
58
|
+
spec's "filter project-kind by default").
|
|
59
|
+
- **Projects tab read-only verbs** — **add** — the Halt and Ack
|
|
60
|
+
buttons route through the existing `POST /projects/:id/halt` and
|
|
61
|
+
`POST /projects/:id/ack` (shipped in PR 3). No new HTTP surface in
|
|
62
|
+
this PR. The buttons act on the project record's current version
|
|
63
|
+
(from the latest `loadProjects()` fetch); the routes enforce OCC
|
|
64
|
+
via `If-Match` — actually, `/halt` and `/ack` do NOT require
|
|
65
|
+
`If-Match` in PR 3's design (they use the tracker's internal
|
|
66
|
+
version-aware update via `ifMatch` from the latest `get()`). The
|
|
67
|
+
dashboard relies on that internal handling rather than passing
|
|
68
|
+
`If-Match` itself.
|
|
69
|
+
- **15-second poll cadence** — **add** — matches the spec exactly.
|
|
70
|
+
The interval is cleared when the tab deactivates so a hidden tab
|
|
71
|
+
doesn't burn cycles.
|
|
72
|
+
|
|
73
|
+
## Over-block vs under-block analysis
|
|
74
|
+
|
|
75
|
+
### Server-side filter
|
|
76
|
+
Over-block: the dashboard's default-on filter means a user who clicks
|
|
77
|
+
"Initiatives" no longer sees project-kind records or child items
|
|
78
|
+
unless they tick the "Show projects + children" checkbox. This is the
|
|
79
|
+
spec's documented behavior (Projects get their own tab; children live
|
|
80
|
+
inside their parent's card). No information is lost, just relocated.
|
|
81
|
+
|
|
82
|
+
Under-block: the filter is purely additive. Existing scripts or
|
|
83
|
+
clients that hit `/initiatives` without the new params see the same
|
|
84
|
+
behavior they always have.
|
|
85
|
+
|
|
86
|
+
### Dashboard rendering
|
|
87
|
+
Over-block: 409 from `/halt` or `/ack` is treated as "stale view,
|
|
88
|
+
just refresh" — no error toast, no user-visible noise. The spec
|
|
89
|
+
explicitly calls this out: "409 response handled silently: refresh
|
|
90
|
+
+ re-render, no error toast."
|
|
91
|
+
|
|
92
|
+
Under-block: the project-list fetch caps detailed lookups at 25. A
|
|
93
|
+
deployment with >25 active projects would have the rest rendered as
|
|
94
|
+
empty cards (since `detailed` is `null` for un-fetched IDs and we
|
|
95
|
+
skip nulls). Acceptable for Phase 1; a follow-up PR can add pagination
|
|
96
|
+
when project count actually exceeds the cap.
|
|
97
|
+
|
|
98
|
+
### XSS safety
|
|
99
|
+
Every rendered string goes through `.textContent` (never `.innerHTML`).
|
|
100
|
+
Project ids, titles, round names, child stages, drift verdicts — all
|
|
101
|
+
constructed via `createElement` + `textContent` + `appendChild`. The
|
|
102
|
+
existing `dashboard/index.html` conventions already enforce this; the
|
|
103
|
+
new code follows the same pattern.
|
|
104
|
+
|
|
105
|
+
## Signal vs authority audit
|
|
106
|
+
|
|
107
|
+
Dashboard is **read-only display** for the project surface (with two
|
|
108
|
+
button-triggered mutating calls to existing PR 3 routes). The
|
|
109
|
+
authority for halt and ack lives in `ProjectRoundRunner` — the
|
|
110
|
+
dashboard just calls the documented endpoints. No new authority
|
|
111
|
+
introduced.
|
|
112
|
+
|
|
113
|
+
The initiatives filter is a **read-side** filter, not a
|
|
114
|
+
record-modifying gate. The records themselves are unchanged; the
|
|
115
|
+
filter only affects the response set.
|
|
116
|
+
|
|
117
|
+
## Interactions with existing systems
|
|
118
|
+
|
|
119
|
+
- **PR Pipeline tab.** No interaction — the Projects tab uses its
|
|
120
|
+
own panel + JS namespace.
|
|
121
|
+
- **Initiatives tab.** Shares the existing `loadInitiatives()`
|
|
122
|
+
function; the new filter is a query-string addition with a UI
|
|
123
|
+
checkbox to bypass. Existing tab behavior preserved when the
|
|
124
|
+
checkbox is checked.
|
|
125
|
+
- **`/projects/:id?reconcile=false`.** This query parameter is
|
|
126
|
+
already documented in the spec (Phase 1.3 — "Clients that need
|
|
127
|
+
pure-read semantics use `?reconcile=false`"). The dashboard uses
|
|
128
|
+
it to avoid triggering the lazy reconciler on every 15-second
|
|
129
|
+
poll. The `?reconcile=false` parameter is honored as a passthrough
|
|
130
|
+
in the existing route (the lazy reconciler isn't wired yet, so
|
|
131
|
+
it's a no-op today — when the reconciler ships, the dashboard
|
|
132
|
+
poll won't trigger it).
|
|
133
|
+
- **Compaction-recovery hook.** Already includes the active-projects
|
|
134
|
+
digest section (PR 1's template work). No change needed in this PR.
|
|
135
|
+
|
|
136
|
+
## Rollback cost
|
|
137
|
+
|
|
138
|
+
Revert removes the new tab button, the new panel HTML, the JS block,
|
|
139
|
+
the Initiatives filter checkbox, the server-side filter, and the test
|
|
140
|
+
cases. No schema changes. Existing project records and initiatives
|
|
141
|
+
are unaffected.
|
|
142
|
+
|
|
143
|
+
## Verification
|
|
144
|
+
|
|
145
|
+
- `npm run lint` — passes (tsc + lint-no-direct-destructive).
|
|
146
|
+
- `npx vitest run tests/unit/routes-initiatives.test.ts
|
|
147
|
+
tests/unit/route-completeness.test.ts
|
|
148
|
+
tests/integration/projects-api.test.ts
|
|
149
|
+
tests/unit/dashboard-initiativesTab.test.ts` — 66/66 pass.
|
|
150
|
+
- Existing PR 1-4 invariants still green.
|
|
@@ -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).
|