instar 1.3.790 → 1.3.792

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.
Files changed (37) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +3 -0
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/config/ConfigDefaults.d.ts.map +1 -1
  5. package/dist/config/ConfigDefaults.js +4 -0
  6. package/dist/config/ConfigDefaults.js.map +1 -1
  7. package/dist/core/types.d.ts +11 -0
  8. package/dist/core/types.d.ts.map +1 -1
  9. package/dist/core/types.js.map +1 -1
  10. package/dist/monitoring/AgentWorktreeReaper.d.ts +19 -0
  11. package/dist/monitoring/AgentWorktreeReaper.d.ts.map +1 -1
  12. package/dist/monitoring/AgentWorktreeReaper.js +46 -0
  13. package/dist/monitoring/AgentWorktreeReaper.js.map +1 -1
  14. package/dist/monitoring/GreenPrAutoMerger.d.ts +54 -0
  15. package/dist/monitoring/GreenPrAutoMerger.d.ts.map +1 -1
  16. package/dist/monitoring/GreenPrAutoMerger.js +97 -1
  17. package/dist/monitoring/GreenPrAutoMerger.js.map +1 -1
  18. package/dist/monitoring/agentWorktreeGit.d.ts.map +1 -1
  19. package/dist/monitoring/agentWorktreeGit.js +29 -0
  20. package/dist/monitoring/agentWorktreeGit.js.map +1 -1
  21. package/dist/monitoring/greenPrAutomergeWiring.d.ts +8 -1
  22. package/dist/monitoring/greenPrAutomergeWiring.d.ts.map +1 -1
  23. package/dist/monitoring/greenPrAutomergeWiring.js +17 -7
  24. package/dist/monitoring/greenPrAutomergeWiring.js.map +1 -1
  25. package/dist/monitoring/greenPrLogic.d.ts +53 -0
  26. package/dist/monitoring/greenPrLogic.d.ts.map +1 -1
  27. package/dist/monitoring/greenPrLogic.js +70 -0
  28. package/dist/monitoring/greenPrLogic.js.map +1 -1
  29. package/dist/server/routes.d.ts.map +1 -1
  30. package/dist/server/routes.js +5 -0
  31. package/dist/server/routes.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/data/builtin-manifest.json +46 -46
  34. package/upgrades/1.3.791.md +21 -0
  35. package/upgrades/1.3.792.md +77 -0
  36. package/upgrades/side-effects/reaper-toctou-fix.md +19 -0
  37. package/upgrades/side-effects/red-pr-watchdog.md +131 -0
