diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a16d081..c0d15771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ 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): **a toolkit copy installed inside an app folder (`apps//bin/`, an `init-project.sh` run there) defers to the outer multi-app project** by the same rule as the root walk, so its `exec.sh` reads the outer register and the plan rule fires under auto; any other installed copy keeps its own root (#489 R17g). Fixture `test-mode-contract.sh` X — review 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 ## 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 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 f8f51de6..f5ab19de 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:-}"; 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 @@ -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:-}"; 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 ;; @@ -295,6 +301,32 @@ 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="" +_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="" + . "$_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; } + 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 # knowledge-base/ directly under the project dir if that's how the project is laid out. @@ -3802,12 +3834,33 @@ 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 + mxtk_app_register_notes "$PROJECT_DIR" "$TOOLKIT_DIR" | 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 85671931..ce26555b 100755 --- a/bin/init-project.sh +++ b/bin/init-project.sh @@ -233,6 +233,17 @@ 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_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")" +[ -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 @@ -269,8 +280,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..92bfe785 --- /dev/null +++ b/bin/lib/app-scope.sh @@ -0,0 +1,235 @@ +#!/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_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 ("", 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" +# 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). 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_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 + mxtk_apps "$pd" 2>/dev/null ) || true +} + +mxtk_app_lines() { + 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 + # Per app, in ONE find and ONE awk (a process per app per fact cost ~0.2 s on six apps): + # " ", 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 +# (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" +} + +# 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 files="" + 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" ] && [ -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 467c713a..e50ebf5c 100755 --- a/bin/lib/marketplace-check.sh +++ b/bin/lib/marketplace-check.sh @@ -218,6 +218,75 @@ 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, 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. +# 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 + 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" + [ -s "$root/architecture/apps/$app/fit-gap.md" ] && fg="$root/architecture/apps/$app/fit-gap.md" + 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 ] && [ -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 + # 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 + notes="${notes:+$notes; }$app: $st" + case "$st" in + FAIL) worst=FAIL ;; + PENDING) [ "$worst" = FAIL ] || worst=PENDING ;; + *) [ -n "$worst" ] || worst="$st" ;; + esac + done <" 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" + [ -n "$shared" ] && gapps="$gapps, from the shared ${shared#"$root"/}" ;; + esac + printf ' [%s] %s — %s\n' "$gapps" "${gk%% *}" "${gk#* }" + done + fi + MXTK_MKT_STATUS="${worst:-PENDING}"; MXTK_MKT_NOTE="${notes:-no app read}"; MXTK_MKT_CONF_STATUS="" + return 0 +} + # _mkt_remember — 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 +294,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/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/bin/status.sh b/bin/status.sh index f6ff4ffd..95886409 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; } @@ -380,12 +386,25 @@ 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" +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 +" +# An app's own PROJECT.md holding register lines (bin/lib/app-scope.sh): a second register, WATCH. +APP_REG_WATCH="$(mxtk_app_register_notes "$PROJECT_DIR" "$TOOLKIT_ROOT" | cut -f2 | sed 's/: the register is the root.*$//' | paste -sd '|' - | sed 's/|/ · /g')" +[ -n "$APP_REG_WATCH" ] && APP_REG_WATCH="$APP_REG_WATCH — the root PROJECT.md is the register" + # --- 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" WATCH="" for _w in "$STAGE_STALE" "${APPROVED_OVER:+APPROVED OVER A FAILING GATE: $APPROVED_OVER}" "$DONE_STALL" "${BP_STALE%% (*}" \ - "$( [ "${PH_TOTAL:-0}" -gt 0 ] && [ "$EAC" = 0 ] && echo "agent slots unfilled: $PH_TOTAL in $PH_FILES file(s)" )" "$PACK_GAP" "$LINT_UNVERSIONED" "$TS_WATCH" "$AE_WATCH"; do + "$( [ "${PH_TOTAL:-0}" -gt 0 ] && [ "$EAC" = 0 ] && echo "agent slots unfilled: $PH_TOTAL in $PH_FILES file(s)" )" "$PACK_GAP" "$LINT_UNVERSIONED" "$TS_WATCH" "$AE_WATCH" "$APP_REG_WATCH"; do [ -n "$_w" ] && WATCH="${WATCH:+$WATCH · }$_w" done if [ "$BRIEF" = 1 ]; then @@ -393,6 +412,7 @@ if [ "$BRIEF" = 1 ]; then [ -n "$POS_BANNER" ] && echo "⚠ $POS_BANNER" 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" @@ -404,6 +424,7 @@ printf '%s\n\n' "$TK" [ -n "$CWD_NOTE" ] && printf 'CWD %s\n' "$CWD_NOTE" [ -n "$POS_BANNER" ] && printf '⚠ %s\n\n' "$POS_BANNER" [ -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 95bdb83a..00243bd6 100755 --- a/bin/sync-project.sh +++ b/bin/sync-project.sh @@ -674,6 +674,35 @@ 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)" +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#* }"; } +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 + mxtk_app_register_notes "$PROJECT_DIR" "$_ATK" | while IFS=' ' read -r _a _l; do echo "Note: $_l"; done + 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 @@ -970,8 +999,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 b2846d51..0174f181 100755 --- a/project-bin/_common.sh +++ b/project-bin/_common.sh @@ -54,11 +54,45 @@ _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 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 +# 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 + # 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" +} 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" ;; @@ -78,8 +112,13 @@ _mxtk_resolve_root() { _src="${BASH_SOURCE[2]:-${BASH_SOURCE[1]:-${BASH_SOURCE[0]}}}" _sd="${_src%/*}"; [ "$_sd" != "$_src" ] || _sd=. self_parent=$(cd "$_sd/.." 2>/dev/null && pwd) - # tier 2: the script sits in a real project's bin/ (a model in any of the three layouts) + # tier 2: the script sits in a real project's bin/ (a model in any of the three layouts). + # A copy installed INSIDE an app folder (apps//bin/, e.g. init-project.sh run there) defers + # to the outer multi-app project, by the same rule the walk applies (_mxtk_outer_project): it + # must not escape the outer register (review of #789: under auto, its exec.sh read the app's + # own PROJECT.md and the plan rule never fired). if [ -n "$self_parent" ] && _mxtk_has_model "$self_parent"; then + _mxtk_outer_project "$self_parent" && self_parent="$_MXTK_OUTER" printf '%s\n' "$self_parent"; return 0 fi # tier 3: walk up from $PWD (mxtk_walk_root). @@ -92,6 +131,95 @@ _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 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 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, 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, +# 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 +# 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 d a m k n=0 + for f in "$r"/*.mpr "$r"/app/*.mpr; do [ -e "$f" ] && return 1; done + 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 d n=0 + for f in "$r"/*.mpr "$r"/app/*.mpr; do [ -e "$f" ] && { echo 0; return 0; }; 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="" 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"; ha="$a"; 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 + printf '%s\n' "$list" | while IFS=' ' read -r a p; do echo " $a ($p)" >&2; done + return 1 + fi + MPR_FILE="$r/$hit"; MXTK_APP="$ha"; 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 +251,14 @@ 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. +# 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 # 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 +385,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 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/project-bin/look-ledger.sh b/project-bin/look-ledger.sh index f0738619..8c7802be 100755 --- a/project-bin/look-ledger.sh +++ b/project-bin/look-ledger.sh @@ -3,8 +3,11 @@ # # 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 [--shots] prints one line per owed page: SEEN or OWED (--shots: state, page, -# and the screenshot that saw it — bin/ready.sh's evidence list) +# bin/look-ledger.sh status [--shots] [--app | --by-app] +# prints one line per owed page: SEEN or OWED (--shots: state, page, +# and the screenshot that saw it — bin/ready.sh's evidence list; +# --app: one app's pages only, also with MXTK_APP set; --by-app: +# every app's, keyed by app, the app as one more 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, @@ -51,7 +54,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 # @@ -61,6 +64,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. @@ -147,9 +159,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 < 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() { @@ -210,7 +227,7 @@ _look_status_ex() { [ -s "$SHOTS" ] && shotf="$SHOTS" # The seen ledger is read with getline in BEGIN, not as a first file: FNR==NR is also true # for the second file when the first is empty, which would read owed rows as screenshots. - awk -F'\t' -v seenf="$seenf" -v shotf="$shotf" ' + awk -F'\t' -v seenf="$seenf" -v shotf="$shotf" -v app="${LOOK_APP:-}" ' function norm(s) { s=tolower(s); gsub(/[^a-z0-9]/, "", s); return s } BEGIN { while ((getline line < seenf) > 0) { @@ -223,17 +240,28 @@ _look_status_ex() { shotmt[g[3] SUBSEP g[4]] = g[5]+0 } } - 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 } @@ -412,7 +440,20 @@ case "${1:-}" in reshoot) shift; cmd_reshoot "$@" ;; owe) shift; cmd_owe "$@" ;; seen) cmd_seen ;; - status) if [ "${2:-}" = --shots ]; then _look_status_ex | cut -f1,2,5; else look_status; fi ;; + status) shift; _ls_shots=0; LOOK_APP=""; _ls_app_set=0 + while [ $# -gt 0 ]; do + case "$1" in + --shots) _ls_shots=1 ;; + --by-app) LOOK_APP="*"; _ls_app_set=1 ;; + --app) shift; LOOK_APP="${1:-}"; _ls_app_set=1 ;; + --app=*) LOOK_APP="${1#--app=}"; _ls_app_set=1 ;; + esac + shift + done + [ "$_ls_app_set" = 1 ] || { [ -n "${MXTK_APP:-}" ] && mxtk_apps >/dev/null 2>&1 && LOOK_APP="$MXTK_APP"; } + if [ "$_ls_shots" = 1 ]; then + if [ "$LOOK_APP" = "*" ]; then _look_status_ex | cut -f1,2,5,6; else _look_status_ex | cut -f1,2,5; fi + else look_status; fi ;; shots) shift; cmd_shots "$@" ;; pages) shift; look_pages_in "${1:-/dev/null}" ;; *) echo "usage: $0 owe | seen < hook-json | status [--shots] | summary [--write] | 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..a567f10b 100644 --- a/skills/module-folder-convention.md +++ b/skills/module-folder-convention.md @@ -185,6 +185,25 @@ 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 `. 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 +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..30dd6714 --- /dev/null +++ b/tests/wave2/fixtures/multi-app/PROVENANCE.txt @@ -0,0 +1,20 @@ +tests/wave2/fixtures/multi-app/ — provenance + +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: + + - 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. + +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 new file mode 100644 index 00000000..4c133c16 --- /dev/null +++ b/tests/wave2/fixtures/multi-app/tree.txt @@ -0,0 +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 +./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-mode-contract.sh b/tests/wave2/test-mode-contract.sh index 812d09fb..a1e2462a 100755 --- a/tests/wave2/test-mode-contract.sh +++ b/tests/wave2/test-mode-contract.sh @@ -18,6 +18,9 @@ # 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; so is an +# exec.sh copy installed in apps//bin/ (its root defers to the outer project) # 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 +113,33 @@ 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