From a22a579ad20fe8e7c4c44f4dc274bbe4b5fbdb80 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:09:38 +0000 Subject: [PATCH 01/11] =?UTF-8?q?new(=5Fcommon):=20multi-app=20resolver=20?= =?UTF-8?q?interface=20=E2=80=94=20mxtk=5Fapps,=20mxtk=5Fselect=5Fapp,=20M?= =?UTF-8?q?XTK=5FAPP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First commit of the multi-app scope work, pushed early so the parallel quality-floor and ready-command branches can read the interface. Readers follow in later commits. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 1 + project-bin/_common.sh | 81 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 105d7619..dbe84aa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 - fix(status, agents): **`bin/status.sh` WATCHes an Agent Editor project whose extension module does not travel with the model (#778)**: Studio Pro reads `agenteditor.agent` from `modules/AgentEditor.mxmodule` beside the `.mpr`, and a sync of only `.mpr` + `mprcontents/` left it out of git, so the builder stayed green while every colleague's clone showed `unknown type 'agenteditor.agent'`. Two WATCH items, warn-only (exit code and every verdict unchanged), local files and `git ls-files` only, root and `app/` layouts: a `modules/*.mxmodule` git does not track, and a project using Agent Editor (`AgentEditorCommons` in `analysis/app-facts/inventory.json`, or a `create agent` statement in `mdlsource/`) with no `modules/AgentEditor*.mxmodule`. `skills/mendix-agents.md` (on demand) gains the rule plus the note that the GenAI key, `Encryption.EncryptionKey` and `GenAICommons.StoreTraces` belong in the Default configuration, not a start script. Empty agent references / missing model version (mendixlabs/mxcli#1867) and unset runtime constants are not checked: they need a captured agent document (option 2). Fixture `tests/wave2/test-status-extension-modules.sh` — field report from an Agent Editor project, Nov 2026 - fix(permissions): **exec approval `auto` no longer prompts on every exec's mode check, and `install-claude-hooks.sh` no longer runs unprompted (#782)**: `install-claude-permissions.sh` now allow-lists `exec-approval.sh`, `interview-mode.sh` and `permission-profile.sh`, so their reads run without a prompt, while their only writers, `--set` and `--clear`, prompt through six `ask` rules (`Bash(*exec-approval.sh*--set*)`, …) in the shared settings under every profile (an ask rule beats an allow rule, `full`'s bare `Bash` included). `install-claude-hooks.sh`, which writes `~/.claude/settings.json` for every repo on the machine, gets no allow rule. A re-install adds the ask rules and removes the hooks-installer rule an earlier install added (sidecar); entries someone else wrote are untouched, and `sync-project.sh`'s permission check names both until then. Field run on claude 2.1.325: the read ran, `--set auto` and `--clear` were refused, and with the ask rules removed `--set` ran — from the two independent reviews of #781 - process(skills): **trim PR, moves only: always-loaded words 66,271 -> 64,984 (budget 80,000); Stage 5 test 21,906 -> 20,619, gate 22,954 -> 21,744, review 31,681 -> 30,394 (#783)**: `testing-shape.md` §5's stack and scratch-copy mechanics move verbatim to `e2e-harness-base.md` § Bringing the stack up (the rule and a one-line list of its rules stay in §5); the three new Unit false-green rows move to `unit-test.md` § False-green rows (a pointer row stays in the register); `module-review.md`'s re-shoot mechanics move to `iterative-build-loop.md` § Pipeline mode (the rule, the denominator and the failure example stay) and its MXTK-AI001 sentence to `marketplace-catalogue.md` § Reviewing a built module. Every removed line is in its destination, checked line by line — weekly word-budget audit (#783) diff --git a/project-bin/_common.sh b/project-bin/_common.sh index b2846d51..8cb16c2d 100755 --- a/project-bin/_common.sh +++ b/project-bin/_common.sh @@ -92,6 +92,79 @@ _mxtk_resolve_root() { # nothing found: keep the old behaviour so the caller's own error is the one seen printf '%s\n' "${self_parent:-$(pwd)}" } + +# --- Multi-app projects: apps//.mpr, one mdlsource/ per app ----------------------- +# THE INTERFACE every reader uses to scope per app (gate-check, status, look-ledger, the +# obligation check, ready.sh). Small on purpose; globs and builtins only, Bash 3.2. +# +# mxtk_apps [root] one line per app model: "" (path relative +# to root), in glob order. Prints nothing and returns 1 unless the +# root holds no *.mpr and no app/*.mpr — single-tree and two-tree +# projects are never multi-app, whatever sits under apps/. +# mxtk_app_count [root] the number of lines mxtk_apps prints (0 for every other layout). +# mxtk_select_app [root] +# sets and exports MPR_FILE (absolute) and MXTK_APP for one app. +# Exact folder name first, then any letter case. rc 1, apps listed +# on stderr, when is not one (or its folder holds two .mpr). +# mxtk_app_of [root] prints when (absolute, or relative to root) sits under +# apps//; nothing, rc 1, otherwise. +# MXTK_APP= the environment form of --app, honoured when this file is sourced, +# so every script takes it without parsing an argument. An MPR_FILE +# the user set wins over it; the cwd auto-pick below never does. +# +# The rule for readers: with mxtk_app_count >= 2 and no app selected, never pick one and never +# report "nothing checked" — iterate mxtk_apps and report one line per app. find_mpr itself +# still refuses (it answers "which model do I WRITE", and that needs a choice). +# WHY (field runs, 2026-11): six apps under apps// printed "more than one .mpr; set +# MPR_FILE to choose, nothing checked" for the Marketplace check, the obligation check found no +# module in scope, and the project's CLAUDE.local.md had to hand-write the MPR_FILE workaround. +mxtk_apps() { + local r="${1:-$PROJECT_ROOT}" f a n=0 + for f in "$r"/*.mpr "$r"/app/*.mpr; do [ -e "$f" ] && return 1; done + for f in "$r"/apps/*/*.mpr; do + [ -e "$f" ] || continue + a="${f%/*}"; a="${a##*/}" + printf '%s\t%s\n' "$a" "${f#"$r"/}"; n=$((n + 1)) + done + [ "$n" -gt 0 ] +} +mxtk_app_count() { + local r="${1:-$PROJECT_ROOT}" f n=0 + for f in "$r"/*.mpr "$r"/app/*.mpr; do [ -e "$f" ] && { echo 0; return 0; }; done + for f in "$r"/apps/*/*.mpr; do [ -e "$f" ] && n=$((n + 1)); done + echo "$n" +} +mxtk_select_app() { + local want="$1" r="${2:-$PROJECT_ROOT}" list a p hit="" n=0 wl al + list="$(mxtk_apps "$r")" || { echo "ERROR: --app $want: $r is not a multi-app project (no apps//*.mpr)" >&2; return 1; } + wl="$(printf '%s' "$want" | tr '[:upper:]' '[:lower:]')" + while IFS=' ' read -r a p; do [ "$a" = "$want" ] && { hit="$p"; n=$((n + 1)); }; done <&2 + else echo "ERROR: --app $want: $n .mpr files in that app folder — set MPR_FILE to the one meant:" >&2; fi + printf '%s\n' "$list" | while IFS=' ' read -r a p; do echo " $a ($p)" >&2; done + return 1 + fi + a="${hit#apps/}"; a="${a%%/*}" + MPR_FILE="$r/$hit"; MXTK_APP="$a"; export MPR_FILE MXTK_APP +} +mxtk_app_of() { + local p="$1" r="${2:-$PROJECT_ROOT}" + case "$p" in "$r"/*) p="${p#"$r"/}" ;; esac + case "$p" in apps/?*/*) p="${p#apps/}"; printf '%s\n' "${p%%/*}"; return 0 ;; esac + return 1 +} + PROJECT_ROOT="${PROJECT_ROOT:-$(_mxtk_resolve_root)}" # Multi-app folder, MPR_FILE unset, the session inside one app's folder: pick that app HERE, # at source time, and export it (#489 review). Since #489 the root from apps// is the @@ -123,6 +196,12 @@ if [ -z "${MPR_FILE:-}" ] && [ -d "$PROJECT_ROOT/apps" ]; then if [ "$_mxtk_n" -eq 1 ]; then MPR_FILE="$_mxtk_pick"; MXTK_MPR_PICKED="$_mxtk_pick"; export MPR_FILE MXTK_MPR_PICKED; fi unset _mxtk_n _mxtk_pick _mxtk_f fi +# MXTK_APP (--app's environment form) wins over the cwd auto-pick, never over a user's MPR_FILE. +# Its MPR_FILE is marked as a pick too, so a child in another project re-derives it from the name. +if [ -n "${MXTK_APP:-}" ] && { [ -z "${MPR_FILE:-}" ] || [ "${MPR_FILE:-}" = "${MXTK_MPR_PICKED:-}" ]; }; then + if mxtk_select_app "$MXTK_APP"; then MXTK_MPR_PICKED="$MPR_FILE"; export MXTK_MPR_PICKED + else unset MPR_FILE MXTK_MPR_PICKED; fi +fi # mxtk_posix_path — a Windows-form path (C:\Program Files\Mendix) as Git Bash addresses it # (/c/Program Files/Mendix). Anything already POSIX passes through untouched. Used for every @@ -249,7 +328,7 @@ find_mpr() { for f in "$PROJECT_ROOT"/*.mpr; do [ -e "$f" ] && echo " $(basename "$f")" >&2; done if [ "$multi" = 1 ]; then for f in "$PROJECT_ROOT"/apps/*/*.mpr; do [ -e "$f" ] && echo " ${f#"$PROJECT_ROOT"/}" >&2; done - echo "Set MPR_FILE=apps//.mpr (relative to $PROJECT_ROOT) to choose." >&2 + echo "Choose one: MXTK_APP=, or MPR_FILE=apps//.mpr (relative to $PROJECT_ROOT)." >&2 else echo "Set MPR_FILE=.mpr to choose." >&2 fi From cd1b3ec4f94402112c425fcb733764c02500273d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:22:29 +0000 Subject: [PATCH 02/11] new(multi-app): per-app scope in gate-check, status, look-ledger; per-app scaffold in init/sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A repo holding several apps (apps//.mpr, one mdlsource/ per app) is now reported per app instead of "more than one .mpr; set MPR_FILE to choose, nothing checked". - gate-check: --app / MXTK_APP scopes a run; with none, Marketplace installs prints one [App] line each (per-app fit-gap may FAIL; a shared fit-gap reads PENDING) and an Apps: section with each app's model, scripts and LOOK debt. build-ready counts a FAIL. - status.sh: one APP line per app (bin/lib/app-scope.sh, shared with gate-check). - look-ledger: one ledger keyed by app (5th owed column only in a multi-app tree); status --app . - init/sync: architecture/apps//{intake,triage}.md + architecture/apps/README.md, Wiring rows naming the app selection. Module briefs stay in architecture/modules/ (every reader looks there). - skills/module-folder-convention.md § Several apps in one repo (baseline 64,984 -> 65,125). Single-tree and two-tree: gate-check, status, init output, CLAUDE.local.md, owed.tsv and the scaffolded tree are byte-identical to master (compared side by side on scratch projects). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 1 + bin/doctor.sh | 4 +- bin/gate-check.sh | 48 ++++- bin/init-project.sh | 14 +- bin/lib/app-scope.sh | 151 +++++++++++++++ bin/lib/marketplace-check.sh | 41 ++++ bin/status.sh | 11 ++ bin/sync-project.sh | 31 ++- project-bin/_common.sh | 5 +- project-bin/look-ledger.sh | 30 ++- skills/module-folder-convention.md | 17 ++ tests/wave2/fixtures/multi-app/PROVENANCE.txt | 16 ++ tests/wave2/fixtures/multi-app/tree.txt | 26 +++ tests/wave2/test-multi-app-scope.sh | 176 ++++++++++++++++++ 14 files changed, 557 insertions(+), 14 deletions(-) create mode 100644 bin/lib/app-scope.sh create mode 100644 tests/wave2/fixtures/multi-app/PROVENANCE.txt create mode 100644 tests/wave2/fixtures/multi-app/tree.txt create mode 100755 tests/wave2/test-multi-app-scope.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index dbe84aa4..c1468f96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt; `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,125 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/`, reconstructed, not a capture — see its PROVENANCE.txt) — two field runs, Nov 2026 - new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 - fix(status, agents): **`bin/status.sh` WATCHes an Agent Editor project whose extension module does not travel with the model (#778)**: Studio Pro reads `agenteditor.agent` from `modules/AgentEditor.mxmodule` beside the `.mpr`, and a sync of only `.mpr` + `mprcontents/` left it out of git, so the builder stayed green while every colleague's clone showed `unknown type 'agenteditor.agent'`. Two WATCH items, warn-only (exit code and every verdict unchanged), local files and `git ls-files` only, root and `app/` layouts: a `modules/*.mxmodule` git does not track, and a project using Agent Editor (`AgentEditorCommons` in `analysis/app-facts/inventory.json`, or a `create agent` statement in `mdlsource/`) with no `modules/AgentEditor*.mxmodule`. `skills/mendix-agents.md` (on demand) gains the rule plus the note that the GenAI key, `Encryption.EncryptionKey` and `GenAICommons.StoreTraces` belong in the Default configuration, not a start script. Empty agent references / missing model version (mendixlabs/mxcli#1867) and unset runtime constants are not checked: they need a captured agent document (option 2). Fixture `tests/wave2/test-status-extension-modules.sh` — field report from an Agent Editor project, Nov 2026 - fix(permissions): **exec approval `auto` no longer prompts on every exec's mode check, and `install-claude-hooks.sh` no longer runs unprompted (#782)**: `install-claude-permissions.sh` now allow-lists `exec-approval.sh`, `interview-mode.sh` and `permission-profile.sh`, so their reads run without a prompt, while their only writers, `--set` and `--clear`, prompt through six `ask` rules (`Bash(*exec-approval.sh*--set*)`, …) in the shared settings under every profile (an ask rule beats an allow rule, `full`'s bare `Bash` included). `install-claude-hooks.sh`, which writes `~/.claude/settings.json` for every repo on the machine, gets no allow rule. A re-install adds the ask rules and removes the hooks-installer rule an earlier install added (sidecar); entries someone else wrote are untouched, and `sync-project.sh`'s permission check names both until then. Field run on claude 2.1.325: the read ran, `--set auto` and `--clear` were refused, and with the ask rules removed `--set` ran — from the two independent reviews of #781 diff --git a/bin/doctor.sh b/bin/doctor.sh index bea53841..24216fb9 100755 --- a/bin/doctor.sh +++ b/bin/doctor.sh @@ -470,7 +470,7 @@ if [ -n "$PS_MODE" ]; then fi PMXCLI_PROBE="$(find_project_mxcli 2>/dev/null || true)" head_ "Property sets (Studio Pro merge safety): $PROJECT_DIR" - [ -n "$_ps_apps" ] && note "multi-app folder ($_ps_apps): checking ${MPR#"$PROJECT_DIR"/} only — rerun with MPR_FILE=apps//.mpr for each other app" + [ -n "$_ps_apps" ] && note "multi-app folder ($_ps_apps): checking ${MPR#"$PROJECT_DIR"/} only — rerun with MXTK_APP= (or MPR_FILE=apps//.mpr) for each other app" if [ "$PS_IF_STALE" = 1 ] && [ "$PS_MODE" = check ] && [ -n "$PMXCLI_PROBE" ]; then PS_VER="$(ps_version "$PMXCLI_PROBE")" if [ -n "$PS_VER" ] && ! ps_stale; then @@ -2045,7 +2045,7 @@ if [ -n "$PROJECT_DIR" ]; then if [ -z "$MPR" ] && ls "$PROJECT_DIR"/apps/*/*.mpr >/dev/null 2>&1; then MPR="$(ls "$PROJECT_DIR"/apps/*/*.mpr | head -1)" _apps="$(cd "$PROJECT_DIR" && ls apps/*/*.mpr | paste -s -d, - | sed 's/,/, /g')" - [ "$(ls "$PROJECT_DIR"/apps/*/*.mpr | wc -l | tr -d ' ')" -gt 1 ] && note "multi-app folder: $_apps — instruments need MPR_FILE=apps//.mpr to pick one" + [ "$(ls "$PROJECT_DIR"/apps/*/*.mpr | wc -l | tr -d ' ')" -gt 1 ] && note "multi-app folder: $_apps — instruments need MXTK_APP= (or MPR_FILE=apps//.mpr) to pick one; gate-check and status report per app" fi [ -n "$MPR" ] && ok "model: ${MPR#$PROJECT_DIR/}" || { warn "no .mpr found in the project root" diff --git a/bin/gate-check.sh b/bin/gate-check.sh index 4c15089d..17d954ee 100755 --- a/bin/gate-check.sh +++ b/bin/gate-check.sh @@ -10,7 +10,10 @@ # Usage: bin/gate-check.sh [--html|--no-html] [--ack-protocol [--approved-in-chat]|--force-stale] [--verbose] # [--adopt --reason "..."] # [--waive |marketplace/> --reason "..."] -# [stage] +# [--app ] [stage] +# - --app (or MXTK_APP=) scopes the model-reading checks to one app of a multi-app +# project (apps//.mpr). Without it, a project with two or more apps gets one line +# per app for those checks (the "Apps:" section) — never a pick, never "nothing checked". # - With a stage-number, additionally exits non-zero if that specific stage's check fails. # - Without one, evaluates and reports all stages, exits 0 regardless (informational run). # - --html forces the dashboard write; --no-html suppresses it. Neither changes any verdict. @@ -67,6 +70,7 @@ ADOPT_STAGE="" WAIVE_STAGE="" CLOSEOUT=0 WAIVER_REASON="" +GC_APP="${MXTK_APP:-}" declare -a GC_ARGS GC_ARGS=() while [ $# -gt 0 ]; do @@ -80,6 +84,8 @@ while [ $# -gt 0 ]; do --closeout) CLOSEOUT=1; HTML_MODE="never" ;; --waive) shift; WAIVE_STAGE="${1:-}" ;; --reason) shift; WAIVER_REASON="${1:-}" ;; + --app) shift; GC_APP="${1:-}" ;; + --app=*) GC_APP="${1#--app=}" ;; --force-stale) FORCE_STALE=1 ;; --strict-protocol) STRICT_PROTOCOL=1 ;; --) shift; while [ $# -gt 0 ]; do GC_ARGS[${#GC_ARGS[@]}]="$1"; shift; done; break ;; @@ -295,6 +301,24 @@ if [ ! -d "$PROJECT_DIR" ]; then exit 1 fi +# --- Multi-app projects (apps//.mpr): which apps, and was one chosen? ------------ +# One subshell over project-bin/_common.sh's resolver (mxtk_apps / mxtk_select_app), with +# PROJECT_ROOT pinned, so the layout rules are the crash net's and not a copy. GC_APPS stays +# empty on single-tree and two-tree projects, and nothing below prints for them. +GC_APPS="" +if [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/project-bin/_common.sh" ] && [ -d "$PROJECT_DIR/apps" ]; then + GC_APPS="$( PROJECT_ROOT="$(cd "$PROJECT_DIR" && pwd)"; MPR_FILE=""; MXTK_APP="" + . "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/project-bin/_common.sh" >/dev/null 2>&1 || exit 0 + mxtk_apps "$PROJECT_ROOT" 2>/dev/null )" +fi +if [ -n "$GC_APP" ]; then + [ -n "$GC_APPS" ] || { echo "Error: --app $GC_APP: $PROJECT_DIR is not a multi-app project (no apps//*.mpr)." >&2; exit 2; } + _gc_sel="$( PROJECT_ROOT="$(cd "$PROJECT_DIR" && pwd)"; MPR_FILE=""; MXTK_APP="" + . "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/project-bin/_common.sh" >/dev/null 2>&1 + mxtk_select_app "$GC_APP" "$PROJECT_ROOT" && printf '%s\t%s\n' "$MXTK_APP" "$MPR_FILE" )" || exit 2 + MXTK_APP="${_gc_sel%% *}"; MPR_FILE="${_gc_sel#* }"; GC_APP="$MXTK_APP"; export MXTK_APP MPR_FILE +fi + # Resolve the knowledge-base dir the same way this project's artifacts actually live. # Convention: analysis//knowledge-base/ under the project dir; fall back to # knowledge-base/ directly under the project dir if that's how the project is laid out. @@ -3721,12 +3745,32 @@ case "${MXTK_ROWS_UPTO:-}" in P|p|0|1|2|3|4) ;; *) if [ -r "$TOOLKIT_DIR/bin/lib/marketplace-check.sh" ]; then # shellcheck source=lib/marketplace-check.sh . "$TOOLKIT_DIR/bin/lib/marketplace-check.sh" - mxtk_mkt_report "$PROJECT_DIR" "${REGISTER:-$PROJECT_DIR/PROJECT.md}" "$(resolve_artifact_nonempty "architecture/fit-gap.md")" + if [ -n "$GC_APP" ] && [ -s "$PROJECT_DIR/architecture/apps/$GC_APP/fit-gap.md" ]; then + mxtk_mkt_report "$PROJECT_DIR" "${REGISTER:-$PROJECT_DIR/PROJECT.md}" "$PROJECT_DIR/architecture/apps/$GC_APP/fit-gap.md" + elif [ -z "$GC_APP" ] && [ "$(printf '%s' "$GC_APPS" | grep -c .)" -ge 2 ]; then + mxtk_mkt_report_apps "$PROJECT_DIR" "${REGISTER:-$PROJECT_DIR/PROJECT.md}" "$(resolve_artifact_nonempty "architecture/fit-gap.md")" "$GC_APPS" + else + mxtk_mkt_report "$PROJECT_DIR" "${REGISTER:-$PROJECT_DIR/PROJECT.md}" "$(resolve_artifact_nonempty "architecture/fit-gap.md")" + fi else printf 'Marketplace installs: NOT CHECKED — bin/lib/marketplace-check.sh missing from %s\n' "$TOOLKIT_DIR" fi ;; esac +# Multi-app projects: one register (PROJECT.md, read above), per-app evidence here — one line per +# app, full runs only (bin/lib/app-scope.sh, the same lines bin/status.sh shows). Prints nothing +# for single-tree and two-tree projects, or for one app under apps/. +if [ -z "$REQUESTED_STAGE" ] && [ -z "$GC_APP" ] && [ -r "$TOOLKIT_DIR/bin/lib/app-scope.sh" ]; then + # shellcheck source=lib/app-scope.sh + . "$TOOLKIT_DIR/bin/lib/app-scope.sh" + _gc_al="$(mxtk_app_lines "$PROJECT_DIR" "$TOOLKIT_DIR")" + if [ -n "$_gc_al" ]; then + printf 'Apps: %s (one register, %s; per-app evidence below; --app scopes a run to one)\n' \ + "$(printf '%s\n' "$_gc_al" | grep -c .)" "$(basename "${REGISTER:-PROJECT.md}")" + printf '%s\n' "$_gc_al" | while IFS=' ' read -r _a _l; do printf ' [%s] %s\n' "$_a" "$_l"; done + fi +fi + # --------------------------------------------------------------------------- # Artifacts — did the stages that promise a file actually leave one? # diff --git a/bin/init-project.sh b/bin/init-project.sh index 70f9f89c..a8892e0d 100755 --- a/bin/init-project.sh +++ b/bin/init-project.sh @@ -277,6 +277,16 @@ fi TOOLKIT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +# Multi-app projects (two or more apps//.mpr): per-app intake/triage under +# architecture/apps//, an index listing every app, and the two Wiring rows that name the app +# selection (bin/lib/app-scope.sh; skills/module-folder-convention.md § Several apps in one repo). +# Nothing happens, and nothing prints, for any other layout. +. "$SCRIPT_DIR/lib/app-scope.sh" +mxtk_scaffold_apps "$PROJECT_DIR" "$TOOLKIT_ROOT" +_WIRE_MPR=""; _WIRE_MDL="" +_wr="$(mxtk_wiring_rows "$PROJECT_DIR" "$TOOLKIT_ROOT")" +[ -n "$_wr" ] && { _WIRE_MPR="${_wr%% *}"; _WIRE_MDL="${_wr#* }"; } + # docs/progress/RESUME.md — the file every generated entry point tells an agent to read FIRST. # Written here so that instruction is true on a project that is two seconds old. Never # overwritten: after the first close-the-loop this file is the project's own, and clobbering it @@ -308,8 +318,8 @@ at build time and correct any that differ**; a path that doesn't resolve is a wi |---|---|---| | Toolkit root | \`$TOOLKIT_ROOT\` | The process authority | | Toolkit commit | see \`PROJECT.md\` \`Toolkit commit:\` | Authoritative there; ritual keeps it fresh | -| Project MPR | \`$(ls "$PROJECT_DIR"/*.mpr 2>/dev/null | head -1 | xargs -r basename || echo ".mpr")\` | The model file | -| MDL source dir | \`mdlsource/\` | Numbered build scripts | +| Project MPR | ${_WIRE_MPR:-\`$(ls "$PROJECT_DIR"/*.mpr 2>/dev/null | head -1 | xargs -r basename || echo ".mpr")\` | The model file} | +| MDL source dir | ${_WIRE_MDL:-\`mdlsource/\` | Numbered build scripts} | | Module briefs | \`architecture/modules//\` | one \`module-brief.md\` per module | | Wireframes | \`design/wireframes/\` | one annotated HTML per screen | | Design system | \`design/ds.css\` + \`design/design-system.html\` | tokens + component showcase | diff --git a/bin/lib/app-scope.sh b/bin/lib/app-scope.sh new file mode 100644 index 00000000..d1ae4473 --- /dev/null +++ b/bin/lib/app-scope.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash +# app-scope.sh — per-app evidence for a multi-app project (apps//.mpr, one +# mdlsource/ per app). Sourced by bin/status.sh and bin/gate-check.sh, so the screen and the +# gate print the same facts. Bash 3.2 safe. +# +# The app list is project-bin/_common.sh's mxtk_apps (the one resolver, read in a subshell with +# PROJECT_ROOT pinned), so single-tree and two-tree projects yield nothing and print nothing. +# The register stays ONE (PROJECT.md); only evidence that is per app is reported per app. +# +# mxtk_scope_apps +# prints mxtk_apps' lines (""), or nothing +# mxtk_app_lines +# one line per app, "", only when there are two or more apps: +# "apps//.mpr · scripts N written / D done- · LOOK: K of M page(s) owed" +# scripts count apps//mdlsource/ (gallery excluded, as status.sh counts the root); +# LOOK is `look-ledger.sh status --app ` (one project ledger, keyed by app). + +mxtk_scope_apps() { + local pd="$1" tk="$2" + [ -d "$pd/apps" ] && [ -f "$tk/project-bin/_common.sh" ] || return 0 + ( PROJECT_ROOT="$pd"; MPR_FILE=""; MXTK_APP="" + . "$tk/project-bin/_common.sh" >/dev/null 2>&1 || exit 0 + mxtk_apps "$pd" 2>/dev/null ) || true +} + +mxtk_app_lines() { + local pd="$1" tk="$2" apps a m d n dn lk ls lt lo + apps="$(mxtk_scope_apps "$pd" "$tk")" + [ "$(printf '%s' "$apps" | grep -c . || true)" -ge 2 ] || return 0 + while IFS=' ' read -r a m; do + [ -n "$a" ] || continue + d="$pd/apps/$a/mdlsource"; n=0; dn=0 + if [ -d "$d" ]; then + n="$(find "$d" -name '*.mdl' -not -path '*/gallery/*' | wc -l | tr -d ' ')" + dn="$(find "$d" -name 'done-*.mdl' | wc -l | tr -d ' ')" + fi + lk="LOOK: no pages owed" + if [ -s "$pd/.claude/loop/look/owed.tsv" ] && [ -f "$tk/project-bin/look-ledger.sh" ]; then + ls="$(PROJECT_ROOT="$pd" MPR_FILE="" MXTK_APP="" bash "$tk/project-bin/look-ledger.sh" status --app "$a" 2>/dev/null)" + lt="$(printf '%s' "$ls" | grep -c . || true)"; lo="$(printf '%s\n' "$ls" | grep -c '^OWED' || true)" + [ "$lt" -gt 0 ] && lk="LOOK: $lo of $lt page(s) owed" + fi + printf '%s\t%s · scripts %s written / %s done- · %s\n' "$a" "$m" "$n" "$dn" "$lk" + done < — the per-app planning folders, one convention +# (skills/module-folder-convention.md § Several apps in one repo): +# +# architecture/apps/README.md the index: every app, its model, its folders, and +# the rule that the build plan is ONE file +# architecture/apps//intake.md this app's answers; shared answers stay in ./intake.md +# architecture/apps//triage.md Stage 0 per app — only when the project has a root +# triage.md (migration entry mode) +# +# Module briefs do NOT move: they stay architecture/modules//module-brief.md, with an +# "**App:** " line, because gate-check build-ready, the artifact manifest, the obligation +# check's module scope, status.sh and the coverage-ledger readers all look there — a per-app +# brief folder would make each of them blind, which is the field run's "no module in scope". +# Under architecture/, not apps//: apps// is the Mendix project folder — what Studio Pro +# commits to Team Server and mxbuild packages — and planning documents do not belong in it. +# Never overwrites; a file that exists is the project's own. Two or more apps only. Prints one +# "Created: ..." line per file it writes. Field reason (2026-11): faced with four apps and a kit +# with no multi-app mode, a lead dropped per-app intake, triage and the register for one +# free-form brief, and that brief carried the spec violation that blocked the first grading. +mxtk_scaffold_apps() { + local pd="$1" tk="$2" apps a m dir idx n + apps="$(mxtk_scope_apps "$pd" "$tk")" + n="$(printf '%s' "$apps" | grep -c . || true)" + [ "$n" -ge 2 ] || return 0 + mkdir -p "$pd/architecture/apps" || return 0 + while IFS=' ' read -r a m; do + [ -n "$a" ] || continue + dir="$pd/architecture/apps/$a" + mkdir -p "$dir" + if [ ! -f "$dir/intake.md" ]; then + cat > "$dir/intake.md" </module-brief.md\` with \`**App:** $a\` + +Answers that hold for every app (entry mode, interview mode, sources shared by all apps, NFRs, +security model) live in the project's \`intake.md\` and are not repeated here. Decisions go to +the ONE register, \`PROJECT.md\`, naming the app in the row (\`$a: ...\`). Write each answer as +\`Answered (CONFIRMED): ...\`, \`Assumed: ... — rejected: ...\` or \`Unverified — how to verify: ...\`. + +## 1. What this app is for, and who uses it (roles) + +## 2. Sources for this app only (code, documents, SME) — and which shared sources it does not use + +## 3. Modules it owns, and modules it shares with or calls in a sibling app + +## 4. Integrations: what it publishes to or consumes from the other apps (one row each) + +## 5. What is out of scope for this app +EOF + echo "Created: architecture/apps/$a/intake.md" + fi + if [ -f "$pd/triage.md" ] && [ ! -f "$dir/triage.md" ] && type mxtk_triage_template >/dev/null 2>&1; then + { printf '\n' "$a" "$m" + mxtk_triage_template; } > "$dir/triage.md" + echo "Created: architecture/apps/$a/triage.md" + fi + done </\` (skills/module-folder-convention.md § Several apps in one repo)." + echo "Tools take one app with \`--app \` (gate-check, look-ledger) or \`MXTK_APP=\` (every" + echo "bin/ script); without one, gate-check and status report one line per app." + echo + echo "Module briefs stay in \`architecture/modules//module-brief.md\`; each names its app (\`**App:** \`)." + echo + echo "| App | Model | MDL scripts | Intake | Modules (filled at Stage 3) |" + echo "|---|---|---|---|---|" + printf '%s\n' "$apps" | while IFS=' ' read -r a m; do + [ -n "$a" ] && echo "| $a | \`$m\` | \`apps/$a/mdlsource/\` | \`architecture/apps/$a/intake.md\` | |" + done + echo + echo "## Build plan — one file, every app" + echo + echo "\`architecture/build-plan.md\` is shared: one \`## App: \` section per app, in build order," + echo "plus one section for the cross-app integrations (the publisher's row before the consumer's)." + echo "Apps not yet planned:" + printf '%s\n' "$apps" | while IFS=' ' read -r a m; do [ -n "$a" ] && echo "- [ ] $a"; done + } > "$idx" + echo "Created: architecture/apps/README.md (index of $n apps)" + fi + return 0 +} + +# mxtk_wiring_rows — for a multi-app project, the two CLAUDE.local.md +# Wiring rows that differ (Project MPR, MDL source dir), as ""; nothing +# otherwise, and the caller keeps its single-app rows byte for byte. Field run (2026-11): the +# generated file said nothing about apps, so the project hand-wrote the MPR_FILE workaround. +mxtk_wiring_rows() { + local apps n names + apps="$(mxtk_scope_apps "$1" "$2")" + n="$(printf '%s' "$apps" | grep -c . || true)" + [ "$n" -ge 2 ] || return 0 + names="$(printf '%s\n' "$apps" | awk -F'\t' 'NF{printf "%s%s", s, $1; s=", "}')" + printf '%s\t%s\n' \ + "\`apps//.mpr\` — $n apps: $names | One model per app. Select with \`MXTK_APP=\` (any bin/ script) or \`--app \` (gate-check, look-ledger); with none, gate-check and status report per app. Index: \`architecture/apps/README.md\`" \ + "\`apps//mdlsource/\` | Numbered build scripts, per app" +} diff --git a/bin/lib/marketplace-check.sh b/bin/lib/marketplace-check.sh index 467c713a..36820792 100755 --- a/bin/lib/marketplace-check.sh +++ b/bin/lib/marketplace-check.sh @@ -218,6 +218,44 @@ mxtk_mkt_report() { return 0 } +# mxtk_mkt_report_apps +# A multi-app project (two or more apps//.mpr, as mxtk_apps prints them) with no +# app selected: one check per app instead of "more than one .mpr ... nothing checked" (field run, +# 2026-11, six apps). Prints a header line and one " [] — ..." line per app. +# Each app reads architecture/apps//fit-gap.md when it has one, else the shared fit-gap. A +# shared fit-gap does not say which app owes a Buy, so a package missing from an app reads PENDING +# there, naming the move that settles it — never a FAIL on a guess. +# Sets MXTK_MKT_STATUS to the worst app verdict (FAIL > PENDING > the first other verdict) and +# MXTK_MKT_NOTE to ": ; ..." — build-ready counts that FAIL as one item. +mxtk_mkt_report_apps() { + local root="$1" reg="$2" shared="$3" apps="$4" app mpr fg out st worst="" notes="" one + printf 'Marketplace installs: per app (%s apps; --app checks one)\n' "$(printf '%s\n' "$apps" | grep -c .)" + while IFS=' ' read -r app mpr; do + [ -n "$app" ] || continue + fg="$shared" + [ -s "$root/architecture/apps/$app/fit-gap.md" ] && fg="$root/architecture/apps/$app/fit-gap.md" + out="$(MPR_FILE="$root/$mpr"; MXTK_APP="$app"; _MKT_NO_REMEMBER=1; export MPR_FILE MXTK_APP + mxtk_mkt_report "$root" "$reg" "$fg" >/dev/null + printf '%s\t%s' "$MXTK_MKT_STATUS" "$MXTK_MKT_NOTE")" + st="${out%% *}"; one="${out#* }" + if [ "$st" = FAIL ] && [ "$fg" = "$shared" ]; then + st=PENDING + one="the shared ${shared#"$root"/} does not say which app owes this Buy; move the row to architecture/apps/$app/fit-gap.md, or waive it. Read: $one" + fi + printf ' [%s] %s — %s\n' "$app" "$st" "$one" + notes="${notes:+$notes; }$app: $st" + case "$st" in + FAIL) worst=FAIL ;; + PENDING) [ "$worst" = FAIL ] || worst=PENDING ;; + *) [ -n "$worst" ] || worst="$st" ;; + esac + done < — project-bin/exec.sh's install gate skips the # SHOW MODULES read when .claude/loop/marketplace-ok.txt holds exactly the current confirmed list # (lower case, sorted, space-separated). Written on PASS/WAIVED by whichever caller ran the check, @@ -225,6 +263,9 @@ mxtk_mkt_report() { _mkt_remember() { local f="$1/.claude/loop/marketplace-ok.txt" list [ -d "$1/.claude" ] || return 0 + # One file per project: a per-app loop (mxtk_mkt_report_apps) must not leave whichever app ran + # last as the answer for all of them, so it writes nothing and exec.sh reads SHOW MODULES. + [ "${_MKT_NO_REMEMBER:-0}" = 1 ] && return 0 case "$3" in PASS|WAIVED) list="$(printf '%s\n' "$2" | awk -F'\t' '$1=="confirmed"{print tolower($2)}' | sort -u | tr '\n' ' ')" diff --git a/bin/status.sh b/bin/status.sh index 3fde58bb..c0d2c8cc 100755 --- a/bin/status.sh +++ b/bin/status.sh @@ -370,6 +370,15 @@ done [ -n "$_ae_untracked" ] && AE_WATCH="extension module not in git: $_ae_untracked — a clone loses its document types; commit it with the model (skills/mendix-agents.md)" [ -n "$_ae_missing" ] && AE_WATCH="${AE_WATCH:+$AE_WATCH · }project uses Agent Editor but $_ae_missing is missing — Studio Pro shows unknown type 'agenteditor.agent' (skills/mendix-agents.md)" +# --- multi-app projects: one line per app (apps//.mpr) ---------------------------- +# The register stays one (PROJECT.md above); the evidence that is per app is shown per app: its +# model, its own mdlsource/ scripts, and its LOOK debt (bin/lib/app-scope.sh, shared with +# gate-check). Single-tree and two-tree projects print nothing here. +. "$TOOLKIT_ROOT/bin/lib/app-scope.sh" +APP_LINES="$(mxtk_app_lines "$PROJECT_DIR" "$TOOLKIT_ROOT")" +[ -n "$APP_LINES" ] && APP_LINES="$APP_LINES +" + # --- print ---------------------------------------------------------------------------------- TK="toolkit $TK_COMMIT_NOW"; [ -n "$TK_COMMIT_REG" ] && [ "$TK_COMMIT_REG" != "$TK_COMMIT_NOW" ] && TK="$TK (register says $TK_COMMIT_REG)" [ -n "$TK_UPD" ] && TK="$TK · updates: $TK_UPD" @@ -382,6 +391,7 @@ if [ "$BRIEF" = 1 ]; then [ -n "$CWD_NOTE" ] && echo "CWD $CWD_NOTE" echo "WHERE $NAME · $STAGE_LINE${ENTRY:+ · $ENTRY}${ADOPTED:+ · joined at $ADOPTED}" [ -n "$ROUND_LINE" ] && echo "ROUND $ROUND_LINE" + printf '%s' "$APP_LINES" | while IFS=' ' read -r _a _l; do [ -n "$_a" ] && echo "APP $_a: $_l"; done echo "STATE scripts $N_SCRIPTS written / $N_PASS gate-pass / $N_DONE done- · modules opened $MOD_OPENED${SKELETON:+ · skeleton $SKELETON} · UNSYNCED $UNSYNCED · open questions $OPEN_Q${MANUAL:+ · $MANUAL}${APPMAP:+ · $APPMAP}" [ -n "$WATCH" ] && echo "WATCH $WATCH" echo "NEXT $NEXT" @@ -392,6 +402,7 @@ printf '\n%s — %s%s%s\n' "$NAME" "$STAGE_LINE" "${ENTRY:+ · $ENTRY}" "${ADOPT printf '%s\n\n' "$TK" [ -n "$CWD_NOTE" ] && printf 'CWD %s\n' "$CWD_NOTE" [ -n "$ROUND_LINE" ] && printf 'ROUND %s\n' "$ROUND_LINE" +printf '%s' "$APP_LINES" | while IFS=' ' read -r _a _l; do [ -n "$_a" ] && printf 'APP %s: %s\n' "$_a" "$_l"; done printf 'DONE scripts: %s written, %s gate-pass, %s done- · modules opened: %s%s\n' "$N_SCRIPTS" "$N_PASS" "$N_DONE" "$MOD_OPENED" "${SKELETON:+ · skeleton proven $SKELETON}" printf 'OVERDUE %s · %s · %s · UNSYNCED markers: %s · open questions: %s\n' "$DOCTOR" "$LINT" "${COH:-coherence: cadence script not installed}" "$UNSYNCED" "$OPEN_Q" [ -n "$MANUAL" ] && printf ' %s (docs/manual-steps.md)\n' "$MANUAL" diff --git a/bin/sync-project.sh b/bin/sync-project.sh index 8e74371e..5cff07a7 100755 --- a/bin/sync-project.sh +++ b/bin/sync-project.sh @@ -673,6 +673,33 @@ else echo "Kept: triage.md has been worked on — not overwritten. Re-read skills/source-triage.md if the toolkit moved." fi +# --- 1d. Multi-app projects: per-app planning folders (bin/lib/app-scope.sh) ------------- +# The same scaffold init-project.sh writes, for a project that gained its second app later or +# predates this. Never overwrites. Nothing happens, and nothing prints, for any other layout. +. "$SCRIPT_DIR/lib/app-scope.sh" +_ATK="$(cd "$SCRIPT_DIR/.." && pwd)" +_WIRE_MPR=""; _WIRE_MDL="" +_wr="$(mxtk_wiring_rows "$PROJECT_DIR" "$_ATK")" +[ -n "$_wr" ] && { _WIRE_MPR="${_wr%% *}"; _WIRE_MDL="${_wr#* }"; } +if [ -n "$_wr" ]; then + if [ "$DRY_RUN" -eq 1 ]; then + _sa="$(mxtk_scope_apps "$PROJECT_DIR" "$_ATK" | while IFS=' ' read -r _a _m; do + [ -f "$PROJECT_DIR/architecture/apps/$_a/intake.md" ] || printf '%s ' "$_a"; done)" + [ -f "$PROJECT_DIR/architecture/apps/README.md" ] || _sa="${_sa}(index) " + [ -n "$_sa" ] && { echo "Would create: per-app planning under architecture/apps/ for: $_sa"; CHANGES=$((CHANGES + 1)); } + else + _sa="$(mxtk_scaffold_apps "$PROJECT_DIR" "$_ATK")" + [ -n "$_sa" ] && { printf '%s\n' "$_sa"; CHANGES=$((CHANGES + 1)); } + fi + if [ -f "$PROJECT_DIR/CLAUDE.local.md" ] && grep -q "## Wiring" "$PROJECT_DIR/CLAUDE.local.md" \ + && ! grep -q 'MXTK_APP=' "$PROJECT_DIR/CLAUDE.local.md"; then + echo "Note: CLAUDE.local.md's Wiring block predates multi-app support — replace its Project MPR and" + echo " MDL source dir rows with:" + echo " | Project MPR | $_WIRE_MPR |" + echo " | MDL source dir | $_WIRE_MDL |" + fi +fi + # --- 2. Agent stubs: refresh pure stubs, report completed ones -------------------------- AGENT_DIR="$PROJECT_DIR/.claude/agents" if [ -d "$AGENT_DIR" ]; then @@ -897,8 +924,8 @@ that doesn't resolve is a wiring failure the \`build-ready\` gate catches. Refre |---|---|---| | Toolkit root | \`$TOOLKIT_ROOT\` | The process authority | | Toolkit commit | see \`PROJECT.md\` \`Toolkit commit:\` | Authoritative there; ritual keeps it fresh | -| Project MPR | \`$MPR_NAME\` | The model file | -| MDL source dir | \`mdlsource/\` | Numbered build scripts | +| Project MPR | ${_WIRE_MPR:-\`$MPR_NAME\` | The model file} | +| MDL source dir | ${_WIRE_MDL:-\`mdlsource/\` | Numbered build scripts} | | Module briefs | \`architecture/modules//\` | one \`module-brief.md\` per module | | Wireframes | \`design/wireframes/\` | one annotated HTML per screen | | Design system | \`design/ds.css\` + \`design/design-system.html\` | tokens + component showcase | diff --git a/project-bin/_common.sh b/project-bin/_common.sh index 8cb16c2d..156cecbf 100755 --- a/project-bin/_common.sh +++ b/project-bin/_common.sh @@ -111,6 +111,7 @@ _mxtk_resolve_root() { # MXTK_APP= the environment form of --app, honoured when this file is sourced, # so every script takes it without parsing an argument. An MPR_FILE # the user set wins over it; the cwd auto-pick below never does. +# Ignored in a project that is not multi-app. # # The rule for readers: with mxtk_app_count >= 2 and no app selected, never pick one and never # report "nothing checked" — iterate mxtk_apps and report one line per app. find_mpr itself @@ -198,7 +199,9 @@ if [ -z "${MPR_FILE:-}" ] && [ -d "$PROJECT_ROOT/apps" ]; then fi # MXTK_APP (--app's environment form) wins over the cwd auto-pick, never over a user's MPR_FILE. # Its MPR_FILE is marked as a pick too, so a child in another project re-derives it from the name. -if [ -n "${MXTK_APP:-}" ] && { [ -z "${MPR_FILE:-}" ] || [ "${MPR_FILE:-}" = "${MXTK_MPR_PICKED:-}" ]; }; then +# Ignored where the project is not multi-app (a value exported for another project's shell). +if [ -n "${MXTK_APP:-}" ] && [ -d "$PROJECT_ROOT/apps" ] && mxtk_apps >/dev/null 2>&1 \ + && { [ -z "${MPR_FILE:-}" ] || [ "${MPR_FILE:-}" = "${MXTK_MPR_PICKED:-}" ]; }; then if mxtk_select_app "$MXTK_APP"; then MXTK_MPR_PICKED="$MPR_FILE"; export MXTK_MPR_PICKED else unset MPR_FILE MXTK_MPR_PICKED; fi fi diff --git a/project-bin/look-ledger.sh b/project-bin/look-ledger.sh index ef58751b..72d4ce46 100755 --- a/project-bin/look-ledger.sh +++ b/project-bin/look-ledger.sh @@ -3,7 +3,9 @@ # # bin/look-ledger.sh owe called by bin/exec.sh after a script lands # bin/look-ledger.sh seen PostToolUse(Read) hook; reads the hook JSON on stdin -# bin/look-ledger.sh status prints one line per owed page: SEEN or OWED +# bin/look-ledger.sh status [--app ] +# prints one line per owed page: SEEN or OWED (one app's +# pages only with --app, or with MXTK_APP set) # bin/look-ledger.sh reshoot [Module] [--all] # which pages a polish round must re-shoot (390 + 1280): the pages # built after their last seen LOOK, plus every page when a layout, @@ -48,7 +50,7 @@ # # Files (all TSV, under .claude/loop/look/; seen is append-only, owed is append-only except that a # DROP PAGE removes the dropped page's rows, shots is rewritten): -# owed.tsv epoch iso-time Module.Page script +# owed.tsv epoch iso-time Module.Page script [app] # seen.tsv epoch iso-time image-path image-mtime sha256 # shots.tsv epoch iso-time Module.Page image-path image-mtime journey step # @@ -58,6 +60,15 @@ # init-project.sh and sync-project.sh). gate-check.sh also accepts evidence it did not create: # a PROOF-OF-LOOK citation in a ui-review report (module-review.md stage 5). # +# MULTI-APP PROJECTS (apps//.mpr): ONE ledger for the project, keyed by app — not one +# per app root. The seen side is the agent's act and an image is not an app's: the Read hook runs +# at the project root (CLAUDE_PROJECT_DIR) and since #489 every app folder resolves to that root, +# so a per-app ledger would need a second root rule and split seen.tsv. Owed rows gain a 5th +# column, the app, only in a multi-app tree (from the script's apps// path, else the selected +# MXTK_APP); every other layout writes the same four columns as before, and readers that take +# cols 1-4 are unchanged. Two apps may both hold Orders.Order_Overview: `status --app` keeps them +# apart; an unscoped status joins them to the newest build, which can only read OWED longer. +# # Fail-open everywhere: a hook that errors must never break a Read, and `owe` must never fail # the exec that called it. Bash 3.2 compatible. @@ -144,9 +155,14 @@ cmd_owe() { _forget_dropped "$script" if [ -n "${EPOCHSECONDS:-}" ]; then now=$EPOCHSECONDS; TZ=UTC printf -v iso '%(%Y-%m-%dT%H:%M:%SZ)T' -1 # bash 5: no date process else now=$(date +%s); iso=$(date -u +%Y-%m-%dT%H:%M:%SZ); fi + local app="" col="" + if mxtk_apps "$PROJECT_ROOT" >/dev/null 2>&1; then + app="$(mxtk_app_of "$script")" || app="${MXTK_APP:-}" + [ -n "$app" ] && col=" $app" + fi while IFS= read -r p; do [ -n "$p" ] || continue - printf '%s\t%s\t%s\t%s\n' "$now" "$iso" "$p" "${script#"$PROJECT_ROOT"/}" >> "$OWED" && n=$((n+1)) + printf '%s\t%s\t%s\t%s%s\n' "$now" "$iso" "$p" "${script#"$PROJECT_ROOT"/}" "$col" >> "$OWED" && n=$((n+1)) done < 0) { @@ -220,6 +236,8 @@ _look_status_ex() { shotmt[g[3] SUBSEP g[4]] = g[5]+0 } } + # --app: rows of that app only — by the app column, or for an older row by its script path + app != "" && !($5 == app || ($5 == "" && index($4, "apps/" app "/") == 1)) { next } NF>=3 { if (!($3 in last) || $1+0 > last[$3]) last[$3]=$1+0 } END { for (p in last) { @@ -365,7 +383,9 @@ case "${1:-}" in reshoot) shift; cmd_reshoot "$@" ;; owe) shift; cmd_owe "$@" ;; seen) cmd_seen ;; - status) look_status ;; + status) shift + case "${1:-}" in --app) LOOK_APP="${2:-}" ;; --app=*) LOOK_APP="${1#--app=}" ;; *) LOOK_APP=""; [ -n "${MXTK_APP:-}" ] && mxtk_apps >/dev/null 2>&1 && LOOK_APP="$MXTK_APP" ;; esac + look_status ;; shots) shift; cmd_shots "$@" ;; pages) shift; look_pages_in "${1:-/dev/null}" ;; *) echo "usage: $0 owe | seen < hook-json | status | reshoot [Module] [--all] | shots [findings.json...] | pages " >&2; exit 2 ;; diff --git a/skills/module-folder-convention.md b/skills/module-folder-convention.md index f47f15df..5ff4f621 100644 --- a/skills/module-folder-convention.md +++ b/skills/module-folder-convention.md @@ -185,6 +185,23 @@ Two consequences, stated so nobody mistakes silence for a pass: --- +## Several apps in one repo + +One app per `apps//` (its `.mpr`, its own `mdlsource/`). The project root keeps ONE +register (`PROJECT.md`), one root `intake.md` for answers shared by every app, and ONE build plan +(`architecture/build-plan.md`, one `## App: ` section per app). Per-app planning goes to +`architecture/apps//` (`intake.md`, `triage.md`, an optional `fit-gap.md`), never into +`apps//` — that folder is the Mendix project Studio Pro commits and mxbuild packages. Module +briefs stay `architecture/modules//module-brief.md` with an `**App:** ` line, because +every brief reader looks there. `init-project.sh` / `sync-project.sh` scaffold this and the index +`architecture/apps/README.md`; select one app with `MXTK_APP=` or `--app `. + +Done when every app in `architecture/apps/README.md` has an intake and a build-plan section. +Failure it prevents (field run, 2026-11): four apps, no per-app intake, one free-form brief +instead — and that brief carried the spec violation that blocked the first grading. + +--- + ## Companion skills `module-brief.md` (where the folder plan is decided) · `learned-mdl-preflight.md` Step 0 (chosen diff --git a/tests/wave2/fixtures/multi-app/PROVENANCE.txt b/tests/wave2/fixtures/multi-app/PROVENANCE.txt new file mode 100644 index 00000000..bb544cd2 --- /dev/null +++ b/tests/wave2/fixtures/multi-app/PROVENANCE.txt @@ -0,0 +1,16 @@ +tests/wave2/fixtures/multi-app/ — provenance + +tree.txt is the SHAPE of a multi-app repository as two field runs (2026-11) reported it: several +Mendix apps side by side under apps//, each a full Mendix project folder (its own .mpr, +mprcontents/, javasource/, themesource/, widgets/) with its own mdlsource/ of numbered MDL page +scripts, and one project root above them (PROJECT.md, .claude/, architecture/). App names are +neutral stand-ins; file names inside each app folder follow a Mendix 11 project folder. + +NOT a verbatim `ls -R` capture: none of the field repositories could be copied here, and the +readers under test (project-bin/_common.sh mxtk_apps, bin/lib/app-scope.sh) glob directory names, +they parse no tool output. Replace tree.txt with a capture from a real multi-app repository +(`cd && find . -path ./.git -prune -o -print | sort`, client names replaced) when one is +available; the fixture reads it as-is. + +Tool output used by test-multi-app-scope.sh is captured, never hand-written: SHOW MODULES replays +tests/wave2/fixtures/show-modules/*.out (see that folder's CAPTURE.txt). diff --git a/tests/wave2/fixtures/multi-app/tree.txt b/tests/wave2/fixtures/multi-app/tree.txt new file mode 100644 index 00000000..c1b665cb --- /dev/null +++ b/tests/wave2/fixtures/multi-app/tree.txt @@ -0,0 +1,26 @@ +./PROJECT.md +./intake.md +./.claude/ +./architecture/ +./apps/Orders/Orders.mpr +./apps/Orders/mprcontents/0a/3f/0a3f6c1e-7d2b-4c55-9a10-2f4e8b9d1c01.mxunit +./apps/Orders/mprcontents/5e/91/5e91b2a4-0c3d-4f6e-8a7b-1d2c3e4f5a6b.mxunit +./apps/Orders/javasource/orders/proxies/ +./apps/Orders/themesource/orders/web/main.scss +./apps/Orders/widgets/ +./apps/Orders/mdlsource/010-orders-domain.mdl +./apps/Orders/mdlsource/030-orders-pages.mdl +./apps/Billing/Billing.mpr +./apps/Billing/mprcontents/7c/02/7c02d9e1-3a4b-4c5d-8e6f-7a8b9c0d1e2f.mxunit +./apps/Billing/javasource/billing/proxies/ +./apps/Billing/themesource/billing/web/main.scss +./apps/Billing/widgets/ +./apps/Billing/mdlsource/010-billing-domain.mdl +./apps/Billing/mdlsource/030-billing-pages.mdl +./apps/Billing/mdlsource/done-020-billing-flows.mdl +./apps/Portal/Portal.mpr +./apps/Portal/mprcontents/1d/e4/1de4f0a2-5b6c-4d7e-9f80-a1b2c3d4e5f6.mxunit +./apps/Portal/javasource/portal/proxies/ +./apps/Portal/themesource/portal/web/main.scss +./apps/Portal/widgets/ +./apps/Portal/mdlsource/ diff --git a/tests/wave2/test-multi-app-scope.sh b/tests/wave2/test-multi-app-scope.sh new file mode 100755 index 00000000..95178cf4 --- /dev/null +++ b/tests/wave2/test-multi-app-scope.sh @@ -0,0 +1,176 @@ +#!/usr/bin/env bash +# test-multi-app-scope.sh — a repo holding several apps (apps//.mpr) is scoped per app. +# +# usage: bash tests/wave2/test-multi-app-scope.sh project-bin/_common.sh +# +# Field runs (2026-11): six apps under apps// printed "more than one .mpr; set MPR_FILE to +# choose, nothing checked" for the Marketplace check; CLAUDE.local.md had to hand-write the +# MPR_FILE workaround; a second run dropped per-app planning for one free-form brief. +# +# The tree is materialised from fixtures/multi-app/tree.txt (see PROVENANCE.txt there); SHOW +# MODULES is replayed from the captures in fixtures/show-modules/ by a stub mxcli keyed on -p. +# +# A1 resolver: mxtk_apps lists the three apps, mxtk_app_count 3; mxtk_select_app exact and any +# letter case, unknown refused listing apps; mxtk_app_of; MXTK_APP at source time beats the +# cwd auto-pick, a user's MPR_FILE beats MXTK_APP; find_mpr still refuses, naming MXTK_APP +# A2 single tree and two-tree: mxtk_apps prints nothing (rc 1) and mxtk_app_count is 0, even +# with an apps/ folder holding a model beside the root model +# A3 gate-check, no app chosen: "Marketplace installs: per app (3 apps", one [App] line each, +# no "nothing checked"; per-app fit-gap missing package -> FAIL for that app only; shared +# fit-gap missing package -> PENDING (owner unknown); build-ready counts the FAIL +# A4 gate-check --app orders: one Marketplace line, Orders' fit-gap; no Apps section; +# --app Nope exits 2 naming the apps; --app on a single-tree project exits 2 +# A5 gate-check "Apps:" section and status.sh: one line per app, scripts per app's mdlsource, +# LOOK owed per app; single-tree and two-tree print neither +# A6 look-ledger: owe writes the app as a 5th column in the multi-app tree, four columns in a +# single tree; status --app keeps two apps' same-named page apart +# A7 init-project scaffolds architecture/apps//intake.md + triage.md + the index and the +# multi-app Wiring rows; sync-project re-run creates nothing and overwrites nothing +set -u + +COMMON="${1:?usage: $0 project-bin/_common.sh}" +COMMON="$(cd "$(dirname "$COMMON")" && pwd)/$(basename "$COMMON")" +TK="$(cd "$(dirname "$COMMON")/.." && pwd)" +FX="$TK/tests/wave2/fixtures" +T="$(mktemp -d "${TMPDIR:-/tmp}/mxtk-multiapp.XXXXXX")"; T="$(cd "$T" && pwd)" +trap 'rm -rf "$T"' EXIT +PASS=0; FAIL=0 +ok() { PASS=$((PASS + 1)); echo " ok $*"; } +fail() { FAIL=$((FAIL + 1)); echo " FAIL $*"; } +has() { if printf '%s\n' "$2" | grep -qF -- "$3"; then ok "$1"; else fail "$1 (no '$3' in: $(printf '%s' "$2" | head -c 600))"; fi; } +hasnt(){ if printf '%s\n' "$2" | grep -qF -- "$3"; then fail "$1 (unexpected '$3')"; else ok "$1"; fi; } +eq() { if [ "$2" = "$3" ]; then ok "$1"; else fail "$1 (want '$3', got '$2')"; fi; } +clean_env() { env -u MPR_FILE -u MXTK_APP -u MXTK_MPR_PICKED -u PROJECT_ROOT -u MXCLI "$@"; } + +# --- the multi-app tree --------------------------------------------------------------------- +P="$T/multi"; mkdir -p "$P" +while IFS= read -r l; do + l="${l#./}"; [ -n "$l" ] || continue + case "$l" in */) mkdir -p "$P/$l" ;; *) mkdir -p "$P/$(dirname "$l")"; : > "$P/$l" ;; esac +done < "$FX/multi-app/tree.txt" +# Page scripts: Orders and Billing both build Administration.Account_Overview (A6). +printf 'create page Orders.Order_Overview (\n);\ncreate page Administration.Account_Overview (\n);\n' > "$P/apps/Orders/mdlsource/030-orders-pages.mdl" +printf 'create or replace page Billing.Invoice_Overview (\n);\ncreate page Administration.Account_Overview (\n);\n' > "$P/apps/Billing/mdlsource/030-billing-pages.mdl" +printf '# Project\n\n## Current stage\n**Stage 5 — build**\n' > "$P/PROJECT.md" + +# stub mxcli: replays a captured SHOW MODULES per app (-p ) +STUB="$T/stub-mxcli" +cat > "$STUB" <&1)" +has "A1 unknown refused" "$r" "rc=1"; has "A1 unknown lists apps" "$r" "Portal (apps/Portal/Portal.mpr)" +r="$(clean_env bash -c "cd '$P'; . '$COMMON'; mxtk_app_of '$P/apps/Orders/mdlsource/x.mdl'; mxtk_app_of docs/x || echo none")" +eq "A1 app_of" "$r" "Orders +none" +r="$(clean_env MXTK_APP=Orders bash -c "cd '$P/apps/Billing'; . '$COMMON'; find_mpr")" +eq "A1 MXTK_APP beats cwd pick" "$r" "$P/apps/Orders/Orders.mpr" +r="$(clean_env MXTK_APP=Orders MPR_FILE=apps/Portal/Portal.mpr bash -c "cd '$P'; . '$COMMON'; find_mpr")" +eq "A1 user MPR_FILE beats MXTK_APP" "$r" "$P/apps/Portal/Portal.mpr" +r="$(clean_env bash -c "cd '$P'; . '$COMMON'; find_mpr" 2>&1)" +has "A1 find_mpr refuses" "$r" "refusing to guess"; has "A1 refusal names MXTK_APP" "$r" "MXTK_APP=" + +echo "A2 single tree and two-tree are never multi-app" +S1="$T/single"; mkdir -p "$S1/apps/Other" "$S1/.claude"; : > "$S1/Single.mpr"; : > "$S1/apps/Other/Other.mpr" +printf '# Project\n\n## Current stage\n**Stage 5 — build**\n' > "$S1/PROJECT.md" +S2="$T/twotree"; mkdir -p "$S2/app" "$S2/.claude"; : > "$S2/app/Two.mpr" +printf '# Project\n\n## Current stage\n**Stage 5 — build**\n' > "$S2/PROJECT.md" +for d in "$S1" "$S2"; do + r="$(clean_env bash -c "cd '$d'; . '$COMMON'; mxtk_apps; echo rc=\$? n=\$(mxtk_app_count)")" + eq "A2 $(basename "$d"): nothing listed" "$r" "rc=1 n=0" +done + +echo "A3 gate-check per-app Marketplace (no app chosen)" +mkdir -p "$P/architecture/apps/Orders" "$P/architecture/apps/Billing" +printf '| Capability | Mendix approach | Verdict |\n|---|---|---|\n| Module | `MyFirstModule` | Buy |\n' > "$P/architecture/apps/Orders/fit-gap.md" +printf '| Capability | Mendix approach | Verdict |\n|---|---|---|\n| Grid | `DataWidgets` | Buy |\n' > "$P/architecture/apps/Billing/fit-gap.md" +printf '| Capability | Mendix approach | Verdict |\n|---|---|---|\n| Grid | `DataWidgets` | Buy |\n' > "$P/architecture/fit-gap.md" +gc() { clean_env MXCLI="$STUB" MXTK_NO_FETCH=1 MXTK_GATE_CACHE_TTL_MIN=0 bash "$TK/bin/gate-check.sh" --no-html "$@" 2>&1; } +out="$(gc "$P")" +has "A3 header" "$out" "Marketplace installs: per app (3 apps" +has "A3 Orders installed" "$out" " [Orders] PASS — 1 of 1 confirmed Buy installed" +has "A3 Billing own fit-gap FAIL" "$out" " [Billing] FAIL — 0 of 1 confirmed Buy installed; NOT INSTALLED: DataWidgets" +has "A3 Portal shared fit-gap PENDING" "$out" " [Portal] PENDING — the shared architecture/fit-gap.md does not say which app owes this Buy" +hasnt "A3 no nothing-checked" "$out" "nothing checked" +br="$(gc "$P" build-ready)" +has "A3 build-ready counts the FAIL" "$br" "✗ Marketplace: Billing: FAIL; Orders: PASS; Portal: PENDING" + +echo "A4 gate-check --app" +out="$(gc --app orders "$P")" +has "A4 one line, Orders' fit-gap" "$out" "Marketplace installs: PASS — 1 of 1 confirmed Buy installed" +hasnt "A4 no per-app header" "$out" "per app (" +hasnt "A4 no Apps section" "$out" "Apps: 3" +out="$(gc --app Nope "$P")"; rc=$? +eq "A4 unknown app exits 2" "$rc" "2"; has "A4 names the apps" "$out" "Orders (apps/Orders/Orders.mpr)" +out="$(gc --app Orders "$S1")"; rc=$? +eq "A4 --app on single tree exits 2" "$rc" "2" + +echo "A5 Apps section and status lines" +for a in Orders Billing; do + (cd "$P/apps/$a" && clean_env bash "$TK/project-bin/look-ledger.sh" owe "$P/apps/$a/mdlsource/030-$(echo "$a" | tr '[:upper:]' '[:lower:]')-pages.mdl" >/dev/null) +done +out="$(gc "$P")" +has "A5 Apps header" "$out" "Apps: 3 (one register, PROJECT.md" +has "A5 Billing line" "$out" " [Billing] apps/Billing/Billing.mpr · scripts 3 written / 1 done- · LOOK: 2 of 2 page(s) owed" +has "A5 Portal line" "$out" " [Portal] apps/Portal/Portal.mpr · scripts 0 written / 0 done- · LOOK: no pages owed" +st="$(clean_env bash "$TK/bin/status.sh" "$P" 2>&1)" +has "A5 status Orders" "$st" "APP Orders: apps/Orders/Orders.mpr · scripts 2 written / 0 done- · LOOK: 2 of 2 page(s) owed" +stb="$(clean_env bash "$TK/bin/status.sh" "$P" --brief 2>&1)" +has "A5 status --brief Portal" "$stb" "APP Portal: apps/Portal/Portal.mpr" +for d in "$S1" "$S2"; do + out="$(gc "$d")"; st="$(clean_env bash "$TK/bin/status.sh" "$d" 2>&1)" + hasnt "A5 $(basename "$d"): no Apps section" "$out" "Apps: " + hasnt "A5 $(basename "$d"): no per-app Marketplace" "$out" "per app (" + hasnt "A5 $(basename "$d"): no APP status line" "$st" "APP " +done + +echo "A6 look-ledger keyed by app" +cols="$(awk -F'\t' '{print NF ":" $5}' "$P/.claude/loop/look/owed.tsv" | sort -u | tr '\n' ' ')" +eq "A6 multi-app rows carry the app" "$cols" "5:Billing 5:Orders " +printf 'create page Single.Home (\n);\n' > "$S1/p.mdl" +(cd "$S1" && clean_env bash "$TK/project-bin/look-ledger.sh" owe "$S1/p.mdl" >/dev/null) +eq "A6 single tree keeps four columns" "$(awk -F'\t' '{print NF}' "$S1/.claude/loop/look/owed.tsv")" "4" +r="$(cd "$P" && clean_env PROJECT_ROOT="$P" bash "$TK/project-bin/look-ledger.sh" status --app Orders | cut -f1,2 | tr '\n' ' ')" +eq "A6 status --app Orders" "$r" "OWED Administration.Account_Overview OWED Orders.Order_Overview " +r="$(cd "$P" && clean_env PROJECT_ROOT="$P" MXTK_APP=Billing bash "$TK/project-bin/look-ledger.sh" status | cut -f2 | tr '\n' ' ')" +eq "A6 MXTK_APP scopes status" "$r" "Administration.Account_Overview Billing.Invoice_Overview " + +echo "A7 init-project and sync-project scaffold per app" +I="$T/init"; mkdir -p "$I" +while IFS= read -r l; do + l="${l#./}"; case "$l" in ''|PROJECT.md|intake.md|.claude/|architecture/) continue ;; esac + case "$l" in */) mkdir -p "$I/$l" ;; *) mkdir -p "$I/$(dirname "$l")"; : > "$I/$l" ;; esac +done < "$FX/multi-app/tree.txt" +(cd "$I" && git init -q .) +out="$(clean_env MXTK_NO_GUIDE=1 MXTK_NO_FETCH=1 bash "$TK/bin/init-project.sh" "$I" 2>&1)" +for a in Orders Billing Portal; do + [ -f "$I/architecture/apps/$a/intake.md" ] && ok "A7 $a intake" || fail "A7 $a intake missing" + [ -f "$I/architecture/apps/$a/triage.md" ] && ok "A7 $a triage" || fail "A7 $a triage missing" +done +has "A7 index lists Portal" "$(cat "$I/architecture/apps/README.md" 2>/dev/null)" "| Portal | \`apps/Portal/Portal.mpr\` |" +has "A7 Wiring names MXTK_APP" "$(cat "$I/CLAUDE.local.md")" "Select with \`MXTK_APP=\`" +echo "own words" >> "$I/architecture/apps/Orders/intake.md" +out="$(clean_env MXTK_NO_FETCH=1 bash "$TK/bin/sync-project.sh" "$I" 2>&1)" +hasnt "A7 sync creates nothing new" "$out" "Created: architecture/apps/" +has "A7 sync kept the edit" "$(tail -1 "$I/architecture/apps/Orders/intake.md")" "own words" +rm -f "$I/architecture/apps/Portal/intake.md" +out="$(clean_env MXTK_NO_FETCH=1 bash "$TK/bin/sync-project.sh" "$I" 2>&1)" +has "A7 sync restores a missing app intake" "$out" "Created: architecture/apps/Portal/intake.md" + +echo "" +echo "multi-app scope: $PASS passed, $FAIL failed" +[ "$FAIL" -eq 0 ] From 9c7649b194346b532260fb571b613006204abd0e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:28:26 +0000 Subject: [PATCH 03/11] fix(multi-app): no 'no pages owed' without a ledger; a shared fit-gap finding prints once From the parent session's field run of #789 on a copy of a six-app repo: - status/gate-check said 'LOOK: no pages owed' per app on a checkout with ~78 built pages, because the LOOK ledger is git-ignored. Now: 'LOOK: no ledger here (N page(s) in its scripts)', 'no ledger row for this app', or 'no page in its scripts'. - the Marketplace check repeated one project-level fit-gap finding six times. Apps on the shared fit-gap are grouped by identical finding: '[all 6 apps, from the shared ...]'. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 2 +- bin/lib/app-scope.sh | 17 +++++++++++-- bin/lib/marketplace-check.sh | 37 ++++++++++++++++++++++++----- tests/wave2/test-multi-app-scope.sh | 18 +++++++++++--- 4 files changed, 62 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1468f96..cda6abf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased -- new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt; `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,125 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/`, reconstructed, not a capture — see its PROVENANCE.txt) — two field runs, Nov 2026 +- new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,125 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/`, reconstructed, not a capture — see its PROVENANCE.txt) — two field runs, Nov 2026 - new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 - fix(status, agents): **`bin/status.sh` WATCHes an Agent Editor project whose extension module does not travel with the model (#778)**: Studio Pro reads `agenteditor.agent` from `modules/AgentEditor.mxmodule` beside the `.mpr`, and a sync of only `.mpr` + `mprcontents/` left it out of git, so the builder stayed green while every colleague's clone showed `unknown type 'agenteditor.agent'`. Two WATCH items, warn-only (exit code and every verdict unchanged), local files and `git ls-files` only, root and `app/` layouts: a `modules/*.mxmodule` git does not track, and a project using Agent Editor (`AgentEditorCommons` in `analysis/app-facts/inventory.json`, or a `create agent` statement in `mdlsource/`) with no `modules/AgentEditor*.mxmodule`. `skills/mendix-agents.md` (on demand) gains the rule plus the note that the GenAI key, `Encryption.EncryptionKey` and `GenAICommons.StoreTraces` belong in the Default configuration, not a start script. Empty agent references / missing model version (mendixlabs/mxcli#1867) and unset runtime constants are not checked: they need a captured agent document (option 2). Fixture `tests/wave2/test-status-extension-modules.sh` — field report from an Agent Editor project, Nov 2026 - fix(permissions): **exec approval `auto` no longer prompts on every exec's mode check, and `install-claude-hooks.sh` no longer runs unprompted (#782)**: `install-claude-permissions.sh` now allow-lists `exec-approval.sh`, `interview-mode.sh` and `permission-profile.sh`, so their reads run without a prompt, while their only writers, `--set` and `--clear`, prompt through six `ask` rules (`Bash(*exec-approval.sh*--set*)`, …) in the shared settings under every profile (an ask rule beats an allow rule, `full`'s bare `Bash` included). `install-claude-hooks.sh`, which writes `~/.claude/settings.json` for every repo on the machine, gets no allow rule. A re-install adds the ask rules and removes the hooks-installer rule an earlier install added (sidecar); entries someone else wrote are untouched, and `sync-project.sh`'s permission check names both until then. Field run on claude 2.1.325: the read ran, `--set auto` and `--clear` were refused, and with the ask rules removed `--set` ran — from the two independent reviews of #781 diff --git a/bin/lib/app-scope.sh b/bin/lib/app-scope.sh index d1ae4473..caa41850 100644 --- a/bin/lib/app-scope.sh +++ b/bin/lib/app-scope.sh @@ -13,7 +13,10 @@ # one line per app, "", only when there are two or more apps: # "apps//.mpr · scripts N written / D done- · LOOK: K of M page(s) owed" # scripts count apps//mdlsource/ (gallery excluded, as status.sh counts the root); -# LOOK is `look-ledger.sh status --app ` (one project ledger, keyed by app). +# LOOK is `look-ledger.sh status --app ` (one project ledger, keyed by app). With no +# ledger, or no row of this app in it, it says so and counts the pages its scripts create +# or alter: never "no pages owed" without a ledger to say it (a field run, six apps: the +# ledger is git-ignored, so a fresh checkout with ~78 built pages read "no pages owed"). mxtk_scope_apps() { local pd="$1" tk="$2" @@ -34,7 +37,17 @@ mxtk_app_lines() { n="$(find "$d" -name '*.mdl' -not -path '*/gallery/*' | wc -l | tr -d ' ')" dn="$(find "$d" -name 'done-*.mdl' | wc -l | tr -d ' ')" fi - lk="LOOK: no pages owed" + np=0 + [ -d "$d" ] && np="$(find "$d" -name '*.mdl' -not -path '*/gallery/*' -exec cat {} + 2>/dev/null | awk ' + /^[[:space:]]*--/ { next } + { l = toupper($0) } + l ~ /^[[:space:]]*(CREATE([[:space:]]+OR[[:space:]]+(REPLACE|MODIFY))?|ALTER)[[:space:]]+PAGE[[:space:]]/ { + n = split($0, w, /[[:space:]]+/); for (i = 1; i < n; i++) if (toupper(w[i]) == "PAGE") { x = w[i+1]; break } + sub(/[(;{].*$/, "", x); gsub(/"/, "", x); if (x ~ /^[A-Za-z0-9_]+\.[A-Za-z0-9_]+$/) seen[x] = 1 } + END { k = 0; for (x in seen) k++; print k }')" + if [ "$np" -eq 0 ]; then lk="LOOK: no page in its scripts" + elif [ -s "$pd/.claude/loop/look/owed.tsv" ]; then lk="LOOK: no ledger row for this app ($np page(s) in its scripts)" + else lk="LOOK: no ledger here ($np page(s) in its scripts) — .claude/loop/look/ is written by bin/exec.sh on this machine"; fi if [ -s "$pd/.claude/loop/look/owed.tsv" ] && [ -f "$tk/project-bin/look-ledger.sh" ]; then ls="$(PROJECT_ROOT="$pd" MPR_FILE="" MXTK_APP="" bash "$tk/project-bin/look-ledger.sh" status --app "$a" 2>/dev/null)" lt="$(printf '%s' "$ls" | grep -c . || true)"; lo="$(printf '%s\n' "$ls" | grep -c '^OWED' || true)" diff --git a/bin/lib/marketplace-check.sh b/bin/lib/marketplace-check.sh index 36820792..8047780d 100755 --- a/bin/lib/marketplace-check.sh +++ b/bin/lib/marketplace-check.sh @@ -221,7 +221,9 @@ mxtk_mkt_report() { # mxtk_mkt_report_apps # A multi-app project (two or more apps//.mpr, as mxtk_apps prints them) with no # app selected: one check per app instead of "more than one .mpr ... nothing checked" (field run, -# 2026-11, six apps). Prints a header line and one " [] — ..." line per app. +# 2026-11, six apps). Prints a header line, one " [] — ..." line per app with its +# own fit-gap, and for the apps on the shared fit-gap one line per distinct finding, naming its +# apps ("[all 6 apps, from the shared architecture/fit-gap.md]" when it holds for every app). # Each app reads architecture/apps//fit-gap.md when it has one, else the shared fit-gap. A # shared fit-gap does not say which app owes a Buy, so a package missing from an app reads PENDING # there, naming the move that settles it — never a FAIL on a guess. @@ -229,7 +231,9 @@ mxtk_mkt_report() { # MXTK_MKT_NOTE to ": ; ..." — build-ready counts that FAIL as one item. mxtk_mkt_report_apps() { local root="$1" reg="$2" shared="$3" apps="$4" app mpr fg out st worst="" notes="" one - printf 'Marketplace installs: per app (%s apps; --app checks one)\n' "$(printf '%s\n' "$apps" | grep -c .)" + local groups="" g gk gapps n_sh=0 n_all key + n_all="$(printf '%s\n' "$apps" | grep -c . || true)" + printf 'Marketplace installs: per app (%s apps; --app checks one)\n' "$n_all" while IFS=' ' read -r app mpr; do [ -n "$app" ] || continue fg="$shared" @@ -238,11 +242,21 @@ mxtk_mkt_report_apps() { mxtk_mkt_report "$root" "$reg" "$fg" >/dev/null printf '%s\t%s' "$MXTK_MKT_STATUS" "$MXTK_MKT_NOTE")" st="${out%% *}"; one="${out#* }" - if [ "$st" = FAIL ] && [ "$fg" = "$shared" ]; then - st=PENDING - one="the shared ${shared#"$root"/} does not say which app owes this Buy; move the row to architecture/apps/$app/fit-gap.md, or waive it. Read: $one" + if [ "$fg" = "$shared" ]; then + [ "$st" = FAIL ] && { st=PENDING + one="the shared ${shared#"$root"/} does not say which app owes this Buy; move the row to architecture/apps//fit-gap.md, or waive it. Read: $one"; } + # Shared source: findings that read the same for several apps print once (a field run, six + # apps, repeated one project-level finding six times). The app's own model name is the + # only per-app word in a note; it is folded to .mpr before comparing. + n_sh=$((n_sh + 1)); key="$st $(printf '%s' "$one" | sed "s#-p ${mpr##*/}#-p .mpr#g")" + g="$(printf '%s' "$groups" | awk -F'\034' -v k="$key" '$2 == k { print $1; exit }')" + if [ -n "$g" ]; then groups="$(printf '%s' "$groups" | awk -F'\034' -v k="$key" -v a="$app" 'BEGIN{OFS="\034"} $2 == k { $1 = $1 ", " a } { print }') +" + else groups="$groups$app$(printf '\034')$key +"; fi + else + printf ' [%s] %s — %s\n' "$app" "$st" "$one" fi - printf ' [%s] %s — %s\n' "$app" "$st" "$one" notes="${notes:+$notes; }$app: $st" case "$st" in FAIL) worst=FAIL ;; @@ -252,6 +266,17 @@ mxtk_mkt_report_apps() { done < FAIL for that app only; shared -# fit-gap missing package -> PENDING (owner unknown); build-ready counts the FAIL +# fit-gap missing package -> PENDING (owner unknown); build-ready counts the FAIL; with +# every app on the shared fit-gap, the one finding prints once ("all 3 apps") # A4 gate-check --app orders: one Marketplace line, Orders' fit-gap; no Apps section; # --app Nope exits 2 naming the apps; --app on a single-tree project exits 2 # A5 gate-check "Apps:" section and status.sh: one line per app, scripts per app's mdlsource, -# LOOK owed per app; single-tree and two-tree print neither +# LOOK owed per app, and "no ledger here (N pages ...)" before any ledger exists — never +# "no pages owed" by absence; single-tree and two-tree print neither # A6 look-ledger: owe writes the app as a 5th column in the multi-app tree, four columns in a # single tree; status --app keeps two apps' same-named page apart # A7 init-project scaffolds architecture/apps//intake.md + triage.md + the index and the @@ -108,6 +110,12 @@ has "A3 Portal shared fit-gap PENDING" "$out" " [Portal] PENDING — the shared hasnt "A3 no nothing-checked" "$out" "nothing checked" br="$(gc "$P" build-ready)" has "A3 build-ready counts the FAIL" "$br" "✗ Marketplace: Billing: FAIL; Orders: PASS; Portal: PENDING" +# every app on the shared fit-gap: one finding, printed once (a field run, six apps, printed it six times) +mv "$P/architecture/apps" "$T/apps-fitgaps" +out="$(gc "$P")" +has "A3 shared finding printed once" "$out" " [all 3 apps, from the shared architecture/fit-gap.md] PENDING" +eq "A3 no per-app repeat" "$(printf '%s\n' "$out" | grep -c '^ \[Orders\] PENDING')" "0" +mv "$T/apps-fitgaps" "$P/architecture/apps" echo "A4 gate-check --app" out="$(gc --app orders "$P")" @@ -120,13 +128,17 @@ out="$(gc --app Orders "$S1")"; rc=$? eq "A4 --app on single tree exits 2" "$rc" "2" echo "A5 Apps section and status lines" +# no ledger yet (it is git-ignored: a fresh checkout has none) is never "no pages owed" +st="$(clean_env bash "$TK/bin/status.sh" "$P" 2>&1)" +has "A5 no ledger is said" "$st" "APP Orders: apps/Orders/Orders.mpr · scripts 2 written / 0 done- · LOOK: no ledger here (2 page(s) in its scripts)" +hasnt "A5 no pass-by-absence" "$st" "no pages owed" for a in Orders Billing; do (cd "$P/apps/$a" && clean_env bash "$TK/project-bin/look-ledger.sh" owe "$P/apps/$a/mdlsource/030-$(echo "$a" | tr '[:upper:]' '[:lower:]')-pages.mdl" >/dev/null) done out="$(gc "$P")" has "A5 Apps header" "$out" "Apps: 3 (one register, PROJECT.md" has "A5 Billing line" "$out" " [Billing] apps/Billing/Billing.mpr · scripts 3 written / 1 done- · LOOK: 2 of 2 page(s) owed" -has "A5 Portal line" "$out" " [Portal] apps/Portal/Portal.mpr · scripts 0 written / 0 done- · LOOK: no pages owed" +has "A5 Portal line" "$out" " [Portal] apps/Portal/Portal.mpr · scripts 0 written / 0 done- · LOOK: no page in its scripts" st="$(clean_env bash "$TK/bin/status.sh" "$P" 2>&1)" has "A5 status Orders" "$st" "APP Orders: apps/Orders/Orders.mpr · scripts 2 written / 0 done- · LOOK: 2 of 2 page(s) owed" stb="$(clean_env bash "$TK/bin/status.sh" "$P" --brief 2>&1)" From 5cfb24b3aeb094fa83c2d0f42061f4d828fa1d2a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:32:58 +0000 Subject: [PATCH 04/11] fix(multi-app): warn on an app's own PROJECT.md register; fixture tree from a field capture - bin/lib/app-scope.sh mxtk_app_register_notes: an apps//PROJECT.md (mxcli init per app) holding register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. The root PROJECT.md stays the register gate-check reads. A plain template file is silent. - tests/wave2/fixtures/multi-app/tree.txt: the structural shape of a field repo (git ls-files, six apps, anonymised AppA..AppF; script counts 69/34/28/26/27/27; each app carries its own PROJECT.md and CLAUDE.md). Fixture adapted to six apps; new case A8. - skills/module-folder-convention.md: one sentence on app-level PROJECT.md (baseline 65,155). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 2 +- bin/gate-check.sh | 1 + bin/lib/app-scope.sh | 35 ++ bin/status.sh | 5 +- bin/sync-project.sh | 1 + skills/module-folder-convention.md | 4 +- tests/wave2/fixtures/multi-app/PROVENANCE.txt | 26 +- tests/wave2/fixtures/multi-app/tree.txt | 370 ++++++++++++++++-- tests/wave2/test-multi-app-scope.sh | 120 +++--- 9 files changed, 472 insertions(+), 92 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cda6abf4..f81ee2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased -- new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,125 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/`, reconstructed, not a capture — see its PROVENANCE.txt) — two field runs, Nov 2026 +- new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. The root `PROJECT.md` is the one register: an app's own `PROJECT.md` (from `mxcli init` per app; the field repo held seven) that holds register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,155 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/` from a field repo's `git ls-files`, six apps, anonymised — see its PROVENANCE.txt) — two field runs, Nov 2026 - new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 - fix(status, agents): **`bin/status.sh` WATCHes an Agent Editor project whose extension module does not travel with the model (#778)**: Studio Pro reads `agenteditor.agent` from `modules/AgentEditor.mxmodule` beside the `.mpr`, and a sync of only `.mpr` + `mprcontents/` left it out of git, so the builder stayed green while every colleague's clone showed `unknown type 'agenteditor.agent'`. Two WATCH items, warn-only (exit code and every verdict unchanged), local files and `git ls-files` only, root and `app/` layouts: a `modules/*.mxmodule` git does not track, and a project using Agent Editor (`AgentEditorCommons` in `analysis/app-facts/inventory.json`, or a `create agent` statement in `mdlsource/`) with no `modules/AgentEditor*.mxmodule`. `skills/mendix-agents.md` (on demand) gains the rule plus the note that the GenAI key, `Encryption.EncryptionKey` and `GenAICommons.StoreTraces` belong in the Default configuration, not a start script. Empty agent references / missing model version (mendixlabs/mxcli#1867) and unset runtime constants are not checked: they need a captured agent document (option 2). Fixture `tests/wave2/test-status-extension-modules.sh` — field report from an Agent Editor project, Nov 2026 - fix(permissions): **exec approval `auto` no longer prompts on every exec's mode check, and `install-claude-hooks.sh` no longer runs unprompted (#782)**: `install-claude-permissions.sh` now allow-lists `exec-approval.sh`, `interview-mode.sh` and `permission-profile.sh`, so their reads run without a prompt, while their only writers, `--set` and `--clear`, prompt through six `ask` rules (`Bash(*exec-approval.sh*--set*)`, …) in the shared settings under every profile (an ask rule beats an allow rule, `full`'s bare `Bash` included). `install-claude-hooks.sh`, which writes `~/.claude/settings.json` for every repo on the machine, gets no allow rule. A re-install adds the ask rules and removes the hooks-installer rule an earlier install added (sidecar); entries someone else wrote are untouched, and `sync-project.sh`'s permission check names both until then. Field run on claude 2.1.325: the read ran, `--set auto` and `--clear` were refused, and with the ask rules removed `--set` ran — from the two independent reviews of #781 diff --git a/bin/gate-check.sh b/bin/gate-check.sh index 17d954ee..c6179729 100755 --- a/bin/gate-check.sh +++ b/bin/gate-check.sh @@ -3768,6 +3768,7 @@ if [ -z "$REQUESTED_STAGE" ] && [ -z "$GC_APP" ] && [ -r "$TOOLKIT_DIR/bin/lib/a printf 'Apps: %s (one register, %s; per-app evidence below; --app scopes a run to one)\n' \ "$(printf '%s\n' "$_gc_al" | grep -c .)" "$(basename "${REGISTER:-PROJECT.md}")" printf '%s\n' "$_gc_al" | while IFS=' ' read -r _a _l; do printf ' [%s] %s\n' "$_a" "$_l"; done + mxtk_app_register_notes "$PROJECT_DIR" "$TOOLKIT_DIR" | while IFS=' ' read -r _a _l; do printf ' ⚠ [%s] %s\n' "$_a" "$_l"; done fi fi diff --git a/bin/lib/app-scope.sh b/bin/lib/app-scope.sh index caa41850..9c55a650 100644 --- a/bin/lib/app-scope.sh +++ b/bin/lib/app-scope.sh @@ -162,3 +162,38 @@ mxtk_wiring_rows() { "\`apps//.mpr\` — $n apps: $names | One model per app. Select with \`MXTK_APP=\` (any bin/ script) or \`--app \` (gate-check, look-ledger); with none, gate-check and status report per app. Index: \`architecture/apps/README.md\`" \ "\`apps//mdlsource/\` | Numbered build scripts, per app" } + +# mxtk_app_register_notes — one line per app whose OWN PROJECT.md +# (apps//PROJECT.md, e.g. from `mxcli init` run per app) holds register lines: an Entry mode, +# a "## Current stage" **Stage line, an "Adopted at stage:" line, or CONFIRMED / ASSUMED table +# rows. The register is the ROOT PROJECT.md (gate-check never reads an app's); a second register +# per app is where decisions go to be lost. Warn-only, never a verdict. An app PROJECT.md with +# none of those lines (a plain mxcli template) says nothing. Field run (six apps): seven +# PROJECT.md files, one per app plus the root. +mxtk_app_register_notes() { + local pd="$1" tk="$2" apps a m f em rem found nd + apps="$(mxtk_scope_apps "$pd" "$tk")" + [ "$(printf '%s' "$apps" | grep -c . || true)" -ge 2 ] || return 0 + _mxtk_em() { awk '{ l = tolower($0); gsub(/[*_>]/, "", l); sub(/^[ \t-]+/, "", l) + if (l ~ /^entry mode[ \t]*:/) { sub(/^entry mode[ \t]*:[ \t]*/, "", l); split(l, w, /[ \t(,;]+/); print w[1]; exit } }' "$1" 2>/dev/null; } + rem="$(_mxtk_em "$pd/PROJECT.md")" + while IFS=' ' read -r a m; do + f="$pd/apps/$a/PROJECT.md" + [ -n "$a" ] && [ -f "$f" ] || continue + found="" + em="$(_mxtk_em "$f")" + if [ -n "$em" ]; then + if [ -n "$rem" ] && [ "$em" != "$rem" ]; then found="Entry mode: $em, the root says $rem" + elif [ -z "$rem" ]; then found="Entry mode: $em, the root has none" + else found="Entry mode"; fi + fi + awk '/^## Current stage/{f=1;next} f && /^\*\*Stage/{ok=1; exit} END{exit !ok}' "$f" 2>/dev/null && found="${found:+$found; }Current stage" + grep -qiE '^Adopted at stage:' "$f" 2>/dev/null && found="${found:+$found; }Adopted at stage" + nd="$(grep -cE '^\|.*\|[[:space:]]*\**(CONFIRMED|ASSUMED)' "$f" 2>/dev/null || true)" + [ "${nd:-0}" -gt 0 ] && found="${found:+$found; }$nd decision row(s)" + [ -n "$found" ] && printf '%s\tapps/%s/PROJECT.md holds register lines (%s): the register is the root PROJECT.md, which gate-check reads; move them there and leave the app file a pointer\n' "$a" "$a" "$found" + done <' "$PROJECT_DIR/CLAUDE.local.md"; then echo "Note: CLAUDE.local.md's Wiring block predates multi-app support — replace its Project MPR and" diff --git a/skills/module-folder-convention.md b/skills/module-folder-convention.md index 5ff4f621..a567f10b 100644 --- a/skills/module-folder-convention.md +++ b/skills/module-folder-convention.md @@ -194,7 +194,9 @@ register (`PROJECT.md`), one root `intake.md` for answers shared by every app, a `apps//` — that folder is the Mendix project Studio Pro commits and mxbuild packages. Module briefs stay `architecture/modules//module-brief.md` with an `**App:** ` line, because every brief reader looks there. `init-project.sh` / `sync-project.sh` scaffold this and the index -`architecture/apps/README.md`; select one app with `MXTK_APP=` or `--app `. +`architecture/apps/README.md`; select one app with `MXTK_APP=` or `--app `. An app's +own `PROJECT.md` (from `mxcli init` per app) is not a register: write decisions to the root one; +gate-check and status warn when an app's file holds register lines. Done when every app in `architecture/apps/README.md` has an intake and a build-plan section. Failure it prevents (field run, 2026-11): four apps, no per-app intake, one free-form brief diff --git a/tests/wave2/fixtures/multi-app/PROVENANCE.txt b/tests/wave2/fixtures/multi-app/PROVENANCE.txt index bb544cd2..30dd6714 100644 --- a/tests/wave2/fixtures/multi-app/PROVENANCE.txt +++ b/tests/wave2/fixtures/multi-app/PROVENANCE.txt @@ -1,16 +1,20 @@ tests/wave2/fixtures/multi-app/ — provenance -tree.txt is the SHAPE of a multi-app repository as two field runs (2026-11) reported it: several -Mendix apps side by side under apps//, each a full Mendix project folder (its own .mpr, -mprcontents/, javasource/, themesource/, widgets/) with its own mdlsource/ of numbered MDL page -scripts, and one project root above them (PROJECT.md, .claude/, architecture/). App names are -neutral stand-ins; file names inside each app folder follow a Mendix 11 project folder. +tree.txt is the structural shape of a real multi-app repository (a field run, six apps, Nov 2026), +from its `git ls-files`: file counts at depth <= 4 under apps/ and <= 2 elsewhere, app names +anonymised to AppA..AppF, every line naming the project dropped. Kept here, one line per entry: -NOT a verbatim `ls -R` capture: none of the field repositories could be copied here, and the -readers under test (project-bin/_common.sh mxtk_apps, bin/lib/app-scope.sh) glob directory names, -they parse no tool output. Replace tree.txt with a capture from a real multi-app repository -(`cd && find . -path ./.git -prune -o -print | sort`, client names replaced) when one is -available; the fixture reads it as-is. + - every top-level entry of the root (files as files, folders as "/"), and architecture/ + holding fit-gap.md only — as captured; + - per app, the captured shape: .mpr, its OWN PROJECT.md and CLAUDE.md (mxcli init per + app — the field repo held seven PROJECT.md files), AGENTS.md, FINDINGS.md, .gitignore, and + the folders .claude/ (4 files), .ai-context/, .devcontainer/ (2), .playwright/, docs/, + mprcontents/, tests/ (7), vendorlib/ (32), widgets/ (33) — each folder as one "/" + line, since no reader under test looks inside them; + - mdlsource/ with the captured script COUNT per app (69 / 34 / 28 / 26 / 27 / 27). The script + NAMES are not captured (they name the project); they are generated, NNN-step.mdl. -Tool output used by test-multi-app-scope.sh is captured, never hand-written: SHOW MODULES replays +The readers under test (project-bin/_common.sh mxtk_apps, bin/lib/app-scope.sh) glob directory +names and count *.mdl files; they parse no tool output. Tool output used by +test-multi-app-scope.sh is captured, never hand-written: SHOW MODULES replays tests/wave2/fixtures/show-modules/*.out (see that folder's CAPTURE.txt). diff --git a/tests/wave2/fixtures/multi-app/tree.txt b/tests/wave2/fixtures/multi-app/tree.txt index c1b665cb..4c133c16 100644 --- a/tests/wave2/fixtures/multi-app/tree.txt +++ b/tests/wave2/fixtures/multi-app/tree.txt @@ -1,26 +1,348 @@ +./.ai-context/ +./.claude/ +./.continue/ +./.cursorrules +./.github/ +./.gitignore +./.gitleaks.toml +./.mxtk-backup/ +./.playwright/ +./.spectral.yaml +./.vscode/ +./.windsurfrules +./AGENTS.md +./BRIEF.md +./CLAUDE.local.md +./CLAUDE.md +./CODEOWNERS +./Makefile ./PROJECT.md +./README.md +./TOOLKIT_COMMIT +./analysis/ +./answers.md +./apps/AppA/.ai-context/ +./apps/AppA/.claude/ +./apps/AppA/.devcontainer/ +./apps/AppA/.gitignore +./apps/AppA/.playwright/ +./apps/AppA/AGENTS.md +./apps/AppA/AppA.mpr +./apps/AppA/CLAUDE.md +./apps/AppA/FINDINGS.md +./apps/AppA/PROJECT.md +./apps/AppA/docs/ +./apps/AppA/mdlsource/010-step.mdl +./apps/AppA/mdlsource/020-step.mdl +./apps/AppA/mdlsource/030-step.mdl +./apps/AppA/mdlsource/040-step.mdl +./apps/AppA/mdlsource/050-step.mdl +./apps/AppA/mdlsource/060-step.mdl +./apps/AppA/mdlsource/070-step.mdl +./apps/AppA/mdlsource/080-step.mdl +./apps/AppA/mdlsource/090-step.mdl +./apps/AppA/mdlsource/100-step.mdl +./apps/AppA/mdlsource/110-step.mdl +./apps/AppA/mdlsource/120-step.mdl +./apps/AppA/mdlsource/130-step.mdl +./apps/AppA/mdlsource/140-step.mdl +./apps/AppA/mdlsource/150-step.mdl +./apps/AppA/mdlsource/160-step.mdl +./apps/AppA/mdlsource/170-step.mdl +./apps/AppA/mdlsource/180-step.mdl +./apps/AppA/mdlsource/190-step.mdl +./apps/AppA/mdlsource/200-step.mdl +./apps/AppA/mdlsource/210-step.mdl +./apps/AppA/mdlsource/220-step.mdl +./apps/AppA/mdlsource/230-step.mdl +./apps/AppA/mdlsource/240-step.mdl +./apps/AppA/mdlsource/250-step.mdl +./apps/AppA/mdlsource/260-step.mdl +./apps/AppA/mdlsource/270-step.mdl +./apps/AppA/mdlsource/280-step.mdl +./apps/AppA/mdlsource/290-step.mdl +./apps/AppA/mdlsource/300-step.mdl +./apps/AppA/mdlsource/310-step.mdl +./apps/AppA/mdlsource/320-step.mdl +./apps/AppA/mdlsource/330-step.mdl +./apps/AppA/mdlsource/340-step.mdl +./apps/AppA/mdlsource/350-step.mdl +./apps/AppA/mdlsource/360-step.mdl +./apps/AppA/mdlsource/370-step.mdl +./apps/AppA/mdlsource/380-step.mdl +./apps/AppA/mdlsource/390-step.mdl +./apps/AppA/mdlsource/400-step.mdl +./apps/AppA/mdlsource/410-step.mdl +./apps/AppA/mdlsource/420-step.mdl +./apps/AppA/mdlsource/430-step.mdl +./apps/AppA/mdlsource/440-step.mdl +./apps/AppA/mdlsource/450-step.mdl +./apps/AppA/mdlsource/460-step.mdl +./apps/AppA/mdlsource/470-step.mdl +./apps/AppA/mdlsource/480-step.mdl +./apps/AppA/mdlsource/490-step.mdl +./apps/AppA/mdlsource/500-step.mdl +./apps/AppA/mdlsource/510-step.mdl +./apps/AppA/mdlsource/520-step.mdl +./apps/AppA/mdlsource/530-step.mdl +./apps/AppA/mdlsource/540-step.mdl +./apps/AppA/mdlsource/550-step.mdl +./apps/AppA/mdlsource/560-step.mdl +./apps/AppA/mdlsource/570-step.mdl +./apps/AppA/mdlsource/580-step.mdl +./apps/AppA/mdlsource/590-step.mdl +./apps/AppA/mdlsource/600-step.mdl +./apps/AppA/mdlsource/610-step.mdl +./apps/AppA/mdlsource/620-step.mdl +./apps/AppA/mdlsource/630-step.mdl +./apps/AppA/mdlsource/640-step.mdl +./apps/AppA/mdlsource/650-step.mdl +./apps/AppA/mdlsource/660-step.mdl +./apps/AppA/mdlsource/670-step.mdl +./apps/AppA/mdlsource/680-step.mdl +./apps/AppA/mdlsource/690-step.mdl +./apps/AppA/mprcontents/ +./apps/AppA/tests/ +./apps/AppA/vendorlib/ +./apps/AppA/widgets/ +./apps/AppB/.ai-context/ +./apps/AppB/.claude/ +./apps/AppB/.devcontainer/ +./apps/AppB/.gitignore +./apps/AppB/.playwright/ +./apps/AppB/AGENTS.md +./apps/AppB/AppB.mpr +./apps/AppB/CLAUDE.md +./apps/AppB/FINDINGS.md +./apps/AppB/PROJECT.md +./apps/AppB/docs/ +./apps/AppB/mdlsource/010-step.mdl +./apps/AppB/mdlsource/020-step.mdl +./apps/AppB/mdlsource/030-step.mdl +./apps/AppB/mdlsource/040-step.mdl +./apps/AppB/mdlsource/050-step.mdl +./apps/AppB/mdlsource/060-step.mdl +./apps/AppB/mdlsource/070-step.mdl +./apps/AppB/mdlsource/080-step.mdl +./apps/AppB/mdlsource/090-step.mdl +./apps/AppB/mdlsource/100-step.mdl +./apps/AppB/mdlsource/110-step.mdl +./apps/AppB/mdlsource/120-step.mdl +./apps/AppB/mdlsource/130-step.mdl +./apps/AppB/mdlsource/140-step.mdl +./apps/AppB/mdlsource/150-step.mdl +./apps/AppB/mdlsource/160-step.mdl +./apps/AppB/mdlsource/170-step.mdl +./apps/AppB/mdlsource/180-step.mdl +./apps/AppB/mdlsource/190-step.mdl +./apps/AppB/mdlsource/200-step.mdl +./apps/AppB/mdlsource/210-step.mdl +./apps/AppB/mdlsource/220-step.mdl +./apps/AppB/mdlsource/230-step.mdl +./apps/AppB/mdlsource/240-step.mdl +./apps/AppB/mdlsource/250-step.mdl +./apps/AppB/mdlsource/260-step.mdl +./apps/AppB/mdlsource/270-step.mdl +./apps/AppB/mdlsource/280-step.mdl +./apps/AppB/mdlsource/290-step.mdl +./apps/AppB/mdlsource/300-step.mdl +./apps/AppB/mdlsource/310-step.mdl +./apps/AppB/mdlsource/320-step.mdl +./apps/AppB/mdlsource/330-step.mdl +./apps/AppB/mdlsource/340-step.mdl +./apps/AppB/mprcontents/ +./apps/AppB/tests/ +./apps/AppB/vendorlib/ +./apps/AppB/widgets/ +./apps/AppC/.ai-context/ +./apps/AppC/.claude/ +./apps/AppC/.devcontainer/ +./apps/AppC/.gitignore +./apps/AppC/.playwright/ +./apps/AppC/AGENTS.md +./apps/AppC/AppC.mpr +./apps/AppC/CLAUDE.md +./apps/AppC/FINDINGS.md +./apps/AppC/PROJECT.md +./apps/AppC/docs/ +./apps/AppC/mdlsource/010-step.mdl +./apps/AppC/mdlsource/020-step.mdl +./apps/AppC/mdlsource/030-step.mdl +./apps/AppC/mdlsource/040-step.mdl +./apps/AppC/mdlsource/050-step.mdl +./apps/AppC/mdlsource/060-step.mdl +./apps/AppC/mdlsource/070-step.mdl +./apps/AppC/mdlsource/080-step.mdl +./apps/AppC/mdlsource/090-step.mdl +./apps/AppC/mdlsource/100-step.mdl +./apps/AppC/mdlsource/110-step.mdl +./apps/AppC/mdlsource/120-step.mdl +./apps/AppC/mdlsource/130-step.mdl +./apps/AppC/mdlsource/140-step.mdl +./apps/AppC/mdlsource/150-step.mdl +./apps/AppC/mdlsource/160-step.mdl +./apps/AppC/mdlsource/170-step.mdl +./apps/AppC/mdlsource/180-step.mdl +./apps/AppC/mdlsource/190-step.mdl +./apps/AppC/mdlsource/200-step.mdl +./apps/AppC/mdlsource/210-step.mdl +./apps/AppC/mdlsource/220-step.mdl +./apps/AppC/mdlsource/230-step.mdl +./apps/AppC/mdlsource/240-step.mdl +./apps/AppC/mdlsource/250-step.mdl +./apps/AppC/mdlsource/260-step.mdl +./apps/AppC/mdlsource/270-step.mdl +./apps/AppC/mdlsource/280-step.mdl +./apps/AppC/mprcontents/ +./apps/AppC/tests/ +./apps/AppC/vendorlib/ +./apps/AppC/widgets/ +./apps/AppD/.ai-context/ +./apps/AppD/.claude/ +./apps/AppD/.devcontainer/ +./apps/AppD/.gitignore +./apps/AppD/.playwright/ +./apps/AppD/AGENTS.md +./apps/AppD/AppD.mpr +./apps/AppD/CLAUDE.md +./apps/AppD/FINDINGS.md +./apps/AppD/PROJECT.md +./apps/AppD/docs/ +./apps/AppD/mdlsource/010-step.mdl +./apps/AppD/mdlsource/020-step.mdl +./apps/AppD/mdlsource/030-step.mdl +./apps/AppD/mdlsource/040-step.mdl +./apps/AppD/mdlsource/050-step.mdl +./apps/AppD/mdlsource/060-step.mdl +./apps/AppD/mdlsource/070-step.mdl +./apps/AppD/mdlsource/080-step.mdl +./apps/AppD/mdlsource/090-step.mdl +./apps/AppD/mdlsource/100-step.mdl +./apps/AppD/mdlsource/110-step.mdl +./apps/AppD/mdlsource/120-step.mdl +./apps/AppD/mdlsource/130-step.mdl +./apps/AppD/mdlsource/140-step.mdl +./apps/AppD/mdlsource/150-step.mdl +./apps/AppD/mdlsource/160-step.mdl +./apps/AppD/mdlsource/170-step.mdl +./apps/AppD/mdlsource/180-step.mdl +./apps/AppD/mdlsource/190-step.mdl +./apps/AppD/mdlsource/200-step.mdl +./apps/AppD/mdlsource/210-step.mdl +./apps/AppD/mdlsource/220-step.mdl +./apps/AppD/mdlsource/230-step.mdl +./apps/AppD/mdlsource/240-step.mdl +./apps/AppD/mdlsource/250-step.mdl +./apps/AppD/mdlsource/260-step.mdl +./apps/AppD/mprcontents/ +./apps/AppD/tests/ +./apps/AppD/vendorlib/ +./apps/AppD/widgets/ +./apps/AppE/.ai-context/ +./apps/AppE/.claude/ +./apps/AppE/.devcontainer/ +./apps/AppE/.gitignore +./apps/AppE/.playwright/ +./apps/AppE/AGENTS.md +./apps/AppE/AppE.mpr +./apps/AppE/CLAUDE.md +./apps/AppE/FINDINGS.md +./apps/AppE/PROJECT.md +./apps/AppE/docs/ +./apps/AppE/mdlsource/010-step.mdl +./apps/AppE/mdlsource/020-step.mdl +./apps/AppE/mdlsource/030-step.mdl +./apps/AppE/mdlsource/040-step.mdl +./apps/AppE/mdlsource/050-step.mdl +./apps/AppE/mdlsource/060-step.mdl +./apps/AppE/mdlsource/070-step.mdl +./apps/AppE/mdlsource/080-step.mdl +./apps/AppE/mdlsource/090-step.mdl +./apps/AppE/mdlsource/100-step.mdl +./apps/AppE/mdlsource/110-step.mdl +./apps/AppE/mdlsource/120-step.mdl +./apps/AppE/mdlsource/130-step.mdl +./apps/AppE/mdlsource/140-step.mdl +./apps/AppE/mdlsource/150-step.mdl +./apps/AppE/mdlsource/160-step.mdl +./apps/AppE/mdlsource/170-step.mdl +./apps/AppE/mdlsource/180-step.mdl +./apps/AppE/mdlsource/190-step.mdl +./apps/AppE/mdlsource/200-step.mdl +./apps/AppE/mdlsource/210-step.mdl +./apps/AppE/mdlsource/220-step.mdl +./apps/AppE/mdlsource/230-step.mdl +./apps/AppE/mdlsource/240-step.mdl +./apps/AppE/mdlsource/250-step.mdl +./apps/AppE/mdlsource/260-step.mdl +./apps/AppE/mdlsource/270-step.mdl +./apps/AppE/mprcontents/ +./apps/AppE/tests/ +./apps/AppE/vendorlib/ +./apps/AppE/widgets/ +./apps/AppF/.ai-context/ +./apps/AppF/.claude/ +./apps/AppF/.devcontainer/ +./apps/AppF/.gitignore +./apps/AppF/.playwright/ +./apps/AppF/AGENTS.md +./apps/AppF/AppF.mpr +./apps/AppF/CLAUDE.md +./apps/AppF/FINDINGS.md +./apps/AppF/PROJECT.md +./apps/AppF/docs/ +./apps/AppF/mdlsource/010-step.mdl +./apps/AppF/mdlsource/020-step.mdl +./apps/AppF/mdlsource/030-step.mdl +./apps/AppF/mdlsource/040-step.mdl +./apps/AppF/mdlsource/050-step.mdl +./apps/AppF/mdlsource/060-step.mdl +./apps/AppF/mdlsource/070-step.mdl +./apps/AppF/mdlsource/080-step.mdl +./apps/AppF/mdlsource/090-step.mdl +./apps/AppF/mdlsource/100-step.mdl +./apps/AppF/mdlsource/110-step.mdl +./apps/AppF/mdlsource/120-step.mdl +./apps/AppF/mdlsource/130-step.mdl +./apps/AppF/mdlsource/140-step.mdl +./apps/AppF/mdlsource/150-step.mdl +./apps/AppF/mdlsource/160-step.mdl +./apps/AppF/mdlsource/170-step.mdl +./apps/AppF/mdlsource/180-step.mdl +./apps/AppF/mdlsource/190-step.mdl +./apps/AppF/mdlsource/200-step.mdl +./apps/AppF/mdlsource/210-step.mdl +./apps/AppF/mdlsource/220-step.mdl +./apps/AppF/mdlsource/230-step.mdl +./apps/AppF/mdlsource/240-step.mdl +./apps/AppF/mdlsource/250-step.mdl +./apps/AppF/mdlsource/260-step.mdl +./apps/AppF/mdlsource/270-step.mdl +./apps/AppF/mprcontents/ +./apps/AppF/tests/ +./apps/AppF/vendorlib/ +./apps/AppF/widgets/ +./architecture/fit-gap.md +./asyncapi/ +./bench-target.json +./bin/ +./budget.md +./contracts/ +./data/ +./design-system/ +./docs/ +./index.html +./infra/ ./intake.md -./.claude/ -./architecture/ -./apps/Orders/Orders.mpr -./apps/Orders/mprcontents/0a/3f/0a3f6c1e-7d2b-4c55-9a10-2f4e8b9d1c01.mxunit -./apps/Orders/mprcontents/5e/91/5e91b2a4-0c3d-4f6e-8a7b-1d2c3e4f5a6b.mxunit -./apps/Orders/javasource/orders/proxies/ -./apps/Orders/themesource/orders/web/main.scss -./apps/Orders/widgets/ -./apps/Orders/mdlsource/010-orders-domain.mdl -./apps/Orders/mdlsource/030-orders-pages.mdl -./apps/Billing/Billing.mpr -./apps/Billing/mprcontents/7c/02/7c02d9e1-3a4b-4c5d-8e6f-7a8b9c0d1e2f.mxunit -./apps/Billing/javasource/billing/proxies/ -./apps/Billing/themesource/billing/web/main.scss -./apps/Billing/widgets/ -./apps/Billing/mdlsource/010-billing-domain.mdl -./apps/Billing/mdlsource/030-billing-pages.mdl -./apps/Billing/mdlsource/done-020-billing-flows.mdl -./apps/Portal/Portal.mpr -./apps/Portal/mprcontents/1d/e4/1de4f0a2-5b6c-4d7e-9f80-a1b2c3d4e5f6.mxunit -./apps/Portal/javasource/portal/proxies/ -./apps/Portal/themesource/portal/web/main.scss -./apps/Portal/widgets/ -./apps/Portal/mdlsource/ +./journeys/ +./mdlsource/010-step.mdl +./openapi/ +./prototypes/ +./questions.md +./scripts/ +./setup.sh +./spec/ +./standards/ +./status.md +./system.tsv +./triage.md diff --git a/tests/wave2/test-multi-app-scope.sh b/tests/wave2/test-multi-app-scope.sh index d9bdc006..bbda3fc7 100755 --- a/tests/wave2/test-multi-app-scope.sh +++ b/tests/wave2/test-multi-app-scope.sh @@ -15,11 +15,11 @@ # cwd auto-pick, a user's MPR_FILE beats MXTK_APP; find_mpr still refuses, naming MXTK_APP # A2 single tree and two-tree: mxtk_apps prints nothing (rc 1) and mxtk_app_count is 0, even # with an apps/ folder holding a model beside the root model -# A3 gate-check, no app chosen: "Marketplace installs: per app (3 apps", one [App] line each, +# A3 gate-check, no app chosen: "Marketplace installs: per app (6 apps", one [App] line each, # no "nothing checked"; per-app fit-gap missing package -> FAIL for that app only; shared # fit-gap missing package -> PENDING (owner unknown); build-ready counts the FAIL; with -# every app on the shared fit-gap, the one finding prints once ("all 3 apps") -# A4 gate-check --app orders: one Marketplace line, Orders' fit-gap; no Apps section; +# every app on the shared fit-gap, the one finding prints once ("all 6 apps") +# A4 gate-check --app appa: one Marketplace line, AppA' fit-gap; no Apps section; # --app Nope exits 2 naming the apps; --app on a single-tree project exits 2 # A5 gate-check "Apps:" section and status.sh: one line per app, scripts per app's mdlsource, # LOOK owed per app, and "no ledger here (N pages ...)" before any ledger exists — never @@ -28,6 +28,8 @@ # single tree; status --app keeps two apps' same-named page apart # A7 init-project scaffolds architecture/apps//intake.md + triage.md + the index and the # multi-app Wiring rows; sync-project re-run creates nothing and overwrites nothing +# A8 an app's own PROJECT.md (mxcli init per app; the field repo had seven) holding register +# lines is warned in gate-check's Apps section and status WATCH; a plain one is silent set -u COMMON="${1:?usage: $0 project-bin/_common.sh}" @@ -50,9 +52,9 @@ while IFS= read -r l; do l="${l#./}"; [ -n "$l" ] || continue case "$l" in */) mkdir -p "$P/$l" ;; *) mkdir -p "$P/$(dirname "$l")"; : > "$P/$l" ;; esac done < "$FX/multi-app/tree.txt" -# Page scripts: Orders and Billing both build Administration.Account_Overview (A6). -printf 'create page Orders.Order_Overview (\n);\ncreate page Administration.Account_Overview (\n);\n' > "$P/apps/Orders/mdlsource/030-orders-pages.mdl" -printf 'create or replace page Billing.Invoice_Overview (\n);\ncreate page Administration.Account_Overview (\n);\n' > "$P/apps/Billing/mdlsource/030-billing-pages.mdl" +# Page scripts: AppA and AppB both build Administration.Account_Overview (A6). +printf 'create page AppA.Order_Overview (\n);\ncreate page Administration.Account_Overview (\n);\n' > "$P/apps/AppA/mdlsource/030-step.mdl" +printf 'create or replace page AppB.Invoice_Overview (\n);\ncreate page Administration.Account_Overview (\n);\n' > "$P/apps/AppB/mdlsource/030-step.mdl" printf '# Project\n\n## Current stage\n**Stage 5 — build**\n' > "$P/PROJECT.md" # stub mxcli: replays a captured SHOW MODULES per app (-p ) @@ -61,7 +63,7 @@ cat > "$STUB" <&1)" -has "A1 unknown refused" "$r" "rc=1"; has "A1 unknown lists apps" "$r" "Portal (apps/Portal/Portal.mpr)" -r="$(clean_env bash -c "cd '$P'; . '$COMMON'; mxtk_app_of '$P/apps/Orders/mdlsource/x.mdl'; mxtk_app_of docs/x || echo none")" -eq "A1 app_of" "$r" "Orders +has "A1 unknown refused" "$r" "rc=1"; has "A1 unknown lists apps" "$r" "AppC (apps/AppC/AppC.mpr)" +r="$(clean_env bash -c "cd '$P'; . '$COMMON'; mxtk_app_of '$P/apps/AppA/mdlsource/x.mdl'; mxtk_app_of docs/x || echo none")" +eq "A1 app_of" "$r" "AppA none" -r="$(clean_env MXTK_APP=Orders bash -c "cd '$P/apps/Billing'; . '$COMMON'; find_mpr")" -eq "A1 MXTK_APP beats cwd pick" "$r" "$P/apps/Orders/Orders.mpr" -r="$(clean_env MXTK_APP=Orders MPR_FILE=apps/Portal/Portal.mpr bash -c "cd '$P'; . '$COMMON'; find_mpr")" -eq "A1 user MPR_FILE beats MXTK_APP" "$r" "$P/apps/Portal/Portal.mpr" +r="$(clean_env MXTK_APP=AppA bash -c "cd '$P/apps/AppB'; . '$COMMON'; find_mpr")" +eq "A1 MXTK_APP beats cwd pick" "$r" "$P/apps/AppA/AppA.mpr" +r="$(clean_env MXTK_APP=AppA MPR_FILE=apps/AppC/AppC.mpr bash -c "cd '$P'; . '$COMMON'; find_mpr")" +eq "A1 user MPR_FILE beats MXTK_APP" "$r" "$P/apps/AppC/AppC.mpr" r="$(clean_env bash -c "cd '$P'; . '$COMMON'; find_mpr" 2>&1)" has "A1 find_mpr refuses" "$r" "refusing to guess"; has "A1 refusal names MXTK_APP" "$r" "MXTK_APP=" @@ -97,52 +100,52 @@ for d in "$S1" "$S2"; do done echo "A3 gate-check per-app Marketplace (no app chosen)" -mkdir -p "$P/architecture/apps/Orders" "$P/architecture/apps/Billing" -printf '| Capability | Mendix approach | Verdict |\n|---|---|---|\n| Module | `MyFirstModule` | Buy |\n' > "$P/architecture/apps/Orders/fit-gap.md" -printf '| Capability | Mendix approach | Verdict |\n|---|---|---|\n| Grid | `DataWidgets` | Buy |\n' > "$P/architecture/apps/Billing/fit-gap.md" +mkdir -p "$P/architecture/apps/AppA" "$P/architecture/apps/AppB" +printf '| Capability | Mendix approach | Verdict |\n|---|---|---|\n| Module | `MyFirstModule` | Buy |\n' > "$P/architecture/apps/AppA/fit-gap.md" +printf '| Capability | Mendix approach | Verdict |\n|---|---|---|\n| Grid | `DataWidgets` | Buy |\n' > "$P/architecture/apps/AppB/fit-gap.md" printf '| Capability | Mendix approach | Verdict |\n|---|---|---|\n| Grid | `DataWidgets` | Buy |\n' > "$P/architecture/fit-gap.md" gc() { clean_env MXCLI="$STUB" MXTK_NO_FETCH=1 MXTK_GATE_CACHE_TTL_MIN=0 bash "$TK/bin/gate-check.sh" --no-html "$@" 2>&1; } out="$(gc "$P")" -has "A3 header" "$out" "Marketplace installs: per app (3 apps" -has "A3 Orders installed" "$out" " [Orders] PASS — 1 of 1 confirmed Buy installed" -has "A3 Billing own fit-gap FAIL" "$out" " [Billing] FAIL — 0 of 1 confirmed Buy installed; NOT INSTALLED: DataWidgets" -has "A3 Portal shared fit-gap PENDING" "$out" " [Portal] PENDING — the shared architecture/fit-gap.md does not say which app owes this Buy" +has "A3 header" "$out" "Marketplace installs: per app (6 apps" +has "A3 AppA installed" "$out" " [AppA] PASS — 1 of 1 confirmed Buy installed" +has "A3 AppB own fit-gap FAIL" "$out" " [AppB] FAIL — 0 of 1 confirmed Buy installed; NOT INSTALLED: DataWidgets" +has "A3 shared fit-gap PENDING, grouped" "$out" " [AppC, AppD, AppE, AppF, from the shared architecture/fit-gap.md] PENDING — the shared architecture/fit-gap.md does not say which app owes this Buy" hasnt "A3 no nothing-checked" "$out" "nothing checked" br="$(gc "$P" build-ready)" -has "A3 build-ready counts the FAIL" "$br" "✗ Marketplace: Billing: FAIL; Orders: PASS; Portal: PENDING" +has "A3 build-ready counts the FAIL" "$br" "✗ Marketplace: AppA: PASS; AppB: FAIL; AppC: PENDING; AppD: PENDING" # every app on the shared fit-gap: one finding, printed once (a field run, six apps, printed it six times) mv "$P/architecture/apps" "$T/apps-fitgaps" out="$(gc "$P")" -has "A3 shared finding printed once" "$out" " [all 3 apps, from the shared architecture/fit-gap.md] PENDING" -eq "A3 no per-app repeat" "$(printf '%s\n' "$out" | grep -c '^ \[Orders\] PENDING')" "0" +has "A3 shared finding printed once" "$out" " [all 6 apps, from the shared architecture/fit-gap.md] PENDING" +eq "A3 no per-app repeat" "$(printf '%s\n' "$out" | grep -c '^ \[AppA\] PENDING')" "0" mv "$T/apps-fitgaps" "$P/architecture/apps" echo "A4 gate-check --app" -out="$(gc --app orders "$P")" -has "A4 one line, Orders' fit-gap" "$out" "Marketplace installs: PASS — 1 of 1 confirmed Buy installed" +out="$(gc --app appa "$P")" +has "A4 one line, AppA' fit-gap" "$out" "Marketplace installs: PASS — 1 of 1 confirmed Buy installed" hasnt "A4 no per-app header" "$out" "per app (" -hasnt "A4 no Apps section" "$out" "Apps: 3" +hasnt "A4 no Apps section" "$out" "Apps: 6" out="$(gc --app Nope "$P")"; rc=$? -eq "A4 unknown app exits 2" "$rc" "2"; has "A4 names the apps" "$out" "Orders (apps/Orders/Orders.mpr)" -out="$(gc --app Orders "$S1")"; rc=$? +eq "A4 unknown app exits 2" "$rc" "2"; has "A4 names the apps" "$out" "AppA (apps/AppA/AppA.mpr)" +out="$(gc --app AppA "$S1")"; rc=$? eq "A4 --app on single tree exits 2" "$rc" "2" echo "A5 Apps section and status lines" # no ledger yet (it is git-ignored: a fresh checkout has none) is never "no pages owed" st="$(clean_env bash "$TK/bin/status.sh" "$P" 2>&1)" -has "A5 no ledger is said" "$st" "APP Orders: apps/Orders/Orders.mpr · scripts 2 written / 0 done- · LOOK: no ledger here (2 page(s) in its scripts)" +has "A5 no ledger is said" "$st" "APP AppA: apps/AppA/AppA.mpr · scripts 69 written / 0 done- · LOOK: no ledger here (2 page(s) in its scripts)" hasnt "A5 no pass-by-absence" "$st" "no pages owed" -for a in Orders Billing; do - (cd "$P/apps/$a" && clean_env bash "$TK/project-bin/look-ledger.sh" owe "$P/apps/$a/mdlsource/030-$(echo "$a" | tr '[:upper:]' '[:lower:]')-pages.mdl" >/dev/null) +for a in AppA AppB; do + (cd "$P/apps/$a" && clean_env bash "$TK/project-bin/look-ledger.sh" owe "$P/apps/$a/mdlsource/030-step.mdl" >/dev/null) done out="$(gc "$P")" -has "A5 Apps header" "$out" "Apps: 3 (one register, PROJECT.md" -has "A5 Billing line" "$out" " [Billing] apps/Billing/Billing.mpr · scripts 3 written / 1 done- · LOOK: 2 of 2 page(s) owed" -has "A5 Portal line" "$out" " [Portal] apps/Portal/Portal.mpr · scripts 0 written / 0 done- · LOOK: no page in its scripts" +has "A5 Apps header" "$out" "Apps: 6 (one register, PROJECT.md" +has "A5 AppB line" "$out" " [AppB] apps/AppB/AppB.mpr · scripts 34 written / 0 done- · LOOK: 2 of 2 page(s) owed" +has "A5 AppC line" "$out" " [AppC] apps/AppC/AppC.mpr · scripts 28 written / 0 done- · LOOK: no page in its scripts" st="$(clean_env bash "$TK/bin/status.sh" "$P" 2>&1)" -has "A5 status Orders" "$st" "APP Orders: apps/Orders/Orders.mpr · scripts 2 written / 0 done- · LOOK: 2 of 2 page(s) owed" +has "A5 status AppA" "$st" "APP AppA: apps/AppA/AppA.mpr · scripts 69 written / 0 done- · LOOK: 2 of 2 page(s) owed" stb="$(clean_env bash "$TK/bin/status.sh" "$P" --brief 2>&1)" -has "A5 status --brief Portal" "$stb" "APP Portal: apps/Portal/Portal.mpr" +has "A5 status --brief AppC" "$stb" "APP AppC: apps/AppC/AppC.mpr" for d in "$S1" "$S2"; do out="$(gc "$d")"; st="$(clean_env bash "$TK/bin/status.sh" "$d" 2>&1)" hasnt "A5 $(basename "$d"): no Apps section" "$out" "Apps: " @@ -152,36 +155,45 @@ done echo "A6 look-ledger keyed by app" cols="$(awk -F'\t' '{print NF ":" $5}' "$P/.claude/loop/look/owed.tsv" | sort -u | tr '\n' ' ')" -eq "A6 multi-app rows carry the app" "$cols" "5:Billing 5:Orders " +eq "A6 multi-app rows carry the app" "$cols" "5:AppA 5:AppB " printf 'create page Single.Home (\n);\n' > "$S1/p.mdl" (cd "$S1" && clean_env bash "$TK/project-bin/look-ledger.sh" owe "$S1/p.mdl" >/dev/null) eq "A6 single tree keeps four columns" "$(awk -F'\t' '{print NF}' "$S1/.claude/loop/look/owed.tsv")" "4" -r="$(cd "$P" && clean_env PROJECT_ROOT="$P" bash "$TK/project-bin/look-ledger.sh" status --app Orders | cut -f1,2 | tr '\n' ' ')" -eq "A6 status --app Orders" "$r" "OWED Administration.Account_Overview OWED Orders.Order_Overview " -r="$(cd "$P" && clean_env PROJECT_ROOT="$P" MXTK_APP=Billing bash "$TK/project-bin/look-ledger.sh" status | cut -f2 | tr '\n' ' ')" -eq "A6 MXTK_APP scopes status" "$r" "Administration.Account_Overview Billing.Invoice_Overview " +r="$(cd "$P" && clean_env PROJECT_ROOT="$P" bash "$TK/project-bin/look-ledger.sh" status --app AppA | cut -f1,2 | tr '\n' ' ')" +eq "A6 status --app AppA" "$r" "OWED Administration.Account_Overview OWED AppA.Order_Overview " +r="$(cd "$P" && clean_env PROJECT_ROOT="$P" MXTK_APP=AppB bash "$TK/project-bin/look-ledger.sh" status | cut -f2 | tr '\n' ' ')" +eq "A6 MXTK_APP scopes status" "$r" "Administration.Account_Overview AppB.Invoice_Overview " echo "A7 init-project and sync-project scaffold per app" I="$T/init"; mkdir -p "$I" while IFS= read -r l; do - l="${l#./}"; case "$l" in ''|PROJECT.md|intake.md|.claude/|architecture/) continue ;; esac + l="${l#./}"; case "$l" in apps/*) ;; *) continue ;; esac # the apps only: init writes the root case "$l" in */) mkdir -p "$I/$l" ;; *) mkdir -p "$I/$(dirname "$l")"; : > "$I/$l" ;; esac done < "$FX/multi-app/tree.txt" (cd "$I" && git init -q .) out="$(clean_env MXTK_NO_GUIDE=1 MXTK_NO_FETCH=1 bash "$TK/bin/init-project.sh" "$I" 2>&1)" -for a in Orders Billing Portal; do +for a in AppA AppB AppC; do [ -f "$I/architecture/apps/$a/intake.md" ] && ok "A7 $a intake" || fail "A7 $a intake missing" [ -f "$I/architecture/apps/$a/triage.md" ] && ok "A7 $a triage" || fail "A7 $a triage missing" done -has "A7 index lists Portal" "$(cat "$I/architecture/apps/README.md" 2>/dev/null)" "| Portal | \`apps/Portal/Portal.mpr\` |" +has "A7 index lists AppC" "$(cat "$I/architecture/apps/README.md" 2>/dev/null)" "| AppC | \`apps/AppC/AppC.mpr\` |" has "A7 Wiring names MXTK_APP" "$(cat "$I/CLAUDE.local.md")" "Select with \`MXTK_APP=\`" -echo "own words" >> "$I/architecture/apps/Orders/intake.md" +echo "own words" >> "$I/architecture/apps/AppA/intake.md" out="$(clean_env MXTK_NO_FETCH=1 bash "$TK/bin/sync-project.sh" "$I" 2>&1)" hasnt "A7 sync creates nothing new" "$out" "Created: architecture/apps/" -has "A7 sync kept the edit" "$(tail -1 "$I/architecture/apps/Orders/intake.md")" "own words" -rm -f "$I/architecture/apps/Portal/intake.md" +has "A7 sync kept the edit" "$(tail -1 "$I/architecture/apps/AppA/intake.md")" "own words" +rm -f "$I/architecture/apps/AppC/intake.md" out="$(clean_env MXTK_NO_FETCH=1 bash "$TK/bin/sync-project.sh" "$I" 2>&1)" -has "A7 sync restores a missing app intake" "$out" "Created: architecture/apps/Portal/intake.md" +has "A7 sync restores a missing app intake" "$out" "Created: architecture/apps/AppC/intake.md" + +echo "A8 an app's own PROJECT.md is not a register" +printf '# AppA\n\nEntry mode: greenfield\n\n## Current stage\n**Stage 2 — x**\n\n| Stage | Decision | Status |\n|---|---|---|\n| 1 | x | CONFIRMED |\n' > "$P/apps/AppA/PROJECT.md" +printf '# AppB\n\nA plain template, no register lines.\n' > "$P/apps/AppB/PROJECT.md" +out="$(gc "$P")" +has "A8 register lines in AppA warned" "$out" "⚠ [AppA] apps/AppA/PROJECT.md holds register lines (Entry mode: greenfield, the root has none; Current stage; 1 decision row(s))" +hasnt "A8 plain AppB file is silent" "$out" "⚠ [AppB]" +st="$(clean_env bash "$TK/bin/status.sh" "$P" 2>&1)" +has "A8 status WATCH" "$st" "apps/AppA/PROJECT.md holds register lines" echo "" echo "multi-app scope: $PASS passed, $FAIL failed" From 40f8125d6c14ed88dcb815bc5b82da54173bc6bb Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:22:43 +0000 Subject: [PATCH 05/11] fix(multi-app): app folders with their own .claude/ resolve to the outer project; review fixes From the independent review of #789 (HOLD) and the maintainer's decision: - project-bin/_common.sh: refinement of #489. An apps// that is a project folder of its own (mxcli init: .claude/ + PROJECT.md) resolves to the OUTER project when that holds a register (## Current stage / ## Decisions / Entry mode), no root or app/ model, and the app folder holds a model. One register, one LOOK ledger, one set of gates. Any other nested project keeps its own root. No subshell on the walk's common path. - mxtk_apps: one line per app folder (.mpr preferred, '-' when ambiguous); select refuses an ambiguous folder; a case-only clash gets its own message. - gate-check: an env MXTK_APP that does not apply is dropped; only --app errors. - app-scope.sh: app list computed once (mxtk_scope_init / MXTK_SCOPE_*), one find + one awk + one look-ledger call (new 'status --by-app'), register notes in one awk; np local; no global helper defined inside a function. Status on six apps 1.41 s -> 1.03 s. - marketplace-check: '-' apps reported, no 'from the shared' label without a shared fit-gap. - fixture: outer-project walk, no ledger split, per-folder dedupe, env MXTK_APP on single tree, no-fit-gap label. Single-tree and two-tree gate-check, status and look-ledger status: byte-identical to master. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 1 + bin/gate-check.sh | 26 ++++-- bin/init-project.sh | 1 + bin/lib/app-scope.sh | 132 ++++++++++++++++++---------- bin/lib/marketplace-check.sh | 18 ++-- bin/status.sh | 1 + bin/sync-project.sh | 1 + project-bin/_common.sh | 83 ++++++++++++----- project-bin/look-ledger.sh | 30 ++++--- tests/wave2/test-multi-app-scope.sh | 42 +++++++-- 10 files changed, 235 insertions(+), 100 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f81ee2d6..52e4381b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that holds a register** (a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line, no model at its root or under `app/`) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap — from the independent review of #789 on a field run's six-app tree - new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. The root `PROJECT.md` is the one register: an app's own `PROJECT.md` (from `mxcli init` per app; the field repo held seven) that holds register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,155 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/` from a field repo's `git ls-files`, six apps, anonymised — see its PROVENANCE.txt) — two field runs, Nov 2026 - new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 - fix(status, agents): **`bin/status.sh` WATCHes an Agent Editor project whose extension module does not travel with the model (#778)**: Studio Pro reads `agenteditor.agent` from `modules/AgentEditor.mxmodule` beside the `.mpr`, and a sync of only `.mpr` + `mprcontents/` left it out of git, so the builder stayed green while every colleague's clone showed `unknown type 'agenteditor.agent'`. Two WATCH items, warn-only (exit code and every verdict unchanged), local files and `git ls-files` only, root and `app/` layouts: a `modules/*.mxmodule` git does not track, and a project using Agent Editor (`AgentEditorCommons` in `analysis/app-facts/inventory.json`, or a `create agent` statement in `mdlsource/`) with no `modules/AgentEditor*.mxmodule`. `skills/mendix-agents.md` (on demand) gains the rule plus the note that the GenAI key, `Encryption.EncryptionKey` and `GenAICommons.StoreTraces` belong in the Default configuration, not a start script. Empty agent references / missing model version (mendixlabs/mxcli#1867) and unset runtime constants are not checked: they need a captured agent document (option 2). Fixture `tests/wave2/test-status-extension-modules.sh` — field report from an Agent Editor project, Nov 2026 diff --git a/bin/gate-check.sh b/bin/gate-check.sh index c6179729..c2a53766 100755 --- a/bin/gate-check.sh +++ b/bin/gate-check.sh @@ -70,7 +70,7 @@ ADOPT_STAGE="" WAIVE_STAGE="" CLOSEOUT=0 WAIVER_REASON="" -GC_APP="${MXTK_APP:-}" +GC_APP="${MXTK_APP:-}"; GC_APP_ARG=0 # 1: named by --app (an error when it does not apply); 0: from the environment (dropped) declare -a GC_ARGS GC_ARGS=() while [ $# -gt 0 ]; do @@ -84,8 +84,8 @@ while [ $# -gt 0 ]; do --closeout) CLOSEOUT=1; HTML_MODE="never" ;; --waive) shift; WAIVE_STAGE="${1:-}" ;; --reason) shift; WAIVER_REASON="${1:-}" ;; - --app) shift; GC_APP="${1:-}" ;; - --app=*) GC_APP="${1#--app=}" ;; + --app) shift; GC_APP="${1:-}"; GC_APP_ARG=1 ;; + --app=*) GC_APP="${1#--app=}"; GC_APP_ARG=1 ;; --force-stale) FORCE_STALE=1 ;; --strict-protocol) STRICT_PROTOCOL=1 ;; --) shift; while [ $# -gt 0 ]; do GC_ARGS[${#GC_ARGS[@]}]="$1"; shift; done; break ;; @@ -306,18 +306,26 @@ fi # PROJECT_ROOT pinned, so the layout rules are the crash net's and not a copy. GC_APPS stays # empty on single-tree and two-tree projects, and nothing below prints for them. GC_APPS="" -if [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/project-bin/_common.sh" ] && [ -d "$PROJECT_DIR/apps" ]; then +_gc_common="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/project-bin/_common.sh" +if [ -f "$_gc_common" ] && [ -d "$PROJECT_DIR/apps" ]; then GC_APPS="$( PROJECT_ROOT="$(cd "$PROJECT_DIR" && pwd)"; MPR_FILE=""; MXTK_APP="" - . "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/project-bin/_common.sh" >/dev/null 2>&1 || exit 0 + . "$_gc_common" >/dev/null 2>&1 || exit 0 mxtk_apps "$PROJECT_ROOT" 2>/dev/null )" fi +# An env MXTK_APP that does not apply (not a multi-app project, or no such app) is dropped, as +# _common.sh drops it; only an explicit --app is an error. +if [ -n "$GC_APP" ] && [ -z "$GC_APPS" ] && [ "$GC_APP_ARG" = 0 ]; then GC_APP=""; fi if [ -n "$GC_APP" ]; then [ -n "$GC_APPS" ] || { echo "Error: --app $GC_APP: $PROJECT_DIR is not a multi-app project (no apps//*.mpr)." >&2; exit 2; } - _gc_sel="$( PROJECT_ROOT="$(cd "$PROJECT_DIR" && pwd)"; MPR_FILE=""; MXTK_APP="" - . "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/project-bin/_common.sh" >/dev/null 2>&1 - mxtk_select_app "$GC_APP" "$PROJECT_ROOT" && printf '%s\t%s\n' "$MXTK_APP" "$MPR_FILE" )" || exit 2 - MXTK_APP="${_gc_sel%% *}"; MPR_FILE="${_gc_sel#* }"; GC_APP="$MXTK_APP"; export MXTK_APP MPR_FILE + if _gc_sel="$( PROJECT_ROOT="$(cd "$PROJECT_DIR" && pwd)"; MPR_FILE=""; MXTK_APP="" + . "$_gc_common" >/dev/null 2>&1 + mxtk_select_app "$GC_APP" "$PROJECT_ROOT" && printf '%s\t%s\n' "$MXTK_APP" "$MPR_FILE" )"; then + MXTK_APP="${_gc_sel%% *}"; MPR_FILE="${_gc_sel#* }"; GC_APP="$MXTK_APP"; export MXTK_APP MPR_FILE + elif [ "$GC_APP_ARG" = 1 ]; then exit 2 + else echo "note: MXTK_APP=$GC_APP names no app here; reporting every app" >&2; GC_APP=""; unset MXTK_APP; fi fi +# The app list, computed once, for every per-app reader in this run (bin/lib/app-scope.sh). +MXTK_SCOPE_APPS="$GC_APPS"; MXTK_SCOPE_ROOT="$PROJECT_DIR"; export MXTK_SCOPE_APPS MXTK_SCOPE_ROOT # the same string the readers are given # Resolve the knowledge-base dir the same way this project's artifacts actually live. # Convention: analysis//knowledge-base/ under the project dir; fall back to diff --git a/bin/init-project.sh b/bin/init-project.sh index a8892e0d..cfd02d5c 100755 --- a/bin/init-project.sh +++ b/bin/init-project.sh @@ -282,6 +282,7 @@ TOOLKIT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" # selection (bin/lib/app-scope.sh; skills/module-folder-convention.md § Several apps in one repo). # Nothing happens, and nothing prints, for any other layout. . "$SCRIPT_DIR/lib/app-scope.sh" +mxtk_scope_init "$(cd "$PROJECT_DIR" && pwd)" "$TOOLKIT_ROOT" mxtk_scaffold_apps "$PROJECT_DIR" "$TOOLKIT_ROOT" _WIRE_MPR=""; _WIRE_MDL="" _wr="$(mxtk_wiring_rows "$PROJECT_DIR" "$TOOLKIT_ROOT")" diff --git a/bin/lib/app-scope.sh b/bin/lib/app-scope.sh index 9c55a650..92bfe785 100644 --- a/bin/lib/app-scope.sh +++ b/bin/lib/app-scope.sh @@ -7,8 +7,14 @@ # PROJECT_ROOT pinned), so single-tree and two-tree projects yield nothing and print nothing. # The register stays ONE (PROJECT.md); only evidence that is per app is reported per app. # +# mxtk_scope_init +# computes the app list ONCE and exports it (MXTK_SCOPE_APPS, keyed by MXTK_SCOPE_ROOT); +# callers run it in their own shell before the readers below (each re-source of _common.sh +# cost ~0.1 s; a status run did it three times). gate-check sets the same pair itself. # mxtk_scope_apps -# prints mxtk_apps' lines (""), or nothing +# prints mxtk_apps' lines ("", model "-" when the folder holds +# several .mpr and none is named for it), or nothing — from the exported list when it was +# computed for this project, else by sourcing _common.sh in a subshell # mxtk_app_lines # one line per app, "", only when there are two or more apps: # "apps//.mpr · scripts N written / D done- · LOOK: K of M page(s) owed" @@ -18,8 +24,17 @@ # or alter: never "no pages owed" without a ledger to say it (a field run, six apps: the # ledger is git-ignored, so a fresh checkout with ~78 built pages read "no pages owed"). +mxtk_scope_init() { + MXTK_SCOPE_ROOT="$1"; MXTK_SCOPE_APPS="" + MXTK_SCOPE_APPS="$(MXTK_SCOPE_ROOT=""; mxtk_scope_apps "$1" "$2")" + export MXTK_SCOPE_APPS MXTK_SCOPE_ROOT +} + mxtk_scope_apps() { local pd="$1" tk="$2" + if [ -n "${MXTK_SCOPE_ROOT:-}" ] && [ "$MXTK_SCOPE_ROOT" = "$pd" ]; then + [ -n "${MXTK_SCOPE_APPS:-}" ] && printf '%s\n' "$MXTK_SCOPE_APPS"; return 0 + fi [ -d "$pd/apps" ] && [ -f "$tk/project-bin/_common.sh" ] || return 0 ( PROJECT_ROOT="$pd"; MPR_FILE=""; MXTK_APP="" . "$tk/project-bin/_common.sh" >/dev/null 2>&1 || exit 0 @@ -27,36 +42,49 @@ mxtk_scope_apps() { } mxtk_app_lines() { - local pd="$1" tk="$2" apps a m d n dn lk ls lt lo + local pd="$1" tk="$2" apps facts look="" own=0 apps="$(mxtk_scope_apps "$pd" "$tk")" [ "$(printf '%s' "$apps" | grep -c . || true)" -ge 2 ] || return 0 - while IFS=' ' read -r a m; do - [ -n "$a" ] || continue - d="$pd/apps/$a/mdlsource"; n=0; dn=0 - if [ -d "$d" ]; then - n="$(find "$d" -name '*.mdl' -not -path '*/gallery/*' | wc -l | tr -d ' ')" - dn="$(find "$d" -name 'done-*.mdl' | wc -l | tr -d ' ')" - fi - np=0 - [ -d "$d" ] && np="$(find "$d" -name '*.mdl' -not -path '*/gallery/*' -exec cat {} + 2>/dev/null | awk ' - /^[[:space:]]*--/ { next } - { l = toupper($0) } - l ~ /^[[:space:]]*(CREATE([[:space:]]+OR[[:space:]]+(REPLACE|MODIFY))?|ALTER)[[:space:]]+PAGE[[:space:]]/ { - n = split($0, w, /[[:space:]]+/); for (i = 1; i < n; i++) if (toupper(w[i]) == "PAGE") { x = w[i+1]; break } - sub(/[(;{].*$/, "", x); gsub(/"/, "", x); if (x ~ /^[A-Za-z0-9_]+\.[A-Za-z0-9_]+$/) seen[x] = 1 } - END { k = 0; for (x in seen) k++; print k }')" - if [ "$np" -eq 0 ]; then lk="LOOK: no page in its scripts" - elif [ -s "$pd/.claude/loop/look/owed.tsv" ]; then lk="LOOK: no ledger row for this app ($np page(s) in its scripts)" - else lk="LOOK: no ledger here ($np page(s) in its scripts) — .claude/loop/look/ is written by bin/exec.sh on this machine"; fi - if [ -s "$pd/.claude/loop/look/owed.tsv" ] && [ -f "$tk/project-bin/look-ledger.sh" ]; then - ls="$(PROJECT_ROOT="$pd" MPR_FILE="" MXTK_APP="" bash "$tk/project-bin/look-ledger.sh" status --app "$a" 2>/dev/null)" - lt="$(printf '%s' "$ls" | grep -c . || true)"; lo="$(printf '%s\n' "$ls" | grep -c '^OWED' || true)" - [ "$lt" -gt 0 ] && lk="LOOK: $lo of $lt page(s) owed" - fi - printf '%s\t%s · scripts %s written / %s done- · %s\n' "$a" "$m" "$n" "$dn" "$lk" - done < ", pages = distinct Module.Page its scripts create or alter. + facts="$(find "$pd"/apps/*/mdlsource -name '*.mdl' -not -path '*/gallery/*' 2>/dev/null | awk -v root="$pd/apps/" ' + { f = $0; a = substr(f, length(root) + 1); sub(/\/.*$/, "", a); n[a]++ + b = f; sub(/.*\//, "", b); if (b ~ /^done-/) dn[a]++ + while ((getline line < f) > 0) { + if (line ~ /^[[:space:]]*--/) continue + u = toupper(line) + if (u !~ /^[[:space:]]*(CREATE([[:space:]]+OR[[:space:]]+(REPLACE|MODIFY))?|ALTER)[[:space:]]+PAGE[[:space:]]/) continue + k = split(line, w, /[[:space:]]+/); x = "" + for (i = 1; i < k; i++) if (toupper(w[i]) == "PAGE") { x = w[i+1]; break } + sub(/[(;{].*$/, "", x); gsub(/"/, "", x) + if (x ~ /^[A-Za-z0-9_]+\.[A-Za-z0-9_]+$/ && !((a SUBSEP x) in seen)) { seen[a SUBSEP x] = 1; np[a]++ } + } + close(f) } + END { for (a in n) print a, n[a], dn[a] + 0, np[a] + 0 }')" + # The LOOK ledger once, every app (look-ledger.sh status --by-app: one project ledger, keyed by app). + if [ -s "$pd/.claude/loop/look/owed.tsv" ] && [ -f "$tk/project-bin/look-ledger.sh" ]; then + own=1 + look="$(PROJECT_ROOT="$pd" MPR_FILE="" MXTK_APP="" bash "$tk/project-bin/look-ledger.sh" status --by-app 2>/dev/null)" + fi + # One join, one awk: apps (in mxtk_apps order) x facts x LOOK counts. + { printf '%s\n' "$apps" | awk '{ print "A\t" $0 }' + printf '%s\n' "$facts" | sed 's/^/F /' + printf '%s\n' "$look" | awk -F'\t' 'NF >= 4 { t[$4]++; if ($1 == "OWED") o[$4]++ } END { for (a in t) print "L", a, t[a], o[a] + 0 }' + } | awk -v own="$own" ' + /^A\t/ { split($0, x, "\t"); if (x[2] == "") next; ord[++na] = x[2]; mdl[x[2]] = x[3]; next } + $1 == "F" { n[$2] = $3; dn[$2] = $4; np[$2] = $5; next } + $1 == "L" { lt[$2] = $3; lo[$2] = $4; next } + END { + for (i = 1; i <= na; i++) { + a = ord[i]; m = mdl[a] + if (lt[a] + 0 > 0) lk = "LOOK: " lo[a] " of " lt[a] " page(s) owed" + else if (np[a] + 0 == 0) lk = "LOOK: no page in its scripts" + else if (own == 1) lk = "LOOK: no ledger row for this app (" np[a] " page(s) in its scripts)" + else lk = "LOOK: no ledger here (" np[a] " page(s) in its scripts) — .claude/loop/look/ is written by bin/exec.sh on this machine" + if (m == "-") m = "apps/" a "/ (several .mpr, none named " a ".mpr: set MPR_FILE)" + printf "%s\t%s · scripts %d written / %d done- · %s\n", a, m, n[a], dn[a], lk + } + }' } # mxtk_scaffold_apps — the per-app planning folders, one convention @@ -171,29 +199,37 @@ mxtk_wiring_rows() { # none of those lines (a plain mxcli template) says nothing. Field run (six apps): seven # PROJECT.md files, one per app plus the root. mxtk_app_register_notes() { - local pd="$1" tk="$2" apps a m f em rem found nd + local pd="$1" tk="$2" apps a m files="" apps="$(mxtk_scope_apps "$pd" "$tk")" [ "$(printf '%s' "$apps" | grep -c . || true)" -ge 2 ] || return 0 - _mxtk_em() { awk '{ l = tolower($0); gsub(/[*_>]/, "", l); sub(/^[ \t-]+/, "", l) - if (l ~ /^entry mode[ \t]*:/) { sub(/^entry mode[ \t]*:[ \t]*/, "", l); split(l, w, /[ \t(,;]+/); print w[1]; exit } }' "$1" 2>/dev/null; } - rem="$(_mxtk_em "$pd/PROJECT.md")" while IFS=' ' read -r a m; do - f="$pd/apps/$a/PROJECT.md" - [ -n "$a" ] && [ -f "$f" ] || continue - found="" - em="$(_mxtk_em "$f")" - if [ -n "$em" ]; then - if [ -n "$rem" ] && [ "$em" != "$rem" ]; then found="Entry mode: $em, the root says $rem" - elif [ -z "$rem" ]; then found="Entry mode: $em, the root has none" - else found="Entry mode"; fi - fi - awk '/^## Current stage/{f=1;next} f && /^\*\*Stage/{ok=1; exit} END{exit !ok}' "$f" 2>/dev/null && found="${found:+$found; }Current stage" - grep -qiE '^Adopted at stage:' "$f" 2>/dev/null && found="${found:+$found; }Adopted at stage" - nd="$(grep -cE '^\|.*\|[[:space:]]*\**(CONFIRMED|ASSUMED)' "$f" 2>/dev/null || true)" - [ "${nd:-0}" -gt 0 ] && found="${found:+$found; }$nd decision row(s)" - [ -n "$found" ] && printf '%s\tapps/%s/PROJECT.md holds register lines (%s): the register is the root PROJECT.md, which gate-check reads; move them there and leave the app file a pointer\n' "$a" "$a" "$found" + [ -n "$a" ] && [ -f "$pd/apps/$a/PROJECT.md" ] && files="$files$a +" done <]/, "", l); sub(/^[ \t-]+/, "", l) + if (l !~ /^entry mode[ \t]*:/) return ""; sub(/^entry mode[ \t]*:[ \t]*/, "", l); split(l, w, /[ \t(,;]+/); return w[1] } + function flush( a, f) { + if (cur == "") return + a = cur; sub(/\/PROJECT\.md$/, "", a); sub(/.*\//, "", a); f = "" + if (e != "") { if (rem != "" && e != rem) f = "Entry mode: " e ", the root says " rem + else if (rem == "") f = "Entry mode: " e ", the root has none"; else f = "Entry mode" } + if (st) f = f (f != "" ? "; " : "") "Current stage" + if (ad) f = f (f != "" ? "; " : "") "Adopted at stage" + if (nd) f = f (f != "" ? "; " : "") nd " decision row(s)" + if (f != "") printf "%s\tapps/%s/PROJECT.md holds register lines (%s): the register is the root PROJECT.md, which gate-check reads; move them there and leave the app file a pointer\n", a, a, f + } + BEGIN { while ((getline line < root) > 0) if (rem == "" && (x = em(line)) != "") rem = x; close(root) } + FNR == 1 { flush(); cur = FILENAME; e = ""; st = 0; ad = 0; nd = 0; cs = 0 } + { if (e == "") e = em($0) + if ($0 ~ /^## Current stage/) cs = 1; else if ($0 ~ /^## /) cs = 0 + if (cs && $0 ~ /^\*\*Stage/) st = 1 + if (tolower($0) ~ /^adopted at stage:/) ad = 1 + if ($0 ~ /^\|.*\|[[:space:]]*\**(CONFIRMED|ASSUMED)/) nd++ } + END { flush() }' "$@"; } } diff --git a/bin/lib/marketplace-check.sh b/bin/lib/marketplace-check.sh index 8047780d..e50ebf5c 100755 --- a/bin/lib/marketplace-check.sh +++ b/bin/lib/marketplace-check.sh @@ -238,12 +238,16 @@ mxtk_mkt_report_apps() { [ -n "$app" ] || continue fg="$shared" [ -s "$root/architecture/apps/$app/fit-gap.md" ] && fg="$root/architecture/apps/$app/fit-gap.md" - out="$(MPR_FILE="$root/$mpr"; MXTK_APP="$app"; _MKT_NO_REMEMBER=1; export MPR_FILE MXTK_APP - mxtk_mkt_report "$root" "$reg" "$fg" >/dev/null - printf '%s\t%s' "$MXTK_MKT_STATUS" "$MXTK_MKT_NOTE")" + if [ "$mpr" = "-" ]; then + out="PENDING apps/$app/ holds more than one .mpr and none is named $app.mpr, so no model was read; name the app's model $app.mpr, or move the extra .mpr out of apps/$app/, to have it checked" + else + out="$(MPR_FILE="$root/$mpr"; MXTK_APP="$app"; _MKT_NO_REMEMBER=1; export MPR_FILE MXTK_APP + mxtk_mkt_report "$root" "$reg" "$fg" >/dev/null + printf '%s\t%s' "$MXTK_MKT_STATUS" "$MXTK_MKT_NOTE")" + fi st="${out%% *}"; one="${out#* }" if [ "$fg" = "$shared" ]; then - [ "$st" = FAIL ] && { st=PENDING + [ "$st" = FAIL ] && [ -n "$shared" ] && { st=PENDING one="the shared ${shared#"$root"/} does not say which app owes this Buy; move the row to architecture/apps//fit-gap.md, or waive it. Read: $one"; } # Shared source: findings that read the same for several apps print once (a field run, six # apps, repeated one project-level finding six times). The app's own model name is the @@ -270,9 +274,11 @@ EOF local IFS=$'\n' for g in $groups; do gapps="${g%%$'\034'*}"; gk="${g#*$'\034'}" + # "from the shared " only when there is one; with no fit-gap at all the finding + # itself says so, and the label is just the apps. case "$gapps" in - *", "*) [ "$(printf '%s' "$gapps" | tr ',' '\n' | grep -c .)" -eq "$n_all" ] \ - && gapps="all $n_all apps, from the shared ${shared#"$root"/}" || gapps="$gapps, from the shared ${shared#"$root"/}" ;; + *", "*) [ "$(printf '%s' "$gapps" | tr ',' '\n' | grep -c .)" -eq "$n_all" ] && gapps="all $n_all apps" + [ -n "$shared" ] && gapps="$gapps, from the shared ${shared#"$root"/}" ;; esac printf ' [%s] %s — %s\n' "$gapps" "${gk%% *}" "${gk#* }" done diff --git a/bin/status.sh b/bin/status.sh index a0344d79..eef8e172 100755 --- a/bin/status.sh +++ b/bin/status.sh @@ -375,6 +375,7 @@ done # model, its own mdlsource/ scripts, and its LOOK debt (bin/lib/app-scope.sh, shared with # gate-check). Single-tree and two-tree projects print nothing here. . "$TOOLKIT_ROOT/bin/lib/app-scope.sh" +mxtk_scope_init "$PROJECT_DIR" "$TOOLKIT_ROOT" # the app list once, for both readers below APP_LINES="$(mxtk_app_lines "$PROJECT_DIR" "$TOOLKIT_ROOT")" [ -n "$APP_LINES" ] && APP_LINES="$APP_LINES " diff --git a/bin/sync-project.sh b/bin/sync-project.sh index 2fa3bc96..40ffb77f 100755 --- a/bin/sync-project.sh +++ b/bin/sync-project.sh @@ -678,6 +678,7 @@ fi # predates this. Never overwrites. Nothing happens, and nothing prints, for any other layout. . "$SCRIPT_DIR/lib/app-scope.sh" _ATK="$(cd "$SCRIPT_DIR/.." && pwd)" +mxtk_scope_init "$PROJECT_DIR" "$_ATK" _WIRE_MPR=""; _WIRE_MDL="" _wr="$(mxtk_wiring_rows "$PROJECT_DIR" "$_ATK")" [ -n "$_wr" ] && { _WIRE_MPR="${_wr%% *}"; _WIRE_MDL="${_wr#* }"; } diff --git a/project-bin/_common.sh b/project-bin/_common.sh index 156cecbf..86bea7b2 100755 --- a/project-bin/_common.sh +++ b/project-bin/_common.sh @@ -54,11 +54,37 @@ _mxtk_is_project_dir() { # two answers for one cwd split the ledgers. An unmarked app folder is still returned as itself, # and so is an app folder that is a project folder of its own (its own install, or .claude/ # beside PROJECT.md): a project nested at apps// or app/ keeps its own root. +# +# REFINEMENT OF #489 (maintainer decision, a field run with six apps, 2026-11): an app folder +# apps// that is a project folder of its own BECAUSE `mxcli init` ran in it (its own .claude/ +# and PROJECT.md) resolves to the OUTER project when that outer folder is a toolkit multi-app +# project: a PROJECT.md holding register lines (## Current stage, ## Decisions, Entry mode), +# no model at its root or under app/, and apps// holding a model. One register, one LOOK +# ledger, one set of gates. Keeping the app folder as its root split the ledger (owe rows in +# apps//.claude/loop/look/, seen rows at the root) and made MXTK_APP a no-op inside it. Any +# other nested project keeps the #489 rule, so a standalone project inside another repo, or an +# app folder under an outer folder with no register, is unaffected. The app's own PROJECT.md is +# warned about, never read (bin/lib/app-scope.sh mxtk_app_register_notes). +# _mxtk_outer_project sets _MXTK_OUTER (no subshell: the walk calls it on every source). +_mxtk_outer_project() { + local d="$1" p f hit=0 + _MXTK_OUTER="" + case "$d" in */[Aa][Pp][Pp][Ss]/?*) ;; *) return 1 ;; esac + p="${d%/*}"; case "$p" in */[Aa][Pp][Pp][Ss]) p="${p%/*}" ;; *) return 1 ;; esac + [ -n "$p" ] && [ -f "$p/PROJECT.md" ] && [ "$p" != "${HOME:-/nonexistent}" ] || return 1 + for f in "$d"/*.mpr; do [ -e "$f" ] && hit=1; done + [ "$hit" = 1 ] || return 1 + for f in "$p"/*.mpr "$p"/app/*.mpr; do [ -e "$f" ] && return 1; done + grep -qiE '^## (Current stage|Decisions)|^[*_ -]*entry mode[*_]*:' "$p/PROJECT.md" 2>/dev/null || return 1 + _MXTK_OUTER="$p" +} mxtk_walk_root() { local d="$1" p while [ -n "$d" ] && [ "$d" != "/" ]; do if _mxtk_has_model "$d" || _mxtk_is_project_dir "$d"; then - if ! _mxtk_is_project_dir "$d"; then + if _mxtk_is_project_dir "$d"; then + _mxtk_outer_project "$d" && d="$_MXTK_OUTER" + else p="${d%/*}" case "$d" in */[Aa][Pp][Pp]) [ -n "$p" ] && _mxtk_is_project_dir "$p" && d="$p" ;; @@ -97,15 +123,18 @@ _mxtk_resolve_root() { # THE INTERFACE every reader uses to scope per app (gate-check, status, look-ledger, the # obligation check, ready.sh). Small on purpose; globs and builtins only, Bash 3.2. # -# mxtk_apps [root] one line per app model: "" (path relative -# to root), in glob order. Prints nothing and returns 1 unless the -# root holds no *.mpr and no app/*.mpr — single-tree and two-tree +# mxtk_apps [root] one line per app FOLDER: "" (path relative +# to root), in glob order; the model is .mpr when the folder holds +# several, and "-" when it holds several and none is named for it. +# Prints nothing and returns 1 unless the root holds no *.mpr and no +# app/*.mpr — single-tree and two-tree # projects are never multi-app, whatever sits under apps/. -# mxtk_app_count [root] the number of lines mxtk_apps prints (0 for every other layout). +# mxtk_app_count [root] the number of app folders mxtk_apps lists (0 for every other layout). # mxtk_select_app [root] # sets and exports MPR_FILE (absolute) and MXTK_APP for one app. -# Exact folder name first, then any letter case. rc 1, apps listed -# on stderr, when is not one (or its folder holds two .mpr). +# Exact folder name first, then any letter case. rc 1, with the reason +# on stderr, when is not one, matches two folders by case only, +# or names a folder whose model is "-". # mxtk_app_of [root] prints when (absolute, or relative to root) sits under # apps//; nothing, rc 1, otherwise. # MXTK_APP= the environment form of --app, honoured when this file is sourced, @@ -120,44 +149,56 @@ _mxtk_resolve_root() { # MPR_FILE to choose, nothing checked" for the Marketplace check, the obligation check found no # module in scope, and the project's CLAUDE.local.md had to hand-write the MPR_FILE workaround. mxtk_apps() { - local r="${1:-$PROJECT_ROOT}" f a n=0 + local r="${1:-$PROJECT_ROOT}" f d a m k n=0 for f in "$r"/*.mpr "$r"/app/*.mpr; do [ -e "$f" ] && return 1; done - for f in "$r"/apps/*/*.mpr; do - [ -e "$f" ] || continue - a="${f%/*}"; a="${a##*/}" - printf '%s\t%s\n' "$a" "${f#"$r"/}"; n=$((n + 1)) + for d in "$r"/apps/*/; do + d="${d%/}"; a="${d##*/}"; m=""; k=0 + for f in "$d"/*.mpr; do [ -e "$f" ] && { k=$((k + 1)); m="$f"; }; done + [ "$k" -gt 0 ] || continue + # One line per app FOLDER: .mpr when it is there, the only .mpr otherwise, "-" when the + # folder holds several and none is named for it (mxtk_select_app then refuses; readers say so). + if [ "$k" -gt 1 ]; then if [ -e "$d/$a.mpr" ]; then m="$d/$a.mpr"; else m="-"; fi; fi + if [ "$m" = "-" ]; then printf '%s\t-\n' "$a"; else printf '%s\t%s\n' "$a" "${m#"$r"/}"; fi + n=$((n + 1)) done [ "$n" -gt 0 ] } mxtk_app_count() { - local r="${1:-$PROJECT_ROOT}" f n=0 + local r="${1:-$PROJECT_ROOT}" f d n=0 for f in "$r"/*.mpr "$r"/app/*.mpr; do [ -e "$f" ] && { echo 0; return 0; }; done - for f in "$r"/apps/*/*.mpr; do [ -e "$f" ] && n=$((n + 1)); done + for d in "$r"/apps/*/; do + for f in "$d"*.mpr; do [ -e "$f" ] && { n=$((n + 1)); break; }; done + done echo "$n" } mxtk_select_app() { - local want="$1" r="${2:-$PROJECT_ROOT}" list a p hit="" n=0 wl al + local want="$1" r="${2:-$PROJECT_ROOT}" list a p hit="" ha="" n=0 wl al list="$(mxtk_apps "$r")" || { echo "ERROR: --app $want: $r is not a multi-app project (no apps//*.mpr)" >&2; return 1; } wl="$(printf '%s' "$want" | tr '[:upper:]' '[:lower:]')" - while IFS=' ' read -r a p; do [ "$a" = "$want" ] && { hit="$p"; n=$((n + 1)); }; done <&2 + elif [ "$n" -gt 1 ]; then + echo "ERROR: --app $want: $n app folders differ from it only in letter case — name one exactly:" >&2 + elif [ "$hit" = "-" ]; then + echo "ERROR: --app $want: apps/$ha/ holds more than one .mpr and none is named $ha.mpr — name the model $ha.mpr (or move the extra one out); a bin/ script also takes MPR_FILE=apps/$ha/.mpr" >&2 + return 1 + fi if [ "$n" -ne 1 ]; then - if [ "$n" -eq 0 ]; then echo "ERROR: --app $want: no such app. Apps in $r:" >&2 - else echo "ERROR: --app $want: $n .mpr files in that app folder — set MPR_FILE to the one meant:" >&2; fi printf '%s\n' "$list" | while IFS=' ' read -r a p; do echo " $a ($p)" >&2; done return 1 fi - a="${hit#apps/}"; a="${a%%/*}" - MPR_FILE="$r/$hit"; MXTK_APP="$a"; export MPR_FILE MXTK_APP + MPR_FILE="$r/$hit"; MXTK_APP="$ha"; export MPR_FILE MXTK_APP } mxtk_app_of() { local p="$1" r="${2:-$PROJECT_ROOT}" diff --git a/project-bin/look-ledger.sh b/project-bin/look-ledger.sh index 72d4ce46..36e39cd5 100755 --- a/project-bin/look-ledger.sh +++ b/project-bin/look-ledger.sh @@ -5,7 +5,8 @@ # bin/look-ledger.sh seen PostToolUse(Read) hook; reads the hook JSON on stdin # bin/look-ledger.sh status [--app ] # prints one line per owed page: SEEN or OWED (one app's -# pages only with --app, or with MXTK_APP set) +# pages only with --app, or with MXTK_APP set; --by-app: +# every app's, keyed by app, the app as a 6th column) # bin/look-ledger.sh reshoot [Module] [--all] # which pages a polish round must re-shoot (390 + 1280): the pages # built after their last seen LOOK, plus every page when a layout, @@ -213,7 +214,7 @@ cmd_seen() { # look_status — one line per owed page, newest build only: SEEN|OWED Module.Page epoch # One awk pass over both ledgers: a per-row fork costs ~150ms under Git Bash on Windows, and a # join of 50 pages against 300 reads would otherwise take minutes (obligation-check.sh, 2026-08-25). -look_status() { _look_status_ex | cut -f1-3; } +look_status() { if [ "${LOOK_APP:-}" = "*" ]; then _look_status_ex | cut -f1-3,6; else _look_status_ex | cut -f1-3; fi; } # _look_status_ex — look_status plus, for a SEEN page, the epoch and path of its newest matching screenshot # (cols 4, 5; 0 and empty when OWED). `status` still prints cols 1-3 only: other tools parse those. _look_status_ex() { @@ -236,19 +237,28 @@ _look_status_ex() { shotmt[g[3] SUBSEP g[4]] = g[5]+0 } } - # --app: rows of that app only — by the app column, or for an older row by its script path - app != "" && !($5 == app || ($5 == "" && index($4, "apps/" app "/") == 1)) { next } - NF>=3 { if (!($3 in last) || $1+0 > last[$3]) last[$3]=$1+0 } + # --app: rows of that app only — by the app column, or for an older row by its script path. + # app "*" (--by-app): every row, keyed by app and page; the app is printed as a 6th column. + app != "" && app != "*" && !($5 == app || ($5 == "" && index($4, "apps/" app "/") == 1)) { next } + NF>=3 { + k = $3 + if (app == "*") { ra = $5; if (ra == "" && $4 ~ /^apps\/[^\/]+\//) { ra = $4; sub(/^apps\//, "", ra); sub(/\/.*$/, "", ra) } + k = ra SUBSEP $3 } + if (!(k in last) || $1+0 > last[k]) last[k]=$1+0 + } END { - for (p in last) { + for (k in last) { + p = k; ka = "" + if (app == "*") { split(k, kk, SUBSEP); ka = kk[1]; p = kk[2] } short=p; sub(/^[^.]*\./, "", short); short=norm(short); ok=0; sa=0; si="" for (i=1; i<=n; i++) { - if (!(at[i]>=last[p] && mt[i]>=last[p])) continue - if (index(base[i], short) || (((p SUBSEP full[i]) in shotmt) && shotmt[p SUBSEP full[i]]>=last[p])) { + if (!(at[i]>=last[k] && mt[i]>=last[k])) continue + if (index(base[i], short) || (((p SUBSEP full[i]) in shotmt) && shotmt[p SUBSEP full[i]]>=last[k])) { ok=1; if (at[i]>=sa) { sa=at[i]; si=full[i] } } } - print (ok ? "SEEN" : "OWED") "\t" p "\t" last[p] "\t" sa "\t" si + if (app == "*") print (ok ? "SEEN" : "OWED") "\t" p "\t" last[k] "\t" sa "\t" si "\t" ka + else print (ok ? "SEEN" : "OWED") "\t" p "\t" last[k] "\t" sa "\t" si } }' "$OWED" 2>/dev/null | sort -k2,2 } @@ -384,7 +394,7 @@ case "${1:-}" in owe) shift; cmd_owe "$@" ;; seen) cmd_seen ;; status) shift - case "${1:-}" in --app) LOOK_APP="${2:-}" ;; --app=*) LOOK_APP="${1#--app=}" ;; *) LOOK_APP=""; [ -n "${MXTK_APP:-}" ] && mxtk_apps >/dev/null 2>&1 && LOOK_APP="$MXTK_APP" ;; esac + case "${1:-}" in --by-app) LOOK_APP="*" ;; --app) LOOK_APP="${2:-}" ;; --app=*) LOOK_APP="${1#--app=}" ;; *) LOOK_APP=""; [ -n "${MXTK_APP:-}" ] && mxtk_apps >/dev/null 2>&1 && LOOK_APP="$MXTK_APP" ;; esac look_status ;; shots) shift; cmd_shots "$@" ;; pages) shift; look_pages_in "${1:-/dev/null}" ;; diff --git a/tests/wave2/test-multi-app-scope.sh b/tests/wave2/test-multi-app-scope.sh index bbda3fc7..1997375b 100755 --- a/tests/wave2/test-multi-app-scope.sh +++ b/tests/wave2/test-multi-app-scope.sh @@ -10,22 +10,28 @@ # The tree is materialised from fixtures/multi-app/tree.txt (see PROVENANCE.txt there); SHOW # MODULES is replayed from the captures in fixtures/show-modules/ by a stub mxcli keyed on -p. # -# A1 resolver: mxtk_apps lists the three apps, mxtk_app_count 3; mxtk_select_app exact and any +# A1 resolver: mxtk_apps lists the six apps, mxtk_app_count 6; mxtk_select_app exact and any # letter case, unknown refused listing apps; mxtk_app_of; MXTK_APP at source time beats the -# cwd auto-pick, a user's MPR_FILE beats MXTK_APP; find_mpr still refuses, naming MXTK_APP +# cwd auto-pick, a user's MPR_FILE beats MXTK_APP; find_mpr still refuses, naming MXTK_APP; +# an app folder with its own .claude/ + PROJECT.md resolves to the outer project when that +# holds a register (refinement of #489), keeps its own root when not; one line per app +# folder (a second .mpr is not a second app; "-" and a refusal when none is .mpr) # A2 single tree and two-tree: mxtk_apps prints nothing (rc 1) and mxtk_app_count is 0, even # with an apps/ folder holding a model beside the root model # A3 gate-check, no app chosen: "Marketplace installs: per app (6 apps", one [App] line each, # no "nothing checked"; per-app fit-gap missing package -> FAIL for that app only; shared # fit-gap missing package -> PENDING (owner unknown); build-ready counts the FAIL; with -# every app on the shared fit-gap, the one finding prints once ("all 6 apps") -# A4 gate-check --app appa: one Marketplace line, AppA' fit-gap; no Apps section; -# --app Nope exits 2 naming the apps; --app on a single-tree project exits 2 +# every app on the shared fit-gap, the one finding prints once ("all 6 apps"); with no +# fit-gap at all, no "from the shared" label +# A4 gate-check --app appa: one Marketplace line, AppA's fit-gap, no Apps section; --app Nope +# exits 2 naming the apps; --app on a single-tree project exits 2; an env MXTK_APP there is +# dropped (exit 0) # A5 gate-check "Apps:" section and status.sh: one line per app, scripts per app's mdlsource, # LOOK owed per app, and "no ledger here (N pages ...)" before any ledger exists — never # "no pages owed" by absence; single-tree and two-tree print neither # A6 look-ledger: owe writes the app as a 5th column in the multi-app tree, four columns in a -# single tree; status --app keeps two apps' same-named page apart +# single tree; nothing lands in an app's own .claude/ (one ledger); status --app keeps two +# apps' same-named page apart # A7 init-project scaffolds architecture/apps//intake.md + triage.md + the index and the # multi-app Wiring rows; sync-project re-run creates nothing and overwrites nothing # A8 an app's own PROJECT.md (mxcli init per app; the field repo had seven) holding register @@ -88,6 +94,23 @@ r="$(clean_env MXTK_APP=AppA MPR_FILE=apps/AppC/AppC.mpr bash -c "cd '$P'; . '$C eq "A1 user MPR_FILE beats MXTK_APP" "$r" "$P/apps/AppC/AppC.mpr" r="$(clean_env bash -c "cd '$P'; . '$COMMON'; find_mpr" 2>&1)" has "A1 find_mpr refuses" "$r" "refusing to guess"; has "A1 refusal names MXTK_APP" "$r" "MXTK_APP=" +# Each captured app folder carries its own .claude/ + PROJECT.md (mxcli init per app). Under an +# outer project with a register they resolve to the OUTER project (refinement of #489). +r="$(clean_env bash -c "cd '$P/apps/AppB/docs'; . '$COMMON'; echo \"\$PROJECT_ROOT|\$MPR_FILE\"")" +eq "A1 app folder with its own .claude/ resolves to the outer project" "$r" "$P|$P/apps/AppB/AppB.mpr" +# ... and keep their own root when the outer PROJECT.md holds no register lines (#489 unchanged) +N="$T/nested"; mkdir -p "$N/apps/X/.claude" "$N/.claude"; : > "$N/PROJECT.md"; : > "$N/apps/X/PROJECT.md"; : > "$N/apps/X/X.mpr" +r="$(clean_env bash -c "cd '$N/apps/X'; . '$COMMON'; echo \"\$PROJECT_ROOT\"")" +eq "A1 no outer register: the app folder keeps its own root" "$r" "$N/apps/X" +# one line per app FOLDER: a second .mpr does not make a second app +: > "$P/apps/AppC/Copy.mpr"; mv "$P/apps/AppD/AppD.mpr" "$P/apps/AppD/Zz.mpr"; : > "$P/apps/AppD/Other.mpr" +r="$(clean_env bash -c "cd '$P'; . '$COMMON'; mxtk_apps | grep -E '^App[CD]'; echo n=\$(mxtk_app_count)")" +eq "A1 one line per folder, .mpr preferred, '-' when ambiguous" "$r" "AppC apps/AppC/AppC.mpr +AppD - +n=6" +r="$(clean_env bash -c "cd '$P'; . '$COMMON'; mxtk_select_app AppD; echo rc=\$?" 2>&1)" +has "A1 ambiguous folder refused" "$r" "apps/AppD/ holds more than one .mpr and none is named AppD.mpr"; has "A1 ambiguous rc" "$r" "rc=1" +rm -f "$P/apps/AppC/Copy.mpr" "$P/apps/AppD/Other.mpr"; mv "$P/apps/AppD/Zz.mpr" "$P/apps/AppD/AppD.mpr" echo "A2 single tree and two-tree are never multi-app" S1="$T/single"; mkdir -p "$S1/apps/Other" "$S1/.claude"; : > "$S1/Single.mpr"; : > "$S1/apps/Other/Other.mpr" @@ -117,6 +140,10 @@ has "A3 build-ready counts the FAIL" "$br" "✗ Marketplace: AppA: PASS; AppB: F mv "$P/architecture/apps" "$T/apps-fitgaps" out="$(gc "$P")" has "A3 shared finding printed once" "$out" " [all 6 apps, from the shared architecture/fit-gap.md] PENDING" +mv "$P/architecture/fit-gap.md" "$T/shared-fitgap" +out="$(gc "$P")" +has "A3 no fit-gap at all: one line, no 'from the shared'" "$out" " [all 6 apps] PENDING — no architecture/fit-gap.md yet" +mv "$T/shared-fitgap" "$P/architecture/fit-gap.md" eq "A3 no per-app repeat" "$(printf '%s\n' "$out" | grep -c '^ \[AppA\] PENDING')" "0" mv "$T/apps-fitgaps" "$P/architecture/apps" @@ -129,6 +156,8 @@ out="$(gc --app Nope "$P")"; rc=$? eq "A4 unknown app exits 2" "$rc" "2"; has "A4 names the apps" "$out" "AppA (apps/AppA/AppA.mpr)" out="$(gc --app AppA "$S1")"; rc=$? eq "A4 --app on single tree exits 2" "$rc" "2" +out="$(clean_env MXTK_APP=AppA MXCLI="$STUB" MXTK_NO_FETCH=1 MXTK_GATE_CACHE_TTL_MIN=0 bash "$TK/bin/gate-check.sh" --no-html "$S1" 2>&1)"; rc=$? +eq "A4 env MXTK_APP on a single tree is dropped (exit 0)" "$rc" "0" echo "A5 Apps section and status lines" # no ledger yet (it is git-ignored: a fresh checkout has none) is never "no pages owed" @@ -156,6 +185,7 @@ done echo "A6 look-ledger keyed by app" cols="$(awk -F'\t' '{print NF ":" $5}' "$P/.claude/loop/look/owed.tsv" | sort -u | tr '\n' ' ')" eq "A6 multi-app rows carry the app" "$cols" "5:AppA 5:AppB " +[ -e "$P/apps/AppA/.claude/loop/look/owed.tsv" ] && fail "A6 ledger split into apps/AppA/.claude/" || ok "A6 one ledger: nothing under apps/AppA/.claude/loop/" printf 'create page Single.Home (\n);\n' > "$S1/p.mdl" (cd "$S1" && clean_env bash "$TK/project-bin/look-ledger.sh" owe "$S1/p.mdl" >/dev/null) eq "A6 single tree keeps four columns" "$(awk -F'\t' '{print NF}' "$S1/.claude/loop/look/owed.tsv")" "4" From 6089d2002096305df16a060500ee2b1e0c4bb7e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:24:41 +0000 Subject: [PATCH 06/11] fix(multi-app): outer project recognised with a hand-written register; status.sh infers the project Field run of 40f8125 on the six-app copy: the root PROJECT.md is hand-written ('- Mode: requirements-driven'), so the register-lines test never fired and app folders kept their own roots. The outer folder now qualifies with any PROJECT.md beside two or more app folders holding a model (no root or app/ model); the register test stays as the one-app alternative. Nested projects elsewhere keep #489. status.sh with no project argument now finds the project from the current folder (mxtk_walk_root) instead of printing usage. Fixture: hand-written outer register from an app cwd; status.sh with no argument from apps/AppB/docs. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 2 +- bin/status.sh | 8 +++++++- project-bin/_common.sh | 14 +++++++++++--- tests/wave2/test-multi-app-scope.sh | 15 +++++++++++++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52e4381b..5543c64a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased -- fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that holds a register** (a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line, no model at its root or under `app/`) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap — from the independent review of #789 on a field run's six-app tree +- fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that is a multi-app project** (no model at its root or under `app/`, and a `PROJECT.md` beside two or more app folders holding a model — any content, since a field root register was hand-written — or, for one app, a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap; `status.sh` with no argument finds the project from the current folder (an app subfolder included) instead of printing usage — from the independent review of #789 on a field run's six-app tree - new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. The root `PROJECT.md` is the one register: an app's own `PROJECT.md` (from `mxcli init` per app; the field repo held seven) that holds register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,155 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/` from a field repo's `git ls-files`, six apps, anonymised — see its PROVENANCE.txt) — two field runs, Nov 2026 - new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 - fix(status, agents): **`bin/status.sh` WATCHes an Agent Editor project whose extension module does not travel with the model (#778)**: Studio Pro reads `agenteditor.agent` from `modules/AgentEditor.mxmodule` beside the `.mpr`, and a sync of only `.mpr` + `mprcontents/` left it out of git, so the builder stayed green while every colleague's clone showed `unknown type 'agenteditor.agent'`. Two WATCH items, warn-only (exit code and every verdict unchanged), local files and `git ls-files` only, root and `app/` layouts: a `modules/*.mxmodule` git does not track, and a project using Agent Editor (`AgentEditorCommons` in `analysis/app-facts/inventory.json`, or a `create agent` statement in `mdlsource/`) with no `modules/AgentEditor*.mxmodule`. `skills/mendix-agents.md` (on demand) gains the rule plus the note that the GenAI key, `Encryption.EncryptionKey` and `GenAICommons.StoreTraces` belong in the Default configuration, not a start script. Empty agent references / missing model version (mendixlabs/mxcli#1867) and unset runtime constants are not checked: they need a captured agent document (option 2). Fixture `tests/wave2/test-status-extension-modules.sh` — field report from an Agent Editor project, Nov 2026 diff --git a/bin/status.sh b/bin/status.sh index eef8e172..e9c0121a 100755 --- a/bin/status.sh +++ b/bin/status.sh @@ -32,7 +32,13 @@ TOOLKIT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" . "$TOOLKIT_ROOT/bin/lib/placeholders.sh" PROJECT_DIR="${1:-}"; BRIEF=0 for a in "$@"; do case "$a" in --brief) BRIEF=1 ;; esac; done -case "$PROJECT_DIR" in ""|--*) echo "usage: bin/status.sh [--brief]" >&2; exit 1 ;; esac +# No project named: the one the current folder belongs to, by _common.sh's own walk +# (mxtk_walk_root, which resolves an app folder of a multi-app project to the project root). +case "$PROJECT_DIR" in ""|--*) + PROJECT_DIR="$(unset PROJECT_ROOT MPR_FILE MXTK_APP; . "$TOOLKIT_ROOT/project-bin/_common.sh" >/dev/null 2>&1; mxtk_walk_root "$(pwd)" 2>/dev/null)" || PROJECT_DIR="" + [ -n "$PROJECT_DIR" ] && [ -f "$PROJECT_DIR/PROJECT.md" ] \ + || { echo "usage: bin/status.sh [--brief] (no project found from $(pwd))" >&2; exit 1; } ;; +esac PROJECT_DIR="$(cd "$PROJECT_DIR" && pwd)" || { echo "not a directory: $1" >&2; exit 1; } REG="$PROJECT_DIR/PROJECT.md" [ -f "$REG" ] || { echo "no PROJECT.md in $PROJECT_DIR — run bin/init-project.sh first" >&2; exit 1; } diff --git a/project-bin/_common.sh b/project-bin/_common.sh index 86bea7b2..f8a009db 100755 --- a/project-bin/_common.sh +++ b/project-bin/_common.sh @@ -57,9 +57,11 @@ _mxtk_is_project_dir() { # # REFINEMENT OF #489 (maintainer decision, a field run with six apps, 2026-11): an app folder # apps// that is a project folder of its own BECAUSE `mxcli init` ran in it (its own .claude/ -# and PROJECT.md) resolves to the OUTER project when that outer folder is a toolkit multi-app -# project: a PROJECT.md holding register lines (## Current stage, ## Decisions, Entry mode), -# no model at its root or under app/, and apps// holding a model. One register, one LOOK +# and PROJECT.md) resolves to the OUTER project when that outer folder is a multi-app project: +# no model at its root or under app/, apps// holding a model, and a PROJECT.md that EITHER +# sits beside two or more apps// folders holding a model (any content: a field root register +# was hand-written, "- Mode: requirements-driven", none of the sections below) OR holds register +# lines (## Current stage, ## Decisions, Entry mode) — the one-app case. One register, one LOOK # ledger, one set of gates. Keeping the app folder as its root split the ledger (owe rows in # apps//.claude/loop/look/, seen rows at the root) and made MXTK_APP a no-op inside it. Any # other nested project keeps the #489 rule, so a standalone project inside another repo, or an @@ -75,6 +77,12 @@ _mxtk_outer_project() { for f in "$d"/*.mpr; do [ -e "$f" ] && hit=1; done [ "$hit" = 1 ] || return 1 for f in "$p"/*.mpr "$p"/app/*.mpr; do [ -e "$f" ] && return 1; done + # two or more app folders holding a model: the outer folder is the multi-app project + local a n=0 + for a in "$p"/apps/*/; do + for f in "$a"*.mpr; do [ -e "$f" ] && { n=$((n + 1)); break; }; done + [ "$n" -ge 2 ] && { _MXTK_OUTER="$p"; return 0; } + done grep -qiE '^## (Current stage|Decisions)|^[*_ -]*entry mode[*_]*:' "$p/PROJECT.md" 2>/dev/null || return 1 _MXTK_OUTER="$p" } diff --git a/tests/wave2/test-multi-app-scope.sh b/tests/wave2/test-multi-app-scope.sh index 1997375b..f5f2b2ed 100755 --- a/tests/wave2/test-multi-app-scope.sh +++ b/tests/wave2/test-multi-app-scope.sh @@ -14,7 +14,9 @@ # letter case, unknown refused listing apps; mxtk_app_of; MXTK_APP at source time beats the # cwd auto-pick, a user's MPR_FILE beats MXTK_APP; find_mpr still refuses, naming MXTK_APP; # an app folder with its own .claude/ + PROJECT.md resolves to the outer project when that -# holds a register (refinement of #489), keeps its own root when not; one line per app +# has two or more app folders (any PROJECT.md, a hand-written one too) or, for one app, a +# register (refinement of #489), keeps its own root otherwise; status.sh with no argument +# finds the project from an app subfolder; one line per app # folder (a second .mpr is not a second app; "-" and a refusal when none is .mpr) # A2 single tree and two-tree: mxtk_apps prints nothing (rc 1) and mxtk_app_count is 0, even # with an apps/ folder holding a model beside the root model @@ -98,7 +100,16 @@ has "A1 find_mpr refuses" "$r" "refusing to guess"; has "A1 refusal names MXTK_A # outer project with a register they resolve to the OUTER project (refinement of #489). r="$(clean_env bash -c "cd '$P/apps/AppB/docs'; . '$COMMON'; echo \"\$PROJECT_ROOT|\$MPR_FILE\"")" eq "A1 app folder with its own .claude/ resolves to the outer project" "$r" "$P|$P/apps/AppB/AppB.mpr" -# ... and keep their own root when the outer PROJECT.md holds no register lines (#489 unchanged) +# ... also under a HAND-WRITTEN outer register (the field root: "- Mode: requirements-driven", +# none of the toolkit's sections): two or more app folders make it the multi-app project +cp "$P/PROJECT.md" "$T/root-register" +printf '# Project\n\n- Owner: someone\n- Mode: requirements-driven (from specs)\n' > "$P/PROJECT.md" +r="$(clean_env bash -c "cd '$P/apps/AppD'; . '$COMMON'; echo \"\$PROJECT_ROOT|\$MPR_FILE\"")" +eq "A1 hand-written outer register: an app cwd resolves to the outer root" "$r" "$P|$P/apps/AppD/AppD.mpr" +st="$(cd "$P/apps/AppB/docs" && clean_env bash "$TK/bin/status.sh" --brief 2>&1)" +has "A1 status.sh with no argument, from an app subfolder, finds the project" "$st" "APP AppF: apps/AppF/AppF.mpr" +cp "$T/root-register" "$P/PROJECT.md" +# ... and keep their own root when the outer folder holds ONE app and no register lines (#489 unchanged) N="$T/nested"; mkdir -p "$N/apps/X/.claude" "$N/.claude"; : > "$N/PROJECT.md"; : > "$N/apps/X/PROJECT.md"; : > "$N/apps/X/X.mpr" r="$(clean_env bash -c "cd '$N/apps/X'; . '$COMMON'; echo \"\$PROJECT_ROOT\"")" eq "A1 no outer register: the app folder keeps its own root" "$r" "$N/apps/X" From d70a02ef49d046bac377bd538e4b6e06f698dd56 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:45:42 +0000 Subject: [PATCH 07/11] test(multi-app): pin the one-app outer-register case (deliberate change from #489) A single apps/X/ with its own .claude/ + PROJECT.md under an outer folder whose PROJECT.md holds a register (## Current stage) resolves to the outer folder; master keeps apps/X. Kept on purpose (one register), pinned per the #789 re-review. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 2 +- tests/wave2/test-multi-app-scope.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10f55ad2..59ffcbd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased -- fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that is a multi-app project** (no model at its root or under `app/`, and a `PROJECT.md` beside two or more app folders holding a model — any content, since a field root register was hand-written — or, for one app, a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap; `status.sh` with no argument finds the project from the current folder (an app subfolder included) instead of printing usage — from the independent review of #789 on a field run's six-app tree +- fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that is a multi-app project** (no model at its root or under `app/`, and a `PROJECT.md` beside two or more app folders holding a model — any content, since a field root register was hand-written — or, for one app, a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line — for that one-app case a deliberate change from #489, where `apps/X` kept its own root) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap; `status.sh` with no argument finds the project from the current folder (an app subfolder included) instead of printing usage — from the independent review of #789 on a field run's six-app tree - new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. The root `PROJECT.md` is the one register: an app's own `PROJECT.md` (from `mxcli init` per app; the field repo held seven) that holds register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,155 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/` from a field repo's `git ls-files`, six apps, anonymised — see its PROVENANCE.txt) — two field runs, Nov 2026 - new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 - process(obligations): **`bin/lib/obligations.tsv` gains column 10 `modes`, the same column, tokens and tokeniser as `artifact-manifest.tsv` (`migration,requirements,greenfield,existing-app-change`, read through artifact-check.sh's own `_art_entry_mode`, never a second copy of its mapping)**: a row the register's `Entry mode:` does not list reads `N/A — not owed (entry mode …)`, never PASS; no or unrecognised mode = owed. Every row lists all four modes today, so no verdict changes; the column lets a mode that genuinely skips a pass be excused by data instead of by absence. Fixture `test-obligation-quality-floor.sh` T9 — follow-up to #787 diff --git a/tests/wave2/test-multi-app-scope.sh b/tests/wave2/test-multi-app-scope.sh index f5f2b2ed..befbe5da 100755 --- a/tests/wave2/test-multi-app-scope.sh +++ b/tests/wave2/test-multi-app-scope.sh @@ -113,6 +113,13 @@ cp "$T/root-register" "$P/PROJECT.md" N="$T/nested"; mkdir -p "$N/apps/X/.claude" "$N/.claude"; : > "$N/PROJECT.md"; : > "$N/apps/X/PROJECT.md"; : > "$N/apps/X/X.mpr" r="$(clean_env bash -c "cd '$N/apps/X'; . '$COMMON'; echo \"\$PROJECT_ROOT\"")" eq "A1 no outer register: the app folder keeps its own root" "$r" "$N/apps/X" +# ONE app under an outer folder WITH a real register (toolkit-scaffolded: ## Current stage): +# resolves to the outer folder. A deliberate change from #489, where apps/X kept its own root +# (one register is the intent; reviewer of #789 asked for it to be pinned). +printf '# Project\n\n## Current stage\n**Stage 1 — x**\n' > "$N/PROJECT.md" +r="$(clean_env bash -c "cd '$N/apps/X'; . '$COMMON'; echo \"\$PROJECT_ROOT\"")" +eq "A1 one app, outer register: resolves to the outer project (deliberate change from #489)" "$r" "$N" +: > "$N/PROJECT.md" # one line per app FOLDER: a second .mpr does not make a second app : > "$P/apps/AppC/Copy.mpr"; mv "$P/apps/AppD/AppD.mpr" "$P/apps/AppD/Zz.mpr"; : > "$P/apps/AppD/Other.mpr" r="$(clean_env bash -c "cd '$P'; . '$COMMON'; mxtk_apps | grep -E '^App[CD]'; echo n=\$(mxtk_app_count)")" From 9cbe111b221d0fccf61f491e049fbf6561653ca4 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 13:28:31 +0000 Subject: [PATCH 08/11] chore(changelog): keep #789's three lines under Unreleased after the v2026.11.17 release merge The release (#794) turned ## Unreleased into ## v2026.11.17; the merge left #789's unreleased lines inside the released section. #789 is held and not in that release. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4bb3025..32382fca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that is a multi-app project** (no model at its root or under `app/`, and a `PROJECT.md` beside two or more app folders holding a model — any content, since a field root register was hand-written — or, for one app, a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line — for that one-app case a deliberate change from #489, where `apps/X` kept its own root) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap; `status.sh` with no argument finds the project from the current folder (an app subfolder included) instead of printing usage — from the independent review of #789 on a field run's six-app tree +- new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. The root `PROJECT.md` is the one register: an app's own `PROJECT.md` (from `mxcli init` per app; the field repo held seven) that holds register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,155 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/` from a field repo's `git ls-files`, six apps, anonymised — see its PROVENANCE.txt) — two field runs, Nov 2026 +- new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 ## v2026.11.17 - fix(exec, ready, gate-check): **unattended mode is recognised by its first word, and an agent cannot approve its own skipped plan** (composition review of the entry-mode PRs): one helper, `mxtk_auto_word` (`project-bin/_position.sh`), now decides "is this Interview mode unattended" for `exec.sh`, `gate-check.sh --adopt` and `ready.sh` — a register line `Interview mode: auto (gate questions go to questions.md …)` was read as attended by the first two, and in a field smoke run the second write of an unattended build got past the plan rule on refuse-once. `ready.sh` reports NOT READY (row `adoption`, named in the evidence file) while any `consentBy: auto-mode` adoption row is unconfirmed — the ✋ only failed Stage 6, which ready.sh does not run before the register reaches Stage 6. Auto is now the STRICTEST of `$CLAUDE_INTERVIEW_MODE`, `.claude/.interview-mode` and the register line, so `CLAUDE_INTERVIEW_MODE=steering` no longer overrides a register that says auto (intended: an override must not quietly switch the unattended guards off). Under auto, a project with no `Entry mode:` is refused like a pipeline mode until build-ready passes or it adopts (attended: banner only, as before). Checkpoint skills no longer describe greenfield as a live mode. Fixtures: `test-mode-contract.sh` W and U, `test-ready.sh` R4 — composition review of #790–#792, Nov 2026 @@ -26,9 +29,6 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m - new(ci, ready): **the gate an agent cannot skip, and a READY nobody can hand-write.** `bin/ci-gates.sh` runs in the project's own CI (`.github/workflows/toolkit-gates.yml`, from `templates/ci/`, installed by `init-project.sh` and `sync-project.sh` create-if-absent, never overwritten, beside any existing CI) on every push and PR, over the committed tree at the pinned toolkit commit: the claimed stage's gate FAILs, a READY line `bin/ready.sh` did not write (`bin/lib/ready-claims.sh`, also a Stage 6 FAIL), committed unseen pages under a done-claim, and model work before Stage 4 all fail it (otherwise it prints `look: K of N pages seen` as a visible warning), in seconds, with no Mendix runtime. `ready.sh` now also requires the position (stages P and 0–4 PASS, WAIVED or not owed by the entry mode: a field run wrote READY with Stage P never passed), honours `Waived obligation must-haves`, writes a review packet (`docs/progress/review-packets/.html`: screenshot beside target with the reviewer's score, paths only), reads the must-have mark on its tracked path `docs/progress/must-haves/.md`, and names every app of a multi-app project instead of checking nothing (field runs, 2026-11: agents skip in-session gates; a hand-written READY graded a 0-of-78-looked build done) — two unattended field runs - new(ready, look-ledger, gate-check): **READY is earned through one command, and its evidence is in git.** `bin/ready.sh [--module M | --app A]` runs `gate-check.sh` Stage 5 (Stage 6 once the register is there), the look ledger, the must-have list when present and, under `Interview mode: auto`, an independent reviewer's verdict file (`docs/progress/look-reviews/`, every page scored 1–5 after its last build, below 4 blocks); it prints K of N per check, exits non-zero unless all pass, writes the READY line to `docs/progress/ready.log` itself and commits `docs/progress/ready--.md` with explicit paths. `look-ledger.sh summary --write` puts the git-ignored ledger into a tracked `docs/progress/look-summary.tsv` (written by `ready.sh` and every `close-task.sh`), and `gate-check.sh` Stage 5 reads it when the ledger is absent, so a copy of the repo reports FAIL instead of MANUAL. `dispatching.md` gains the reviewer dispatch rule; the `ready` routing row reaches `CLAUDE.local.md` and every agent stub (field runs, 2026-11: a build wrote READY by hand with 0 of ~78 pages looked at; another marked itself ready 3 hours early with no review pass) — two unattended field runs - process(entry modes): **greenfield is retired; two doors replace it** (stacked on the mode-contract PR): an idea for a demo is `Build type: poc` (unchanged), an idea for a real app is requirements-driven with the conversation as the source (Stages 1–2 a short interview that writes the BRDs, then 3–6 as usual; the small-project tier and `Pipeline mode: high-speed` keep it light) — no mode skips design and planning any more. `sync-project.sh` maps a register's `Entry mode: greenfield` to `requirements-driven` once (old line kept as a comment), adopted at the stage its readout shows through `gate-check.sh --adopt` (so under `Interview mode: auto` it is a ✋ human-pending decision), with `ENTRY-MODE-MAPPED` and `TOOLKIT-ADOPTED-AT` rows in `docs/BUILD-LOG.md`. `greenfield` is dropped from `artifact-manifest.tsv` column 6 and `obligations.tsv` column 10 (now `migration,requirements,existing-app-change`; `test-mode-contract.sh` V checks both against the reader). Until synced, gate-check, status and exec.sh print one "run sync" line and excuse nothing (the tokeniser reads it as `greenfield-retired`; the artifact check owes every row). A POC that becomes a real app hands its hand-over to a requirements-driven build or starts change-an-existing-app, stated once in the runbook (rule 4). `poc-build.md` gains step 0 "Inputs" (read a supplied spec once, list use cases/rules/must-haves; over POC size, recommend requirements-driven in the same message). Runbook, intake Q1, interview-protocol, README, toolkit-guide, `CONVERSION-RUNBOOK.md`, `pipeline-walks.html` and 12 skills' mode lists updated; the 2026-07-14 misclassification note is kept. Fixture `tests/wave2/test-greenfield-retired.sh` — owner decision, Nov 2026 -- fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that is a multi-app project** (no model at its root or under `app/`, and a `PROJECT.md` beside two or more app folders holding a model — any content, since a field root register was hand-written — or, for one app, a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line — for that one-app case a deliberate change from #489, where `apps/X` kept its own root) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap; `status.sh` with no argument finds the project from the current folder (an app subfolder included) instead of printing usage — from the independent review of #789 on a field run's six-app tree -- new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. The root `PROJECT.md` is the one register: an app's own `PROJECT.md` (from `mxcli init` per app; the field repo held seven) that holds register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,155 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/` from a field repo's `git ls-files`, six apps, anonymised — see its PROVENANCE.txt) — two field runs, Nov 2026 -- new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 - process(obligations): **`bin/lib/obligations.tsv` gains column 10 `modes`, the same column, tokens and tokeniser as `artifact-manifest.tsv` (`migration,requirements,greenfield,existing-app-change`, read through artifact-check.sh's own `_art_entry_mode`, never a second copy of its mapping)**: a row the register's `Entry mode:` does not list reads `N/A — not owed (entry mode …)`, never PASS; no or unrecognised mode = owed. Every row lists all four modes today, so no verdict changes; the column lets a mode that genuinely skips a pass be excused by data instead of by absence. Fixture `test-obligation-quality-floor.sh` T9 — follow-up to #787 - fix(obligations): **`Must-haves: advisory` for projects already past Stage 5 when the must-haves row arrived (follow-up to #787)**: `sync-project.sh` writes one `Must-haves:` line into `PROJECT.md` when none exists, and only then: `advisory — joined at stage N before the must-haves row existed` when gate-check's derived Current stage or `Adopted at stage:` is 6 or 7, else `bound`. `init-project.sh` writes `bound` for new projects. An advisory project's `Obligation must-haves` row reads `ADVISORY` and is left out of the pending count; `bound` keeps PENDING. It is keyed on the written line, not the project's position: a position check would silence a new project the day it passed Stage 5 without the marks. Fixture `tests/wave2/test-must-haves-advisory.sh` — owner request at the review of #787 - fix(obligations): **a quality floor in every entry mode: no per-module obligation reads PASS by absence, and a new `must-haves` row owes one mode-independent checklist per module**: with no module brief and no verify run, `obligation-check.sh` printed `Obligation look PASS — no module has been opened for work yet; nothing owed` (and the same for fidelity, sweep, journeys) on a project that had built ~78 pages and reviewed 0. Now an empty planned scope falls back to the modules that hold built pages, read from the look ledger (`.claude/loop/look/owed.tsv`), else page statements in the project's `*.mdl` scripts, else `.claude/loop/page-scope.json`, each looked for at the root, `app/` and `apps/*/`; every module row reads PENDING with an `OWED BY WHAT WAS BUILT: N page(s) built in M module(s) (...), K of M module(s) discharged` line. A model that has been built on (exec rows in `docs/BUILD-LOG.md`, `*.mdl` scripts, or a derived stage at 5+) with no countable pages is one FAULT naming `bin/page-scope.sh`, never "0 pages"; a `.mpr` with no build evidence (a fresh scaffold) keeps master's PASS line, so `bin/status.sh` still reads `modules opened: 0`. `existing-app-change` never takes scope from `page-scope.json`, which lists the whole model. A project with briefs keeps every earlier verdict. `skills/must-haves.md` (new, on demand) is the single source of poc-build.md's 12-row must-have checklist, generalised to every build type, plus row 13: every region the design shows is on the built page, counted; `poc-build.md` points to it, `module-review.md` stage 5 requires its mark `docs/progress/must-haves/.md` (first line `13 of 13 rows ticked or NOT DONE with a reason`). Informational, like every obligation row: no gate verdict or exit code changes; synced projects at Stage 5+ gain one `must-haves` PENDING row per module. Always-loaded words 64,984 -> 65,032 (budget 80,000). Fixture `tests/wave2/test-obligation-quality-floor.sh` — two field runs, unattended and requirements-driven, Nov 2026 From 2cb9d705d0d678e600f8d823e0951286770ea345 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:08:34 +0000 Subject: [PATCH 09/11] fix(ready): read the per-app look ledger so a multi-app project can reach READY ready.sh marked every app NOT MEASURED ('the look ledger is not kept per app yet'), so a four-app build could never be READY. A whole-project run now prints one app: row per app from look-ledger.sh status --by-app (K of N seen, unseen pages named) and needs every app's row; --app scopes the gate-check stage 5 and ledger steps to that app via MXTK_APP. Single-tree output is byte-identical to 8aa2ac6. Fixture: test-ready.sh R11 (two apps). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 1 + bin/ready.sh | 49 +++++++++++++++++++++++++++++++-------- tests/wave2/test-ready.sh | 42 +++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32382fca..9ad649dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- fix(ready, multi-app): **`bin/ready.sh` reads the per-app look ledger, so a multi-app project can reach READY**: it printed `NOT MEASURED — the look ledger is not kept per app yet` for every app, so a four-app build could never be READY. Now a whole-project run prints one `app:` row per app, `K of N page(s) seen since their last build` with the unseen pages named (`look-ledger.sh status --by-app`), and READY needs every app's row; `--app ` scopes the gate-check stage 5 and ledger steps to that app (`MXTK_APP`). A single-tree project's output is byte-identical. Fixture `test-ready.sh` R11 (two apps: one looked, one not, then both) — requested for the multi-app trial of #789 - fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that is a multi-app project** (no model at its root or under `app/`, and a `PROJECT.md` beside two or more app folders holding a model — any content, since a field root register was hand-written — or, for one app, a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line — for that one-app case a deliberate change from #489, where `apps/X` kept its own root) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap; `status.sh` with no argument finds the project from the current folder (an app subfolder included) instead of printing usage — from the independent review of #789 on a field run's six-app tree - new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. The root `PROJECT.md` is the one register: an app's own `PROJECT.md` (from `mxcli init` per app; the field repo held seven) that holds register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,155 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/` from a field repo's `git ls-files`, six apps, anonymised — see its PROVENANCE.txt) — two field runs, Nov 2026 - new(_common, multi-app): **a repo holding several apps (`apps//.mpr`, one `mdlsource/` per app) gets a resolver interface every reader can scope by**: `project-bin/_common.sh` adds `mxtk_apps` (one line per app), `mxtk_app_count`, `mxtk_select_app ` (exports `MPR_FILE` + `MXTK_APP`) and `mxtk_app_of `, and honours `MXTK_APP=` at source time (a user's `MPR_FILE` still wins; the cwd auto-pick never does). `find_mpr` still refuses two models and now names `MXTK_APP`. Single-tree and two-tree projects are never multi-app: `mxtk_apps` prints nothing there — two field runs, Nov 2026 diff --git a/bin/ready.sh b/bin/ready.sh index 2a559022..ce3183e4 100755 --- a/bin/ready.sh +++ b/bin/ready.sh @@ -4,7 +4,9 @@ # # Usage: bin/ready.sh [--module | --app ] [--no-commit] # --module M scope every check to module M (its pages, its must-have list, its review) -# --app A the whole app, labelled A (default: the whole project, labelled "app") +# --app A the whole app, labelled A (default: the whole project, labelled "app"). In a +# multi-app project (apps//.mpr) it reads app A's pages only; with no +# --app there, every app gets its own row and READY needs each of them. # --no-commit write the files, leave committing to the caller # Exit 0 READY, 1 NOT READY, 2 usage. Bash 3.2 compatible. # @@ -133,14 +135,41 @@ step "apps: multi-app resolver" "$TMP/apps" env PROJECT_ROOT="$ROOT" bash -c \ '. "$1/project-bin/_common.sh" >/dev/null 2>&1; type mxtk_apps >/dev/null 2>&1 && mxtk_apps "$2" 2>/dev/null | cut -f1' _ "$TOOLKIT_ROOT" "$ROOT" apps="$(cat "$TMP/apps" 2>/dev/null)" [ -n "$apps" ] || apps="$(ls -d "$ROOT"/apps/*/ 2>/dev/null | while IFS= read -r d; do ls "$d"*.mpr >/dev/null 2>&1 && basename "$d"; done)" +MULTI=0 if [ "$(printf '%s\n' "$apps" | sed '/^$/d' | wc -l | tr -d ' ')" -ge 2 ]; then - # Never "nothing checked": every app is named, and none is READY until the ledger is per app. - for a in $apps; do - [ -z "$APP" ] || [ "$APP" = "$a" ] || continue - row fail "app:$a" "NOT MEASURED — the look ledger is not kept per app yet, so no check here can be read for app $a alone" - done - [ -z "$APP" ] || printf '%s\n' $apps | grep -qx "$APP" || row fail scope "no app $APP here; apps: $(printf '%s ' $apps)" + MULTI=1 + # Never "nothing checked": every app is named and gets its own row, from the look ledger kept per + # app (look-ledger.sh status --by-app: one project ledger, the app as a column). READY needs every + # app's row to pass. With --app only A is read, and MXTK_APP=A scopes the gate-check and + # ledger steps below to it. A field build had four apps, and with no per-app row it could + # never reach READY. + if [ -n "$APP" ] && ! printf '%s\n' $apps | grep -qx "$APP"; then + row fail scope "no app $APP here; apps: $(printf '%s ' $apps)" + else + : > "$TMP/byapp" + if [ -s "$ROOT/.claude/loop/look/owed.tsv" ]; then + step "apps: look ledger per app" "$TMP/byapp" env PROJECT_ROOT="$ROOT" MPR_FILE= MXTK_APP= bash "$LEDGER" status --by-app || : > "$TMP/byapp" + fi + for a in $apps; do + [ -z "$APP" ] || [ "$APP" = "$a" ] || continue + n="$(awk -F'\t' -v a="$a" '$4 == a { t++ } END { print t + 0 }' "$TMP/byapp")" + k="$(awk -F'\t' -v a="$a" '$4 == a && $1 == "SEEN" { t++ } END { print t + 0 }' "$TMP/byapp")" + if [ "$n" -eq 0 ]; then + if [ -f "$REG" ] && grep -qiE "^[-*[:space:]]*Waived obligation look/$a[[:space:]]*:" "$REG"; then + row ok "app:$a" "WAIVED — Waived obligation look/$a in PROJECT.md" + else + row fail "app:$a" "NOT MEASURED — no page of app $a recorded as built in the look ledger (.claude/loop/look/owed.tsv): the denominator is unknown" + fi + elif [ "$k" -lt "$n" ]; then + row fail "app:$a" "$k of $n page(s) seen since their last build — unseen: $(awk -F'\t' -v a="$a" '$4 == a && $1 != "SEEN" { printf "%s%s", s, $2; s = ", " }' "$TMP/byapp")" + else + row ok "app:$a" "$n of $n page(s) seen since their last build" + fi + done + fi fi +# One app chosen: the gate-check and ledger steps below read that app only (the resolver's MXTK_APP). +SCOPE_ENV="MXTK_APP="; [ "$MULTI" = 1 ] && [ -n "$APP" ] && SCOPE_ENV="MXTK_APP=$APP" # --- position: every stage before Build passed, waived (adopted) or not owed by the entry mode --- # A field run wrote READY with no stage past P ever passed (pinned gate-check: Stage P FAIL). A look @@ -173,7 +202,7 @@ else fi # --- gate 5 --------------------------------------------------------------------------------- -step "gate5: gate-check stage 5" "$TMP/g5" env MXTK_LOOK_MODULE="$MOD" bash "$GC" --no-html "$ROOT" 5; rc5=$? +step "gate5: gate-check stage 5" "$TMP/g5" env "$SCOPE_ENV" MXTK_LOOK_MODULE="$MOD" bash "$GC" --no-html "$ROOT" 5; rc5=$? g5="$(cat "$TMP/g5")" l5="$(printf '%s\n' "$g5" | grep -m1 '^Stage 5 (' | sed 's/^Stage 5 ([^)]*): //')" v5="$(printf '%s' "$l5" | awk '{print $1}')" @@ -220,8 +249,8 @@ fi # per-page facts for the evidence file and the review join: state, page, built-epoch, shot if [ -s "$ROOT/.claude/loop/look/owed.tsv" ]; then step "look: ledger summary" "$TMP/sum" env PROJECT_ROOT="$ROOT" bash "$LEDGER" summary --write - step "look: ledger status" "$TMP/st" env PROJECT_ROOT="$ROOT" bash "$LEDGER" status || : > "$TMP/st" - step "look: screenshots seen" "$TMP/shots" env PROJECT_ROOT="$ROOT" bash "$LEDGER" status --shots || : > "$TMP/shots" + step "look: ledger status" "$TMP/st" env "$SCOPE_ENV" PROJECT_ROOT="$ROOT" bash "$LEDGER" status || : > "$TMP/st" + step "look: screenshots seen" "$TMP/shots" env "$SCOPE_ENV" PROJECT_ROOT="$ROOT" bash "$LEDGER" status --shots || : > "$TMP/shots" else : > "$TMP/st"; : > "$TMP/shots" fi diff --git a/tests/wave2/test-ready.sh b/tests/wave2/test-ready.sh index 1cd4b217..1c0da2b1 100755 --- a/tests/wave2/test-ready.sh +++ b/tests/wave2/test-ready.sh @@ -8,6 +8,8 @@ # `look-ledger.sh owe` from a build script in the captured statement shapes, and the seen ledger # by the real `seen` hook from Claude Code's PostToolUse JSON. Nothing in .claude/loop/ is typed. # +# R11 adds a two-app project (apps//.mpr): ready.sh reads the per-app look ledger. +# # Usage: bash tests/wave2/test-ready.sh [path-to-bin/ready.sh] SUBJECT="${1:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/bin/ready.sh}" @@ -189,5 +191,45 @@ start=$(date +%s); out="$(MXTK_READY_STEP_TIMEOUT=0 bash "$SUBJECT" "$P" --no-co && printf '%s\n' "$out" | grep -q 'FAIL gate5 NOT MEASURED' && printf '%s\n' "$out" | grep -q '^NOT-READY' \ && ok "R9: every step killed at its timeout → NOT READY in ${took}s, each stalled step named" || bad "R9: rc=$rc took=${took}s $out" +# ── R11: two apps (apps//.mpr): one row per app from the per-app look ledger ───────── +# READY needs every app's row; NOT READY names the app and its unseen page; --app A reads A only. +P="$WORK/r11" +mkdir -p "$P/bin" "$P/shots" "$P/docs/progress/must-haves" "$P/apps/A/mdlsource" "$P/apps/B/mdlsource" +: > "$P/apps/A/A.mpr"; : > "$P/apps/B/B.mpr" +cp "$TK/project-bin/look-ledger.sh" "$TK/project-bin/_common.sh" "$P/bin/" +printf '# PROJECT.md\n\n## Current stage\n\n**Stage P — Kickoff**, in progress.\n\n' > "$P/PROJECT.md" +printf '.claude/loop/\n' > "$P/.gitignore" +printf 'Approval · 2 of 2 rows ticked\n1 TICKED — inbox lists open requests\n2 TICKED — decide records the decision\n' > "$P/docs/progress/must-haves/Approval.md" +printf 'Billing · 1 of 1 rows ticked\n1 TICKED — invoice shows its lines\n' > "$P/docs/progress/must-haves/Billing.md" +cat > "$P/apps/A/mdlsource/20-approval-pages.mdl" <<'MDL' +CREATE PAGE "Approval"."Dashboard" +( + Title: 'Dashboard' +) { } +create or replace page Approval.Approval_Inbox (Title: 'Approval inbox') { } +CREATE OR MODIFY PAGE Approval.Approval_Decide { +} +MDL +printf 'CREATE OR MODIFY PAGE Billing.Invoice_View {\n}\n' > "$P/apps/B/mdlsource/30-billing.mdl" +(cd "$P" && bash bin/look-ledger.sh owe "$P/apps/A/mdlsource/20-approval-pages.mdl" >/dev/null \ + && bash bin/look-ledger.sh owe "$P/apps/B/mdlsource/30-billing.mdl" >/dev/null) +bash "$TK/bin/gate-check.sh" --no-html --waive P --reason "fixture: kickoff held elsewhere" "$P" >/dev/null 2>&1 +bash "$TK/bin/gate-check.sh" --no-html --adopt 5 --reason "fixture: joins at build" "$P" >/dev/null 2>&1 +G "$P" init -q; G "$P" add -A; G "$P" commit -qm scaffold +see_all "$P" +run "$P" --no-commit +[ "$rc" = 1 ] && printf '%s\n' "$out" | grep -q 'PASS app:A 3 of 3 page(s) seen' \ + && printf '%s\n' "$out" | grep -q 'FAIL app:B 0 of 1 page(s) seen since their last build — unseen: Billing.Invoice_View' \ + && ok "R11: two apps, B unlooked → NOT READY, app:B named with its unseen page" || bad "R11: rc=$rc $out" +run "$P" --app A --no-commit +[ "$rc" = 0 ] && printf '%s\n' "$out" | grep -q 'look 3 of 3' && ! printf '%s\n' "$out" | grep -q 'app:B' \ + && ok "R11: --app A reads A only → READY, 3 of 3" || bad "R11 --app A: rc=$rc $out" +see "$P" invoice_view-1280 J-APP-01-step1.png +run "$P" --no-commit +[ "$rc" = 0 ] && printf '%s\n' "$out" | grep -q 'PASS app:B 1 of 1' && printf '%s\n' "$out" | grep -q 'look 4 of 4' \ + && ok "R11: both apps looked → READY" || bad "R11 both: rc=$rc $out" +run "$P" --app Nope --no-commit +[ "$rc" = 1 ] && printf '%s\n' "$out" | grep -q 'FAIL scope no app Nope here' && ok "R11: an unknown --app is named, NOT READY" || bad "R11 Nope: rc=$rc $out" + echo "PASS=$PASS FAIL=$FAIL" [ "$FAIL" -eq 0 ] From b2546d8e035851704e16484c73e3ac6e9b459a33 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:25:53 +0000 Subject: [PATCH 10/11] fix(exec): relative _XD and script path no longer skip the plan rule after the cd _XD="${0%/*}" stayed relative (../../bin); after exec.sh's cd to the project root the guard [ -f "$_XD/_position.sh" ] failed in silence, so 'cd apps/Orders && ../../bin/exec.sh ../../mdlsource/x.mdl' wrote under Interview mode: auto while the same call by absolute path was refused. A relative MDL script path broke every [ -f "$SCRIPT" ] guard the same way. Both are made absolute before the cd, only when the caller is not at the project root, so a run from the root is unchanged. Fixture: test-mode-contract.sh X. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HXpQSmcGH9hcq6GdHyLxdh --- CHANGELOG.md | 1 + project-bin/exec.sh | 11 +++++++++++ tests/wave2/test-mode-contract.sh | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad649dd..9278bb94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- fix(exec): **`exec.sh` called by relative paths from another folder no longer skips the plan rule**: `_XD="${0%/*}"` stayed relative (`../../bin`), and after exec.sh's `cd` to the project root the guard `[ -f "$_XD/_position.sh" ]` failed in silence, so `cd apps/Orders && ../../bin/exec.sh ../../mdlsource/x.mdl` wrote under `Interview mode: auto` where the same call by absolute path was refused; a relative MDL script path broke every `[ -f "$SCRIPT" ]` guard the same way. Both are made absolute before the `cd`, only when the caller is not at the project root (a run from the root is unchanged). Arguments passed through to a `--patch` script are still taken as given. Fixture `test-mode-contract.sh` X — independent review of #789 - fix(ready, multi-app): **`bin/ready.sh` reads the per-app look ledger, so a multi-app project can reach READY**: it printed `NOT MEASURED — the look ledger is not kept per app yet` for every app, so a four-app build could never be READY. Now a whole-project run prints one `app:` row per app, `K of N page(s) seen since their last build` with the unseen pages named (`look-ledger.sh status --by-app`), and READY needs every app's row; `--app ` scopes the gate-check stage 5 and ledger steps to that app (`MXTK_APP`). A single-tree project's output is byte-identical. Fixture `test-ready.sh` R11 (two apps: one looked, one not, then both) — requested for the multi-app trial of #789 - fix(_common, multi-app): **an app folder that is a project of its own because `mxcli init` ran in it (its own `.claude/` + `PROJECT.md`) resolves to the OUTER project when that is a multi-app project** (no model at its root or under `app/`, and a `PROJECT.md` beside two or more app folders holding a model — any content, since a field root register was hand-written — or, for one app, a `PROJECT.md` with `## Current stage`, `## Decisions` or an Entry mode line — for that one-app case a deliberate change from #489, where `apps/X` kept its own root) — a stated refinement of #489, decided by the maintainer: one register, one LOOK ledger, one set of gates. Before it, `look-ledger owe` from an app folder wrote `apps//.claude/loop/look/owed.tsv` while `seen` wrote the root's (the ledger split), and `MXTK_APP` was a no-op inside an app folder. Any other nested project keeps its own root. Also: `mxtk_apps` lists one line per app FOLDER (`.mpr` preferred; `-` and a refusal when it holds several and none is named for it); an env `MXTK_APP` that does not apply is dropped by gate-check instead of exiting 2 (an explicit `--app` still errors); the per-app readers compute the app list once and read the LOOK ledger once (`look-ledger.sh status --by-app`), status on six apps 1.41 s -> 1.03 s; no "from the shared" label without a shared fit-gap; `status.sh` with no argument finds the project from the current folder (an app subfolder included) instead of printing usage — from the independent review of #789 on a field run's six-app tree - new(gate-check, status, look-ledger, init, sync): **multi-app projects are reported per app, never "nothing checked"**: with two or more `apps//.mpr` and no app chosen, `gate-check.sh` prints `Marketplace installs: per app (N apps)` with one `[App]` line each (an app's own `architecture/apps//fit-gap.md` can FAIL; a package missing through the shared fit-gap reads PENDING, since it does not say which app owes it, and a finding that reads the same for several apps prints once, `[all N apps, from the shared architecture/fit-gap.md]`; build-ready counts a FAIL) and an `Apps:` section with each app's model, `mdlsource/` scripts and LOOK debt (with no ledger — it is git-ignored — `LOOK: no ledger here (N page(s) in its scripts)`, never "no pages owed"); `status.sh` prints one `APP` line per app (`bin/lib/app-scope.sh`, shared). `--app ` (gate-check, `look-ledger.sh status`) or `MXTK_APP=` scopes a run to one app. The LOOK ledger stays one file keyed by app: owed rows gain a 5th column only in a multi-app tree. `init-project.sh` / `sync-project.sh` scaffold `architecture/apps//{intake,triage}.md` and the index `architecture/apps/README.md` (one shared build plan, one `## App:` section each), and the Wiring rows name the app selection; module briefs stay in `architecture/modules/` with an `**App:**` line. The root `PROJECT.md` is the one register: an app's own `PROJECT.md` (from `mxcli init` per app; the field repo held seven) that holds register lines (Entry mode, Current stage, Adopted at stage, CONFIRMED/ASSUMED rows) gets a warn-only line in gate-check's Apps section, status WATCH and a sync note. Convention: `skills/module-folder-convention.md` § Several apps in one repo (baseline 64,984 -> 65,155 words). Single-tree and two-tree output is byte-identical to before. Fixture `tests/wave2/test-multi-app-scope.sh` (tree shape in `fixtures/multi-app/` from a field repo's `git ls-files`, six apps, anonymised — see its PROVENANCE.txt) — two field runs, Nov 2026 diff --git a/project-bin/exec.sh b/project-bin/exec.sh index ae8a503d..c4a721a7 100755 --- a/project-bin/exec.sh +++ b/project-bin/exec.sh @@ -625,6 +625,17 @@ if [ -n "$CHANGE_CLASS" ]; then fi fi +# Paths taken relative to the CALLER's folder stop resolving at the cd below. `cd apps/Orders && +# ../../bin/exec.sh ../../mdlsource/x.mdl` left _XD="../../bin", so the plan-rule guard +# `[ -f "$_XD/_position.sh" ]` failed in silence and an unattended write went through, while the +# same call by absolute path was refused (review of #789). The script path was used the same way +# by every [ -f "$SCRIPT" ] guard after the cd. Both are made absolute HERE, and only when the +# caller is not already at the project root, so a run from the root prints what it always did. +if [ "$PWD" != "$PROJECT_ROOT" ]; then + case "$_XD" in /*) ;; *) _XD="$(cd "$_XD" && pwd)" ;; esac + case "$SCRIPT" in /*) ;; *) [ -f "$SCRIPT" ] && SCRIPT="$(cd "$(dirname "$SCRIPT")" && pwd)/$(basename "$SCRIPT")" ;; esac +fi + cd "$PROJECT_ROOT" # ── Build log (auto) ───────────────────────────────────────────────────────── diff --git a/tests/wave2/test-mode-contract.sh b/tests/wave2/test-mode-contract.sh index 812d09fb..1e7bdb9d 100755 --- a/tests/wave2/test-mode-contract.sh +++ b/tests/wave2/test-mode-contract.sh @@ -18,6 +18,8 @@ # W `Interview mode: auto (...)` / `unattended — ...` read as auto (first word) in exec.sh and # in gate-check.sh's --adopt ✋ check; `autopilot` is not # U no Entry mode under auto is refused every write; attended keeps the banner only +# X exec.sh called by relative paths from inside apps/ (../../bin/exec.sh +# ../../mdlsource/x.mdl) is refused under auto exactly as the absolute call is # G init-project.sh over a hand-written PROJECT.md appends Current stage, Decisions, Open # questions and Change log, says so, and keeps the hand-written lines # @@ -110,6 +112,27 @@ G="$("$GC" "$P" 2>&1)" n="$(printf '%s\n' "$G" | grep -cE '^Stage [0-4] .*not owed \(mode: Build type: poc\)|^Stage [67] .*not owed \(mode: Build type: poc\)')" [ "$n" = 7 ] && ok "K stages 0-4, 6, 7 not owed (mode) — 7 of 7" || bad "K stages 0-4, 6, 7 not owed (mode)" "$n of 7" +echo "-- X: exec.sh called by RELATIVE paths from inside an app folder (review of #789)" +# _XD="${0%/*}" was relative (../../bin); after exec.sh's cd to the project root the plan-rule +# guard [ -f "$_XD/_position.sh" ] failed in silence and the unattended write went through, while +# the same call by absolute path was refused. A relative script path broke the same way. +# runat