Skip to content

feat(bin): track the fleet-shared learnings record across home syncs - #6

Merged
kirkins merged 8 commits into
mainfrom
fm/firstmate-fork-sync-20261010b
Oct 10, 2026
Merged

kirkins merged 8 commits into
mainfrom
fm/firstmate-fork-sync-20261010b

Conversation

@kirkins

@kirkins kirkins commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Intent

Fork sync for firstmate: merge the two local-main learnings-only commits into origin/main so the merged away-cap fix (PR 5) and the fleet learnings reach running sessions on the next update pass. The merge was content-disjoint with no conflicts; suites (fm-spend-cap, fm-pipeline-spend) and lint already pass locally with FM_LINT_JOBS=1. Learnings data files are captain-private durable records being synced, not new content to review. PR 6 exists but was refused at merge for being raised outside no-mistakes; this run supersedes it procedurally.

What Changed

  • Made data/learnings.md the one tracked file under the otherwise-gitignored data/ dir (.gitignore now uses data/* with a !data/learnings.md exception) and seeded it with the fleet's durable learnings record (emergency SSH access, k3s dead-replica cleanup, fleet service access).
  • Added preserve_pretracking_learnings() to bin/fm-ff-lib.sh and wired it into both the fast-forward and redundant-divergence reset --keep advance paths: when a target introduces the tracked file over a home's pre-tracking local copy, the copy is moved to a dated data/learnings.local.*.md sibling instead of blocking or clobbering the advance, and a converged home still reads clean.
  • Updated the skills (stow, secondmate-provisioning, operational-home-layout, updatefirstmate), AGENTS.md, CONTRIBUTING.md, and docs to the tracked fleet-shared contract (secondmate homes treat data/learnings.md as a read-only primary-shipped input like captain-shared.md), and added T15/T16 tests in tests/fm-secondmate-sync.test.sh covering convergence over a local copy and that preservation never fires without an advance.

Risk Assessment

⚠️ Medium: The merge plus three approved fix rounds now form a coherent, behavior-tested contract change, but it inverts a repo-wide privacy invariant (one tracked file under previously wholesale-gitignored data/) and adds state-transition logic to the shared fast-forward helper every fleet home depends on, with only a transient, self-remediating remote-host skew remaining.

Testing

Drove the real update-pass product end-to-end in disposable fixture worlds: the fleet learnings record reached the primary and a running secondmate home in one pass with the pre-tracking local copy preserved at a dated sibling and the home reading clean, restart-secondmates scheduling the live session; adversarially, a diverged home was skipped with its learnings byte-for-byte untouched and a converged home's curated tracked learnings refused the unsafe advance at the dirty guard. Both modified suites and git's own ignore resolution confirm the tracked-learnings contract; every scenario passed.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
One update pass delivers the tracked fleet learnings to the primary checkout and a running secondmate home ✅ pass live evidence/fm-update-learnings-live.txt: 'firstmate: updated', 'secondmate sm1: preserved pre-tracking local data/learnings.md at .../data/learnings.local.<stamp>.md', 'secondmate sm1: updated', 'restar…
A home's pre-tracking local learnings copy is preserved only when the home actually advances (no preservation side effect on a skipped pass) ✅ pass live evidence/fm-learnings-adversarial.txt section A: diverged home 'skipped: diverged from origin/main; reconciliation required' with durable record, HEAD unchanged, data/learnings.md still the local copy…
The tracked learnings record converges over a home's local copy instead of wedging every future fast-forward ✅ pass live evidence/fm-update-learnings-live.txt (home advances c0afacf..tip over its untracked copy) and suite T15, which asserts FF_STATUS=updated, fleet record landed, dated sibling holds local bytes, and cle…
A converged home's locally curated tracked learnings is never clobbered by a later update pass ✅ pass live evidence/fm-learnings-adversarial.txt section B: 'secondmate sm1: skipped: dirty working tree', HEAD unchanged, curated bytes intact, no restart forced
The .gitignore exception tracks exactly data/learnings.md while the rest of data/ stays captain-private in every home ✅ pass live git check-ignore in the real worktree and in the advanced fixture home: data/learnings.md not ignored (tracked), data/captain.md ignored; git ls-files data/ lists only learnings.md; fm-shared-captain-…
Evidence: Live fm-update.sh pass: fleet learnings reach primary and secondmate home, local copy preserved, home clean, restart scheduled

Source: Live fm-update.sh pass: fleet learnings reach primary and secondmate home, local copy preserved, home clean, restart scheduled

=== fixture world: /tmp/fm-live-update.hyeBkV ===
--- before: secondmate home HEAD=925db34; primary main=925db34; origin tip=27932f7
--- before: home data/: captain.md
learnings.md

=== running the real bin/fm-update.sh (one update pass) ===
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 0s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e /tmp/fm-live-update.hyeBkV/world1/main/.pi/extensions/fm-primary-turnend-guard.ts -e /tmp/fm-live-update.hyeBkV/world1/main/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
firstmate: updated 925db34..27932f7
no watches registered
secondmate sm1: preserved pre-tracking local data/learnings.md at /tmp/fm-live-update.hyeBkV/world1/sm1/data/learnings.local.20261010T081018Z.md
secondmate sm1: updated 925db34..27932f7
reread-firstmate: no
restart-secondmates: fm-sm1
nudge-secondmates: none
=== fm-update.sh exit=0 ===

=== observable results ===
--- primary checkout now at: 27932f7 (tip 27932f7)
--- primary tracked learnings present: data/learnings.md content: # Fleet learnings (tracked record)
--- secondmate home now at: 27932f7
--- home data/ listing:
captain.md
learnings.local.20261010T081018Z.md
learnings.md
--- home learnings.md (tracked fleet record): # Fleet learnings (tracked record)
--- preserved sibling: /tmp/fm-live-update.hyeBkV/world1/sm1/data/learnings.local.20261010T081018Z.md content: home-local learning (pre-tracking)
--- home git status --porcelain: []
--- git check-ignore in home: data/learnings.md -> not-ignored; data/captain.md -> data/captain.md
--- divergence record: none
Evidence: Adversarial fm-update.sh drives: diverged home untouched, curated tracked learnings refuse dirty advance

Source: Adversarial fm-update.sh drives: diverged home untouched, curated tracked learnings refuse dirty advance

############ A) diverged home: skipped, learnings untouched ############
●  repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e /tmp/fm-live-adv.Pn912s/advA/main/.pi/extensions/fm-primary-turnend-guard.ts -e /tmp/fm-live-adv.Pn912s/advA/main/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
secondmate sm1: skipped: diverged from origin/main; reconciliation required (record: /tmp/fm-live-adv.Pn912s/advA/home/state/.secondmate-update-reconcile/sm1.pending)
reread-firstmate: no
restart-secondmates: none
nudge-secondmates: none
--- home HEAD: before=8909c75d47d427ad394d9f4db4f850b7ecf7dd9e after=8909c75d47d427ad394d9f4db4f850b7ecf7dd9e (advanced? no)
--- home data/ listing: learnings.md 
--- learnings.md still the local copy: home-local learning (pre-tracking)
--- sibling created: NONE

############ B) converged home with curated tracked learnings ############
--- converged at be83b39; porcelain: []
secondmate sm1: skipped: dirty working tree
reread-firstmate: no
restart-secondmates: none
nudge-secondmates: none
--- home HEAD after: be83b39 (origin tip 94d050b; advanced? no)
--- curated bytes still present: # locally curated learning (session wrote here)
Evidence: fm-secondmate-sync suite: T15/T16 pass

Source: fm-secondmate-sync suite: T15/T16 pass

ok - T15 tracked learnings: the fleet record converges while the home's local copy is preserved ok - T16 preserve-only-on-advance: a skipped home keeps its learnings untouched # all fm-secondmate-sync tests passed

ok - T15 tracked learnings: the fleet record converges while the home's local copy is preserved
ok - T16 preserve-only-on-advance: a skipped home keeps its learnings untouched
# all fm-secondmate-sync tests passed
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=19707

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⚠️ **Rebase** - 1 warning
  • ⚠️ data/learnings.md - branch carries 2 commit(s) that exist on your local main branch but were never pushed to origin/main; these may be unintended bundled work (proposed PR changes 1 file(s)):
  • 28612b8 Record 2026-10-10 fleet notes in learnings (mac secondmate, capacity pivots, credential cross-reference rule)
  • 79170da Record emergency SSH procedure and debris-cleanup notes in learnings

Confirm these commits belong in this PR before approving, or manually separate the intended work onto origin/main before gating.

🔧 No changes applied.
1 warning still open:

  • ⚠️ data/learnings.md - branch carries 2 commit(s) that exist on your local main branch but were never pushed to origin/main; these may be unintended bundled work (proposed PR changes 1 file(s)):
  • 28612b8 Record 2026-10-10 fleet notes in learnings (mac secondmate, capacity pivots, credential cross-reference rule)
  • 79170da Record emergency SSH procedure and debris-cleanup notes in learnings

Confirm these commits belong in this PR before approving, or manually separate the intended work onto origin/main before gating.

no changes applied: bundled local-default commits require manual separation or explicit approval; the rebase conflict resolver cannot safely select commits to discard.

⚠️ **Review** - 1 info
  • ⚠️ data/learnings.md:1 - This merge makes data/learnings.md a tracked file headed for origin/main, but the repo's own policy declares data/ captain-private and gitignored (AGENTS.md:48 ".env, data/, ... are captain-private and gitignored"; .gitignore:3 data/; docs/configuration.md:666 "it is gitignored"; docs/configuration.md:669 "There is no shared learnings file by captain decision"), and the secondmate sync contract relies on that invariant: .agents/skills/secondmate-provisioning/SKILL.md:103 guarantees updates "never touch the gitignored operational dirs, so a secondmate's backlog, projects, and in-flight work are never disturbed". Concrete failing sequence after this lands on origin/main: (1) a standalone secondmate/clone home holds its own untracked domain-local data/learnings.md (tests/fm-shared-captain-inheritance.test.sh:5,52 asserts learnings stays domain-local in every home); (2) its next /updatefirstmate origin refresh or guarded fast-forward (SKILL.md:101,107) targets a commit that adds tracked data/learnings.md; (3) git refuses ("untracked working tree files would be overwritten by merge") or flags the home dirty, so firstmate updates stop flowing to exactly the homes that have their own learnings — undermining this change's own stated goal of learnings reaching running sessions. In the primary, any session's uncommitted learnings curation (AGENTS.md:66,149 instructs sessions to write there) now dirties a tracked file, tripping the "dirty homes launch unchanged with a warning" guard. The missing policy decision: whether the captain-private learnings contract becomes tracked-and-fork-synced (requiring doc/.gitignore updates to match plus a per-home reconcile procedure), or stays local-only (untrack the file and distribute the content another way). The intent authorizes the content sync but never addresses overriding the gitignored/captain-private contract or the update-pass wedge, so this needs the captain's explicit call; remedy extends beyond correcting the merge, hence ask-user rather than auto-fix.
  • ℹ️ data/learnings.md:1 - The new file is 11,725 bytes ≈ 3,909 estimated tokens (bin/fm-startup-memory-budget.sh estimator: ceil(bytes/3)), which is ~52% of the 7,500-token default startup budget that data/captain.md + data/captain-shared.md + data/learnings.md share (docs/configuration.md:673). Depending on the primary's live captain files and configured budget, the startup growth check may report an over-budget finding after this sync; that surface is advisory by design and the stow aging-tier contract is expected to curate it, so no action required — noting the share so the budget signal is not a surprise.

🔧 Fix applied.
1 warning still open:

  • ⚠️ AGENTS.md:48 - Fix round 1 (commit 6aa76a1) reconciled the new tracked-fleet learnings contract in .gitignore:3-4, docs/configuration.md:668-673, .agents/skills/secondmate-provisioning/SKILL.md:103,132, and .agents/skills/updatefirstmate/SKILL.md:35, but left AGENTS.md asserting the old contract it was replacing: line 48 still declares ".env, data/, state/, config/, projects/, and .no-mistakes/ are captain-private and gitignored" (data/learnings.md is now tracked fleet-shared), line 66 still calls data/learnings.md "curated home-local knowledge", and line 149 still says "Fleet-local operational facts belong in curated, home-local data/learnings.md". Concrete sequence: a session in any home loads AGENTS.md at start, follows line 149 and appends a learning to its now-tracked data/learnings.md (in a secondmate home the stow/AGENTS instruction to record learnings there predates the read-only-between-propagation carve-out only captain-shared got), and the home's next advance skips at the dirty guard with "dirty working tree" until a human reconciles — exactly the wedge docs/configuration.md:674 now documents but the instruction surface agents actually read still invites. AGENTS.md is an agent memory file not part of the change under validation, so amending its policy wording is a deliberate captain decision rather than pipeline output; the remedy, not the defect, is what needs authorization. Sibling sites: AGENTS.md:66, AGENTS.md:149.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ⚠️ .agents/skills/operational-home-layout/SKILL.md:54 - Fix round 1 (6aa76a1) and the round-2-approved AGENTS.md fix (45a1459) reconciled the new tracked fleet-shared learnings contract in .gitignore, docs/configuration.md, both sync skills, and AGENTS.md, but left the other instruction surfaces agents load still asserting the replaced contract. .agents/skills/operational-home-layout/SKILL.md:54 still declares learnings.md "LOCAL, gitignored ... created lazily, absent until this home has a learning to store", and .agents/skills/stow/SKILL.md:89 still carves out only data/captain-shared.md as read-only in secondmate homes while directing the memory pass to "curate only the editable local files" (with data/learnings.md counted among the three memory files at line 86), plus stow:220 "Create data/learnings.md only for a genuinely new local learning" and stow:224 "Keep the candidate in data/learnings.md". Concrete failing sequence: a converged secondmate home runs its /stow memory pass (AGENTS.md routes it); step 2 treats the now-tracked data/learnings.md as an editable local file (only captain-shared is excluded in secondmate homes); the pass stamps, prunes, or archives entries in the tracked file per the aging-tier contract; the home turns dirty and every subsequent spawn/bootstrap/update sync skips at the dirty guard until a human reconciles - the exact wedge docs/configuration.md:674-675 documents but these surfaces still invite, and secondmate-provisioning SKILL.md:132 contradicts by saying "the primary curates it". Sibling site: docs/architecture.md:508 still lumps data/learnings.md under "local markdown under data/". This is the same class round 2 fixed for AGENTS.md, left behind in shared tracked skill docs; the remedy corrects these files to the already-decided contract (tracked, primary-curated, read-only curation input in secondmate homes, no lazy local creation) and does not extend the change's intent, so auto-fix rather than ask-user.
  • ℹ️ bin/fm-ff-lib.sh:485 - The fix-round-1 preserve_pretracking_learnings call (function at bin/fm-ff-lib.sh:290, introduced by 6aa76a1) runs at line 485, before the already-current short-circuit and before the divergence decision at line 492, so a home that will NOT advance still gets its untracked data/learnings.md renamed to the dated sibling. Concrete sequence: a secondmate home holds a clean local divergence (e.g. an unpushed squash-merged contribution) plus its pre-tracking local learnings copy (invisible to the dirty guard); the bootstrap sweep reaches ff_target, preservation moves data/learnings.md to data/learnings.local.<stamp>.md, then divergence_is_redundant fails, a reconcile marker is recorded, and the home is skipped - the home never advanced, yet its learnings file is now absent at the original name, so the running session's next context digest prints ABSENT and the header's own wording ("whose pre-tracking local copy such an advance preserves") is violated for a non-advance. Content is preserved and the wedge-prevention goal is unaffected, so this is minor; the mechanical remedy is to invoke preserve only immediately before the two sites that actually advance (the redundant-divergence reset --keep at line 497 and the merge --ff-only at line 527), leaving a skipped home byte-for-byte untouched. Same exposure applies if the merge itself fails after preservation (e.g. concurrent dirt); the reorder reduces but does not fully eliminate that window, which is acceptable.

🔧 Fix applied.
1 info still open:

  • ℹ️ bin/fm-remote-secondmate-control.sh:377 - Every local advance boundary routes through ff_target and gets preserve_pretracking_learnings, but a remote secondmate host (e.g. the registered mac home this change's own learnings record) runs its own Firstmate copy during cmd_update: until that host refreshes its copy past this merge, its older ff_target lacks the preservation step, so the first remote sync of a home holding a pre-tracking untracked data/learnings.md will fail once with "untracked working tree files would be overwritten" and the parent dies with the actionable remedy ("run /updatefirstmate") already printed. After the host copy refreshes, the same sync preserves the copy correctly. Loud, self-remediating version skew inherent to shipping the fix through the artifact it fixes - noting so the one-time skip is not read as a regression.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
One update pass delivers the tracked fleet learnings to the primary checkout and a running secondmate home ✅ pass live evidence/fm-update-learnings-live.txt: 'firstmate: updated', 'secondmate sm1: preserved pre-tracking local data/learnings.md at .../data/learnings.local.<stamp>.md', 'secondmate sm1: updated', 'restar…
A home's pre-tracking local learnings copy is preserved only when the home actually advances (no preservation side effect on a skipped pass) ✅ pass live evidence/fm-learnings-adversarial.txt section A: diverged home 'skipped: diverged from origin/main; reconciliation required' with durable record, HEAD unchanged, data/learnings.md still the local copy…
The tracked learnings record converges over a home's local copy instead of wedging every future fast-forward ✅ pass live evidence/fm-update-learnings-live.txt (home advances c0afacf..tip over its untracked copy) and suite T15, which asserts FF_STATUS=updated, fleet record landed, dated sibling holds local bytes, and cle…
A converged home's locally curated tracked learnings is never clobbered by a later update pass ✅ pass live evidence/fm-learnings-adversarial.txt section B: 'secondmate sm1: skipped: dirty working tree', HEAD unchanged, curated bytes intact, no restart forced
The .gitignore exception tracks exactly data/learnings.md while the rest of data/ stays captain-private in every home ✅ pass live git check-ignore in the real worktree and in the advanced fixture home: data/learnings.md not ignored (tracked), data/captain.md ignored; git ls-files data/ lists only learnings.md; fm-shared-captain-…
  • bin/fm-test-run.sh tests/fm-secondmate-sync.test.sh (includes new T15 tracked-learnings convergence and T16 preserve-only-on-advance)
  • bin/fm-test-run.sh tests/fm-shared-captain-inheritance.test.sh (inherit contract after the learnings tracking change)
  • Live drive of bin/fm-update.sh with FM_ROOT_OVERRIDE/FM_HOME into a disposable fixture world: origin tip adds tracked data/learnings.md, secondmate home holds a pre-tracking local copy (transcript: evidence/fm-update-learnings-live.txt)
  • Adversarial live drives of bin/fm-update.sh: uniquely diverged home with pre-tracking learnings copy (skipped, untouched, no sibling), and converged home with curated tracked learnings (dirty-guard refusal, no clobber) (transcript: evidence/fm-learnings-adversarial.txt)
  • git check-ignore / git ls-files / git status --porcelain against the real worktree: data/learnings.md tracked and not ignored, data/captain.md still ignored, tree clean
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kirkins kirkins changed the title Sync fork: merge local learnings into main feat(bin): track the fleet-shared learnings record across home syncs Oct 10, 2026
…eet paths must not be tracked' step in .github/workflows/ci.yml still asserted the pre-decision contract that nothing under data/state/config/projects/.no-mistakes may be tracked, but the recorded captain decision (review rounds 1-3) made data/learnings.md the one tracked fleet-shared file (already reconciled in .gitignore, docs/configuration.md, AGENTS.md, sync/stow skills, and the docs inventory). Added a one-line pathspec carve-out ':(exclude)data/learnings.md' to the same git ls-files invocation at that single enforcement boundary, with a comment referencing the owning doc. Verified by running the exact step body in the worktree (passes), a negative scratch-repo case proving data/captain.md and state/x still fail the guard on every path axis, tests/fm-ci-workflow.test.sh (all assertions pass, invariants job stays fast-tier), bin/fm-doc-audience-check.sh (ok, 118 surfaces), and actionlint (clean)
@kirkins
kirkins merged commit a39a8e4 into main Oct 10, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant