Skip to content

feat(bmad): add polyrepo workspace linking, root stacking, and no-_bmad degradation - #3313

Merged
bmadcode merged 8 commits into
devfrom
story-17-polyrepo-workspace-obeya-decoupling
Nov 30, 2026
Merged

bmadcode merged 8 commits into
devfrom
story-17-polyrepo-workspace-obeya-decoupling

Conversation

@bmadcode

Copy link
Copy Markdown
Collaborator

Summary

Implements Story 17 atop PR #3311 (story-04-phase-2-module-defaults-rules-customize), decoupling workspace linking, multi-repo _bmad/ config/customization layering, Obeya planning/store resolution, and non-_bmad graceful degradation:

  • Scattered polyrepo workspace link (git config bmad.workspace <path>):
    • Pure-Python INI/config reader across regular repositories, linked worktrees (.git -> gitdir -> commondir), and submodules in config_utils.py, tickets.py, and eval_common.py, handling escaping in/outside quotes, backslash-newline continuations, inline comments, and empty/invalid entries without spawning git subprocesses.
    • Exposes find_linked_workspace_root, find_outer_workspace_root, and workspace_link_diagnostics, wiring workspace_link into setup.py --status and broken-workspace-link into resolve_config.py --check.
  • Workspace-to-repo layer stacking & opt-outs:
    • Stacks outer workspace layers beneath repository layers across central configuration, cross-skill rules (rules.toml / rules.user.toml), per-skill overrides, and module setup answers (find_bmad_roots), anchoring {project-root}, file: references (including workspace paths with spaces), and relative paths only on outer layers while preserving Story 16 worktree main-checkout fallbacks on inner layers.
    • Supports core.standalone = true across central config layers (with strict bool validation in --check) and --no-workspace CLI isolation in resolve_config.py, resolve_customization.py, render_skill.py, tickets.py, and read_store.py.
    • Keeps setup.py workspace-aware so inherited workspace output_folder and answered module questions are neither shadowed nor re-asked, while enforcing cross-boundary write safety for mutating setup.py and startup_check.py runs.
  • Decoupled Obeya & store resolution (tickets.py, read_store.py):
    • Resolves workspace-linked or outer-inherited Obeya stores, deep-merges workspace-to-repo ticketing-store-config.toml, locates frontmatter.py across stacked roots, supports --no-workspace in both scripts, and halts cleanly when required _bmad/ runtime state is absent.
  • No-_bmad graceful degradation & docs:
    • Removes raw "can't open file" subprocess noise in isolated resolve_personas.py and resolve_party.py runs when neither _bmad/ nor sibling bmad/ exists.
    • Updates docs/reference/configuration.md, docs/customize/adopt-bmad-across-a-team.md, skills/core-tools/bmod-core-tools/help/team-adoption.md, and skills/core-tools/bmad/references/setup.md covering single-repo, shared-parent polyrepo, scattered polyrepo, out-of-tree worktrees, standalone opt-out, and harness .git skill-discovery boundaries (including Antigravity).

Stacked PR Order

  1. PR refactor(bmad)!: remove ~/.bmad/ surfaces and standardize on project-local _bmad/ #3306 (story-04-remove-global-bmad -> dev)
  2. PR feat(bmad): resolve _bmad root, relative paths, and user config across git worktrees #3308 (story-16-git-worktree-bmad-root -> story-04-remove-global-bmad)
  3. PR feat(bmad): add module defaults, cross-skill rules, and unified customization #3311 (story-04-phase-2-module-defaults-rules-customize -> story-16-git-worktree-bmad-root)
  4. This PR (story-17-polyrepo-workspace-obeya-decoupling -> story-04-phase-2-module-defaults-rules-customize)

Verification

  • uv run --frozen python -B -m pytest: 1703 passed, 1 skipped, 372 subtests passed
  • uv run ruff check & uv run ruff format --check: passing cleanly
  • uv run tools/validate_skills.py --strict, uv run tools/validate_file_refs.py --strict, uv run skills/core-tools/bmad/scripts/validate_manifests.py, uv run tools/check_help_freshness.py, and prepass.py: passing cleanly
  • npm --prefix docs-site run validate-links & npm --prefix docs-site run build: passing cleanly

@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5 · Fix module-default expansion and setup's overwriting of inherited workspace settings before merging.RetriggerView in GreptileConfidence Score: 3/5

[High impact] Shared BMad configuration and planning workflows can now inherit settings across repositories.

Fix module-default expansion and setup's overwriting of inherited workspace settings before merging.

Findings

  1. P1 Defaults keep literal folder placeholders ▶
  2. P1 Setup hides shared module settings ▶
Fix with agent prompt
### Issue 1
skills/core-tools/bmad/scripts/config_utils.py:1004-1005
If an installed module declares `reports_folder = "{project-root}/reports/{directory_name}"` and that key has not been saved yet, `load_module_defaults` returns the literal `{directory_name}` placeholder. Setup expands the same default to the project folder name, so resolving or rendering before setup uses a different, incorrect folder. Expand `{directory_name}` against the effective project root when loading runtime defaults.

