Skip to content

fix: honor registered integration branches across fleet operations - #14

Open
cisrd wants to merge 6 commits into
mainfrom
fm/fm-fleet-sync-integration-branch
Open

cisrd wants to merge 6 commits into
mainfrom
fm/fm-fleet-sync-integration-branch

Conversation

@cisrd

@cisrd cisrd commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Intent

Le capitaine demande de lancer une autre tâche en attente tout en surveillant la capacité de la machine. Cette tâche corrige un défaut déjà mesuré : la synchronisation de flotte compare Project Code Zero à origin/main, alors que sa branche d'intégration réelle et obligatoire est develop. Le diagnostic actuel affirme donc à tort que le projet est en retard sur main et refuse de le rafraîchir après les fusions.

What Changed

  • Resolve structured integration-branch registry declarations centrally, retaining default-branch fallback for unannotated projects and rejecting invalid declarations.
  • Use the selected branch for fleet refreshes, new secondmate clones, pooled task bases, review diffs, local merges, and teardown safety checks; report branch-specific sync status and missing declared branches.
  • Document the registry contract and add regression coverage for integration-branch handling across these workflows.

Risk Assessment

✅ Low: The changes consistently honor declared integration branches, preserve legacy fallback, and refuse invalid or unavailable bases without introducing a substantiated material defect.

Testing

Targeted lifecycle tests and a captured CLI demonstration confirm develop-based refresh despite origin/HEAD pointing to main, with blocking invalid declarations and legacy fallback. Corrected a temporary-directory setup issue; teardown retry exposed unavailable lsof. No UI changed.

Evidence: Fleet-sync CLI and resulting Git state

Source: Fleet-sync CLI and resulting Git state

Remote default: refs/remotes/origin/main

$ fm-fleet-sync.sh project_code_zero
project_code_zero: synced 01b4795..006c996 to origin/develop
Checked-out branch: develop
Delivered content: merged feature

$ fm-fleet-sync.sh project_code_zero (repeat)
project_code_zero: already current on develop (origin/develop)

$ fm-fleet-sync.sh project_code_zero (declaration=missing)
project_code_zero: STUCK: declared integration branch missing is not published by origin - needs attention

$ fm-fleet-sync.sh project_code_zero (declaration=..bad)
error: invalid integration branch "..bad" for project_code_zero; fix the registry entry
project_code_zero: STUCK: the registry declares an invalid integration branch - needs attention

$ fm-fleet-sync.sh project_code_zero (declaration=)
error: invalid integration branch "" for project_code_zero; fix the registry entry
project_code_zero: STUCK: the registry declares an invalid integration branch - needs attention

Legacy registry (prose mentions develop, no declaration):
project_code_zero: already current on main (origin/main)
Legacy branch: main
Evidence: Reproducible isolated Git demonstration

Source: Reproducible isolated Git demonstration

#!/usr/bin/env bash
set -eu
ROOT=$PWD
D="$ROOT/.test-tmp/demo"
mkdir -p "$D/home/data" "$D/home/projects"
export GIT_CONFIG_COUNT=2 GIT_CONFIG_KEY_0=user.name GIT_CONFIG_VALUE_0=Test GIT_CONFIG_KEY_1=user.email GIT_CONFIG_VALUE_1=test@example.invalid
export FM_HOME="$D/home" FM_GATE_REFUSE_BYPASS=1
W="$D/upstream"; C="$FM_HOME/projects/project_code_zero"
git init -q -b main "$W"
printf 'initial\n' > "$W/base.txt"
git -C "$W" add .; git -C "$W" commit -qm initial
git -C "$W" branch develop
git clone -q --bare "$W" "$D/origin.git"
git -C "$W" remote add origin "$D/origin.git"
git clone -q "$D/origin.git" "$C"
git -C "$C" checkout -q develop
printf -- '- project_code_zero [no-mistakes integration-branch=develop] - fixture\n' > "$FM_HOME/data/projects.md"
git -C "$W" checkout -q develop
printf 'merged feature\n' > "$W/feature.txt"
git -C "$W" add .; git -C "$W" commit -qm 'merged feature on develop'; git -C "$W" push -q origin develop
printf 'Remote default: '; git -C "$C" symbolic-ref refs/remotes/origin/HEAD
printf '\n$ fm-fleet-sync.sh project_code_zero\n'
bash "$ROOT/bin/fm-fleet-sync.sh" project_code_zero
printf 'Checked-out branch: '; git -C "$C" branch --show-current
printf 'Delivered content: '; git -C "$C" show HEAD:feature.txt
test "$(git -C "$C" rev-parse HEAD)" = "$(git -C "$W" rev-parse develop)"
printf '\n$ fm-fleet-sync.sh project_code_zero (repeat)\n'
bash "$ROOT/bin/fm-fleet-sync.sh" project_code_zero
for declaration in missing ..bad ''; do
 printf -- '- project_code_zero [no-mistakes integration-branch=%s] - fixture\n' "$declaration" > "$FM_HOME/data/projects.md"
 printf '\n$ fm-fleet-sync.sh project_code_zero (declaration=%s)\n' "$declaration"
 before=$(git -C "$C" rev-parse HEAD)
 bash "$ROOT/bin/fm-fleet-sync.sh" project_code_zero
 test "$before" = "$(git -C "$C" rev-parse HEAD)"
