Skip to content

fix(bin): keep home-summary collection inside its refresh deadline - #7376

Merged
kunchenguid merged 3 commits into
kunchenguid:mainfrom
LifeBringer:fm/firstmate-home-summary-timeout
Nov 12, 2026
Merged

kunchenguid merged 3 commits into
kunchenguid:mainfrom
LifeBringer:fm/firstmate-home-summary-timeout

Conversation

@LifeBringer

@LifeBringer LifeBringer commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Fixes #6257. On a home with many tasks and long status histories, bin/fm-home-summary-refresh.sh exits 124 at its unchanged 60-second deadline while bin/fm-fleet-snapshot.sh --secondmate-home-summary is still collecting, so the home summary stops updating. The snapshot composed every task row one task at a time after the bounded reads, and each row re-folded the task's whole status history through status_open_decisions, which forked subshells for every status line. This change runs each task's open-decision fold and row composition inside that task's own observation worker (still batched by FM_SNAPSHOT_LOCAL_READ_CONCURRENCY, default 8), and lets the fold helpers in bin/fm-classify-lib.sh fill an optional output variable so the whole-file fold forks nothing per line; called without that variable they print exactly what they printed before. The 60-second deadline, the per-child read bounds, the default concurrency, and the published summary content stay unchanged. Collection cost still grows with unbounded history, and the pending-reply retention from the issue's follow-up is out of scope; both are follow-ups. Earlier open PRs #6464 and #6980 target the same issue; the maintainer chooses the direction to keep. This revision rebases onto current main to clear a conflict with the timed fold view in _fm_decision_fold_line. Evidence, from the reproduction posted at #6257 (comment): running the incident-shaped case of tests/fm-home-summary-refresh.test.sh (12 tasks, about 508 status lines each, default 60s deadline) on main a9ae3c0 printed INCIDENT_WALL=37s on a quiet machine and 'not ok - the incident-shaped fleet did not publish within the default deadline' (stderr 'refresh exceeded its 60-second deadline') under background-QoS contention; the pre-rebase head fd404cb printed 6s quiet and 20s contended. After the rebase, 480 whole-file, per-line, and timed folds over 40 fuzzed status logs matched main byte for byte.
AI assistance: an assistant helped write this change and ran the documented checks through no-mistakes.

What Changed

  • bin/fm-fleet-snapshot.sh now folds each local task's open decisions and builds its row inside that task's own observation worker. Workers still run in batches of FM_SNAPSHOT_LOCAL_READ_CONCURRENCY (default 8). Before, every row was built one task at a time after the bounded reads finished. The 60-second refresh deadline, the per-child read bounds, and the published summary content are unchanged.
  • The fold helpers in bin/fm-classify-lib.sh (status_line_note, _fm_decision_key, _fm_key_at_note_head, _fm_decision_drop, _fm_decision_fold_line) accept an optional output variable. With it, a whole-file status-history fold starts no subshell per line. Without it, they print the same output as before.
  • tests/fm-home-summary-refresh.test.sh adds three cases: a hung row build that must still be stopped by the deadline, a check that row builds run concurrently, and an incident-shaped fleet (12 tasks with long status histories) that must publish within the default deadline. docs/configuration.md updates the FM_SNAPSHOT_LOCAL_READ_CONCURRENCY description to match the new behavior.

Risk Assessment

✅ Low: The out-variable forms of the fold helpers reproduce the old command-substitution results: trailing newlines are stripped the same way, invalid-slug and keyless paths match, and local names cannot collide with the caller variables (folded, key, note, stated, open). Moving each task's row composition into its own observation worker keeps the generation-race discard, the failure handling, and the empty-fleet output; the deadline, the read bounds, and the default concurrency are unchanged, as the intent requires.

Testing

