Repository navigation
feat: sync fork with upstream firstmate (role authority, memory tiers, relaunch races) - #10
Merged
Merged
Conversation
* fix: serialize secondmate liveness relaunches across task set * no-mistakes(review): Remove relaunch wait override and test bounded contention * no-mistakes(document): Clarify secondmate relaunch locking and timeout documentation * chore: keep local Stele binding out of shared template * no-mistakes(document): Correct stale secondmate recovery timing comment * chore: exclude local Stele binding from relaunch fix * ci: retrigger CI after a timed-out test shard * no-mistakes(document): Correct secondmate recovery ordering documentation (cherry picked from commit 6407052)
…(#7172) * feat(bin): gate firstmate-upstream publication behind a declared home role Users who clone firstmate and run it as-is got a surprise: when their agent hit a firstmate bug, it could drive a pull request at upstream because nothing distinguished the maintainer's home from an ordinary user's. Every home now resolves to user/operator unless the gitignored config/firstmate-role grants a maintainer scope, or a single task carries the captain's recorded --upstream-consent on the brief, spawn, and promotion. fm-brief, fm-spawn, and fm-promote apply one fail-closed gate in bin/fm-role-lib.sh; the role is never inferred from gh identity, remotes, permissions, or CI, and secondmates honor only receipt-proven inherited grants so a child cannot grant itself. Session start reports the resolved role with no network call. Ordinary project delivery and the clone-and-run setup flow are unchanged. * no-mistakes(review): Harden firstmate role parsing, normalization, and inheritance * no-mistakes(review): Detect firstmate by lineage; drop consent fallback; fix claims * no-mistakes(document): Correct and consolidate Firstmate role documentation (cherry picked from commit 7df545b)
* fix: narrow Pi before-agent prompt events * no-mistakes(review): Restore processing-run abort detection and type Pi test events (cherry picked from commit 8c9c67d)
* docs: let a home declare authoritative external memory tiers
AGENTS.md section 6 routed durable knowledge only to firstmate-local files,
so a home whose captain keeps reasoning and facts in external stores had no
tracked rule keeping those stores authoritative over the per-machine data/
cache. Add a generic home-declared Memory layering contract (schema in
docs/configuration.md), make firstmate the capture path for workers whose
harness cannot reach a declared tier, and teach the stow skill to route to
declared tiers first and never prune a tier-owned entry without capturing it.
* no-mistakes(review): Report missing memory-layering declaration and index tier docs
* no-mistakes(document): Narrow memory-tier re-seed step to captain re-declaration
* no-mistakes(ci): Environment: 2026-10-05, host wildrobot, Linux 7.0.0-34. Finding ci-1 (Greptile): a tier-owned fact could be lost when its declared tier was unreachable from the session. - The invariant that was broken: until the declared tier holds a tier-owned fact, that fact must stay in a memory file loaded at startup. - Where it could be broken: the declared-tier guard, which said to archive the entry to the never-loaded cold tier; the routing step for new findings, which only mentioned the receipt; and the budget-eviction and offload eligibility rules. Fix, made only in .agents/skills/stow/SKILL.md: - **New marker.** Added `<!--t:NAME-->` to the existing compact marker list, so its meaning lives in one place. It marks a tier-owned entry that tier NAME does not hold yet. Stow never prunes, ages out, evicts, offloads, consolidates away, or archives an entry carrying it, whatever its tier clock says. A later pass that can reach NAME captures the entry there and removes the marker. - **Declared-tier guard.** "still archive rather than delete" now says to leave the entry in place with its pending-capture marker, and the receipt still names it. - **Routing step 2.** When the tier is unreachable, a new finding is written to the startup-loaded local file its class would otherwise use, or kept where it already lives, with the marker. It is still reported as an exception in the receipt. - **Budget eviction and offload eligibility.** Both now exclude entries pending capture, so the convergence pool is counted correctly. - **Receipt bullet.** Changed "finding or pruned entry" to entries left carrying the pending-capture marker, because those entries are no longer pruned. docs/configuration.md ("protects tier-owned entries from pruning") and AGENTS.md section 6 are still accurate, so I left them unchanged. No new file, queue, script, or digest section. One sentence per line, plain dashes. Verification: tests/fm-stow-cascade.test.sh, tests/fm-documentation-audiences.test.sh, and tests/fm-lint.test.sh all pass
* docs: keep undeclared memory-tier path silent and close stuck tier markers
Drop the stow receipt line reporting a missing Memory layering declaration
(AGENTS.md section 6, the stow skill, docs/configuration.md) so a home with
no declaration behaves exactly as before. Name pending-capture entries in the
exempt floor wording, and say how stow retargets or clears a pending-capture
marker whose tier was renamed or retired.
(cherry picked from commit 2911a3b)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Sync the lstutzman/firstmate fork with upstream kunchenguid/firstmate main. The previous sync (PR #7) was squash-merged, so only four upstream commits are actually missing: #7154 (secondmate relaunch races), #7172 (explicit firstmate-role authority for upstream contributions), #7248 (pi before_agent_start narrowing), and #6608 (home-declared external memory tiers via a Memory layering section). They are applied as cherry-picks (-x) rather than a git merge, deliberately, because merging upstream/main would replay the eight already-squashed commits and conflict. One conflict was resolved in bin/fm-config-inherit-lib.sh FM_INHERITABLE_CONFIG: keep BOTH the fork's typesafe-base-url/typesafe-model/typesafe-token-file items (fork-only feature from PR #6, local Jev resolver) AND upstream's new firstmate-role item plus its receipt comment. The captain needs #6608 so the home can declare the Slarti memory MCP as an authoritative memory tier. No fork behaviour should be dropped; upstream content should land as-is.
What Changed
-x) the four upstream firstmate commits the fork was missing. #7154 serializes secondmate relaunches to stop concurrent relaunch races (fm-secondmate-liveness-lib.sh,fm-spawn.sh). #7172 adds explicit firstmate-repository role authority for upstream contributions (newbin/fm-role.shandbin/fm-role-lib.sh, wired into brief, promote, session-start, spawn and teardown, plus a newfirstmate-self-reposkill). #7248 narrows pibefore_agent_startevents before reading the prompt (.pi/extensions/*). #6608 lets a home declare authoritative external memory tiers through a Memory layering section (stowskill,AGENTS.md,docs/configuration.md).bin/fm-config-inherit-lib.sh.FM_INHERITABLE_CONFIGkeeps the fork-onlytypesafe-base-url,typesafe-modelandtypesafe-token-fileitems and adds upstream'sfirstmate-roleitem. Upstream's proof-of-state receipt handling for that item (.fm-inherit-firstmate-role.generation) comes in with it, andfm-remote-inherit-push.shis updated to match.tests/fm-self-repo-role.test.sh, plus updates to the secondmate liveness/safety, session-start and pi extension tests.🤖 Generated with Claude Code
Risk Assessment
Testing
I built disposable fixtures for this run: a marked lab primary home (fm-lab-home.sh), a throwaway git-clone secondmate home, a fork-like clone with origin set to lstutzman/firstmate, and an unrelated repo. Against these I drove the real fm-role.sh and fm-config-push.sh CLIs. Results: the fork-only typesafe-* items and upstream's firstmate-role both propagate. The role receipt is written, the secondmate reports the role as inherited, tampering fails closed, and revocation converges. A Memory layering declaration in captain-shared.md lands read-only (444) in the secondmate home. The role gate refuses by default and authorizes only on a matching consent or maintainer scope. Seven targeted upstream test files then passed with 0 failures, covering the relaunch-race lock, Pi before_agent_start handling, the self-repo gate in spawn/promote, stow tier handling, and the session-start role line. Those test-only scenarios (relaunch serialization, Pi extensions, stow/session-start) are recorded as untested because they were not driven live. The CONFIG_REREAD nudge send was refused because the gate's lifecycle guard is in force inside the gate worktree. That is the expected environment behaviour, not a product defect. All lab homes and clones were removed afterwards and the worktree is clean.
Evidence: fm-role report/check transcript (default, consent, maintainer, adversarial)
Source: fm-role report/check transcript (default, consent, maintainer, adversarial)
Evidence: Config inheritance transcript: typesafe-* and firstmate-role push, receipt, tamper, revocation
Source: Config inheritance transcript: typesafe-* and firstmate-role push, receipt, tamper, revocation
Evidence: Memory layering section inherited via captain-shared.md
Source: Memory layering section inherited via captain-shared.md
Evidence: Targeted upstream test results (relaunch race, pi, role, stow, session-start)
Source: Targeted upstream test results (relaunch race, pi, role, stow, session-start)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-role-lib.sh:228- Upstream #7172 lands as-is, as intended, but it changes how the fork works. Every home now defaults to the user/operator role. fm_role_gate_self_publish, called from fm-spawn.sh, refuses any publishing ship task whose project shares firstmate's root commit unless one of two things matches the publication target: amaintainer <scope>line in config/firstmate-role, or a per-task --upstream-consent. fm_role_publication_target picks theupstreamremote beforeorigin(fm-role-lib.sh:230). A fork clone used for syncing normally hasupstreampointing at kunchenguid/firstmate, so the computed target is kunchenguid/firstmate, not lstutzman/firstmate. Concretely: after this sync, dispatching a PR task against the fork, such as the next upstream sync or a fork-only fix like PR feat: configurable base URL, model, and token file for the Jev dispatch resolver #6, is refused with 'holds no publication authority for github.com/kunchenguid/firstmate'. The only home-level grant that would pass names kunchenguid/firstmate, which also authorizes publishing to the real upstream. That is the opposite of what the fork wants. The intent says 'No fork behaviour should be dropped'. The fork's previously working ability to dispatch publishing tasks to its own repo now depends on new config, or on --upstream-consent for every task. The captain needs to decide one of: accept per-task --upstream-consent; remove or rename theupstreamremote in the captain's checkout soorigin(lstutzman/firstmate) is the target and grantmaintainer github.com/lstutzman/firstmate; or carry a fork-only change to the target resolution. Changing code would go beyond 'upstream content should land as-is', so this needs authorization rather than an auto-fix.bin/fm-config-inherit-lib.sh:90- The FM_INHERITABLE_CONFIG conflict was resolved as stated. The fork's typesafe-base-url, typesafe-model and typesafe-token-file items are kept, and upstream's firstmate-role is appended with its receipt comment block. No conflict markers remain, and no other fork-specific (typesafe or Jev) lines are deleted anywhere in the diff. Every helper the cherry-picks call exists in the fork: fm_lock_acquire_wait_bounded, fm_lock_role, fm_sm_live_require_locks, fm_inherit_sha256 and isProcessingCustomMessage. The upstream source commits are not present locally, so byte-identity with upstream could not be checked directly; the review relied on the -x trailers and a clean read of the diff.✅ **Test** - passed
✅ No issues found.
FM_HOME=<lab> bin/fm-role.sh reportwith no config, a maintainer grant, and a malformed role fileFM_HOME=<lab> bin/fm-role.sh check <fork clone origin=lstutzman/firstmate>for default user, upstream-consent with the right scope, upstream-consent with the wrong scope, a maintainer grant, a maintainer grant with an added upstream remote, and an unrelated repoFM_HOME=<lab primary> bin/fm-config-push.shinto a disposable cloned secondmate home (state/sm-lab.meta) with typesafe-base-url/model/token-file, firstmate-role, and captain-shared.md holding a Memory layering sectionFM_HOME=<secondmate> bin/fm-role.sh report/checkafter inheritance, after tampering with the inherited role file, and after the primary revokes the grant and pushes againbash tests/fm-secondmate-liveness.test.shbash tests/fm-secondmate-safety.test.shbash tests/fm-pi-branch-extension.test.shbash tests/fm-pi-watch-extension.test.shbash tests/fm-self-repo-role.test.shbash tests/fm-stow-cascade.test.shbash tests/fm-session-start.test.sh✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.