Skip to content

feat(bin): add opt-in operator guard consult before wedge escalation - #7431

Closed
Moshik21 wants to merge 4 commits into
kunchenguid:mainfrom
Moshik21:fm/fm-upstream-6958-refresh
Closed

Moshik21 wants to merge 4 commits into
kunchenguid:mainfrom
Moshik21:fm/fm-upstream-6958-refresh

Conversation

@Moshik21

Copy link
Copy Markdown
Contributor

Intent

Upstream firstmate PR #6958 (ours) needs work: the operator guards evidence PR (issue 6919): its branch conflicts with current main. The captain's words: 'yes. do all work for upstream things we have.' Upstream contribution consent for this repo is recorded for this task. The PR (branch fm/fm-upstream-guard-evidence) adds an opt-in, deterministic, read-only, fail-open hook where the watcher consults operator-supplied guard commands (listed in config/wedge-evidence-guards; absent means off) only in the at-threshold wedge branch, after the wait evidence and dead-endpoint checks; a CRITICAL guard answer defers one wedge window for a bounded run of consecutive deferrals, after which the escalation names the guard and its reason. Keep that behavior and the maintainers' accepted shape while resolving the conflict with current main, update the existing PR rather than opening a new one.

What Changed

  • bin/fm-watch.sh gains an opt-in, read-only, fail-open consult of operator guards listed in config/wedge-evidence-guards (absent means off). It runs only at the at-threshold wedge branch, after the wait-evidence and dead-endpoint checks (wedge_guard_evidence, wedge_guard_file_trusted). Each guard runs as <guard> --json, with FM_GUARD_TASK and FM_GUARD_ENDPOINT set, bounded by FM_WEDGE_GUARD_TIMEOUT_SECS. The config file and each guard must be trusted: a regular file, not a symlink, owned by the watcher's user, and not group or world writable. A timeout, non-zero exit, malformed output, or any status other than CRITICAL is no answer.
  • A CRITICAL answer defers one wedge window through wedge_defer_guard, without advancing the escalation count. The run of consecutive deferrals is capped at FM_WEDGE_GUARD_DEFER_MAX and persisted in state/.guard-deferrals-<key>. After the cap the escalation fires and its reason names the guard and the first line of its recommendation. The record is cleared with the other write-tracking resets (clear_write_tracking) and in bin/fm-supervise-daemon.sh clear_pause_tracking.
  • The docs now cover the new behavior. docs/configuration.md has a "Wedge evidence guards" section and the two new knobs, docs/architecture.md and docs/jev-guards.md (new "Caller" section, bounded CRITICAL semantics) describe it, and the operational-home-layout skill lists the new config file and .guard-deferrals-* state records. tests/fm-watch-triage.test.sh gains 193 lines of cases.

Risk Assessment

✅ Low: The merge keeps the opt-in, read-only, fail-open guard consult only in the at-threshold wedge branch, after the wait-evidence and dead-endpoint checks, with a bounded deferral cap, and no regressions or intent contradictions showed up on a read of the diff.

Testing

