Repository navigation
Commit caa93c6
fix(omp): harden idle-turn supervision and wake delivery (#129)
* fix(bin): derive watcher beacon staleness grace from poll cadence
Port of upstream kunchenguid/firstmate kunchenguid#3946, adapted: the fork has no
away-mode daemon predicate, so only the shared derivation and its two
in-scope readers change.
fm-claude-stop-autoarm.sh required the watcher beacon fresh within the
flat FM_GUARD_GRACE default (300s), but a healthy watcher touches the
beacon once per cycle and can legitimately age up to FM_POLL seconds
between touches, so a long-poll home reads stale mid-wait and the hook
misjudges a live cycle as down.
fm-wake-lib.sh gains fm_poll_derived_grace, the single owner of the
max(300, FM_POLL + 60) formula. fm-watch.sh's own pre-acquisition
beacon-staleness check and the auto-arm hook both derive their default
grace from it, and the hook now exports its resolved FM_GUARD_GRACE to
the fm-watch-arm.sh invocations so arm and check agree on one value.
* fix(bin): count only actor-presentable wake rows and retire unusable rows
Port of upstream kunchenguid/firstmate kunchenguid#3950, adapted to the fork's
SCOPED drain and OMP branch-grant machinery.
A branch grant already excluded its rows from a main drain, but
fm-guard.sh still counted every queued row as pending for the calling
actor, so main was told to run a drain that could only print nothing for
as long as the branch held the grant. And a queue row that lost the five
appended fields or its numeric sequence was counted as queued while it
could never be claimed, presented, or named by an --ack-through cutoff,
wedging the queue permanently.
fm-wake-lib.sh gains the shared per-actor helpers:
fm_wake_grant_rows_valid, fm_wake_branch_owner_matches,
fm_wake_branch_grant_live, and fm_wake_actor_pending_count - the last
reports a pending row when a queue exists but cannot be counted, so an
unreadable queue still raises the alarm. fm-wake-drain.sh and
fm-wake-grant.sh now delegate their grant row-list and owner-record
reads to the library. A main drain retires structurally unusable rows
under the queue lock and reports them verbatim (a branch drain never
does), and a main drain left with only branch-held rows names the
holder instead of exiting silently. fm-guard.sh warns only for rows the
calling actor can itself present or retire, and gives main a distinct
held-by-branch advisory when that is the whole non-empty queue.
tests/fm-wake-queue.test.sh covers the branch-held warning boundary end
to end, the uncountable-queue alarm, and main-only retirement.
* fix(bin): gate secondmate wake-loop stall alerts on real queue no-progress
Port of upstream kunchenguid/firstmate kunchenguid#3943, which lands the detector's
final form on this fork (the fork had no foreign-queue stall check at
all, so the whole feature arrives already fixed).
The watcher now reads the oldest structurally valid actionable row in
every endpoint-recorded local secondmate home's durable wake queue, and
times the interval since that position last changed instead of the row's
age. A queue that is draining is not stalled, so a moved oldest row -
drain progress, or a queue reprovisioned under the same task id that
restarts its sequence anywhere - ends the no-progress episode and starts
a fresh observation interval, recorded by
state/.secondmate-wake-progress-<task> as the same epoch-sequence row
identity the stall receipts use. Declared external-wait pause rows are
not actionable evidence, and a mate provably inside an active turn (an
exact busy verdict bounded by FM_BUSY_TURN_MAX_SECS) never escalates.
One keyed check notification covers each no-progress episode across
watcher and handling crashes; the foreign queue is only ever read.
FM_SECONDMATE_WAKE_STALL_SECS defaults to 180 and is the backstop behind
the active-turn gate, not a substitute for it.
Fork adaptation: the parent watcher keeps its secondmate home-beacon
rule, so the ported tests give the fixture mate a fresh
.last-watcher-beat under its (stubbed or real) clock to isolate the
stall detector; assertions are unchanged from upstream.
tests/fm-wake-queue.test.sh covers progress tracking, once-per-episode
alerting, declared-pause exclusion, reprovisioned-generation reset,
active-turn deferral, and marker symlink rejection.
* fix(bin): never type doorbells into dead panes; recover them instead
Port of upstream kunchenguid#3823, adapted: the fork's task-inbox ring reserves
return code 6 for a positively dead or missing endpoint (codes 3-5 are
OMP-native and Hermes-lock outcomes here). The doorbell line itself is
now a shell no-op (": ...") with quoted, printable-only paths, so even a
liveness race that loses to an exiting agent runs nothing in a bare
shell. The watcher escalates a dead/missing endpoint's unhandled record
once through the ordinary stale wake - over stale busy-state evidence -
instead of walking the re-ring ladder, and fm-send reports the skipped
doorbell as recovery, not a re-ring. Remote secondmate send inherits the
rc-6 recovery notice through fm-send without a new branch. Secondmate
restart also resolves all arrived persist answers before any timeout
decision and rechecks at the decision boundary, so a reply landing at
the deadline wins over the fallback nudge.
Regression coverage: doorbell shell-noop across real shells, control-byte
path rejection, dead/missing ring skip, watcher escalate-once-without-
ringing, dead-pane override of stale busy state, and the
resolution/timeout boundary race. Fake tmux inventories across the suite
now list recorded windows and answer pane_current_command so the
recovery-grade endpoint check exercises real paths.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(omp): prove the doorbell turn instead of trusting triggerTurn
The task-inbox doorbell claimed `.delivered` the moment sendMessage
returned, but OMP can downgrade `triggerTurn` to append-only delivery on
an idle, non-streaming session: the steer was accepted and reported
received while no turn ever ran, leaving an idle worker stranded with an
unhandled durable record.
The extension now renames an accepted request to `.awaiting-turn` when no
turn is open and settles it to `.delivered` only on a `turn_start` or
`agent_start` proving the turn actually began. A steer that lands while a
turn is open is still delivered immediately, since it joins that turn.
When the bound passes with no turn, the extension re-drives the same
instruction through `sendUserMessage` - a user prompt an idle session
cannot defer - and a failed re-drive reports `.failed` rather than
stranding silently. Requests left `.awaiting-turn` by a dead generation
re-queue as `.pending` on the next activation. Installs on runtimes
without the event or user-prompt surface keep the prior accept-only
semantics.
On the shell side, `fm_omp_task_doorbell_request_existing` reports an
awaiting-turn request as in-flight, so fm-send honestly reports a
downgraded doorbell as queued (exit 4 semantics) rather than received
while the extension's own recovery still wakes the worker.
Regression coverage drives the downgrade end to end: an accepted
sendMessage with no turn event stays unproven, the bounded grace re-drives
the identical instruction through sendUserMessage exactly once, a firing
turn_start settles without any re-drive, an open turn delivers the steer
immediately, a failing re-drive reports failed, and a dead generation's
unsettled proof re-enters delivery on activate. The suite's tmux fake also
now lists the recorded task window so the recovery-grade endpoint check
exercises the live path instead of classifying the fixture missing.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(bin): bound detached procevent runners to their owning home's lease
A runner is detached into its own process group so it survives the turn
that started it, and on its own that lets a runner outlive its whole
home: once reparented to init, nothing bounds its lifetime, so a blocking
source child - and everything it spawns - can poll forever after the home
that owns the work is gone. This is the upstream kunchenguid#3904 port, adapted to
the fork's simpler procevent (no extension subsystem or capture
reservations).
Every claim now records the canonical physical state root with its
device, inode, owner, and mode, and every claimed runner spawns a
detached owner guard in a separate process group. The guard re-reads the
recorded root's .owner-lease marker - refreshed by register, handled,
reconcile, sweep, and an attached start's keepalive - and after two
consecutive checks cannot prove both the root identity and a fresh lease,
it signals the runner's whole process group. Runner descendants inherit
FM_PROCEVENT_IN_RUNNER so they cannot keep their own lease alive; a
confused agent that deliberately strips the marker is out of scope.
Reconcile no longer signals a leaderless surviving group: once the leader
is gone, PID/PGID reuse makes the group's provenance unprovable, so the
claim stays owned and uncertain instead of risking a foreign group or a
second poller on one canonical source. Retirement and reconcile take
their signal through an identity-and-leadership-gated group path, and a
launch floor paces relaunches per registration generation so a
crash-looping source cannot spin.
Fork deviations from upstream: the state-root check requires ownership
and canonicality but not a private mode (operational homes use
group-readable state roots), the serialized launch-floor section releases
the source lock at the stamp write because this caller holds no further
locked work, central storage keeps its distinct commit point, and the
usage window is widened to keep the durability-boundary line visible.
Regression coverage: an orphaned runner's group is stopped by its guard
after the home's lease expires, a crashed leader's ambiguous group is
preserved rather than signalled or replaced, and the registration
replacement test now waits for the old generation's source to actually
start so the launch-floor supersede check cannot eat the race.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(omp): latch a provider-broken branch with a bounded cooldown probe
A settled branch prompt whose last assistant message carries stopReason
"error" is a provider failure OMP reports on the message instead of
rejecting prompt(), so the old code never latched: every later wake kept
paying for a predictably broken branch turn before its settlement could
reject to main. Port of upstream kunchenguid#3497, adapted to the fork's extension
shape (generation-only guards, offer.accept(promise) settlement).
Two consecutive settled provider errors now latch the branch off and
merge a captain-facing health note. While latched, main keeps every wake
except one recovery probe after each cooldown, which starts at five
minutes and doubles to a one-hour ceiling; a probe that ends in a durable
fm_branch_report clears the latch with a second note, and a failed probe
reschedules by the current cooldown. A settled prompt that produced no
durable outcome now rejects its settlement instead of silently claiming
its granted wake rows.
The branch record keeps its SessionManager so the settled-prompt scan can
read only the entries the prompt appended. The strict typecheck also
caught two stale errors from the earlier doorbell work: the doorbell
options builder returned a Required<> literal missing turnGraceMs, and
its `on` property signature could not accept the runtime's overloaded
event subscription - the latter is now a method declaration so the
parameter stays bivariant.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(omp): start a fresh supervision branch conversation per main session
Port of upstream kunchenguid#3600. A branch conversation that outlives its main
session keeps reasoning from an older thread's accumulated memory, which
competes with today's generated prompt and current fleet rules. The OMP
extension kept one persistent conversation keyed on a durable pointer,
so /new, /resume, /fork, and reload all reopened the stale thread.
The branch record is now scoped to the extension generation: createBranch
reopens only a conversation it built under the current generation, and
both session_start and session_switch advance the generation, drop the
live handle (beginDispose + dispose), and re-anchor the mirror so the
fresh branch receives the new main session's dialog from its start. The
durable outcome store, not the conversation, carries unacknowledged
outcomes across the boundary. The on-disk pointer remains a record for
operators and the effort picker's model lookup, not a reopen source.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(omp): give the supervision branch main's live model registry
Port of upstream kunchenguid#3871 by equivalent mechanism. A provider an extension
registered into main's runtime at run time is invisible to a freshly
discovered registry, so pinning or following such a model built a branch
that could not resolve its own model. OMP's createAgentSession already
takes a modelRegistry option, so instead of upstream's provider-by-provider
config copy into an isolated ModelRuntime, the branch session now receives
main's live registry directly - read-only sharing: the branch never
installs, converts, or overwrites credentials or registrations. The
resolve and picker paths already read that same registry, so the build,
the pin resolution, and the picker now agree on one model catalog.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(bin/omp): route decision-owned signal and stale wake batches to main
Port of upstream kunchenguid#3776. A needs-decision status append, a captain-held
status transfer surfaced through the no-verb signal path, or a blocked
pending-reply escalation is owned by the captain and must stay on main.
The previous logic only forced the check-kind class to main, so a
coalesced signal batch that also contained routine rows could end up split:
the decision row to the branch, the rest to main, which loses the
single-actor ordering the per-actor acknowledgement contract depends on.
The bash side now:
- `status_span_first_actionable_record` returns a side-band flag when its
span carries a needs-decision, a captain-held declaration, or a pending-
reply escalation, without changing the event text it already returns.
- `signal_files_actionable` surfaces those files (even when the captain-held
line is otherwise non-actionable) and populates
`FM_SIGNAL_NEEDS_DECISION_FILES`.
- The watcher appends the row payload as `needs-decision:$files` for exactly
the flagged files; other files in the same batch keep the ordinary reason.
The OMP dispatch side now:
- `scopeForUnreadWake` parses each mapped task's `.status` log to detect an
open needs-decision or a current captain-held declaration, and excludes
those rows from `eligibleSeqs` while populating `needsDecisionKeys`.
- `offerWakeToBranch` in `fm-primary-omp.ts` cross-references the current
signal or stale trigger keys against every unread decision-owned row by
task identity: any overlap forces the entire coalesced batch to main.
- Heartbeat handling remains independent, and a decision-owned row in one
task does not affect eligibility for other tasks.
Also fixed a pre-existing full-lint `SC2031` info note in
`tests/fm-afk-launch.test.sh` by disabling it file-wide, so the canonical
lint run is green again.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(core/omp/pi): settle watcher delivery on runtime acceptance, consume on turn start
Port of upstream kunchenguid#3513. A follow-up queued while main is streaming joins
that run as a user message without raising before_agent_start, so waiting
for the model to consume the wake stalled the successor chain: no successor
started, later wakes were not delivered, and the turn-end guard re-armed by
hand.
The shared core now:
- Treats sendFollowUp resolution as delivery; consumption is tracked only
to let a session replacement replay a wake the runtime accepted but had
not yet read.
- Keeps accepted-but-unconsumed wakes in a per-generation unconsumedWakes
map keyed by the pending token.
- Consumes a wake when the runtime starts a turn carrying the exact wake
text: before_agent_start for an idle main, message_start for a streaming
main.
- Does not mark a pending row delivered or finish cleanup until the wake is
consumed or the branch owns it.
- Skips over unconsumed rows when picking the next pending record, so the
successor chain keeps moving while waiting for a streaming main to read
the prior wake.
- Defers a verified successor's failure close when the pipeline is still
delivering the wake it was started for; the retry runs once that delivery
settles.
- Adds armRetired so a child the core itself killed does not earn a
deferred retry.
The Pi and OMP adapters both gain a message_start handler that extracts the
user message text and passes it to watch.acknowledgeWake.
Documentation in docs/omp-supervision-branch.md now states the delivery
versus consumption boundary for main fall-back follow-ups.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* no-mistakes(review): Make supervision provider latch recoverable after transient failures
* no-mistakes(review): Correlate doorbells and latch rejected supervision prompts
* no-mistakes(review): Correlate doorbell turn proofs and recover prompt failures
* no-mistakes(review): Correlate synchronous turn proofs to each doorbell dispatch
* no-mistakes(review): Correlate turn proof and redrive uncorrelated doorbells
* no-mistakes(test): Fix procevent sweep claims and OMP turn handler coexistence
* no-mistakes(test): Preserve claim-only sources for reliable home sweeps
* no-mistakes(test): Disabled unreliable turn observation for generated OMP workers
* no-mistakes(document): Updated stale branch-session documentation
* no-mistakes(review): Enforce state-root identity before ownership and stale-claim decisions
* no-mistakes(review): Requeue unreadable awaiting-turn requests for redelivery
* no-mistakes(document): Correct stale supervision and process-event verification docs
---------
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent 8a5de1e commit caa93c6
46 files changed
Lines changed: 2968 additions & 368 deletions
File tree
- .omp/extensions
- lib
- .pi/extensions
- bin
- docs
- verification
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
237 | 255 | | |
238 | 256 | | |
239 | 257 | | |
| |||
259 | 277 | | |
260 | 278 | | |
261 | 279 | | |
262 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
263 | 300 | | |
264 | 301 | | |
265 | 302 | | |
| |||
322 | 359 | | |
323 | 360 | | |
324 | 361 | | |
| 362 | + | |
325 | 363 | | |
326 | 364 | | |
327 | 365 | | |
| |||
350 | 388 | | |
351 | 389 | | |
352 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
353 | 396 | | |
354 | 397 | | |
355 | 398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
50 | 60 | | |
51 | 61 | | |
52 | | - | |
53 | | - | |
| 62 | + | |
| 63 | + | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
| |||
65 | 75 | | |
66 | 76 | | |
67 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
68 | 84 | | |
69 | 85 | | |
70 | 86 | | |
| |||
81 | 97 | | |
82 | 98 | | |
83 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
84 | 165 | | |
85 | 166 | | |
86 | 167 | | |
| |||
105 | 186 | | |
106 | 187 | | |
107 | 188 | | |
| 189 | + | |
| 190 | + | |
108 | 191 | | |
109 | 192 | | |
110 | 193 | | |
| |||
117 | 200 | | |
118 | 201 | | |
119 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
120 | 211 | | |
121 | 212 | | |
122 | 213 | | |
| |||
136 | 227 | | |
137 | 228 | | |
138 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
139 | 239 | | |
140 | 240 | | |
141 | 241 | | |
142 | 242 | | |
143 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
144 | 283 | | |
145 | 284 | | |
146 | 285 | | |
| |||
159 | 298 | | |
160 | 299 | | |
161 | 300 | | |
162 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
163 | 311 | | |
164 | 312 | | |
165 | 313 | | |
| |||
0 commit comments