done
printf '\nLegacy registry (prose mentions develop, no declaration):\n'
printf -- '- project_code_zero [no-mistakes] - develop mentioned only in prose\n' > "$FM_HOME/data/projects.md"
git -C "$C" checkout -q main
bash "$ROOT/bin/fm-fleet-sync.sh" project_code_zero
printf 'Legacy branch: '; git -C "$C" branch --show-current
- Outcome: ⚠️ 1 warning across 1 run (10m8s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 3 issues found → auto-fixed ✅
  • 🚨 bin/fm-project-mode.sh:111 - An explicit empty declaration (- p [no-mistakes integration-branch=] - ...) passes validation because the check requires a nonempty value. The resolver then treats it as absent and silently selects origin/HEAD, allowing sync and spawn to use main. Preserve whether the annotation was present and reject an empty declared value nonzero with a diagnostic.
  • ⚠️ bin/fm-spawn.sh:2427 - The new resolver is unreachable for originless projects: freshen_spawn_worktree_base returns at lines 2413–2415 first. With a local-only project declaring develop and a clean pooled worktree still at main, spawn launches from main without error, while review and local landing now target develop. The originless launch is an explicitly supported path in fm-spawn-pool-base-freshen.test.sh. Resolve declarations before that early return and base declared originless tasks on the verified local integration branch; retain the existing behavior for undeclared projects.
  • ⚠️ bin/fm-spawn.sh:2427 - Spawn still requires git remote set-head origin --auto to succeed before consulting the declaration. If origin publishes develop but its HEAD references a deleted main branch, the initial fetch succeeds and set-head fails, preventing a task despite its valid, fetchable declared base. Resolve the declaration first and require remote-default discovery only for undeclared projects.

🔧 Fix: Enforce declared integration branches across spawn base selection
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ tests/fm-teardown.test.sh:3342 - Teardown's leaked-process regression failed because this host lacks lsof. Declared-branch landing and cleanup cases passed, but process-reaping validation remains incomplete. Provision lsof in the test environment and rerun this test; system installation was prohibited in this phase.
  • TMPDIR="$PWD/.test-tmp" bash tests/fm-fleet-sync.test.sh
  • TMPDIR="$PWD/.test-tmp" bash tests/fm-review-diff.test.sh
  • tests/fm-secondmate-safety.test.sh: initial worktree-local TMPDIR rejected by home-boundary guard; reran successfully with default temporary fixtures.
  • bash tests/fm-spawn-pool-base-freshen.test.sh
  • bash tests/fm-task-delivery.test.sh
  • bash tests/fm-teardown.test.sh: initial shared command timeout; standalone retry reached missing-lsof process-reaping failure.
  • bash ~/.no-mistakes/evidence/01M20Y3C1MVXK9MMRY03GWG722/fleet-sync-demo.sh: real Git sync, delivered content, repeat sync, missing/malformed/empty declarations, unchanged HEAD on refusal, and legacy prose-only fallback.
  • Removed transient worktree fixtures and verified clean Git status.
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Quote hyphenated test identifier to satisfy ShellCheck
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

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