Repository navigation
feat(logbook): group monorepo sub-projects on the attention board - #4
Merged
Merged
Conversation
Declare sub-projects per project in data/projects.md via non-dash "sub"
continuation lines ({key, name, branch}), tag each item by its base_branch
meta field, and emit the board's per-project subprojects arrays and per-item
subproject keys from fm-logbook-compose.sh. The "sub" leading token keeps the
existing $1=="-" registry parsers (fm-project-mode.sh, fm-home-seed.sh)
unaffected, so projects without declarations compose exactly as before.
docs/configuration.md owns the schema and the base_branch recording path.
SchokoShake
added a commit
that referenced
this pull request
Jul 21, 2026
…awn reuse Address the review on PR #7: - treehouse_reservation replaces the boolean holds-check and captures the `treehouse status` exit code separately, so a treehouse outage reports could-not-ask instead of a false "no longer reserves" on every respawn (#1). - Match the leased `(held by <holder>)` against this task's fm-<id>, so a worktree treehouse re-leased to a different task is caught, not silently adopted; an in-use row carries no holder, so the gate only strengthens (#3). - Cover the lease-release trap for a turn-end hook-block failure between the lease and the meta write, the leak class new to this change (#2). - Record the deliberate readiness-barrier trade at the cd site, marking the brief's isolation assertion load-bearing and forbidding a re-added pane probe (#4). - Make the two treehouse human-text couplings a conscious v2.0.0 assumption; v2.0.0 has no --json/--porcelain and both fail loud-but-wrong (#5). The test treehouse stub now records the real --lease-holder so status renders the caller's fm-<id>, exercising the holder match faithfully.
SchokoShake
added a commit
that referenced
this pull request
Jul 22, 2026
…ane-cwd discovery (#7) * fix(spawn): capture crew worktree via treehouse get --lease; guard against $FM_HOME Every projects/* spawn recorded worktree=$FM_HOME (the primary checkout) in state/<id>.meta instead of the crew's real ~/.treehouse/... worktree, forcing a manual repair each time and risking teardown/review on the wrong path. The crew itself was always fine; firstmate-self spawns were immune. Root cause: worktree discovery sent `treehouse get` into the pane and polled #{pane_current_path} until it differed from the project dir, taking that as the worktree. Right after `tmux new-window -c <project>`, the pane process is still the forked tmux-server child (the shell has not yet exec'd and chdir'd), so #{pane_current_path} transiently reports the tmux SERVER's own cwd - $FM_HOME (the server was started there) - before settling on the -c dir a moment later. The poll's "any path != project dir" exit latched that transient $FM_HOME on the first iteration of a projects/* spawn ($FM_HOME != $FM_HOME/projects/<repo>), before `treehouse get` even ran; a firstmate-self spawn ($FM_HOME == project dir) kept polling to the real worktree - the exact projects/*-only signature. kunchenguid#134's stable-window-id targeting could not help: the correctly-targeted pane transiently reports the server cwd. Fix (bin/fm-spawn.sh): - Capture authoritatively: lease from fm-spawn itself with `treehouse get --lease` (prints only the ~/.treehouse/... path to stdout, banners to stderr) and cd the pane into that exact path. No poll, no startup-transient race. worktree= and the turn-end hook use the leased path; fm-teardown's existing `treehouse return --force <worktree=>` releases it, same as before. Consistent with fm-home-seed.sh's existing lease pattern. Applies to every non-orca backend and to batch (which re-execs the single path per pair). - Loud backstop in validate_spawn_worktree: assert the worktree is not the primary checkout ($FM_HOME/$FM_ROOT). Because firstmate is a git repo of itself, $FM_HOME is a valid git toplevel that cleared every prior clause silently; now a regression aborts loudly instead of corrupting meta. Tests updated to the lease-based capture; new cases pin real-worktree capture (never $FM_HOME) and the $FM_HOME abort. Docs: tmux-backend.md gains a root-cause/verification section; architecture.md and herdr-backend.md corrected. Root cause reproduced with tmux 3.6; fix verified end-to-end against real treehouse (worktree= records a real .treehouse/... path, pane cd's into it). Refs fm-spawn-wt-batch-x5. * test(spawn): strengthen symlinked-prefix test with a tangle case guarding PROJ_ABS_REAL Review (decision A, captain rule: fix the root cause, do not soften) found the reframed test_spawn_symlinked_project_prefix_avoids_false_refusal no longer exercised the PROJ_ABS_REAL canonicalization its comment claimed to guard: its leased worktree was entirely distinct from the project, so validate_spawn_worktree's only project-dependent clause (wt_real == proj_real) was never near-triggered and the test would pass even if PROJ_ABS_REAL regressed to a logical PROJ_ABS. Add a tangle case: the treehouse stub leases the PROJECT ITSELF reached back through the symlinked prefix (physical path equal to the project), and the spawn must be REFUSED with "did not yield an isolated worktree". That refusal holds ONLY because validate_spawn_worktree resolves both sides with pwd -P; were PROJ_ABS_REAL the logical PROJ_ABS the physical worktree path would compare unequal and the tangle would be wrongly allowed. Test-only; bin/fm-spawn.sh unchanged. Refs fm-spawn-wt-batch-x5. * no-mistakes(review): fix(spawn): release treehouse lease on abort; drop dead current_path ops * no-mistakes(review): fix(spawn): reuse recorded worktree on respawn; refresh stale adapter docs * no-mistakes(review): fix(spawn): gate respawn reuse on meta identity and lease reservation * no-mistakes(review): extend respawn identity gate to recorded backend * no-mistakes(review): scope respawn backend refusal to orca; derive --help range * no-mistakes(document): sync backend docs with treehouse-lease worktree capture and respawn * fix(spawn): distinguish treehouse-status failure and re-lease on respawn reuse Address the review on PR #7: - treehouse_reservation replaces the boolean holds-check and captures the `treehouse status` exit code separately, so a treehouse outage reports could-not-ask instead of a false "no longer reserves" on every respawn (#1). - Match the leased `(held by <holder>)` against this task's fm-<id>, so a worktree treehouse re-leased to a different task is caught, not silently adopted; an in-use row carries no holder, so the gate only strengthens (#3). - Cover the lease-release trap for a turn-end hook-block failure between the lease and the meta write, the leak class new to this change (#2). - Record the deliberate readiness-barrier trade at the cd site, marking the brief's isolation assertion load-bearing and forbidding a re-added pane probe (#4). - Make the two treehouse human-text couplings a conscious v2.0.0 assumption; v2.0.0 has no --json/--porcelain and both fail loud-but-wrong (#5). The test treehouse stub now records the real --lease-holder so status renders the caller's fm-<id>, exercising the holder match faithfully. * no-mistakes(document): sync tmux worktree-capture doc with --lease-holder flag --------- Co-authored-by: SchokoShake <[email protected]>
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
Build the firstmate feed side of logbook sub-project support so the attention board can render display-only sub-project groupings under a project (the board/tool side is already merged and out of scope). Motivating case: a monorepo (zeigmal_mono) whose work splits across integration branches (placement-tool off feat/placement-tool, outdoor-tour-navigation off feat-outdoor-tour-navigation). Three parts, all in bin/fm-logbook-compose.sh plus docs and tests:
Declaration syntax: sub-projects are firstmate-declared per project in data/projects.md as ordered {key,name,branch} triples, one per indented non-dash 'sub' continuation line ('sub | | ', space-pipe-space delimited). The non-dash leading token was a deliberate choice for backward-compatibility: an indented '- sub' list item would have collided with the existing $1=='-' awk registry parsers in BOTH fm-project-mode.sh and fm-home-seed.sh (the latter collects $2 of every dash line as a project entry, which would have broken its --no-projects seed guard). A 'sub' leading token is invisible to every $1=='-' parser, so those scripts needed ZERO changes and projects without sub-projects parse byte-identically as before. Field parse is robust: key first, branch last, name is the middle so a display name may itself contain the ' | ' delimiter. Malformed lines, invalid-slug keys (validated with logbook_valid_id, the one-owner safe-slug rule), and empty name/branch are dropped with a stderr warning and never emitted, so an item can only ever map to a valid declared key.
Per-item tagging by base/integration branch: a new optional base_branch= field in state/.meta records the branch a task's PR targets; compose maps it to the parent project's matching sub-project key. Deliberately OUT of scope (per the task): wiring the dispatch-time recording of base_branch into fm-spawn and back-filling in-flight items - firstmate does that after this lands. Documented the field and recording path instead.
Emission: compose emits per-project an ordered 'subprojects' array of {key,name,branch} (empty when none, capped at the tool's 100/project limit) and per-item an optional 'subproject' key, only when base_branch matches a declared sub-project; most items target the default branch, carry no base_branch, and stay ungrouped. Sub-projects have no independent active/toggle state - grouping only.
Knowledge placement follows firstmate-coding-guidelines: docs/configuration.md (Logbook -> Sub-projects) is the single owner of the schema and base_branch recording path; the script header carries a concise mechanics summary plus a one-line cross-reference to docs; AGENTS.md deliberately left untouched (nameable-situation reference detail, not every-session knowledge). Tests colocated in tests/fm-logbook.test.sh following the existing curl-mocking compose pattern, covering a project with sub-projects, an item mapped by branch, an ungrouped item, the no-declaration backward-compatible path, malformed-line skipping, and fm-project-mode.sh non-breakage. Verified locally: full logbook suite 58 ok/0 fail, and bin/fm-lint.sh clean under the pinned shellcheck 0.11.0. This is firstmate's own repo shipping through its own no-mistakes gate.
What Changed
fm-logbook-compose.shnow reads firstmate-declared, orderedsub <key> | <name> | <branch>continuation lines under each project indata/projects.mdand emits a per-projectsubprojectsarray (declaration-ordered, capped at the tool's 100/project limit, empty when none); thesubleading token keeps these lines invisible to the$1=="-"registry parsers so declaration-free projects compose byte-identically as before.subprojectkey by mapping a newbase_branch=meta field (the branch a task's PR targets) to the parent project's matching declared branch, carried internally as_base_branchand stripped before output; items with no base branch or no match stay ungrouped, and malformed lines, invalid-slug keys, or empty name/branch fields are dropped with stderr warnings.logbook_valid_idinfm-logbook-lib.shis documented as the single owner of the safe-slug rule for both item ids and sub-project keys;docs/configuration.mdgains the sub-project schema andbase_branchrecording path, andtests/fm-logbook.test.shadds coverage for ordered declarations, branch-based tagging, the no-declaration path, malformed-line skipping, andfm-project-mode.shnon-breakage. Only thePOST /api/syncbaseline carries sub-project grouping; richPOST /api/itemspushes are unchanged.Risk Assessment
✅ Low: The change is additive, display-only, well-bounded, thoroughly tested, verified backward-compatible with the sibling $1=="-" registry parsers, and the single prior-round concern was already resolved by a doc-only fix.
Testing
The configured e2e baseline command already passed; I then ran the full logbook suite (
bash tests/fm-logbook.test.sh, 58 ok / 0 fail incl. the 5 new sub-project tests) and demonstrated the feed end-to-end by composing the real POST /api/sync board body from a fleet-state home matching the motivating zeigmal_mono monorepo — the payload shows ordered per-project subprojects arrays, items tagged onto sub-projects by base_branch, ungrouped default-branch/plain-project items, malformed declarations dropped with stderr warnings, and byte-identical output to the base commit when nothing is declared. No board screenshot was produced because this is a bash JSON-feed change (not a UI change), the actual rendering board is the separate already-merged tool that isn't cloned in this worktree, and no browser executable is installed to render; the product surface of this change — the emitted feed JSON — is captured directly, plus a reviewer-openable HTML preview of the resulting grouping. All checks pass with no actionable findings.Evidence: Composed POST /api/sync board body (motivating zeigmal_mono monorepo case)
projects[0] zeigmal_mono → subprojects: [ {key:placement-tool, name:"Placement Tool", branch:feat/placement-tool}, {key:outdoor-tour-navigation, name:"Outdoor Tour Navigation", branch:feat-outdoor-tour-navigation} ]; projects[1] solo → subprojects: [] items: place-x1 → subproject:"placement-tool"; tour-x3 → subproject:"outdoor-tour-navigation"; main-x2 (default branch) → no subproject; solo-x4 (no sub-projects) → no subproject; no _base_branch helper leaked on any itemEvidence: Malformed sub-project declarations dropped with stderr warnings
fm-logbook-compose: skipping sub-project with invalid key "bad key" under mono fm-logbook-compose: skipping sub-project "emptyname" under mono (empty name or branch) fm-logbook-compose: skipping malformed sub-project line under mono: sub nodelims just words here → surviving keys: ["good-key","piped"]; piped keeps name "Display | With | Pipes" with branch feat/pipedEvidence: Surviving well-formed declarations after malformed-line skip
Evidence: Rendered HTML preview of the feed's sub-project grouping (built from the actual composed payload; no browser available to export a PNG)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
docs/configuration.md:367- Sub-project grouping only reaches the board on the compose->fm-logbook-sync.sh baseline (POST /api/sync). The rich cards firstmate escalates via fm-logbook-push.sh (POST /api/items) are unchanged and carry nosubproject; docs lines 332-333 describe that upsert as a whole-item replace with full validation, so an item drops out of its sub-project group the moment it is enriched. Doc line 367 claims fm-logbook-compose.sh emits into the /api/items payloads, but compose only produces the /api/sync body and nothing setssubprojecton a push. Confirm whether the board's /api/items upsert preserves an existing item'ssubprojecton a partial re-upsert; if it does not, the most attention-worthy (decision/action) cards will be ungrouped, and either fm-logbook-push.sh should carrysubprojector the doc's /api/items claim should be corrected.bin/fm-logbook-compose.sh:278- The newsubcontinuation-line format relies on each sub line immediately following its project's dash line socur_projectattributes it correctly. fm-home-seed.sh's sync_project_registry (line 754) reorders selected projects' dash lines to the end of the registry while passing non-dashsublines through in place, which would detach/misattribute them in compose. This is latent-only today because sub-project declarations are never propagated into secondmate homes by seeding (registry_line_for_project emits only the dash line), so it is unreachable through normal flows; noting it so the invariant is recorded should sub declarations ever be added to a re-seeded home.🔧 Fix: correct logbook sub-project doc to only feed /api/sync
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"bash tests/fm-logbook.test.sh— full logbook suite, 58 ok / 0 fail, including the 5 new sub-project tests (declares-ordered-subprojects, tags-item-by-base-branch, no-declaration-backward-compatible, skips-malformed-lines, project-mode-unaffected)End-to-end: built a realisticzeigmal_monomonorepo fleet home and ranFM_HOME=... LOGBOOK_ENABLE=1 bin/fm-logbook-compose.sh, capturing the actual POST /api/sync body — verified ordered subprojects arrays, place-x1→placement-tool and tour-x3→outdoor-tour-navigation tagging, ungrouped main-x2/solo-x4, and stripped _base_branch helperMalformed-line robustness: composed a registry with a bad-slug key, empty name, and missing-delimiter line — confirmed the 3 are dropped withskipping ...stderr warnings while the 2 valid ones (incl. a name containing|) survive with branch as the last fieldParser non-breakage:bin/fm-project-mode.sh zeigmal_mono→no-mistakes onandbin/fm-project-mode.sh solo→direct-PR offthrough the sub lines;awk '$1=="-" && $2!="" {print $2}'(fm-home-seed registry parse) collects only zeigmal_mono/solo, no sub keysBackward-compat: composed the same no-declaration fleet under base commit 830c27d and the target commit — items byte-identical, projects differ only by the additivesubprojects: []✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed (4) ✅
🔧 Fix: no lint issues found; scripts pass shellcheck 0.11.0
1 warning still open:
🔧 Fix: no lint issues; scripts pass ShellCheck 0.11.0 clean
1 warning still open:
🔧 Fix: no lint issues; scripts pass shellcheck 0.11.0 clean
1 warning still open:
🔧 Fix: no lint issues; fm-lint.sh passes shellcheck 0.11.0 clean
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.