The federation
fleet-sync — one drift report for every file the fleet shares
Which files the fleet shares across repos, how Gitea's workflow reuse shapes them, and how drift gets caught.
Roadmap item fleet-file-sync
(§8). Gitea drops cross-repo reusable workflows silently, so CI logic and the
agent pack are copied into ≈20 repos; this is the tool that finds the copies
that have drifted.
Status
plan— built. One command, fleet-wide drift report, no clones.apply— built. A worktree per repo, the drifted files written fromclaude/pack/, one commit, one push, one PR throughfgit pr create, and a comment on that PR naming the owning session. The owner check is mechanical: a repo whose owner is known is only opened after that owner was notified.land— built. Merge-on-green per PR, with per-repo rules (merge: land·merge: checks-then-merge·train: required). Never--force, never past a red required check.
Proven end to end on 2026-10-20: world-map-editor (22 files, pack v0.1.20) → PR #591.
Usage
node claude/scripts/fleet-sync/plan.mjs # all repos × sets
node claude/scripts/fleet-sync/plan.mjs --repos world-map-editor
node claude/scripts/fleet-sync/plan.mjs --sets pack-docs --json
node claude/scripts/fleet-sync/apply.mjs # dry run: what would be written
node claude/scripts/fleet-sync/apply.mjs --execute --clone-missing --notified marketing
node claude/scripts/fleet-sync/land.mjs # dry run: the gate of every fleet PR
node claude/scripts/fleet-sync/land.mjs --execute
Read-only: sources come from this checkout's claude/pack/, targets are read
with fgit cat <repo> <path> — no clones, no writes, no git. Exit 0 when
everything is in sync, 1 when anything is drifted, edited or missing, 2 usage, 4 when a
fetch fails for a reason other than "file does not exist".
Row states: drift is stale, edited is a hand edit
| state | meaning | what apply does |
|---|---|---|
in-sync |
the target matches what this checkout renders | nothing |
drift |
stale: the target equals the current source, or an older published revision of it, apart from the version marker | regenerates it; nothing is lost |
edited |
the target carries our marker but its content matches no published revision of the source: someone edited a generated file by hand | skips it and says why |
missing |
the file does not exist on the repo's default branch | creates it |
foreign |
no pack marker | never touched; a human decides |
edited exists because a rollout overwrites generated files: a hand edit in a vendored copy survives until the next roll and is
then erased without a trace (this is how forge-git's hand-added @repo-creator alias nearly vanished in the v0.1.22 round; the alias
had never been in claude/pack/docs). To tell stale from edited, plan compares the target's body (marker removed) with every
revision of that source file in this checkout's git history, so it needs a full clone: in a shallow clone, or for a file with no
history, there is nothing to compare against and a differing file stays plain drift (the previous behaviour).
A hand edit that the pack later adopted verbatim is no longer an edit: it equals a published revision, so it reads drift and
regenerating it loses nothing. What to do with a real edited row: put the content into claude/pack/ if it belongs fleet-wide, then
re-roll; or, if the owner agrees it should go, apply --overwrite-edited.
apply: writing the drifted files
node claude/scripts/fleet-sync/apply.mjs [--repos a,b] [--sets x,y]
[--execute] [--notified s1,s2] [--repos-root <dir>] [--worktrees <dir>]
[--branch <name>] [--clone-missing] [--overwrite-edited]
[--ask-project <uuid>]
Default is a dry run: it plans, prints the files per repo and stops.
--clone-missing clones a repo that has no local checkout yet (shallow,
single branch) so that one apply really is one command for the whole fleet.
With --execute, per repo: a git worktree off that repo's own clone
(--repos-root, default ~/Repos-internal), the drifted files written, one
commit, one push to fleet-sync/pack-v<version>, one PR through
fgit pr create, and a comment naming the owner. The state file
(~/.fleet-sync/applied.json) records the PRs for land.
Three things it refuses to do:
- It never overwrites an
editedfile unless--overwrite-editedis passed (see the row states above). - It never touches a
foreignfile — one without our marker. Those are reported and left to a human: opting a repo into a set it did not choose is the tool's explicit anti-goal. - It never opens a PR in a repo whose owner was not notified. The federation
rule is "tell owners before opening PRs in their repos";
--notifiedis how the caller says that happened. An empty owner in the manifest means the owner is unknown — the PR opens, and the comment says so.
The ask ledger (--ask-project <uuid>, since pack 0.1.31 / blueforge#917).
After the PRs open, apply files one cross-session ask task per PR in an owned
repo — labels cross-session, to:<owner>, from:blueforge, idempotent per
PR — so tm tasks list --label cross-session answers who owes what; the
printed Ask tracked: taskmaster <id> line is what goes into the message to
the owner (the pack's docs/tasks.md § Asking another repo's session is the
procedure). The uuid must be a board the owner can read: tm projects list
only shows the boards your key's user owns (--any-owner needs
federation:admin), so ask the receiver for theirs when you cannot see it.
A tm failure is reported per repo and never fails the apply — the PR is
already open. Ownerless repos and PRs whose number was not read get no ask.
One PR, or two
A skill file whose body changed is what a human must read, so it gets its
own PR; everything else — the managed block, the generated docs, and skills
whose only difference is the pack footer — rides together in one mechanical PR.
That halves the CI of a footer-only re-roll (roadmap item pack-single-pr).
fleet-sync/pack-v0.1.20 → mechanical: block + docs + footer-only skills
fleet-sync/pack-v0.1.20-skills → review: the skills whose body changed
The PR body says which group it is, and the branch name carries it.
land: merging them
node claude/scripts/fleet-sync/land.mjs [--repos a,b] [--prs repo:n,...]
[--execute] [--timeout <minutes>]
The PRs come from the state file apply wrote, from --prs, or from the open
PRs whose title carries the fleet-sync: marker. Default is a dry run.
Per repo, the manifest's rules: decide how it merges:
| rule | what happens |
|---|---|
merge: land (default) |
fgit pr land — waits for the gate, retries a transient failure once, merges, never forces |
merge: checks-then-merge |
for a repo whose required job is skipped by design: fgit pr checks (exit 0, skipped is fine), then a plain fgit pr merge |
train: required |
reported, never merged alone — the repo wants a merge-train partner |
A failing required check stops that PR (and fails the run); a pending one is reported and left alone.
The manifest: claude/fleet/manifest.yml
sets:
pack-docs: { source: claude/pack/docs, target: docs/agent-pack, mode: generated }
pack-block: { source: claude/pack/AGENTS.core.md, target: [AGENTS.md, CLAUDE.md], mode: managed-block }
pack-skills: { source: claude/pack/skills, target: .claude/skills, mode: owned-if-footer }
repos:
forge-control: [pack-docs, pack-block, pack-skills]
...
Modes:
| mode | target is current when | apply writes |
|---|---|---|
generated |
file == header marker + source bytes | overwrite, header marker |
managed-block |
the block between BEGIN/END markers == the rendered block; the rest of the file byte-identical | replace the block only |
owned-if-footer |
absent, or content + our trailing footer | write only if absent or already ours |
Row states
| state | meaning |
|---|---|
in-sync |
target matches what this checkout would render |
drift |
target exists and differs |
missing |
target does not exist on the repo's default branch — a candidate create |
foreign |
target exists without our footer/marker — never touched; a human decides. Opting a repo into a set it did not choose is this tool's explicit anti-goal |
Adding a repo
Only after verifying it already carries the set (fgit cat <repo> AGENTS.md | grep blueforge-pack), then add it to repos:. A repo that never opted in must
not appear in the manifest, or plan reports phantom missing rows for files
nobody asked for. Verified 2026-10-19 (pack v0.1.20): forge-control, forge-git,
marketing-os, taskmaster, world-map-editor.