I ran tests/fm-watch-triage.test.sh against the merged tree. Its real fm-watch.sh subprocess fixtures covered all the guard scenarios, and all four passed. The file was stopped at the 10-minute limit, so the later non-guard tests did not run; the output up to that point had no failures. I did not run the Herdr lab or the daemon's pause-tracking cleanup of the guard-deferral record. The only evidence is the captured test transcript in the evidence directory; there is no UI surface.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Absent config/wedge-evidence-guards: a quiet live pane at the wedge threshold escalates exactly as before, no guard runs, no guard-deferral record is written, and an otherwise identical armed home doe… ✅ pass live fm-watch-triage.out: 'with config/wedge-evidence-guards absent no guard runs and the ladder, timing and wording are unchanged'
A guard answering CRITICAL defers the wedge escalation one window at a time up to the cap. The next escalation names the guard and its reason, the escalation count is not advanced by deferrals, and th… ✅ pass live fm-watch-triage.out: 'a CRITICAL guard defers one window at a time, the cap escalates naming the guard, and the run survives a restart'
Fail-open: a guard that times out, exits non-zero, prints malformed output, answers UNKNOWN or WARNING, or is untrusted does not change the ladder ✅ pass live fm-watch-triage.out: 'a guard that times out, fails, answers malformed, UNKNOWN or WARNING, or is untrusted leaves the ladder unchanged'
A gone endpoint is reported before any guard is asked, so a CRITICAL guard cannot defer it ✅ pass live fm-watch-triage.out: 'a gone endpoint is reported before any guard is asked, so a guard never defers it'
Herdr-lab or lab-primary drive of the guard hook, and the supervise daemon clearing the guard-deferral record when pause tracking resets ⏸️ untested no The hook is exercised through fm-watch.sh subprocess fixtures, not through a Herdr lab session. I did not drive the daemon cleanup path. Run the daemon-side tests (for example tests/fm-daemon.test.sh)…
Evidence: fm-watch-triage test transcript (stopped at the 10-minute limit)

Source: fm-watch-triage test transcript (stopped at the 10-minute limit)