### Issue 2
skills/core-tools/bmad/scripts/setup.py:658-666
If the workspace sets `modules.acme.depth = "thorough"` and the module ships `depth = "standard"`, setting up a child repo writes `"standard"` into its local `_bmad/config.toml`. That local layer overrides the workspace's choice and blocks later workspace updates. The new inheritance check preserves `core.output_folder`, but module defaults need the same check before setup writes them locally.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds workspace links, workspace-to-repo configuration layers, shared ticket stores, and --no-workspace isolation.

  • Repositories can find a separate BMad workspace through their Git config.
  • BMad combines workspace and repository settings, with repository choices taking priority.
  • Setup uses inherited workspace answers without writing setup files outside the repository.
  • Ticket tools resolve planning data and store settings across workspace and repository roots.
  • Tools without a BMad runtime use shipped data or give a clear setup message.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Working directory] --> B[Find local or main-checkout root]
  B --> C{Workspace inheritance enabled?}
  C -->|Yes| D[Find linked or parent workspace]
  C -->|No| E[Repository layers only]
  D --> F[Module defaults]
  F --> G[Workspace team layers]
  G --> H[Repository team layers]
  H --> I[Workspace personal layer]
  I --> J[Repository personal layer]
  E --> K[Resolve configuration]
  J --> K
Loading

Reviews (4) · Last reviewed commit: "fix(bmad): include inner team layers whe..." · Reviewed by Greptile

@bmadcode

Copy link
Copy Markdown
Collaborator Author

Addressed both review findings and the Windows subprocess test issue in 8dcfda79:

  1. --no-workspace initial root discovery (resolve_config.py, resolve_customization.py, render_skill.py): Passed include_workspace=not args.no_workspace into initial root discovery so --no-workspace without --project-root inside a linked or shared-parent repo without local _bmad/ isolates cleanly instead of selecting the inherited workspace root.
  2. Sparse outer override path anchoring (config_utils.py): Tracked cumulative outer-layer metadata across central_config_layers_for_roots and passed inherited_kind into is_path_field, so outer personal overrides that set only target under [core.knowledge_sources.<id>] or [core.artifact_destinations.<id>] inherit kind = "path" and anchor against the workspace root rather than the inner repository.
  3. Windows subprocess UTF-8 decoding (test_story17_polyrepo_and_degradation.py): Pinned encoding="utf-8", errors="replace" on subprocess test runners.

Added regression coverage for both scenarios in test_story17_polyrepo_and_degradation.py. @greptileai please re-review.

@bmadcode

Copy link
Copy Markdown
Collaborator Author

Fixed the sparse-target interaction in central_config_layers_for_roots (config_utils.py):

  • Tracked effective_merged across inner repository layers as well as outer layers (starting from defaults_layer), so outer personal overrides that change only target observe any intermediate repo-team kind override (e.g., path -> mcp) and keep non-path external targets intact rather than rewriting them as workspace paths.
  • Added regression coverage in test_story17_polyrepo_and_degradation.py verifying both knowledge_sources and artifact_destinations with repo-team kind = "mcp" overrides.

@greptileai please re-review.

@bmadcode
bmadcode force-pushed the story-04-phase-2-module-defaults-rules-customize branch from c81ca57 to a21b69c Compare November 30, 2026 05:04
@bmadcode
bmadcode force-pushed the story-17-polyrepo-workspace-obeya-decoupling branch from 687f1a3 to 07befe6 Compare November 30, 2026 05:05
@bmadcode
bmadcode force-pushed the story-04-phase-2-module-defaults-rules-customize branch from a21b69c to 398f9ae Compare November 30, 2026 05:10
@bmadcode
bmadcode force-pushed the story-17-polyrepo-workspace-obeya-decoupling branch from 07befe6 to 155c502 Compare November 30, 2026 05:11
…mization

Add `[bmod.defaults]` support in bmod.toml (validating table shape and
key uniqueness against `config_questions`), 4-layer central config
precedence with home-installed module discovery and `resolve_config.py
--check`, `_bmad/custom/rules.toml` / `rules.user.toml` cross-skill rule
matching (skipping heterogeneous type mismatches gracefully with
`--check` warnings and read-only linked-worktree fallbacks), unified
customization across all four surfaces in `bmad-customize` with trigger
evals, and aligned reference docs and tests.
…ation

