feat(git-tools): consume .mosaic/repo.json declarations in compat mode (T51 WP5b) (#1416)
ci/woodpecker/push/publish Pipeline failed

Co-authored-by: code-be-02 <[email protected]>
This commit was merged in pull request #1416.
This commit is contained in:
2026-08-25 12:55:40 +00:00
committed by orch-01
parent 4cd280e48d
commit d30a4cce00
8 changed files with 684 additions and 8 deletions
@@ -192,6 +192,47 @@ cmd_new() {
local path; path="$(derive_path "$branch")"
assert_not_home "$path"
# T51 WP5b (spec 4.4 staged rule + 4.5 advisory policy): placement stays
# DERIVED; the declaration never moves the worktree. An INVALID declaration
# fails branch-creation loud (a broken structure file must not ride a new
# branch); an absent one warns (rollout window, Q-C); a valid one contributes
# policy ADVICE only. The advisory worktree_root comparison runs only when
# MOSAIC_HOST_ROOT is set (1.2a: warn-and-omit for advisory display).
# shellcheck source=packages/mosaic/framework/tools/git/repo-decl.sh
_rd="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)/repo-decl.sh"
if [ -f ""$_rd"" ]; then
source ""$_rd""
repo_decl_load
else
DECL_STATE=absent; DECL_SCHEMA=""
repo_decl_warn() { printf 'repo-decl: %s\n' "$*" >&2; }
repo_decl_report_invalid() { :; }
repo_decl_warn_absent_reversible() { :; }
repo_decl_warn_absent_irreversible() { :; }
repo_decl_remote_matches() { return 0; }
repo_decl_check_transition() { return 2; }
fi
case "$DECL_STATE" in
invalid)
repo_decl_report_invalid
die "worktree branch-creation refused: the structure declaration is invalid (spec 4.4 — fix it before creating branches)"
;;
absent)
repo_decl_warn_absent_irreversible "worktree branch-creation"
;;
valid)
if [ "$DECL_SCHEMA" = 2 ] && [ "$DECL_POLICY" = "orchestrator-precreated" ]; then
echo "repo-decl: worktree_policy=orchestrator-precreated (TRANSITIONAL, spec 4.5): tasking pre-creates worktrees; creating one directly is the interim path until the J3/#1174 amendment unblocks the wrapper consumer." >&2
fi
if [ -n "${MOSAIC_HOST_ROOT:-}" ] && [ -n "$DECL_WT_ROOT" ]; then
dwt="$(repo_decl_path "$DECL_WT_ROOT" 2>/dev/null || true)"
if [ -n "$dwt" ] && [ "${dwt%/}" != "${WT_ROOT%/}" ]; then
echo "repo-decl: derived root $WT_ROOT diverges from the declared advisory worktree_root $dwt (advisory per spec 4.1/5.2 — placement stays derived)" >&2
fi
fi
;;
esac
if [ -e "$path" ]; then
echo "exists: $path"
echo "(already checked out — reuse it, or 'rm' it first)"