ok - status_span_has_actionable: benign absorbed, captain events surfaced, classified events not re-fired
ok - an actionable event is not hidden by later routine appends, and is named as itself
ok - span classification retires closed decisions and surfaces rejected transitions for reconciliation
ok - span classification from an offset keeps closed decisions closed and live ones live
ok - a malformed seen signature causes the whole status log to be classified
ok - stale_is_terminal: terminal status surfaces, non-terminal and no-status are benign
ok - classifier primitives: keyed decisions and activity phases, captain relevance, window-to-task, and overrides
ok - unrecognized status prefixes are visible and recognized prefixes are unchanged
ok - crew_is_provably_working: only working+run-step/pane is provable; idle/finished/parked/failed/unknown surface
ok - status_is_paused: only the leading paused verb matches, paused is not captain-relevant, and the two declared-wait verbs stay separable
ok - crew_absorb_class: working/paused/none from one read; crew_is_paused and crew_is_provably_working agree
ok - crew_worktree_written_since: real writes are evidence; no worktree, no anchor, quiet trees, .git churn and a mate's own home are not
ok - an empty FM_WORKTREE_WRITE_PRUNE widens the probe to the whole depth-bounded tree instead of disabling it
ok - an empty FM_WORKTREE_WRITE_PRUNE exported into the environment prunes nothing, widening the probe
ok - the worktree write probe is wall-clock bounded, and hitting the bound reads as no write evidence
ok - signal_crew_provably_working: benign only when every referenced crew is provably working
ok - a secondmate's unmarked routine progress absorbs when provably working; routed, terminal, note, marked, and unknown lines surface
ok - a no-verb signal whose crew is provably working is absorbed (no exit, no queue, suppressor advanced, beacon present)
ok - a bare turn-end whose crew is provably working (busy pane) is absorbed
ok - a bare turn-end whose crew is not provably working is surfaced (the swallowed-finish fix)
ok - a bare turn-end from a pane that churned since the previous poll is absorbed
ok - pane churn starts a fresh stale-classification interval before a stopped render returns
ok - pane churn resets prior wedge escalation state before the stale-path poll
ok - a churning turn-end inside an already-open deferral window is absorbed without re-marking
ok - a bare turn-end from a pane unchanged since the previous poll still surfaces
ok - a bare turn-end backed by a malformed prior hash surfaces
ok - a bare turn-end backed by a newline-terminated prior hash surfaces
ok - a churning secondmate turn-end surfaces without a stale resurface path
ok - a turn-end whose marker key matches another recorded endpoint surfaces
ok - two metadata records sharing one endpoint make churn evidence ambiguous
ok - a batch may satisfy positive evidence independently per task
ok - per-task evidence composition stays off until the home opts in
ok - a status-bearing batch never falls through to pane-churn evidence
ok - pane-churn turn-end absorb is off until a home opts in
ok - a perpetually churning pane surfaces once its bounded deferral window is spent
ok - an unrecordable pane-churn deadline surfaces the turn-end
ok - an invalid pane-churn bound surfaces the turn-end
ok - an oversized pane-churn bound surfaces the turn-end
ok - invalid existing pane-churn deadlines surface without mutation
ok - a surfaced batch opens no partial pane-churn deadline
ok - a no-verb working: note whose crew is idle with no running pipeline is surfaced
ok - a secondmate's status note surfaces even while its own agent is busy
ok - a busy secondmate's routine working: is absorbed while its later note: still surfaces
ok - a secondmate blocker wakes despite busy evidence and later unrelated appends
ok - a self-announced close never wakes its own home, and the next real note still does
ok - a close after OPEN DECISIONS fold never wakes its own home, and the next real note still does
ok - a folded worker decision with no home append still wakes
ok - separate answers over unclassified decisions wake once, and the next real note still does
ok - a close after OPEN DECISIONS fold still surfaces a worker failure inside the folded span
ok - a close after OPEN DECISIONS fold still surfaces unlisted secondmate lines inside the folded span
ok - captain-relevant signal is surfaced (queue + exit) and marked surfaced
ok - a needs-decision signal row's queued payload is marked needs-decision: for branch exclusion
ok - a reconciliation-required needs-decision row's queued payload is still marked needs-decision:
ok - a captain-held signal stays actionable while the crew is still working
ok - a pending-reply second-mate escalation is marked for main-only routing
ok - an ordinary blocked event remains branch-eligible
ok - a routine event containing a needs-decision phrase keeps its ordinary payload, unmarked
ok - a captain event hidden behind a later routine append is still surfaced (queue + exit)
ok - a keyed decision signal reads only the newly appended span, not the whole log
ok - a finished release reported before routine cleanup chatter is still surfaced
ok - a routine append after an already-classified event is absorbed (no re-wake)
ok - unreadable status reports are bounded without advancing classification
ok - permission recovery surfaces content from the unadvanced position
ok - a stale pane sitting on a terminal status is surfaced (queue + exit)
ok - a stale terminal-looking status is overridden and absorbed while a run is actively working, then wedge-escalated
ok - provably-working non-terminal stale is absorbed on first sight, then wedge-escalated past the threshold
ok - consecutive wedge escalations on the same pane accumulate and demand deep inspection at the threshold
ok - a pane becoming active again resets the consecutive wedge-escalation counter
ok - a record whose endpoint is dead or missing reports itself once and is never re-escalated
ok - a live wedged agent, an unattributable one, and an unreadable endpoint escalate unchanged
ok - with config/wedge-evidence-guards absent no guard runs and the ladder, timing and wording are unchanged
ok - a CRITICAL guard defers one window at a time, the cap escalates naming the guard, and the run survives a restart
ok - a guard that times out, fails, answers malformed, UNKNOWN or WARNING, or is untrusted leaves the ladder unchanged
ok - a gone endpoint is reported before any guard is asked, so a guard never defers it
ok - the once-only gone report re-arms when the endpoint comes back, and reports a later death again
ok - a second death after a same-window relaunch reports in full without a live probe, and an unchanged dead pane stays silent
ok - a successor's byte-identical dead display reports in full, and the same incarnation still absorbs
~/.no-mistakes/worktrees/889b963008ec/01M53D6VYQ2348GC8JZ4KQJ480/bin/fm-watch.sh: line 2288: 21213 Terminated: 15          fm_backend_capture "$@" < /dev/null > "$FM_CAPTURE_OUTPUT"
ok - TERM stops a watcher blocked inside a poll and still runs its cleanup
watcher: recovery state could not be persisted; retaining stale lock evidence
ok - TERM stops a watcher whose downtime-marker lock is held, retaining stale evidence
ok - the cleanup marker-lock bound is decimal and zero falls back to the default
ok - a busy worker below the turn-age bound remains working with no escalation
ok - a busy worker with a stable pane hash still escalates once its completed-turn age reaches the bound
ok - a busy worker whose pane hash changes every poll still escalates once its completed-turn age reaches the bound
ok - touching a busy worker's completed-turn marker resets the age and prevents an old-age escalation
ok - native progress resets busy age without a completed turn or notification
ok - repeated busy turn-age escalations reuse the existing escalation counter and demand deep inspection at the threshold
ok - the production default busy-turn-age bound is 3600s (5min under does not wedge, 66min over does)
ok - a busy pane under a declared pause is rechecked on the long cadence, and lifting the pause restores the wedge escalation
ok - away mode hands a busy declared pause to the daemon as a plain stale, and lifting the declaration restores the wedge escalation
ok - away mode wakes the daemon once per declaration for a busy pane whose footer ticks on every capture
ok - a not-provably-working non-terminal stale is surfaced immediately (never left to wait out the timer)
ok - a declared pause is absorbed on first sight, then re-surfaced as a recheck past the threshold, never wedge-escalated
ok - exited declared-pause and captain-held panes use bounded pause cadence while a live decision gate still surfaces once
ok - own-work waits keep one first alert, then bounded rechecks without wedges; undeclared idle still alarms
ok - absorbed paused and captain-held replacements each start their own re-surface cadence
ok - a parked live worker surfaces once, absorbs pane churn for the whole re-surface window, then re-surfaces when it elapses
Terminated: 15

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Absent config/wedge-evidence-guards: a quiet live pane at the wedge threshold escalates exactly as before, no guard runs, no guard-deferral record is written, and an otherwise identical armed home doe… ✅ pass live fm-watch-triage.out: 'with config/wedge-evidence-guards absent no guard runs and the ladder, timing and wording are unchanged'
A guard answering CRITICAL defers the wedge escalation one window at a time up to the cap. The next escalation names the guard and its reason, the escalation count is not advanced by deferrals, and th… ✅ pass live fm-watch-triage.out: 'a CRITICAL guard defers one window at a time, the cap escalates naming the guard, and the run survives a restart'
Fail-open: a guard that times out, exits non-zero, prints malformed output, answers UNKNOWN or WARNING, or is untrusted does not change the ladder ✅ pass live fm-watch-triage.out: 'a guard that times out, fails, answers malformed, UNKNOWN or WARNING, or is untrusted leaves the ladder unchanged'
A gone endpoint is reported before any guard is asked, so a CRITICAL guard cannot defer it ✅ pass live fm-watch-triage.out: 'a gone endpoint is reported before any guard is asked, so a guard never defers it'
Herdr-lab or lab-primary drive of the guard hook, and the supervise daemon clearing the guard-deferral record when pause tracking resets ⏸️ untested no The hook is exercised through fm-watch.sh subprocess fixtures, not through a Herdr lab session. I did not drive the daemon cleanup path. Run the daemon-side tests (for example tests/fm-daemon.test.sh)…
  • bash tests/fm-watch-triage.test.sh (single file, run in the background; stopped at the 10-minute background limit before reaching the end, with no failure in the output captured up to that point)
  • Four guard tests in that file ran and passed: absent config, CRITICAL deferral up to the cap, fail-open cases, and gone endpoint
  • Reviewed git diff 7099556..4f7c494 for bin/fm-watch.sh, bin/fm-supervise-daemon.sh and docs/configuration.md against the stated intent
  • Confirmed the worktree is clean after the run
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Add config/wedge-evidence-guards, an opt-in list of operator-owned guard
executables that the watcher's at-threshold wedge branch consults after the
wait evidence, worktree-write probe and dead-endpoint probe. A CRITICAL
answer defers one window at a time, capped by FM_WEDGE_GUARD_DEFER_MAX
consecutive deferrals recorded beside the other wedge-window records, and
the escalation that ends a capped run names the guard and its reason.
Timeouts, failures, malformed output, UNKNOWN and WARNING fail open, and an
untrusted config or guard is never run. With the config absent the ladder is
unchanged.

Refs kunchenguid#6919
@Moshik21

Copy link
Copy Markdown
Contributor Author

Superseded by #6958, which now carries the same change merged with current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant