Skip to content

Merge upstream (kunchenguid/firstmate) into fork main - #8

Merged
Bre77 merged 19 commits into
mainfrom
fm/fm-upstream-integrate-r6
Jul 8, 2026
Merged

Bre77 merged 19 commits into
mainfrom
fm/fm-upstream-integrate-r6

Conversation

@Bre77

@Bre77 Bre77 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Intent

Catch the fork up with upstream (kunchenguid/firstmate main, through kunchenguid#339), merging origin/main into fork/main.

  • Five files conflicted; each was resolved by integrating both sides, never picking one wholesale.
    • bin/fm-watch.sh - fork's herdr semantic stale-dedup (busy_state_is_busy/stale_signal, resolving the backend busy state once and hashing on semantic agent state for herdr) coexists with upstream's wedge-escalation-count feature (FM_WEDGE_DEMAND_INSPECT_COUNT, .wedge-escalations-*, the demand-deep-inspection marker).
      • The one real code hunk (the hash-changed reset branch) now clears the stale-classification marker (fork's aae1e47 fix), the wedge timer, and the escalation count together, instead of dropping either fix.
    • bin/fm-brief.sh - fork's PR-body Intent contract and Code-comments contract sit alongside upstream's AGENTS.md-authoring-bar wording and the fm-ensure-agents-md.sh self-governance-section instruction; only the header comment block needed manual merging, the actual generated-brief body content had already auto-merged correctly.
    • tests/fm-brief.test.sh - kept every fork-added test (--fork-only, PR-body-by-mode, --amend, Code-comments contract) and added upstream's test_ship_project_memory_wording, in both the function-definition region and the invocation list at the bottom.
    • CONTRIBUTING.md / docs/scripts.md - one-line description conflicts (both sides had extended the same doc line); merged to mention both the herdr semantic-dedup coverage and the wedge-demand-marker coverage, and both the --fork-only brief flag and the fm-ensure-agents-md.sh self-governance-wording addition.
  • One additional fixup outside the flagged conflict set: bin/fm-ff-lib.sh auto-merged cleanly onto upstream's #331 fix (NUDGE_SECONDMATES now emits a stable fm-<id> selector instead of a raw, respawn-fragile window target), but the fork's own tests/fm-update.test.sh (added before that upstream fix landed, so git never flagged it as conflicting) still asserted the old main:fm-sm1 value in its non-fork-backward-compat case. Updated that one assertion to match the now-correct behavior; nothing else in that test file needed changing since the rest had already merged onto upstream's fixed expectations.
  • Scope boundary: no product behavior was deliberately changed beyond what upstream and the fork each already intended - this is purely conflict integration, plus the one test-expectation fix described above.

What Changed

  • Merge commit integrating origin/main (228963d) into fork/main (5d987a4), preserving full history from both lines.
  • Conflict resolutions in CONTRIBUTING.md, bin/fm-brief.sh, bin/fm-watch.sh, docs/scripts.md, tests/fm-brief.test.sh.
  • One follow-up test fix in tests/fm-update.test.sh to match upstream's stable-nudge-selector behavior that was adopted via clean auto-merge.

Risk Assessment

Low. No new features were added; this only reconciles two already-shipped lines of development. All fork-only capabilities (clickstack webhook receiver, fork-only delivery path, per-crew memory cgroup cap, fork-model fm-update phase (a), review-diff fork-only base, herdr semantic stale dedup, PR-body/code-comments brief contracts) were verified present and unchanged after the merge.

Testing

  • shellcheck bin/*.sh bin/backends/*.sh tests/*.sh - clean.
  • Every tests/*.test.sh (50 files) run individually - all pass, including the previously-failing fm-update.test.sh after the one-line fix.
Full narrative / original brief

Catch the Bre77 fork up with its upstream (kunchenguid/firstmate). Upstream has advanced, and merging it into the fork main conflicts on five files. Resolve the conflicts by integrating BOTH sides, and deliver the merged result.

Do:

  1. git fetch origin && git fetch fork.
  2. git merge origin/main (upstream). It conflicted on: CONTRIBUTING.md, bin/fm-brief.sh, bin/fm-watch.sh, docs/scripts.md, tests/fm-brief.test.sh.
  3. Resolve each conflict by integrating both sides - keep the fork's own features (per-crew memory cap, brief code-comments contract, review-diff fork-only base, clickstack webhook receiver, etc.), take upstream's improvements, and where both sides changed the same region, produce a result that preserves both intents.
  4. Complete it as a real merge commit (keep the upstream history; do not squash it away).
  5. Verify before delivering: shellcheck clean, full shell test suite green.

kunchenguid and others added 19 commits July 6, 2026 11:21
* fix(fleet-sync): auto-sync on merged-PR wake, accept project name

fm-fleet-sync.sh's single-project form failed on a bare project name
("not a directory"), forcing hand-typed full paths (4 manual runs in
one incident). It now resolves a bare name or projects/<name> against
the home's projects dir.

AGENTS.md now encodes the trigger: a wake whose status reports a
merged PR for a project cloned in this home runs fleet-sync for that
project as part of handling the wake, so a secondmate-reported merge
does not leave the primary's clone stale until the next session start
or teardown.

* no-mistakes(review): Fix fleet-sync project name shadowing

* no-mistakes(document): sync fleet-sync docs
* fix(spawn): canonicalize worktree-isolation guard against symlinked project prefixes

fm-spawn.sh compared a logical PROJ_ABS against the physically-resolved
pane cwd every backend reports, so a project reached through a symlinked
prefix (e.g. macOS's /tmp -> /private/tmp) could trip the isolation
guard's false refusal before treehouse ever moved the pane. Canonicalize
once into PROJ_ABS_REAL and compare against that everywhere instead.

* no-mistakes(review): Canonicalize spawn cwd comparisons

* no-mistakes(document): Refresh symlinked spawn docs
* docs: add Orca operator skill

* no-mistakes(document): Document Orca checklist

---------

Co-authored-by: Stephen Brouhard <[email protected]>
* fix(crew-state): detect green-PR CI monitoring, escalate repeat wedges

fm-crew-state.sh's ci step never distinguishes "still waiting on checks"
from "checks green, waiting on merge" via axi status alone, since a repo
that defers merge to the captain keeps the ci step at status=running for
the whole monitor phase. Read the ci step's own log tail (axi logs) for
the checks-passed marker and surface done instead of a false "validating
(running)" - verified against the real PR kunchenguid#252 run's ci.log.

The watcher's wedge timer can re-escalate the same stale pane forever
without ever signaling that it is a repeat; track a per-pane consecutive
escalation count and add a demand-deep-inspection marker to the wake
payload once it crosses a threshold, so the supervisor can no longer
dismiss each one as an isolated, still-validating pane.

Also clarify the ship-brief's checks-green line: it is owed at the
CI-ready return point, not after the background monitor-until-merge
loop finishes.

* no-mistakes(review): Captain, distinguish pending no-checks CI marker

* no-mistakes(review): Harden CI relapse handling

* no-mistakes(review): Block stale done during fixing

* no-mistakes(review): Captain, tighten CI status gating

* no-mistakes(review): Captain, harden stale CI green handling

* no-mistakes(review): Captain, recognize ranged CI rearm markers

* no-mistakes(document): Sync crew-state supervision docs
* fix(teardown): recover from a stale worktree git index.lock

A crew process killed mid-git-operation can leave a stale
.git/worktrees/<wt>/index.lock behind, making fm-teardown.sh's
`treehouse return --force` fail closed. On that failure, retry once
after a short wait (the owning process may be exiting), then remove
the lock and retry once more only when it is provably stale: old
enough by mtime and lsof shows no live holder on the lock or the
worktree itself. A lock that isn't provably stale is left in place and
the original failure still surfaces.

* no-mistakes(review): Harden teardown lock refusal paths

* no-mistakes(review): Harden stale-lock teardown safety rechecks

* no-mistakes(review): Harden stale teardown lock checks

* no-mistakes(document): Document teardown lock recovery
…-governance section (kunchenguid#307)

* Encode project AGENTS authoring bar

* no-mistakes(review): Captain, centralize CLAUDE promotion governance

* no-mistakes(review): make ensure_maintenance_section idempotent-success, drop || true guards

* no-mistakes(review): separate appended maintenance section on newline-less CLAUDE.md promotion

* no-mistakes(review): assert maintenance heading present before separator check in test

* no-mistakes(document): sync docs with AGENTS.md authoring bar and self-governance

---------

Co-authored-by: fmtest <[email protected]>
…chenguid#300)

* Add captain-invocable bearings skill

Generates a pick-up-where-I-left-off status report from live fleet
state to data/status-report-<YYYY-MM-DD>.md plus a concise chat
summary. Read-mostly procedure: reads backlog, per-task crew state
via bin/fm-crew-state.sh, open PRs via gh-axi, scout reports,
pending decisions, and date-gated queued work; composes the
exemplar's sections (TL;DR, Check first, Landed, In flight, Plans,
Decisions pending, Date-gated/queued); never tears down, merges, or
mutates task state as a side effect.

* no-mistakes(document): docs: list new /bearings skill in README built-in skills table
* fix(watcher): pin LC_ALL=C in fm_pid_identity for locale-invariant identity

ps's lstart date format follows the caller's LC_TIME/LC_ALL. The watcher records
its process identity under one locale, but arm/guard/turn-end re-read it under the
machine's ambient locale. On a non-C locale (e.g. ko_KR) the two strings differ
only in the date portion, so fm_watcher_lock_matches_pid / fm_watcher_healthy
reject a genuinely live watcher - breaking fm-watch-arm.sh, fm-guard.sh, and
fm-turnend-guard.sh on every non-C-locale machine.

Pin LC_ALL=C on that one ps call so the write and read sides agree regardless of
machine locale, matching the LC_ALL=C determinism the file already uses elsewhere.
Add a colocated regression test asserting fm_pid_identity is locale-invariant
across exported LC_ALL/LC_TIME.

* no-mistakes(document): Document watcher PID identity coverage
* docs: reconcile Codex App backend contract

* no-mistakes(document): Sync backend docs

* docs: clarify Codex Desktop bridge blocker

* no-mistakes(document): Align Codex App backend docs

* no-mistakes(test): Captain, stabilize watcher self-eviction test cadence

* no-mistakes(document): Document Codex App backend contract

* no-mistakes(document): Captain, document blocked codex-app coverage

* docs: make Codex App contract doc authoritative

* no-mistakes(document): Align Codex App backend docs

* docs: redact local Codex App smoke paths

---------

Co-authored-by: Stephen Brouhard <[email protected]>
* docs: add Codex App coordination skill

* no-mistakes(review): Captain, mark Codex App skill agent-only

* no-mistakes(document): Document Codex App backend boundary

* no-mistakes(document): Captain, document Codex Desktop backend boundary

* no-mistakes(lint): Captain, lint clean

* no-mistakes(document): Document Codex Desktop boundaries

* docs: narrow Codex App skill playbook
* fix(afk): recognize unbordered herdr composer rows to stop escalation redelivery loop

fm_backend_herdr_composer_state only recognized bordered composer rows
(the grok shape). Real claude and codex render their live input row
with no border at all, so once a harness's own startup banner scrolled
out of the capture window the classifier read the composer as unknown
forever. fm_backend_herdr_send_text_submit never confirmed "empty", so
escalate_flush never cleared state/.subsuper-escalations, and the
away-mode daemon retyped and resubmitted the same buffered digest every
housekeeping cycle - reproduced live against a real herdr+claude pane
(5+ identical deliveries in 40s).

The classifier now recognizes an unbordered (bare) composer row led by
a known prompt glyph alongside the existing bordered shape, keeping
whichever match is bottom-most so a stale decorative box never
outranks the live composer.

* no-mistakes(review): Narrow herdr bare prompt matcher

* no-mistakes(document): Sync herdr composer docs
…guid#323)

* fix(herdr): confirm message submit via native agent-state, not composer text

fm_backend_herdr_send_text_submit now confirms a landed submit by polling
herdr's own agent-state (agent get) for the idle->working transition instead
of reading composer content. Composer scraping remains, unchanged, for the
away-mode daemon's pre-injection empty-box guard only.

This fixes the practical effect of the codex idle-tip gap from the
2026-07-07 incident: codex's dynamic idle-composer hint text can no longer
misread as pending and block/mis-confirm a send, since confirmation no
longer looks at composer text at all. Verified empirically against real
claude and codex agents (timing, swallowed-Enter, unreadable-target, and
already-busy-target scenarios), and against the real away-mode daemon
end-to-end after updating its synthetic supervisor-pane test fixture to
register itself as a real herdr agent (herdr's own report-agent primitive)
so it can still exercise the new confirmation path.

* no-mistakes(review): Captain, harden herdr submit confirmation

* no-mistakes(review): Captain, harden herdr submit confirmation

* no-mistakes(document): Sync Herdr submit docs

* no-mistakes: apply CI fixes
* Add quota-balanced dispatch selection

* no-mistakes(document): Document dispatch selector guidance
* fix(session-start): deterministically respawn dead-shell secondmates

A secondmate agent that exits leaves its backend pane alive as a bare
shell. The session-start endpoint check only verified pane presence, so
recovery and the watcher (which exempts secondmates from stale-pane
detection) never noticed - evidence 2026-07-07: every secondmate in one
fleet was found sitting at a dead zsh shell.

Add fm_backend_agent_alive (bin/fm-backend.sh), a deeper per-backend
liveness probe distinct from pane presence: fm_backend_tmux_agent_alive
classifies the pane's live foreground process via tmux's own
pane_current_command, and fm_backend_herdr_agent_alive reuses the
already-verified pane_agent_state husk classifier. Both are conservative:
anything ambiguous reports unknown, never a false dead.

Wire this into a new session-start-only, locked-and-primary-only sweep in
bin/fm-bootstrap.sh that kills and respawns only a confidently dead
secondmate endpoint, leaving alive/unknown readings untouched - idempotent
by construction, so repeated runs converge without duplicating agents.

* no-mistakes(review): Guard raw secondmate liveness respawns

* no-mistakes(review): Fix detect-only bootstrap test

* no-mistakes(test): Pin liveness fixture harness

* no-mistakes(document): Sync secondmate liveness docs

* no-mistakes: apply CI fixes
* Fix NUDGE_SECONDMATES to print stable fm-<id> selectors.

Session-start secondmate sync used to accumulate raw backend window targets
into NUDGE_SECONDMATES, but the liveness sweep in the same bootstrap run can
respawn secondmates onto new endpoints. fm-send with those stale explicit
targets bypasses meta resolution and fails, while fm-<id> resolves correctly.

Accumulate fm-<id> in process_secondmate, update the bootstrap/update contracts
and /updatefirstmate skill, and add a herdr respawn regression test.

* no-mistakes(review): Captain, guard herdr regression jq dependency

* no-mistakes(document): Document stable secondmate nudge selectors

* no-mistakes(lint): Fix shell lint hints
* Make tasks-axi and quota-axi required bootstrap tools

Add both to the normal toolchain checks alongside lavish-axi, keep the
tasks-axi 0.1.1+ compatibility gate, and report quota-axi through the
standard MISSING install-consent flow. TASKS_AXI: available remains a
backlog-backend capability signal only; manual opt-out no longer suppresses
the missing-tool report.

Update bootstrap tests and point docs/configuration.md at the canonical
toolchain contract.

* no-mistakes(review): Clarify manual backlog bootstrap reporting

* no-mistakes(document): Document bootstrap AXI tools
Replace overwrite-in-place wording with explicit delete-then-create
instructions so agents do not modify an existing daily report file.
* Add primary turn-end guards for all harnesses

* no-mistakes(review): Normalize Codex hook cwd resolution

* no-mistakes(review): Fix OpenCode guard worktree anchoring

* no-mistakes(review): Anchor Codex guard outside nested roots

* no-mistakes(review): Anchor Codex guard to hook root

* no-mistakes(review): Avoid Grok permission escalation

* no-mistakes(document): Sync turn-end guard docs
…ate-r6

# Conflicts:
#	CONTRIBUTING.md
#	bin/fm-brief.sh
#	bin/fm-watch.sh
#	docs/scripts.md
#	tests/fm-brief.test.sh
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.

4 participants