Ensure `render_skill.render()` preserves explicit/project `skill_roots`
precedence ahead of `skill_dir.parent`, validate per-harness
`core.models.<harness>` and `core.capabilities.<harness>` tables inside
`check_central_config()`, validate list element shapes across cross-skill
rules and per-skill overrides, allow populated `[bmod.defaults]` tables
with sibling non-colliding `config_questions` keys, and invoke `READ_RE`
explicitly in the `scan_config_reads` open-table test.
Include `.agent/skills`, `.cline/skills`, `.bob/skills`, and `.adal/skills`
in `DEFAULT_SKILL_ROOT_CANDIDATES` and `HOME_SKILL_ROOT_CANDIDATES` so
automatic `[bmod.defaults]` discovery covers all supported tool installs
without requiring `--root`, and rename the regression test cleanly.
…ad degradation

Add pure-Python `git config bmad.workspace` discovery across repos,
linked worktrees, and submodules with exact git-config escaping/line
continuation and diagnostic reporting; stack workspace-to-repo central
and skill customization layers with per-layer `{project-root}` / `file:`
and relative path anchoring plus `core.standalone = true` and
`--no-workspace` isolation; keep `setup.py` workspace-aware for shared
`output_folder` and answered module questions; enforce cross-boundary
write safety for mutating setup and onboarding CLI calls; update
`tickets.py` (with `--no-workspace`), `read_store.py`, and
`eval_common.py` for workspace-linked and stacked stores; fix non-`_bmad`
fallbacks in `resolve_personas.py` and `resolve_party.py`; and document
multi-repo, worktree, standalone, and harness skill-discovery topologies
with comprehensive test coverage.
…ing, and UTF-8 test subprocesses

Pass `include_workspace` into initial root discovery across
`resolve_config.py`, `resolve_customization.py`, and `render_skill.py`
so `--no-workspace` without `--project-root` never leaks an inherited
outer workspace root when a linked or child repository has no local
`_bmad/`. Track cumulative outer-layer metadata when anchoring sparse
`knowledge_sources.<id>.target` and `artifact_destinations.<id>.target`
overrides in `config_utils.central_config_layers_for_roots`. Pin UTF-8
decoding on subprocess test runners in
`test_story17_polyrepo_and_degradation.py` so Windows runs decode UTF-8
CLI output cleanly.
Update `effective_merged` across inner repository layers as well as
outer layers inside `central_config_layers_for_roots`, so workspace
personal overrides that change only `target` observe any intermediate
repo-team `kind` override and never rewrite non-path external targets as
filesystem paths.
@bmadcode
bmadcode force-pushed the story-17-polyrepo-workspace-obeya-decoupling branch from 155c502 to 169c897 Compare November 30, 2026 06:08
@bmadcode
bmadcode changed the base branch from story-04-phase-2-module-defaults-rules-customize to dev November 30, 2026 06:08
@bmadcode
bmadcode merged commit 875c012 into dev Nov 30, 2026
9 checks passed
Comment on lines +1004 to +1005
if raw_defaults and code not in modules_defaults:
modules_defaults[code] = copy.deepcopy(raw_defaults)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Defaults keep literal folder placeholders

If an installed module declares reports_folder = "{project-root}/reports/{directory_name}" and that key has not been saved yet, load_module_defaults returns the literal {directory_name} placeholder. Setup expands the same default to the project folder name, so resolving or rendering before setup uses a different, incorrect folder. Expand {directory_name} against the effective project root when loading runtime defaults.

Prompt To Fix With AI
This is a comment left during a code review.
Path: skills/core-tools/bmad/scripts/config_utils.py
Line: 1004-1005

Comment:
**Defaults keep literal folder placeholders**

If an installed module declares `reports_folder = "{project-root}/reports/{directory_name}"` and that key has not been saved yet, `load_module_defaults` returns the literal `{directory_name}` placeholder. Setup expands the same default to the project folder name, so resolving or rendering before setup uses a different, incorrect folder. Expand `{directory_name}` against the effective project root when loading runtime defaults.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +658 to +666
outer_root, outer_team, _outer_user = _outer_workspace_layers(project_root)
if (
outer_root is not None
and lookup(outer_team, ("core", "output_folder")) is not _MISSING
and lookup(existing, ("core", "output_folder")) is _MISSING
and isinstance(template.get("core"), dict)
):
# Preserve workspace-inherited output_folder instead of stamping a repo default over it.
template["core"].pop("output_folder", None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Setup hides shared module settings

If the workspace sets modules.acme.depth = "thorough" and the module ships depth = "standard", setting up a child repo writes "standard" into its local _bmad/config.toml. That local layer overrides the workspace's choice and blocks later workspace updates. The new inheritance check preserves core.output_folder, but module defaults need the same check before setup writes them locally.

Prompt To Fix With AI
This is a comment left during a code review.
Path: skills/core-tools/bmad/scripts/setup.py
Line: 658-666

Comment:
**Setup hides shared module settings**

If the workspace sets `modules.acme.depth = "thorough"` and the module ships `depth = "standard"`, setting up a child repo writes `"standard"` into its local `_bmad/config.toml`. That local layer overrides the workspace's choice and blocks later workspace updates. The new inheritance check preserves `core.output_folder`, but module defaults need the same check before setup writes them locally.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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