@@ -0,0 +1,131 @@
1
+ # Side-Effects Review — Red-PR Watchdog
2
+
3
+ **Version / slug:** `red-pr-watchdog`
4
+ **Date:** `2026-07-09`
5
+ **Author:** `Echo (instar-dev agent)`
6
+ **Second-pass reviewer:** `Echo (self, second pass)`
7
+
8
+ ## Summary of the change
9
+
10
+ A signal-only watchdog on the existing green-PR auto-merge watcher tick. After the merge
11
+ logic runs, `redPrWatchdogPass` sweeps my own open PRs and raises ONE deduped,
12
+ age-escalating attention line for any PR with a required check stuck RED past a threshold
13
+ (default 2h). Files touched: `src/monitoring/greenPrLogic.ts` (new pure helpers
14
+ `latestRunPerCheck` / `failingChecksFromRollup` / `stuckRedChecks`, a `failingChecks` field
15
+ on `PrSummary`, and a correctness fix to `deriveRollup`), `src/monitoring/greenPrAutomergeWiring.ts`
16
+ (`mapPr` populates `failingChecks`; `deriveRollup` dedups first), `src/monitoring/GreenPrAutoMerger.ts`
17
+ (the pass + `redPrRaised` state memory + the `redPrWatchdogView` read + config),
18
+ `src/server/routes.ts` (GET fields), `src/config/ConfigDefaults.ts`, `src/core/types.ts`,
19
+ `src/commands/server.ts` (defaults/type/wiring). It is a DETECTOR only — it never merges,
20
+ closes, arms, or blocks.
21
+
22
+ ## Decision-point inventory
23
+
24
+ - `redPrWatchdogPass` (GreenPrAutoMerger.tick) — **add** — decides whether to RAISE an
25
+ attention line for a stuck-red self-authored PR. Signal-only; no blocking/merge authority.
26
+ - `deriveRollup` (greenPrAutomergeWiring) — **modify** — the SUCCESS/PENDING/FAILURE verdict
27
+ now dedups to the latest run per check first. This IS consumed by the merge candidate
28
+ gate (`classifyCandidate` reads `statusRollup`), so the change is a correctness improvement
29
+ to an existing authority's input, not a new authority.
30
+
31
+ ---
32
+
33
+ ## 1. Over-block
34
+
35
+ **What legitimate inputs does this change reject that it shouldn't?**
36
+
37
+ The watchdog has no block/allow surface — it only raises attention, so it cannot over-block
38
+ a message or a merge. The one behavior it could over-*alert* on is a genuinely-red PR that
39
+ the operator already knows about; that is bounded to ONE deduped line per PR and clears on
40
+ recovery, so the cost is a single ignorable heads-up. The `deriveRollup` fix makes the merge
41
+ gate LESS restrictive (a re-run-green PR that previously read FAILURE now reads SUCCESS) —
42
+ this is the correct direction; safe-merge re-verifies at act time, so a misread here can only
43
+ cause a refusal, never an unintended merge.
44
+
45
+ ## 2. Under-block
46
+
47
+ **What failure modes does this still miss?**
48
+
49
+ - A failing check with an unknown `completedAt` (0) is deliberately NOT flagged — we cannot
50
+ prove it has been red long enough, so we fail toward silence. A rollup shape that never
51
+ carries a completed time would therefore never alert. Acceptable: the common case (GitHub
52
+ Actions CheckRun) always carries `completedAt`.
53
+ - A PR that is red because it is *unmergeable* (conflicts) rather than a failed check is not
54
+ the watchdog's target — it watches failing checks, not merge conflicts. That is a separate
55
+ signal the merger already skips on.
56
+ - A PR authored by me but on a branch outside my namespace is skipped (the author proxy is
57
+ the branch-namespace filter, since `listOpenPrs` already passes `--author @me`).
58
+
59
+ ## 3. Level-of-abstraction fit
60
+
61
+ Right layer. The green-PR watcher already enumerates my open PRs with their check status
62
+ every tick; the watchdog rides that existing loop and reuses the already-fetched rollup — no
63
+ new gh call, no parallel poller. It feeds the existing attention-queue coalescing rather than
64
+ inventing a new notification surface. A higher layer (a generic PR monitor) would duplicate
65
+ the enumeration; a lower layer (the pure helpers) is where the check-dedup logic correctly
66
+ lives and is unit-tested.
67
+
68
+ ## 4. Signal vs authority compliance
69
+
70
+ Compliant. Per `docs/signal-vs-authority.md`, the watchdog is a pure SIGNAL producer: its
71
+ only effect is `refreshAggregate` → an attention line. It holds NO blocking authority — it
72
+ cannot merge, close, arm, disarm, or block a message. The brittle part (heuristic "is this
73
+ check stuck red") is confined to the signal; no authority is gated on it. The `deriveRollup`
74
+ change improves an existing detector's accuracy; it does not add a new authority.
75
+
76
+ ## 5. Interactions
77
+
78
+ - Runs AFTER the merge logic and the Layer-2 snapshot in the same tick, so it never shadows
79
+ or races the merge path. It only reads `candidates` (already gathered) and writes its own
80
+ `redPrRaised` state slice + the shared `attentionLines` set.
81
+ - Shares the aggregated attention item (`green-pr-automerge:aggregate`) with the merger's
82
+ other lines; the P17 attention coalescing dedups the ITEM, and the `redPrRaised` memory
83
+ dedups the LINE, so the two dedup layers stack rather than fight.
84
+ - The `deriveRollup` fix is consumed by `classifyCandidate` (settled-green gate) — verified
85
+ no other consumer exists (grep: `deriveRollup` is used only in `mapPr`). Single-run rollups
86
+ are unchanged, so existing green/pending/failure classification is byte-identical.
87
+ - No double-fire: the watchdog runs once per tick; a busy/disabled/breaker-open/list-failed
88
+ tick returns before it, so it never runs on stale data.
89
+
90
+ ## 6. External surfaces
91
+
92
+ Adds two fields to `GET /green-pr-automerge` (`stuckRed`, `redPrWatchdog`) — additive, no
93
+ removed fields, no breaking change to existing consumers. Raises attention lines visible to
94
+ the operator (the intended surface). No change visible to other agents or peers. It depends
95
+ on the green-PR watcher's tick cadence and the gh rollup shape, both already in use.
96
+
97
+ ## 6b. Operator-surface quality
98
+
99
+ No operator-surface file (no `dashboard/*` renderer, approval page, or grant/secret form) is
100
+ touched — the only operator-visible output is a plain-English attention line and a JSON read
101
+ field, both already-established surfaces. Operator-surface quality: the attention line leads
102
+ with the action ("PR #N red for Xh — <checks>"), exposes no raw internals, and reads at phone
103
+ width. No raw technical input is ever requested from the operator.
104
+
105
+ ## 7. Multi-machine posture (Cross-Machine Coherence)
106
+
107
+ **Machine-local BY DESIGN**, inheriting the parent green-PR watcher's posture exactly. The
108
+ green-PR watcher's state (`state/green-pr-automerge.json`) is per-machine and lease-gated —
109
+ ticks run only on the lease holder. The `redPrRaised` memory lives in that same per-machine
110
+ state file and is therefore never replicated; the watchdog only runs on the machine holding
111
+ the serving lease, so there is no double-alert across machines. The attention item it raises
112
+ is one-voice by construction (the shared `green-pr-automerge:aggregate` id + P17 coalescing).
113
+ No durable state strands on topic transfer (it is watcher-state, not topic-state), and it
114
+ generates no cross-machine URLs. This matches how green-pr-automerge already behaves.
115
+
116
+ ## 8. Rollback cost
117
+
118
+ Cheap. Revert the PR — the watchdog is signal-only, so there is no data migration and no agent
119
+ state to repair (the `redPrRaised` slice is ignored by older code and re-derived each tick).
120
+ Softer levers without a revert: set `monitoring.greenPrAutoMerge.redPrWatchdog.enabled: false`
121
+ to turn just the watchdog off, or raise `redThresholdMs`. The `deriveRollup` fix is the only
122
+ behavioral change to an existing path; if it were ever wrong it would make the merger MORE
123
+ conservative (skip), never over-merge — safe-merge remains the act-time authority.
124
+
125
+ ## Self-action note
126
+
127
+ `unbounded-self-action`: n/a — the watchdog performs no self-triggered control action (no
128
+ restart / respawn / spawn / kill / swap / retry / re-drive). Its only effect is raising an
129
+ attention line, and that is bounded by the per-PR `redPrRaised` dedup memory (ONE line per
130
+ stuck PR, re-raised only on age-escalation, cleared on recovery) — so it converges under
131
+ sustained pressure rather than emitting unboundedly.