Repository navigation
feat(bin): fleet ops hardening with login probe, PR auto-merge, and relay trust - #6924
derickdsouza wants to merge 22 commits into
Conversation
…guid#149) (#1) Extend fmx_poll_shim_valid to honor config/harbor-telegram-hitl.poll-shim.registration.json so harbor telegram-hitl can replace x-watch.check.sh without watcher rejection. Enforce relay ack-before-long-work: fm-x-reply records x-context/<id>.answered.json on the initial answer; fm-spawn refuses while any open x-inbox row lacks that marker. Co-authored-by: Cursor <cursoragent@cursor.com>
Port of derickdsouza/firstmate PR #2 onto org main: the explicit bin/fm-x-watch-register.sh binding command with colocated tests, the stock/registered validator split, watcher exec-target dispatch with the re-register hint, and bootstrap preservation of a still-matching binding. Mainline harbor manifest validation is kept as fmx_poll_shim_manifest_valid and chained into fmx_poll_shim_valid, so harbor-installed and CLI-registered alternates authenticate through one dispatch-time check.
Port of derickdsouza/firstmate PR #3 in full: deterministic length-bound fm-untrusted-text-lib.sh neutralizing injection role-markers, HTML comments, and operational-prefix impersonation, wired into the relay mention stash path with claim-and-dismiss for empty-after-sanitize mentions, batched chain sanitizing bounded by string size rather than entry count, and colocated coverage across locale, multibyte, fixed-point, and budget cases.
…ontract Port of the parked fm/adopt-constitution-layering branch (7ba0d37): ship and promoted-scout briefs carry the layering discipline - shared worker-facing rule files are law and are never same-name overridden by a project; project specialization lives in distinctly-namespaced local files. Scaffold tests pin the contract on both brief paths.
Bring in 9 upstream commits (relay media, spawn/startup/wake fixes, Bearings concurrency, pi supervision, CI shards) while preserving fleet commits: HITL poll-shim trust, ack-before-spawn, sanitizer, constitution layering. Conflicts resolved in docs/configuration.md and tests/fm-x-mode.test.sh (fleet untrusted-text sanitization kept). Co-authored-by: Cursor <cursoragent@cursor.com>
…-09-02 merge(upstream): sync kunchenguid/firstmate main (9 commits)
Process-alive is not health. A remote helper with unacked steering-inbox mail past the ladder, or a repeating Node missing-module capture after a harness upgrade under a live process, is stuck. launch now replaces stuck helpers instead of reusing them. Session-start liveness respawns those stuck remotes. The parent watcher ticks the remote inbox ladder on the host. Spawn/bootstrap reconcile the reply runner after arming so a registered source is not left without a child.
…down (kunchenguid#4) (kunchenguid#5) Co-authored-by: Derick D'Souza <derick@nivasritech.com>
* feat(bin): fleet when-watch poller with cron dedupe and single-flight lock * feat(bin): agent login probe with login-shell PATH resolution Cron hardening: default USER/LOGNAME when unset and prepend the standard CLI install roots (~/.local/bin, nvm per-version bin, ~/.grok/bin, Homebrew) to PATH so a minimal cron environment no longer misreports installed CLIs as absent. Also fix the grok and cursor checks, whose has_stdout ... | grep pipeline could never match because has_stdout captures the output and returns only a status; they now grep the real command output. Every expansion is set -u safe under env -i.
kunchenguid#7) (kunchenguid#8) Grok and cursor cannot neutralize AGENTS.md/CLAUDE.md, so they cannot gate fleet repos. Keep the chain in ~/.no-mistakes/config.yaml and out of the tracked repo override.
Darwin still uses zsh -l for pi and may ssh to the VPS. Linux is the VPS: probe locally as vps via PATH, and do not ssh to ghwave.
Merge upstream firstmate into nivasritech/firstmate without rebasing so pm-dev can keep pulling with --ff-only. Conflict resolutions (section 6 of the 6 Oct 2026 upstream check): Take upstream, then re-apply fork lines: - AGENTS.md — upstream layout; x-watch.poll-trust row lives in operational-home-layout - CONTRIBUTING.md — drop our now-covered reviewer-chain line - bin/fm-brief.sh, bin/fm-dod-lib.sh, bin/fm-promote.sh, tests/fm-brief.test.sh — layering line moved to per-home config/brief-include.md (not in this repo) - tests/fm-task-delivery.test.sh — keep Captain's intent / Firstmate spec checks; drop the layering assertion Keep both: - bin/fm-spawn.sh — upstream meta fields plus usage_source/usage_log, account pin, usage bind, and the remote procevent reconcile - bin/fm-teardown.sh — usage-ledger header plus captain-hold retention - docs/configuration.md — upstream structure plus poll-shim, sanitizer, ack-before-spawn, and usage-ledger sentences - docs/scripts.md — upstream rows plus fm-x-watch-register.sh - tests/fm-gotmp.test.sh — both fm-env-lib.sh and fm-untrusted-text-lib.sh Manual: - bin/fm-bootstrap.sh — keep the upstream liveness lock; classify stuck remote helpers inside that lock - bin/fm-remote-secondmate-control.sh — upstream 4-arg relaunch; keep health and inbox-tick - bin/fm-watch.sh — upstream inbox policy plus remote inbox-tick; keep both check-loop variables - docs/remote-secondmates.md — match the inbox-tick keep Usage ledger kept. Layering line not kept in code. Co-authored-by: Derick D'souza <derick-dsouza@users.noreply.github.com>
Upstream fm_test_run_spawn now pins a throwaway user-home, so the usage-ledger spawn checks read that store. Teardown gotmp fixtures also link fm-usage-lib.sh because teardown still sources the retained ledger. Co-authored-by: Derick D'souza <derick-dsouza@users.noreply.github.com>
…am-2026-10-9321 sync: merge kunchenguid/firstmate main (5838f10)
Move remote alive-but-stuck upgrade into the full-mode liveness probe and remote inbox escalate reason into the health lib so bootstrap and watch stay one-call hooks. Keep health/inbox-tick on the remote control script. Co-authored-by: Derick D'souza <derick-dsouza@users.noreply.github.com>
…k-helper-hooks-9321 refactor: thin stuck-helper hooks into secondmate libs
…unchenguid#15) Implements harbor kunchenguid#664 R1-R10 on firstmate: rebase when dirty, refuse on red CI / missing Evidence / open ask-user / protected paths, respect the harbor queue-only freeze, then squash-merge with --match-head-commit and write a ledger note. Not enabled or deployed — callers opt in.
…chenguid#17) Call fm-pr-auto-merge for every armed GitHub PR poll on the check cadence. Kill switch FM_PR_AUTO_MERGE defaults to on. Harbor merges stay refused while HARBOR_DO_UNFREEZE is unset (tick gate + script gate). Triage_log only — never wakes on refuse/idle.
…unchenguid#16) Firstmate's own crew spawns had no fleet cap in code. A host may now set one command that every fresh ship/scout spawn must pass, under the task-set lock and before any endpoint, worktree, or record exists: <cmd> acquire <id>; non-zero refuses. fm-teardown calls <cmd> release <id> after the record is removed (never fails teardown). Unset = no-op. No shell eval. Relaunch and secondmate exempt. For harbor: harbor-slot-gate.sh fm-hook (nivasritech/harbor#728).
While HARBOR_DO_UNFREEZE is unset, the auto-merge tick and merge script refuse merges in every repo (not only */harbor). The PR stays open and queued. Unfrozen behaviour and the other R1–R10 gates are unchanged. Refs: harbor kunchenguid#676 (freeze), harbor kunchenguid#737 (merged during freeze; no revert).
A single transient `pi --list-models` blip was declaring needs re-login and waking the daily login-watch. Retry the catalog once so only a confirmed double failure becomes FAIL.
|
Speaking as Kun's firstmate (OSS triage, not the captain). Thanks @derickdsouza. I read the whole PR at head What the tip bundles: 42 files and about 4.4k lines. That's the pi login-probe retry from the Intent, plus a default-on PR auto-merge tick wired into VISION.md, rule by rule
Contract-class: new-default. The auto-merge tick, Telegram-ack spawn guard, and Relay trust changes all run on the unconfigured path. Security note: the Relay change widens which executable the watcher runs for This looks like the same wrong-parent push you described on #3533 (fork-home commits pushed to kunchenguid/firstmate). If the login-probe retry or the mention-text sanitizer is meant for upstream, a small generic PR for each would get a fresh look. |
Intent
The daily login-health watch keeps producing false FAILs for pi on the VPS: a transient
pi --list-modelscatalog blip makesbin/fm-agent-login-probe.shdeclare "needs re-login" from a single unverified pass. Confirmed transients: 2026-09-08, 2026-09-10, and again today 2026-10-09 (each FAIL was followed by a clean live re-run showing OK pi@g vps; grok/cursor/claude always OK). Each false FAIL burns a firstmate wake and risks escalating a credential problem that does not exist. The ask, per the queued task: add one retry before declaring a failure - a single blip must never produce FAIL.What Changed
bin/fm-agent-login-probe.sh, an agent-agnostic pi/grok/cursor/claude login health probe that retries a failedpi --list-modelscatalog pass once (locally and over the VPS ssh) so a single transient blip never reports FAIL, plusbin/fm-fleet-watch-poller.sh, a harness-independent when-watch supervisor with single-flight locking and cron install.bin/fm-pr-auto-merge.shwith thefm-pr-auto-merge-tick.shtick wired intofm-watch.shbehind theFM_PR_AUTO_MERGEkill switch, refusing merges for every repo while the harbor queue-only freeze is on), a per-task token usage ledger (bin/fm-usage-lib.sh, harness session log bound at spawn and token totals appended at teardown), and an optionalFM_SPAWN_GATE_CMDpre-spawn gate hook (bin/fm-spawn-gate-lib.sh, acquire infm-spawn.sh, release infm-teardown.sh).bin/fm-untrusted-text-lib.shsanitization of stashed mention strings (.text,.in_reply_to.text,.in_reply_to_chain[].text), validated alternate poll-shim registration viabin/fm-x-watch-register.sh, an ack-before-spawn guard that blocks long work until the initial relay answer is recorded, and stuck-remote-helper classification with replace-relaunch and parent-driven steering-inbox ticks viabin/fm-secondmate-health-lib.shand the liveness/watch wiring; updates the configuration, remote-secondmates, and scripts docs.Risk Assessment
✅ Low: The new commits are small and exactly implement the requested single catalog retry for pi with behavior-level tests; two confirmed failures still FAIL, the failure path for genuine re-login is preserved, and the bundled earlier commits were previously gated with no new defects found beyond one trivial duplicated assignment.
Testing
Exercised the login-health probe end-to-end through its public OK/FAIL stdout + exit-code contract, which is the exact surface the daily login-watch consumes (this change has no GUI; the captured CLI transcripts are the reviewer-visible end-user evidence). Ran the focused automated suites (login-probe and fleet-watch-poller, all passing), reproduced the reported false FAIL against the pre-fix script, and demonstrated the fixed script recovers from a single transient pi catalog blip without retrying healthy passes while still FAILing on a confirmed double failure, on both the local VPS path and the remote ssh path. Five transcript artifacts are in the evidence directory; the worktree was left clean.
Evidence: Pre-fix false FAIL reproduction: single transient pi catalog blip -> FAIL pi@vps (needs re-login), exit 1, after only 1 unverified pass (parent commit 8c7c604)
Source: Pre-fix false FAIL reproduction: single transient pi catalog blip -> FAIL pi@vps (needs re-login), exit 1, after only 1 unverified pass (parent commit 8c7c604)
Evidence: Fixed probe, same single blip: OK pi@vps, exit 0, exactly 2 pi invocations (one retry) - no FAIL, no firstmate wake (target commit 6e9e1e0)
Source: Fixed probe, same single blip: OK pi@vps, exit 0, exactly 2 pi invocations (one retry) - no FAIL, no firstmate wake (target commit 6e9e1e0)
Evidence: Fixed probe, catalog down on both passes: FAIL pi@vps (needs re-login), exit 1, 2 pi invocations - real credential problems still escalate
Source: Fixed probe, catalog down on both passes: FAIL pi@vps (needs re-login), exit 1, 2 pi invocations - real credential problems still escalate
Evidence: Fixed probe, healthy first pass: OK pi@vps, exit 0, only 1 pi invocation - no wasteful retry on a normal day
Source: Fixed probe, healthy first pass: OK pi@vps, exit 0, only 1 pi invocation - no wasteful retry on a normal day
Evidence: Remote ssh path (Darwin watch host -> VPS): single remote blip retried once -> OK pi@vps; remote double failure -> FAIL pi@vps (needs re-login)
Source: Remote ssh path (Darwin watch host -> VPS): single remote blip retried once -> OK pi@vps; remote double failure -> FAIL pi@vps (needs re-login)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
⏭️ **Rebase** - skipped
.agents/skills/agent-skill-trigger-index/SKILL.md- branch carries 20 commit(s) that exist on your local main branch but were never pushed to origin/main; rebasing would bundle this unrelated work (91 file(s)) into the PR:Push main to origin, or rebase your branch onto origin/main, before gating.
bin/fm-watch.sh:2779- The bundled auto-merge tick wiring (commit 43527d9, inside this branch's diff) initializesrejected_checks=twice back-to-back (lines 2779-2780) before the check sweep loop. The duplicate assignment is a harmless copy-paste leftover with no behavioral effect; dropping one line is a purely mechanical simplification.✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-agent-login-probe.test.sh (4/4 pass: blip recovers on one retry, double failure still FAILs, first-pass OK does not retry, absent pi fails as not installed)bin/fm-test-run.sh tests/fm-fleet-watch-poller.test.sh (7/7 pass, including login probe under minimal cron env and PATH-pi-on-Linux checks)Manual before/after end-to-end: pre-fix probe from parent commit 8c7c604 vs fixed probe from 6e9e1e0, run viaenv -i HOME=<empty> PATH=<fakebin>:/usr/bin:/bin FM_LOGIN_PROBE_SKIP_VPS=1with a fake pi whose first--list-modelscall exits 1 with an empty catalog (the transient blip) — pre-fix reproducedFAIL pi@vps (needs re-login)exit 1 after 1 call; fixed printedOK pi@vpsexit 0 after exactly 2 callsManual persistent-failure and healthy-catalog runs of the fixed probe (double blip -> FAIL needs re-login exit 1 after 2 calls; healthy -> OK exit 0 after 1 call, no wasteful retry)Manual remote-path run: fixed probe with fake uname(Darwin) + fake ssh (FM_LOGIN_PROBE_VPS_SSH=fakevps) where the remote pi catalog blips once ->OK pi@vpsafter 2 remote invocations; always-down remote catalog ->FAIL pi@vps (needs re-login)Confirmed thessh <alias> truereachability gate requiring non-empty stdout is pre-existing (present unchanged at parent commit 8c7c604 line 137), not introduced by this fixdocs/scripts.md:154- Pre-existing inventory gap, not staleness from the login-probe retry: docs/scripts.md lists 148 of 219 bin scripts and gained a row for fm-x-watch-register.sh during this branch, but the branch's other new fleet scripts (fm-agent-login-probe.sh, fm-fleet-watch-poller.sh, fm-pr-auto-merge.sh, fm-pr-auto-merge-tick.sh, and the new *-lib.sh helpers) have no rows. Each script's header remains the authoritative owner per the table's own preamble, so nothing is inaccurate. Worth a separate follow-up pass to decide inventory criteria; deliberately not bundled here because most of those scripts come from commits the user declined to treat as this PR's work.✅ **Push** - passed
✅ No issues found.