I drove the real snapshot producer and refresh writer against a disposable lab home shaped like the incident, on both head and base. Head collected in 4s vs 26s (11s vs 60s at concurrency 1) and published in 7s vs 39s. The snapshot JSON was byte-identical, and the published summaries matched apart from nothing at all (the generated stamp was pinned and equal). Fuzzed fold-helper output on head matched base exactly in print and out-var modes. The targeted test file passed its new incident and concurrency cases every time. One unchanged existing case, a dead publication lock, flaked twice under host load and passed twice once load dropped; it is reported as a warning. No UI surface is involved, so the evidence is CLI transcripts and JSON.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Operator home with 12 tasks x 508-line status histories: fm-home-summary-refresh.sh publishes well inside its unchanged 60s deadline (local lab home, synthetic histories) ✅ pass live incident-head-vs-base.txt: head refresh exit=0 wall=7s published=yes; base exit=0 wall=39s
The secondmate home summary collected on head is byte-identical to base for the same home (published content unchanged) ✅ pass live incident-head-vs-base.txt 'SNAPSHOT JSON: byte-identical head vs base'; home-summary-head.json vs home-summary-base.json identical
Bounded concurrency: with FM_SNAPSHOT_LOCAL_READ_CONCURRENCY=1, collection still finishes (11s vs base 60s) and gives the same summary ✅ pass live incident-concurrency1.txt
Fold helpers called without an out-var print exactly what base printed, and the out-var path gives the same result (fuzzed adversarial status logs) ✅ pass live fold-fuzz-equivalence.txt: seeds 1 and 2, print and out-var identical to base
Repository regression test: incident-shaped fleet and concurrent row composition publish within the deadline ✅ pass live home-summary-refresh-test-run3.log lines 'ok - task rows are composed concurrently...' and 'ok - an incident-shaped fleet publishes inside the default deadline'
Evidence: Incident-shaped lab home: head vs base snapshot and refresh timing plus content equality

Source: Incident-shaped lab home: head vs base snapshot and refresh timing plus content equality

status lines per task:      508
head snapshot exit=0 wall=4s
base snapshot exit=0 wall=26s
SNAPSHOT JSON: byte-identical head vs base
{"state":"unknown","counts":{"active_children":0,"decisions_open":22,"holds":0,"queued":0,"landed":0,"endpoints":12},"decisions_open":[{"id":"fleet-1","key":"gate-1","verb":"needs-decision"},{"id":"fleet-10","key":"gate-10","verb":"needs-decision"},{"id":"fleet-10","key":"hold-10","verb":"blocked"},{"id":"fleet-11","key":"gate-11","verb":"needs-decision"},{"id":"fleet-12","key":"gate-12","verb":"needs-decision"},{"id":"fleet-12","key":"hold-12","verb":"blocked"},{"id":"fleet-12","key":"default","verb":"needs-decision"},{"id":"fleet-2","key":"gate-2","verb":"needs-decision"},{"id":"fleet-2","key":"hold-2","verb":"blocked"},{"id":"fleet-3","key":"gate-3","verb":"needs-decision"},{"id":"fleet-3","key":"default","verb":"needs-decision"},{"id":"fleet-4","key":"gate-4","verb":"needs-decision"},{"id":"fleet-4","key":"hold-4","verb":"blocked"},{"id":"fleet-5","key":"gate-5","verb":"needs-decision"},{"id":"fleet-6","key":"gate-6","verb":"needs-decision"},{"id":"fleet-6","key":"hold-6","verb":"blocked"},{"id":"fleet-6","key":"default","verb":"needs-decision"},{"id":"fleet-7","key":"gate-7","verb":"needs-decision"},{"id":"fleet-8","key":"gate-8","verb":"needs-decision"},{"id":"fleet-8","key":"hold-8","verb":"blocked"}]}

base refresh exit=0 wall=39s published=yes stderr=
head refresh exit=0 wall=7s published=yes stderr=
Evidence: Same scenario with FM_SNAPSHOT_LOCAL_READ_CONCURRENCY=1

Source: Same scenario with FM_SNAPSHOT_LOCAL_READ_CONCURRENCY=1

status lines per task:      508
head snapshot exit=0 wall=11s
base snapshot exit=0 wall=60s
SNAPSHOT JSON: byte-identical head vs base

identical apart from lab home path
Evidence: Published home-summary.json from head refresh

Source: Published home-summary.json from head refresh

