Skip to content

Merge upstream: PR-poll security hardening, decision holds, instruction-ownership cleanup - #23

Merged
Bre77 merged 22 commits into
mainfrom
fm/fm-upstream-pull-t4
Jul 17, 2026
Merged

Bre77 merged 22 commits into
mainfrom
fm/fm-upstream-pull-t4

Conversation

@Bre77

@Bre77 Bre77 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Intent

Conflict resolution (7 files)

All conflicts were resolved by integrating both sides; no fork-only file or behavior was dropped.

  • AGENTS.md - three conflicts, all upstream's condensation of already-shared sections (wake-handling list, escalation phrasing, crewmate-brief scaffolding). Kept upstream's tightened prose in each, but preserved the fork-only lines it would otherwise have swept away: paging the captain via bin/fm-notify-captain.sh (section 9) and the --fork-only brief flag / docs/fork-only-delivery.md pointer (section 11). Section 13's fork-only skill entries (clickstack-alert-response, betterstack-alert-response) sat outside any conflict and merged in cleanly alongside upstream's new decision-hold-lifecycle/project-management/diagnostic-reasoning skills.
  • bin/backends/herdr.sh - one conflict in fm_backend_herdr_composer_state. Upstream added the Pi native-identity/separator-pair detection this fork's copy predates; the fork's own recent fix (PR fix(herdr): recognize queued-message hint and use unwrapped captures in composer_state #22, unshipped upstream) captures with recent-unwrapped instead of the width-dependent recent source so a narrow pane's word-wrap can't split or miscount the composer row. Took upstream's structure (session/pane setup, Pi detection) and layered the fork's recent-unwrapped capture calls on top - both fixes now apply together.
  • bin/fm-brief.sh - one header-comment wording conflict (local-only mode's done line). During resolution I initially kept the fork's older wording ("firstmate reviews, captain approves..."), which turned out to be stale against upstream's own "firstmate never personally reviews code" contract change; a later commit on this branch corrects it to upstream's "captain approves, firstmate merges to local main". The --fork-only/--amend flags and their full contracts sat outside the conflict and were untouched.
  • bin/fm-pr-check.sh - two conflicts: adopted upstream's hardened arm flow in full (validated atomic sidecar + static template, replacing the fork's old dynamic check.sh heredoc). The fork-only PR-activity-poll feature (bin/fm-pr-activity-poll.sh, surfacing new PR comments/reviews as pr-comment wakes) no longer needs a hand-rolled check.sh; it's re-wired one layer up, in the watcher itself (next bullet), so it benefits from upstream's security hardening instead of fighting it.
  • bin/fm-watch.sh - two conflicts. (1) Sequencing: upstream now runs the non-executing PR-check migration before lock acquisition; the fork writes its own watcher identity into the lock owner dir via a prep_fn hook for the turnend-guard race fix (PRs fix(watcher): publish watch lock identity atomically to close turnend-guard race #19-21). Kept both, migration first, identity-write during lock acquire. (2) Wired the fork-only activity poll into the per-task check loop: after the byte-static merge poll finds a tracked PR still open (empty output), the watcher now also runs bin/fm-pr-activity-poll.sh and surfaces its pr-comment lines as the wake reason - merge still takes precedence and a merged PR never triggers an activity-poll gh api call, same contract as before.
  • docs/scripts.md - two conflicts, purely from the same file list growing on both sides; combined rows for upstream's new fm-decision-hold.sh, fm-check-register.sh, fm-check-lib.sh, fm-pr-lib.sh, fm-pr-poll.sh, fm-pr-check-migrate.sh plus the fork's fm-pr-activity-poll.sh (updated to describe it as watcher-run rather than check.sh-run) and the fm-brief.sh row's fork-only-delivery mention.
  • tests/fm-spawn-agent-secrets.test.sh - a modify/delete conflict from the mid-pull upstream revert of feat: gate local agent secret injection kunchenguid/firstmate#658: upstream deleted this test along with the feature it covered; took the deletion.

Fixes for silent (non-textual) integration gaps

Three problems surfaced only by running the test suite, not by git merge itself - each is an upstream refactor or new invariant landing on lines that never textually overlapped the fork's own code, so the merge produced no conflict but broke at runtime:

  • bin/fm-bootstrap.sh: upstream renamed the shared write_if_changed(dest, content) helper to the hardened x_mode_write_if_changed(dest, content, mode) (atomic write + mode/device/link-count validation) and updated its own X-mode call sites, but the fork's ClickStack and BetterStack webhook shim setup (added on non-overlapping lines) still called the old, now-deleted name. Fixed both call sites to use the new helper.
  • PR-poll security hardening vs. the fork's other watcher checks: the hardened watcher now requires every state/*.check.sh to be either the exact-content-validated X-mode shim or a registered custom check (bin/fm-check-register.sh); anything else is treated as a legacy poll needing migration. The fork's ClickStack/BetterStack poll shims were neither, so bin/fm-pr-check-migrate.sh quarantined them as ambiguous legacy polls on the very first post-merge bootstrap+watcher cycle, permanently breaking both alert features. Fixed by registering both shims via fm-check-register.sh at arm time (and removing the resulting .check-trust file on opt-out); updated the two suites' "no duplicate artifact" file-count assertions to account for it.
  • bin/fm-brief.sh: a merge-conflict resolution mistake (see above) left a phrase upstream's own new firstmate-instruction-owners test explicitly forbids; corrected to upstream's wording.

Validation

  • bash -n on every bin/*.sh and bin/backends/*.sh - clean.
  • shellcheck -x -S warning on every file touched by the merge or the follow-up fixes - clean, no findings.
  • Rewrote tests/fm-pr-check.test.sh (fork-only) for the new architecture: it previously drove the old dynamic check.sh directly, which no longer exists. It now tests fm-pr-activity-poll.sh standalone (watermark init/preservation, item formatting/truncation, gh api error handling) plus integration tests that run the real bin/fm-watch.sh bounded to verify it surfaces a pr-comment wake when the tracked PR is open and never calls the activity poll once merged. All 7 pass.
  • Full tests/*.test.sh suite (82 files after the deletion above): every file passes, including tests/fm-pr-check-security.test.sh (upstream's own hardening tests, unmodified - confirms the fork's watcher and bootstrap changes don't regress the security properties it tests) and tests/fm-crew-memory-cap.test.sh (confirms the fork's per-crew systemd-run memory cap, unrelated to and unaffected by the reverted secrets feature, still works).
  • One pre-existing, unrelated flake in tests/fm-afk-launch.test.sh ("launcher signal: interrupted lifecycle resumed or retained its lock") reproduced identically on a clean pre-merge fork checkout, confirming it predates this pull (same flake PR fix(herdr): recognize queued-message hint and use unwrapped captures in composer_state #22 already documented).
  • Diffed the file list against pre-merge main: no files were deleted; every fork-only file (bin/fm-notify-captain.sh, bin/fm-fork-deliver.sh, bin/fm-pr-activity-poll.sh, bin/fm-clickstack-recv.sh, docs/fork-only-delivery.md, docs/clickstack-webhook.md, docs/betterstack-webhook.md, the ClickStack/BetterStack alert-response skills) is present and unchanged in content.

kunchenguid and others added 22 commits July 14, 2026 20:02
…d#587)

* fix: close away-mode blocker supervision gap

* no-mistakes(review): Gate teardown retries and verify U+2063 dedupe

* no-mistakes(test): Fail closed on incomplete Pi composer separators

* no-mistakes(document): Document Pi composer recognition and return gating
* support Pi max thinking profiles

* no-mistakes(review): Captain, allow Pi max dispatch profiles
…nguid#595)

* Clarify validation response ownership

* no-mistakes(document): Clarify yolo response ownership
* Add instruction owners foundation

* no-mistakes(document): Refresh project-management owner pointers
…kunchenguid#626)

* docs: compress firstmate operating contract

* docs: make delivery rigor single-owner

PR B already removed personal and stacked review requirements, but it did not explicitly assign rigor to the selected delivery path or forbid risk-based manual clean gates. That gap still permitted the Hi Bit inversion.

* no-mistakes(review): Honor configured merge authority across faster delivery paths

* no-mistakes(document): Align docs with compressed operating contract
* Add durable captain decision holds

* no-mistakes(review): Validate decision hold retries and origin paths

* no-mistakes(review): Enforce durable decision lifecycle boundaries

* no-mistakes(review): Harden decision display and partial retry recovery

* no-mistakes(test): Update scout teardown fixtures for decision inventory

* no-mistakes(document): Align decision lifecycle and scout teardown documentation

* no-mistakes: apply CI fixes

* no-mistakes(review): Reconcile terminal decision holds

* no-mistakes(document): Align captain decision-hold documentation
* fix: harden PR check artifacts

* fix: close PR check migration gaps

* fix: close PR check retry gaps

* fix: clarify migration outcomes and ESM boundary

* fix: keep failed migrations authoritative

* test: use inert PR validation fixtures

* no-mistakes(review): Reserve noncanonical PR quarantine namespace

* no-mistakes(review): Prevalidate final PR-check teardown artifacts

* no-mistakes(review): Preserve X metadata and validate teardown IDs

* no-mistakes(review): Initialize migration state before watcher exclusion

* no-mistakes(review): Isolate failed poll migrations from bootstrap recovery

* no-mistakes(review): Allow safe polling during incomplete private repairs

* no-mistakes(review): Authenticate watcher checks at execution time

* no-mistakes(review): Preserve custom checks with hash-bound registration

* no-mistakes(review): Clean custom check snapshots on watcher signals

* no-mistakes(review): Stop watcher checks promptly on signals

* no-mistakes(review): Terminate watcher check groups before cleanup

* no-mistakes(document): Correct stale X-mode watcher documentation

* fix: drain returned watcher check groups

* no-mistakes(review): Harden quarantine links and recover validated replacement polls

* no-mistakes(review): Preserve X mode across shim version transitions

* no-mistakes(review): Refresh legacy X shims before marker short-circuits

* no-mistakes(document): Correct persisted PR-check artifact documentation

* no-mistakes(document): Correct stale PR-check documentation

* fix: bind PR poll repair provenance

* no-mistakes(review): Enforce single-link ownership for custom check artifacts

* no-mistakes(review): Preserve private checks, X polling, and lifecycle IDs

* no-mistakes(review): Separate task creation and legacy teardown validation

* no-mistakes(review): Restore safe legacy operations and teardown validation

* no-mistakes(review): Disambiguate migration obligations and preserve legacy retries

* no-mistakes(review): Preserve fail-closed diagnostics and legacy quarantine evidence

* no-mistakes(review): Reconcile legacy migration retries and teardown collisions

* no-mistakes(review): Force legacy namespace reconciliation before marker short-circuits

* no-mistakes(document): Document private poll artifact safety contracts

* no-mistakes(lint): Suppress intentional literal-dollar lint finding

* fix: migrate historical X poll identity

* fix: harden PR check artifacts

* no-mistakes(review): Preserve fail-closed diagnostics and legacy quarantine evidence

* no-mistakes(review): Reconcile legacy migration retries and teardown collisions

* fix: migrate historical X poll identity

* no-mistakes(review): Harden X-mode artifact publication against symlink corruption

* no-mistakes(review): Guard X artifact publication

* no-mistakes(review): Enforce private X artifact reads

* no-mistakes(test): Fix backend compatibility fixture dependencies

* no-mistakes(document): Refresh PR-check documentation

* no-mistakes(lint): Remove unused x-mode test locals

* no-mistakes: apply CI fixes
* fix: compact session-start backlog digest

* no-mistakes(test): Fix legacy backend fixture helper

* no-mistakes(test): Fix watcher exit wait helper

* no-mistakes(document): Document compact backlog digest
* fix: dedupe stale watcher guard banner

* no-mistakes(review): Keep read-only guard state nonmutating

* no-mistakes(document): Clarify stale watcher docs
* fix: balance bearings landed defaults

* no-mistakes(document): Document balanced landed baseline

* no-mistakes: apply CI fixes
* docs: clarify captain-facing translation contract

* no-mistakes(review): Restore runtime fallback mandate

* no-mistakes(document): Align Bearings translation wording
…#646)

* fix: make bootstrap nudges deterministic

* no-mistakes(review): Honor state override for bootstrap nudges

* no-mistakes(review): Update benign bootstrap documentation labels

* no-mistakes(review): Validate bootstrap nudge retry markers

* no-mistakes(document): Align bootstrap nudge documentation

* no-mistakes: apply CI fixes
…nchenguid#649)

* Clarify concise secondmate registry contract

* no-mistakes(review): Expand secondmate registry boilerplate coverage

* no-mistakes(document): Point route docs to owner
…kunchenguid#654)

* fix(bin): strip quotes on blocked_by in decision-hold resolve

tasks-axi quotes multi-entry blocked_by as "a,b,c", so the comma-boundary
membership test only matched middle elements. Strip surrounding quotes
before matching so first and last hold ids resolve correctly.

* no-mistakes(document): Refresh decision-hold regression evidence
* feat(secondmate): inherit shared captain preferences

* no-mistakes(review): Honor shared captain data overrides

* no-mistakes(review): Honor bootstrap data override registry

* no-mistakes(document): Refresh shared inheritance docs

* no-mistakes(document): Clarify inherited local-material docs
* feat(spawn): gate local agent secret injection

* fix(spawn): align final Keychain slot

* no-mistakes: apply CI fixes
* test: isolate herdr autodetect smoke session

* no-mistakes(review): Restored autodetect smoke gate bypass

* no-mistakes(test): Harden Herdr lab provisioning

* no-mistakes(document): Refresh Herdr lab docs
# Conflicts:
#	AGENTS.md
#	bin/backends/herdr.sh
#	bin/fm-brief.sh
#	bin/fm-pr-check.sh
#	bin/fm-watch.sh
#	docs/scripts.md
Several upstream changes merged silently (no textual conflict) against
fork-only additions in ways that broke at runtime rather than at merge
time:

- fm-bootstrap.sh: upstream renamed the shared write_if_changed helper to
  the hardened x_mode_write_if_changed(dest, content, mode), but the
  fork's ClickStack/BetterStack webhook shim setup still called the old,
  now-deleted name on non-overlapping lines. Switched both call sites to
  the new helper.
- Upstream's PR-poll security hardening made the watcher require every
  state/*.check.sh file to be either the x-mode shim or a registered
  custom check; the fork's ClickStack/BetterStack poll shims were neither,
  so the new migration step quarantined them as ambiguous legacy polls on
  first run, permanently breaking both alerts features. Registered both
  shims via bin/fm-check-register.sh at arm time (and clean up the
  resulting check-trust file on opt-out), updating the two tests' "no
  duplicate artifact" counts to include it.
- bin/fm-brief.sh: a merge conflict resolution kept the fork's stale
  "firstmate reviews, captain approves" local-only wording instead of
  upstream's updated "captain approves" phrasing, tripping the new
  instruction-owners test that forbids the old personal-review phrasing.
- tests/fm-spawn-agent-secrets.test.sh: the "op absent" gate case let a
  real system-installed op leak in through the ambient PATH tail; added a
  fake failing systemd-run so the fork's separate memory-cap wrapper
  (tests/fm-crew-memory-cap.test.sh) doesn't interfere with either.
# Conflicts:
#	tests/fm-spawn-agent-secrets.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.

3 participants