{
  "schema": "fm-secondmate-home-summary.v1",
  "hold_classifier_schema": "fm-captain-hold-buckets.v1",
  "contributions": {
    "known": 0,
    "checked": 0,
    "counts": {
      "captain": 0,
      "fleet": 0,
      "maintainer": 0,
      "nobody": 0
    },
    "unmeasured": 0,
    "complete": true,
    "proven_clear": true,
    "stale_verdicts": 0,
    "missing_verdicts": 0,
    "unreadable_records": 0,
    "valid_until": 900,
    "captain": [],
    "captain_omitted": 0
  },
  "generated": "2026-11-12T12:00:00Z",
  "generated_epoch": 1794312000,
  "home": "/var/folders/ck/xknkdlkn2r988194hhjy9m0r0000gn/T//fm-lab.CzeCDC",
  "valid": false,
  "reason": "child current state unavailable: fleet-1, fleet-10, fleet-11, fleet-12, fleet-2, fleet-3, fleet-4, fleet-5, fleet-6, fleet-7, fleet-8, fleet-9",
  "invalidity": {
    "kind": "child_current_unavailable",
    "ids": [
      "fleet-1",
      "fleet-10",
      "fleet-11",
      "fleet-12",
      "fleet-2",
      "fleet-3",
      "fleet-4",
      "fleet-5",
      "fleet-6",
      "fleet-7",
      "fleet-8",
      "fleet-9"
    ]
  },
  "state": "unknown",
  "active_children": [],
  "decisions_open": [
    {
      "id": "fleet-1",
      "key": "gate-1",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-10",
      "key": "gate-10",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-10",
      "key": "hold-10",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-11",
      "key": "gate-11",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-12",
      "key": "gate-12",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-12",
      "key": "hold-12",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-12",
      "key": "default",
      "verb": "needs-decision",
      "summary": "keyless question for task 12",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-2",
      "key": "gate-2",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-2",
      "key": "hold-2",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-3",
      "key": "gate-3",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-3",
      "key": "default",
      "verb": "needs-decision",
      "summary": "keyless question for task 3",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-4",
      "key": "gate-4",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-4",
      "key": "hold-4",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-5",
      "key": "gate-5",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-6",
      "key": "gate-6",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-6",
      "key": "hold-6",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-6",
      "key": "default",
      "verb": "needs-decision",
      "summary": "keyless question for task 6",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-7",
      "key": "gate-7",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-8",
      "key": "gate-8",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-8",
      "key": "hold-8",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    }
  ],
  "holds": [],
  "queued": [],
  "landed": [],
  "endpoints": [
    {
      "id": "fleet-1",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-1",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-10",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-10",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-11",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-11",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-12",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-12",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-2",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-2",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-3",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-3",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-4",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-4",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-5",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-5",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-6",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-6",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-7",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-7",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-8",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-8",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-9",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-9",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    }
  ],
  "counts": {
    "active_children": 0,
    "decisions_open": 22,
    "holds": 0,
    "queued": 0,
    "landed": 0,
    "endpoints": 12
  },
  "omitted": [
    {
      "surface": "decisions_open",
      "count": 2
    }
  ]
}
Evidence: Published home-summary.json from base refresh

Source: Published home-summary.json from base refresh

{
  "schema": "fm-secondmate-home-summary.v1",
  "hold_classifier_schema": "fm-captain-hold-buckets.v1",
  "contributions": {
    "known": 0,
    "checked": 0,
    "counts": {
      "captain": 0,
      "fleet": 0,
      "maintainer": 0,
      "nobody": 0
    },
    "unmeasured": 0,
    "complete": true,
    "proven_clear": true,
    "stale_verdicts": 0,
    "missing_verdicts": 0,
    "unreadable_records": 0,
    "valid_until": 900,
    "captain": [],
    "captain_omitted": 0
  },
  "generated": "2026-11-12T12:00:00Z",
  "generated_epoch": 1794312000,
  "home": "/var/folders/ck/xknkdlkn2r988194hhjy9m0r0000gn/T//fm-lab.CzeCDC",
  "valid": false,
  "reason": "child current state unavailable: fleet-1, fleet-10, fleet-11, fleet-12, fleet-2, fleet-3, fleet-4, fleet-5, fleet-6, fleet-7, fleet-8, fleet-9",
  "invalidity": {
    "kind": "child_current_unavailable",
    "ids": [
      "fleet-1",
      "fleet-10",
      "fleet-11",
      "fleet-12",
      "fleet-2",
      "fleet-3",
      "fleet-4",
      "fleet-5",
      "fleet-6",
      "fleet-7",
      "fleet-8",
      "fleet-9"
    ]
  },
  "state": "unknown",
  "active_children": [],
  "decisions_open": [
    {
      "id": "fleet-1",
      "key": "gate-1",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-10",
      "key": "gate-10",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-10",
      "key": "hold-10",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-11",
      "key": "gate-11",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-12",
      "key": "gate-12",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-12",
      "key": "hold-12",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-12",
      "key": "default",
      "verb": "needs-decision",
      "summary": "keyless question for task 12",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-2",
      "key": "gate-2",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-2",
      "key": "hold-2",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-3",
      "key": "gate-3",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-3",
      "key": "default",
      "verb": "needs-decision",
      "summary": "keyless question for task 3",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-4",
      "key": "gate-4",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-4",
      "key": "hold-4",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-5",
      "key": "gate-5",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-6",
      "key": "gate-6",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-6",
      "key": "hold-6",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-6",
      "key": "default",
      "verb": "needs-decision",
      "summary": "keyless question for task 6",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-7",
      "key": "gate-7",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-8",
      "key": "gate-8",
      "verb": "needs-decision",
      "summary": "which base to rebuild from",
      "reason": null,
      "source": "status"
    },
    {
      "id": "fleet-8",
      "key": "hold-8",
      "verb": "blocked",
      "summary": "waiting on creds until 2026-12-01",
      "reason": null,
      "source": "status"
    }
  ],
  "holds": [],
  "queued": [],
  "landed": [],
  "endpoints": [
    {
      "id": "fleet-1",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-1",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-10",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-10",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-11",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-11",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-12",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-12",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-2",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-2",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-3",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-3",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-4",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-4",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-5",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-5",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-6",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-6",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-7",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-7",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-8",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-8",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    },
    {
      "id": "fleet-9",
      "state": "unknown",
      "source": "none",
      "endpoint": {
        "target": "fmlab:fm-fleet-9",
        "exists": false,
        "agent_alive": "not_checked",
        "status": "absent",
        "observed_at": "2026-11-12T12:00:00Z",
        "freshness": "fresh"
      }
    }
  ],
  "counts": {
    "active_children": 0,
    "decisions_open": 22,
    "holds": 0,
    "queued": 0,
    "landed": 0,
    "endpoints": 12
  },
  "omitted": [
    {
      "surface": "decisions_open",
      "count": 2
    }
  ]
}
Evidence: Fold helper fuzz equivalence base vs head

Source: Fold helper fuzz equivalence base vs head

seed 1: lines=    2637 base-vs-head-print=identical base-vs-head-outvar=identical open-records=678
seed 2: lines=    2610 base-vs-head-print=identical base-vs-head-outvar=identical open-records=765
Evidence: Targeted test run 3 (all pass)

Source: Targeted test run 3 (all pass)

ok - watcher-carried status append publishes the real home summary
ok - large backlog snapshots and home-summary publication stay within exec limits
ok - fleet snapshot transport does not require or mutate operational state
ok - parent snapshot consumes large child ledgers without argument transport
ok - live watcher cadence bounds publication staleness without signals
ok - fleet snapshot consumes the published local ledger by default
ok - writer kill and replacement preserve an atomic JSON ledger
ok - best-effort publication logs and continues
Terminated: 15             sleep 0.1
Terminated: 15             sleep 0.1
ok - best-effort refresh bounds publication lock acquisition
Terminated: 15             jq -e --arg home "$FM_HOME" '
    .schema == "fm-secondmate-home-summary.v1"
    and .hold_classifier_schema == "fm-captain-hold-buckets.v1"
    and .home == $home
    and (.generated | type) == "string"
    and (.generated | length) > 0
    and (.generated_epoch | type) == "number"
    and .generated_epoch >= 0
    and (.generated_epoch | floor) == .generated_epoch
    and (.valid | type) == "boolean"
    and (.state | type) == "string"
    and (.invalidity | type) == "object"
    and (.active_children | type) == "array"
    and (.decisions_open | type) == "array"
    and (.holds | type) == "array"
    and (.queued | type) == "array"
    and (.landed | type) == "array"
    and (.endpoints | type) == "array"
    and (.counts | type) == "object"
    and (.omitted | type) == "array"
  ' "$HOME_SUMMARY_TMP" > /dev/null 2>&1
ok - best-effort refresh bounds validation and publication
ok - best-effort refresh bounds state initialization
ok - best-effort refresh logs worker termination
ok - best-effort refresh bounds failure reporting fallback
ok - valid publication ignores an unavailable failure record
ok - publication completes on a home carrying accumulated status history
ok - a refresh killed while collecting keeps the last complete summary
ok - task rows are composed concurrently and publish within the refresh deadline
ok - an incident-shaped fleet publishes inside the default deadline
ok - producer skips remote per-task state probes
ok - a stalled publication does not delay the watcher liveness beacon
ok - publication remains single-flight across watcher restart
ok - bootstrap scopes retained failures to the current publication
Terminated: 15             sleep 0.1
ok - failure records preserve refresh attempt ordering
ok - repeated publication failure is reported at session start until it clears
Evidence: Targeted test run 1 (flaky dead-lock case failed under load)

Source: Targeted test run 1 (flaky dead-lock case failed under load)

ok - watcher-carried status append publishes the real home summary
ok - large backlog snapshots and home-summary publication stay within exec limits
ok - fleet snapshot transport does not require or mutate operational state
ok - parent snapshot consumes large child ledgers without argument transport
ok - live watcher cadence bounds publication staleness without signals
ok - fleet snapshot consumes the published local ledger by default
ok - writer kill and replacement preserve an atomic JSON ledger
ok - best-effort publication logs and continues
Terminated: 15             sleep 0.1
Terminated: 15             sleep 0.1
ok - best-effort refresh bounds publication lock acquisition
Terminated: 15             env FM_ROOT_OVERRIDE="$FM_ROOT" FM_HOME="$FM_HOME" FM_STATE_OVERRIDE="$STATE" FM_DATA_OVERRIDE="$DATA" FM_CONFIG_OVERRIDE="$CONFIG" FM_PROJECTS_OVERRIDE="$PROJECTS" "$SCRIPT_DIR/fm-fleet-snapshot.sh" --secondmate-home-summary > "$HOME_SUMMARY_TMP" 2> "$HOME_SUMMARY_ERR_TMP"
ok - best-effort refresh bounds validation and publication
ok - best-effort refresh bounds state initialization
ok - best-effort refresh logs worker termination
ok - best-effort refresh bounds failure reporting fallback
ok - valid publication ignores an unavailable failure record
ok - publication completes on a home carrying accumulated status history
ok - a refresh killed while collecting keeps the last complete summary
ok - task rows are composed concurrently and publish within the refresh deadline
ok - an incident-shaped fleet publishes inside the default deadline
ok - producer skips remote per-task state probes
ok - a stalled publication does not delay the watcher liveness beacon
not ok - a dead publication lock wedged publication
Evidence: Targeted test run 2 (flaky dead-lock case failed under load)

Source: Targeted test run 2 (flaky dead-lock case failed under load)

ok - watcher-carried status append publishes the real home summary
ok - large backlog snapshots and home-summary publication stay within exec limits
ok - fleet snapshot transport does not require or mutate operational state
ok - parent snapshot consumes large child ledgers without argument transport
ok - live watcher cadence bounds publication staleness without signals
ok - fleet snapshot consumes the published local ledger by default
ok - writer kill and replacement preserve an atomic JSON ledger
ok - best-effort publication logs and continues
Terminated: 15             sleep 0.1
Terminated: 15             rm -f "$lockdir/pid" "$lockdir/pid".tmp.* "$lockdir/fm-home" "$lockdir/pid-identity" "$lockdir/pid-start" "$lockdir/role" "$lockdir/watcher-path" 2> /dev/null
ok - best-effort refresh bounds publication lock acquisition
Terminated: 15             env FM_ROOT_OVERRIDE="$FM_ROOT" FM_HOME="$FM_HOME" FM_STATE_OVERRIDE="$STATE" FM_DATA_OVERRIDE="$DATA" FM_CONFIG_OVERRIDE="$CONFIG" FM_PROJECTS_OVERRIDE="$PROJECTS" "$SCRIPT_DIR/fm-fleet-snapshot.sh" --secondmate-home-summary > "$HOME_SUMMARY_TMP" 2> "$HOME_SUMMARY_ERR_TMP"
ok - best-effort refresh bounds validation and publication
ok - best-effort refresh bounds state initialization
ok - best-effort refresh logs worker termination
ok - best-effort refresh bounds failure reporting fallback
ok - valid publication ignores an unavailable failure record
ok - publication completes on a home carrying accumulated status history
ok - a refresh killed while collecting keeps the last complete summary
ok - task rows are composed concurrently and publish within the refresh deadline
ok - an incident-shaped fleet publishes inside the default deadline
ok - producer skips remote per-task state probes
ok - a stalled publication does not delay the watcher liveness beacon
not ok - a dead publication lock wedged publication
  • Outcome: ⚠️ 1 warning across 1 run (20m5s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

⚠️ **Rebase** - 1 warning
  • ⚠️ bin/fm-classify-lib.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/fm/firstmate-home-summary-timeout
✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ tests/fm-home-summary-refresh.test.sh:1081 - The unchanged case 'a dead publication lock wedged publication' in tests/fm-home-summary-refresh.test.sh failed in 2 of 4 head runs. Both failures came while the host load average was about 9 (15-minute average about 26). It passed in 2 later runs at load about 5 to 6, and base passed the same test file once at moderate load. The case gives a background best-effort publication only 10s (200 x 0.05s) to appear, which looks like a timing-only flake under host contention. This change speeds collection up and does not slow it down. It may still need a longer wait if CI hosts are as loaded.
  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Operator home with 12 tasks x 508-line status histories: fm-home-summary-refresh.sh publishes well inside its unchanged 60s deadline (local lab home, synthetic histories) ✅ pass live incident-head-vs-base.txt: head refresh exit=0 wall=7s published=yes; base exit=0 wall=39s
The secondmate home summary collected on head is byte-identical to base for the same home (published content unchanged) ✅ pass live incident-head-vs-base.txt 'SNAPSHOT JSON: byte-identical head vs base'; home-summary-head.json vs home-summary-base.json identical
Bounded concurrency: with FM_SNAPSHOT_LOCAL_READ_CONCURRENCY=1, collection still finishes (11s vs base 60s) and gives the same summary ✅ pass live incident-concurrency1.txt
Fold helpers called without an out-var print exactly what base printed, and the out-var path gives the same result (fuzzed adversarial status logs) ✅ pass live fold-fuzz-equivalence.txt: seeds 1 and 2, print and out-var identical to base
Repository regression test: incident-shaped fleet and concurrent row composition publish within the deadline ✅ pass live home-summary-refresh-test-run3.log lines 'ok - task rows are composed concurrently...' and 'ok - an incident-shaped fleet publishes inside the default deadline'
  • bash tests/fm-home-summary-refresh.test.sh on head, 3 times (first 2 failed only at the dead-publication-lock case under high load, third passed fully); the new incident-shaped and concurrent-composition cases passed in every run
  • bash tests/fm-home-summary-refresh.test.sh on an extracted copy of base a9ae3c0c (passed)
  • Lab home minted with bin/fm-lab-home.sh create (private tmux dir) and seeded with 12 tasks of 508-line incident histories plus varied open decisions: bin/fm-fleet-snapshot.sh --secondmate-home-summary run on head and base, timed, and the JSON compared
  • Real bin/fm-home-summary-refresh.sh run on head and base against the same lab home: exit code, wall time, and the published state/home-summary.json compared
  • The same lab scenario with FM_SNAPSHOT_LOCAL_READ_CONCURRENCY=1 on head and base
  • Fuzz equivalence: 80 random status logs (both key positions, malformed slugs, colon time tags, until tags, unterminated last line) folded through status_open_decisions, per-line _fm_decision_fold_line (plain and timed, kinds ship/scout/secondmate), status_line_note, and _fm_decision_key, on base (print) vs head (print and out-var)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Reviews (2) · Last reviewed commit: "no-mistakes(review): Rename per-task row..." · Reviewed by Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @LifeBringer for keeping home-summary collection inside its refresh deadline on fd404cbde1b6e08c41a5adc97b3eaf73c4d9e183. I reviewed the tip against main bf05a4fc and approved the pending fork CI runs for this head.

Gates: coverage guard, repo invariants and no-mistakes all pass on this head; attestation binds fd404cbde1b6e08c41a5adc97b3eaf73c4d9e183 with every pipeline step completed and no skips; live validation go 4/4 (incident-shaped lab vs base). Greptile is green. The red Full suite row only means our full-ci label is not on yet. Mergeable, not draft. Workflow-zero; no credential/installer touches.

Contract-class: restore. Main already promises FM_HOME_SUMMARY_TIMEOUT=60 for the complete refresh. The tip moves per-task open-decision fold and row composition into the existing observation workers and removes per-line classify forks, so the already-specified deadline can complete without raising the bound. Output equivalence vs base is in the evidence. VISION: One captain aligns · Authority aligns (no new autonomy) · Scripts-vs-agents aligns (exact fold/collection mechanics) · Restart aligns (last complete summary stays intact on deadline kill) · Delegation aligns · Fleet-outlives-vendor aligns · Scope aligns. Peace-of-mind aligns (stale home-summary is the crack this closes).

Next: nothing waiting on you. Ours to run Full; restore path means auto-merge after Full is green.

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 6, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @LifeBringer. Quick checks are green on fd404cbd. Contract-class is restore. I've added the full-ci label so the full suite runs; if it's green this merges on its own. Nothing more is needed from you.

A home of twelve scouts with long status histories repeatedly hit the
60-second home-summary refresh deadline while fm-fleet-snapshot.sh was
still collecting. After the bounded concurrent reads, every task row was
composed one task at a time, and each row re-folded that task's whole
append-only status history through status_open_decisions, which forked
four to five subshells per decision transition. Collection cost grew
with task count times history and had no concurrency of its own, so a
busy host pushed it past the whole-operation bound before validation or
publication.

Fold each task's status history inside its own observation worker while
its bounded current-state read is outstanding, and compose its row in
that same worker, so FM_SNAPSHOT_LOCAL_READ_CONCURRENCY now bounds the
whole per-task cost. Give the whole-file fold's per-line helpers the
optional out-variable form status_line_verb already uses, so the fold no
longer forks per line; every printed form is unchanged for other
callers.

The refresh deadline, per-child current-state bound, validation, atomic
last-good publication, and refresh lock are unchanged.
@LifeBringer
LifeBringer force-pushed the fm/firstmate-home-summary-timeout branch from fd404cb to daaa666 Compare November 12, 2026 17:42
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @LifeBringer for rebasing onto current main. I read the full diff on daaa66600726b999213cd58651a06d59378fca87 against main a9ae3c0c and approved the pending fork CI runs for this head.

The no-mistakes attestation binds daaa6660 with every step completed and no skips, and live validation is go 5/5. Greptile is 5/5 with no open threads. The PR is mergeable. Contract class is still restore: main already promises the 60-second home-summary refresh, and this change makes that path finish in time without changing the deadline, bounds, or published content.

Next: full-ci is already on, so the full suite now runs on this head. If it's green, this merges on its own. You don't need to do anything.

@kunchenguid
kunchenguid merged commit ed7fbb8 into kunchenguid:main Nov 12, 2026
24 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @LifeBringer — really appreciate you taking the time on this.

mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Nov 13, 2026
…unchenguid#7376)

* fix(bin): keep home-summary collection inside its refresh deadline

A home of twelve scouts with long status histories repeatedly hit the
60-second home-summary refresh deadline while fm-fleet-snapshot.sh was
still collecting. After the bounded concurrent reads, every task row was
composed one task at a time, and each row re-folded that task's whole
append-only status history through status_open_decisions, which forked
four to five subshells per decision transition. Collection cost grew
with task count times history and had no concurrency of its own, so a
busy host pushed it past the whole-operation bound before validation or
publication.

Fold each task's status history inside its own observation worker while
its bounded current-state read is outstanding, and compose its row in
that same worker, so FM_SNAPSHOT_LOCAL_READ_CONCURRENCY now bounds the
whole per-task cost. Give the whole-file fold's per-line helpers the
optional out-variable form status_line_verb already uses, so the fold no
longer forks per line; every printed form is unchanged for other
callers.

The refresh deadline, per-child current-state bound, validation, atomic
last-good publication, and refresh lock are unchanged.

* no-mistakes(review): Describe batched snapshot workers and remaining history-growth cost

* no-mistakes(review): Rename per-task row temp file to avoid dotted-id collisions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Home summary refresh exceeds its 60s deadline: snapshot re-runs full status_open_decisions fold per task

2 participants