A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.
/app-builder — design record
The two design records the /app-builder engine cites, in one file. They were previously
app-builder-staged-flow-design.md and changed-only-design.md; the content is unchanged.
- Part I — staged-flow architecture. The shipped architecture and the reasoning behind it. Its numbered sections are cited from code (§6, §7, §9, §11, §13, §14), so the numbers are load-bearing: keep them stable, and never renumber. (The numbering skips §16 and §17 — those were removed without shifting anything else, for exactly this reason.)
- Part II —
--changed-onlysafe partial apply. The v1 scope and safety contract for the partial-apply mode built on top of Part I. Read it before touching that mode.
Current status of shipped/pending capabilities lives in
app-builder-capabilities.md — this file is the "why", the capabilities doc is the
"what/where". Wiring and flow diagrams live in architecture.md.
Part I — staged-flow architecture
Status: IMPLEMENTED / LANDED. This is the design record for the
/app-builderstaged-flow architecture that shipped — the engine now runs it (staged flow, design-only author, generate-pages stage, structural evals, fail-closed safety). It began as a re-architecture proposal and was subsequently implemented, reviewed, and live-verified. It is retained as the design rationale the engine's code cites by section (§6, §7, §9, §11, §13, §14); the section numbers are load-bearing — keep them stable, and do not renumber when trimming (§16 and §17 were removed without shifting anything else, which is why the numbering skips them).Current status of shipped/pending capabilities lives in
app-builder-capabilities.md(the canonical capability record), not here — this doc is the "why", the capabilities doc is the "what/where". The--changed-onlypartial-apply mode built ON TOP of this staged flow has its own contract in Part II below.The App Spec core contract and the 13 engine phase names are unchanged; the staged flow is an additive naming/orchestration layer over them.
1. Why
This section is the original motivation (pre-implementation). All five problems below were addressed by the design that landed — see the capabilities doc for current status.
The build engine is sound — spec-driven, idempotent, create == edit, a large regression suite, a
parity oracle. But the flow around it had five concrete problems:
- Mental-model mismatch. The engine exposes 13 fine-grained phases; the user and the skill
narration think in ~6 stages. "Build the pages" maps to three scattered phases
(
app-shell→pages(upload) → sitemap rewrite). - Author codes pages too early. Forms/views are declared in author and serialized later,
but generative pages are fully coded (
.tsx) during author — before the design is approved. Design and implementation are entangled. - Eval gap.
/app-builderhas one eval (smoke-eval.js, a single hardcoded live spec). No data-driven offline harness like/genpage'sevals/model-apps/genpage/. - No autopilot/consent awareness, and destructive ops are not fail-closed. The flow assumes an attended human at every gate; there is no non-interactive path (needed for evals), and updates already prune form fields and replace sitemaps with only a warning.
- Multi-page apps have no look-and-feel contract and no verified cross-page navigation.
Parallel page-builders diverge visually, and cross-page
pageInputnavigation (PAGEREF_→ real GUID) is not resolved by the app-builder engine today.
2. Goals
- A 6-stage user-facing model (
data → generate-pages → ui → app → publish → verify, preceded by a design-onlyauthorstage) for narration, consent, and evals — without merging or renaming the 13 engine phases. - Author emits a design-only App Spec; page
.tsxis generated in a distinct stage after plan approval and after tables are deployed, reusing the/genpagepage-builder. - Mode-aware consent (interactive vs autopilot/eval) with destructive ops fail-closed.
- Consistent page look-and-feel and working, portable cross-page navigation designed up front.
- Evals fall out of the stage boundaries via structural (not snapshot) oracles.
3. Non-goals (YAGNI)
- Not merging or renaming the 13 phases (churns ~510 tests/journal/
--only; loses fine re-run control). The stage layer delivers the UX for near-zero phase churn. - Not agentizing the deterministic engine. Entity/form/view/app creation stays in the engine.
- Not rewriting
/genpage. We reuse its page-builder core, itsPAGEREF_convention, and its navigation rules — adapting the agent contracts (§8, §11) rather than the code-gen logic.
4. Design invariants (the review contract)
- The main loop owns judgment + consent + narration. It is never a
Tasksubagent — a subagent is headless, soAskUserQuestion/plan mode cannot reach the user from inside one. - The deterministic engine owns all Dataverse writes and never dispatches an LLM agent. Agents are dispatched only from the main loop, as headless workers (§8). This keeps the build idempotent and eval-able.
- Only two LLM agents exist:
page-builder(writes/edits one page's.tsx) andedit-planner(headless analyzer of a downloaded app). Both are adapted from/genpage. - The 13 engine phases keep their names and order. Stages are a naming/orchestration layer.
5. Execution model
Why the first draft was wrong. runSdkBuild allocates a fresh result.created map on
every invocation (sdk-build.js:540). Downstream phases resolve dependencies from that
in-memory map, not from Dataverse: table icons skip a table not built this run
(sdk-build.js:587-599); appDef reads result.dashboards/pages/forms/views/charts
for sitemap subareas and pinned components (sdk-build.js:493-518). So running ui and app
as separate --from/--to process invocations would lose IDs or throw. My original mechanic
was unsound.
The corrected pipeline runs the write phases as one full idempotent build, with only a minimal data pre-build ahead of code-gen:
author (main loop) design-only App Spec, consent, plan-mode approval
│
data pre-build (engine, run 1) build --stage data --apply → tables exist (for type-gen)
│
generate-pages (main loop) genpage.js types + page-builder agents → fill page source (.tsx)
│
full build (engine, run 2) build --apply (FULL, idempotent) → ui + app + publish + verify
- Two engine invocations only. Run 1 materializes tables so
genpage.js typescan emitRuntimeTypes.ts. Run 2 is a full build: it re-discovers the tables (rehydratingresult.created.entities), then builds web-resources/views/charts/forms/ commands/dashboards, creates the app, uploads pages, resolvesPAGEREF_, finalizes the sitemap, publishes (opt-in), and verifies. result.createdintegrity is preserved because run 2 is a full run: every phase discovers existing artifacts and repopulatesresult.created(existing web resource → recorded at:570-573; the same discover-and-record pattern rehydrates entities/forms/views/charts/ dashboards). This is the exact path that already makescreate == editwork — an edit is a full idempotent rebuild — so it is proven, not new.- Parity by construction (answers the parity test). Run 2 is today's monolithic
full build; run 1 is an idempotent prefix (solution + data-model only). Because
data-modelis discover-reconcile — as are forms/views/charts (sdk-build.js:782-786,835-838) — run 1's tables are transparently rediscovered by run 2, which then does everything else (includingsample-data) exactly once. So run 1 + run 2 reach the identical end state as one monolithic build. (Dashboards/commands are re-created rather than reconciled on a rebuild — a pre-existing idempotency nuance atsdk-build.js:966-975,951-958— which §14 fixes so a full-build retry stays idempotent.) Only the no-write main-loop code-gen sits between the runs. - Simpler than a per-range rehydration context. We reuse the proven full-rebuild discovery instead of adding a bespoke rehydrator per phase-range. The cost is that run 2 re-runs data-model discovery (a few metadata reads, no writes) — acceptable and DRY.
- LLM code-gen stays in the main loop, between the two engine runs (invariant §4). The engine never awaits an agent.
- One apply of an app at a time per workspace. Each engine run that applies — run 1, run 2, or a
--changed-onlyapply — holds the app's build lease (<workspace>/app-build.<hash>.lock,lib/app-operation-lease.js) for all of its work, from before its auth check to its result, so a second run of the same app cannot interleave its discovery and creates with this one's: the generated app icon, the app, a web resource or a page would otherwise be found missing by both and created twice. The second run stops at once (build-locked) and is re-run after the first finishes. The lease is released between run 1 and run 2 (page generation holds none); run 2 rediscovers state, as above. It is a local courtesy between cooperating runs of this version — not a server transaction, not across workspaces or machines, and a build of an earlier release takes none (the legacy pages lock still keeps such a build out of the pages phase when it spells the app the same way).
Stages are therefore a vocabulary and orchestration layer, not independent write
invocations. data executes in run 1; generate-pages in the main loop; ui/app/publish/
verify are phase groups within run 2.
6. Stages (the vocabulary over the execution model)
| Stage | Executes in | Owns | Engine phases |
|---|---|---|---|
| author | main loop | design-only spec, lint, consent, plan-mode | (none) |
| data | run 1 (schema) + run 2 (rows) | tables, columns, relationships, sample data | solution→data-model (run 1); sample-data (run 2) |
| generate-pages | main loop + agents | RuntimeTypes + page .tsx (symbolic, PAGEREF_) |
(none — writes files) |
| ui | run 2 (engine) | web-resources, views, charts, forms, commands, dashboards | web-resources…dashboards |
| app | run 2 (engine) | app module, sitemap, page upload + PAGEREF_ resolve |
app-shell→pages(upload)→ai-features |
| publish | run 2 (engine) | publish (opt-in) | publish |
| verify | run 2 or standalone | reconcile spec vs deployed (incl. pages) | (reconcile pass) |
Renamed from the first draft: the code-gen stage is generate-pages, never pages — the
engine phase pages (upload, a member of stage app) keeps its name, and using one word for
both was ambiguous. One namespace is used for stage names across
narration, journal, and CLI.
--stage <name> sugar on build-model-app.js maps a stage to its phase range internally
(over the existing --from/--to). Run 1 uses --stage data without --sample-data (solution +
data-model only); sample rows are created once in run 2 (§14), so the data stage's schema lands in
run 1 and its rows in run 2. Run 2 is a full build, not a --from range, per §5. Unknown
stage/phase selectors are rejected (today resolvePhases silently ignores unknown endpoints,
sdk-build.js:191-198 — tightened to error).
7. Author redesign & App Spec schema
Author stops emitting .tsx. It produces a design-only spec and freezes it via consent gates
(two shape-level design checkpoints + the single plan-mode build approval, which is unchanged).
7.1 Validation profiles
validateAppSpec is currently unconditional and requires every page's codeFile
(build-model-app.js:98, app-spec.js:431-438), so an intent-only spec fails before the first
write. Introduce profiles:
design/plan— pages may be intent;codeFilenot required. Validates intent fields, unique stable keys, navigationtargetKeys resolve to known pages, design-contract shape, andappShellpage references resolve.planFormust plan pending page implementations.deploy— every page must be implemented (source.kind === 'tsx'with a workspace-confinedcodeFile); allPAGEREF_targets resolvable. Run 2 usesdeployand fails fast if any page is still intent (i.e.,generate-pageswas skipped).
Profile per caller (every validateAppSpec call site takes an explicit profile — none stays
unconditional; build-model-app.js:97-101, teardown-model-app.js:62-65, verify-model-app.js:59-65):
| Caller | Profile |
|---|---|
author plan / full dry-run (planFor) |
plan |
run-1 data apply (--stage data) |
plan (pages still intent) |
| run-2 full apply + verify | deploy |
| teardown / partial cleanup | structural (no codeFile required) |
| default programmatic build | deploy |
7.2 Page shape — discriminated source
One pages[] collection; implementation state is explicit, not a nullable field:
{
"schemaVersion": 2,
"pages": [{
"key": "overview", // STABLE, unique — the only cross-reference id
"name": "Overview",
"purpose": "At-a-glance dashboard of open work",
"dataSources": ["contoso_workorder"],
"navigatesTo": [{ "targetKey": "wo-detail", "data": { "workOrderId": "string" } }],
"pageInput": { "data": { "workOrderId": "string" } },
"source": { "kind": "intent" } // → { "kind": "tsx", "codeFile": "overview.tsx" }
}]
}
- Stable
keyis the single identity used bynavigatesTo.targetKey,PAGEREF_<key>, andappShellsubareas — eliminating the mixing of key, filename and display name. sitemapSlotis dropped: placement lives only inappShell(the authoritative sitemap model), whose page subareas reference the pagekey(appDefresolves key →genPageId, adaptingsdk-build.js:497-506). Single source of truth.schemaVersiongates the new shape; loaders reject unknown versions.- Path confinement:
codeFilemust resolve inside the working dir (no../absolute escape; today it is resolved arbitrarily atsdk-build.js:1037-1041). Duplicate key/name/path are rejected.
7.3 Round-trip (download → edit → rebuild)
download-model-app.js/hydrate-spec.js currently retain only name/dataSources/prompt/codeFile
(hydrate-spec.js:61-66) and lose keys/intent; PAC lists pages by name (not key) and
download returns resolved, GUID-bearing source (download-model-app.js:86-106). Stable-key
persistence is therefore foundational, and the mechanism is decided (not left open):
- Durable page manifest (versioned). The
appstage writes a<app>_pagemanifestweb resource carrying the full design-time metadata —{ schemaVersion, pages: [{ key, name, pageId, purpose, dataSources, navigatesTo, pageInput }], design }— not just id/name, so the round-trip below actually restores purpose/navigation/design. It travels inside the solution and survives download. - Lifecycle is explicit. On first build the manifest web resource is created; its solution
membership is re-asserted every run (an idempotent add, not only on first creation — skipped only
when the build's one read of the solution proves it is already a member); on rebuild its
content is updated in place via
updateWebResource(MakerSdk.ts:529-543) — the engine today reuses an existing web resource without updating its content (sdk-build.js:565-580), so the manifest needs the update path, not plain reuse.planTeardownremoves it (it currently deletes only the app icon,sdk-teardown.js:338-348). pageIds are validated deployment state, not blind portable identity. Manifest ids are environment-specific and can be stale after import to another env, so they are reconciled against the fail-closed current-app enumeration (§9) before use — the manifest keepskey ↔ namedurable (so a display-name change never orphans a page), while the deployed id is confirmed live each run. An off-sitemap id additionally needs a local CREATE receipt for this app/key/id and a corroborating stored name; a remote manifest or matching name alone never authorizes reuse.- Canonical symbolic source is retained in the working dir / app-spec sidecar (the
.tsxwithPAGEREF_<key>); the resolved deployment derivative is never written back over it. - Download reconstructs keys from the manifest and reverse-normalizes sibling page-GUID
literals in downloaded source back to
PAGEREF_<key>. A page the manifest does not bind (a legacy or Maker-authored app) keeps the key an earlier download of the same app gave it — matched by page id, from theapp-spec.jsonalready in the output folder, when that file names this app inapp.uniqueName— and only a page with neither gets a fresh slug key, minted in the order of the page ids, never of the names. A key never moves between two downloads of an unchanged app: a spec deployed to another environment holds no page ids, so that environment binds each key to the page it built, and a moved key would swap what two pages hold there. When that file gives one key to two pages (or one page two keys) for a page the manifest does not bind, the download stops withpage-keys-ambiguousrather than guess, unless--reset-page-keyssays to give those pages fresh keys. Downloaded pages hydrate assource.kind === 'tsx'. - Migration: specs without
schemaVersion/keys (name-referenced) are upgraded on load — keys minted from names,navigatesTo/appShellreferences rewritten name→key.
8. Generate-pages stage & agent contracts
After run 1 (tables exist), the main loop:
- runs
genpage.js types→RuntimeTypes.ts; - for each intent page, dispatches the
page-builderworker with a generated per-page build contract (see below),RuntimeTypes.ts, the page design contract (§10), and the navigation graph (targets +datashapes); - validates every generated page (compile/structure + verified columns + navigation, §13)
before committing the
sourcetransition intent→tsx. Commit is all-or-nothing.
Agent-contract adaptations (the reused agents do not fit as-is):
page-buildertoday requires agenpage-plan.mdcontract (genpage-page-builder.md:24-51). The generate-pages step generates that contract from the page-intent (a stable, generated plan input), so the page-builder's code-gen core is reused unchanged. It must own both new-page and page-code edit generation (for the edit flow).edit-plannertoday asks questions and enters plan mode itself, handles one page, and rejects schema edits (genpage-edit-planner.md:10-49,94-116). It becomes a headless analyzer with no consent tools: it returns a proposed diff; the main loop gathers requirements and approves; schema edits are handled by the main-loop author, not the page edit-planner./app-builderSKILLallowed-toolsgains theTaskdispatch tool so the main loop can dispatch these headless workers. This does not violate the "interactive steps stay in the main loop" rule — the interactive author never runs inside a subagent; only the pure code-gen workers are dispatched.
9. Cross-page navigation & the PAGEREF_ resolver
Reuse /genpage's navigation contract (references/rules.md 299–356): navigate via
Xrm.Navigation.navigateTo({ pageType:'generative', pageId, data }); custom ids go in data:
(never recordId), read as pageInput?.data?.<key>.
Source stays symbolic. Code-gen emits PAGEREF_<page-key> and the canonical .tsx is never
mutated with a GUID (mutation would bake environment-specific ids into source and break
cross-env deploy / recreate, and a page's id is an opaque identity its source should not carry). Because the page backend takes a
page's text (genpage-sdk.js, create() / update()), the resolver holds each resolved copy in
memory; the canonical source is left untouched.
Deployment protocol (safe recovery). The listing must fail closed: the first
page backend (a PAC wrapper) turned any failure into [], which the engine treated as "no pages" — risking
duplicates and orphans. enumerateEnv answers { ok:false } on a failure (genpage-sdk.js). The app
stage:
- Enumerate fail-closed — page listing retries and distinguishes failure from empty; a
failed enumeration halts (never "no pages exist"). Seed the
key → pageIdmap from the durable manifest (§7.3) first. - Create only absent pages (no known
pageId) by uploading their symbolic source to mint ids — brand-new pages have no live navigation to disturb. Persist each returnedkey → pageIdto pipeline state and the manifest immediately. - Once all ids are known, resolve the graph (validate every
PAGEREF_<key>; fail on any dangling target) and keep per-page resolved copies in memory with GUIDs substituted. - Upload resolved content exactly once per page (existing pages get their resolved content in a single update — no symbolic intermediate that could break live nav).
- Finalize the sitemap (
sdk-build.js:1045-1054) — the true commit point, only after all resolved uploads succeed.
- Recovery is forward-only idempotent recompute: a re-run re-seeds ids from the manifest, re-resolves, and re-uploads deterministically (no rollback).
- Pure resolver module
pageref-resolver.js((sources, keyMap) → deploymentSources) is unit-tested offline (dangling-target failure, stable substitution) (§14).
10. Look-and-feel: a page design contract
appDef has no theme field or mutation (sdk-build.js:516-518), so a spec.design cannot drive
the model-driven shell today. Scope honestly:
- v1:
spec.designis a page design contract (accent, density, corner radius, dark-mode policy, layout) threaded to every page-builder → pages are consistent with each other. - Shell alignment is achieved by targeting the same Fluent UI V9 tokens the shell uses, via a documented semantic-value → Fluent-token mapping table; generated pages are validated for token conformance (§13). We do not claim to write the app theme.
- Future (optional): a supported
appDeftheme read/write mapping — deferred until the SDK exposes it; called out as an extension point, not v1 scope. - Since 2.21.0 (Preview): the app theme and header logo are written separately from
appDef, by the optionalapp.themekey (an explicit branding request only), through the SDK's theme methods.spec.designstill drives pages only; seeapp-builder-capabilities.mdfor the theme.
11. Safety & autopilot — fail-closed destructive ops
Consent is mode-aware; autopilot mode is also eval mode (both non-interactive).
The problem the first draft missed: --allow-destructive was not tied to any real diff, and
--non-interactive on the CLI cannot gate main-loop questions. Meanwhile updates already removed
content — collision was warning-only (build-model-app.js:111-119), explicit-form fields were
pruned (sdk-build.js:690-725), and the sitemap was fully replaced (:995-1007); teardown was
gated by --apply alone (teardown-model-app.js:62-95).
The fix — a read-only operation-diff planner (op-diff.js, new pure module):
- Read-only classification, reusing existing logic — not a duplicate differ. Diff the spec
against discovered artifacts via the same reconciliation the build uses (and the SDK's generic
diffArtifact), so the planner can't drift from build behavior. - v1 scope = the realistically detectable destructive ops (do not claim table/column/form
deletion classification — the build has no such delete path today):
- unexpected app collision (see below);
- explicit-layout form-field removals (
sdk-build.js:690-725); - sitemap target removals (
:995-1007); - all
planTeardownoperations — already a pure plan (sdk-teardown.js:269-358).
- Collision is scoped, not blanket. Existing solutions (including Default) and the run 1 → run 2 sequence are normal, so solution existence must not fail unattended. Bind approval to pipeline-owned ids; fail only on an unexpected app collision or an incompatible solution identity.
- Hard gate + TOCTOU: any destructive op without
--allow-destructivehalts before writes (incl. teardown). Recompute the diff immediately before apply so a state change between plan and apply can't slip through. - Approval binding: a refused apply records the exact removals it listed in
.maker-workspace/destructive-approval.json(each form's fields, the sitemap targets, and the run that wrote it). The approved re-run removes only those and halts, naming the new ones, if anything else would now be removed. An approved run rewrites or consumes the record only if it found it at its start or wrote it, so a concurrent build cannot consume it; a new refusal replaces it with the list that refusal showed, and a halt naming new removals refreshes it with the full current list. - Env var suppresses questions only — never grants destructive authority;
--allow-destructiveis always explicit, even in autopilot.
| Gate | Interactive | Autopilot / eval |
|---|---|---|
| Design gates #1/#2, build approval | AskUserQuestion / plan mode |
auto-approve, journaled (design + op hash) |
| Destructive ops | explicit confirm | fail-closed unless --allow-destructive |
| Collision on create | confirm | fail (no silent update) |
| Design artifacts | shown inline (preview-app.js, §12) |
written to disk + narrated |
12. Whole-app design preview (preview-app.js, new)
Today only forms render (preview-form.js). preview-app.js renders the entire design as the
approval artifact: data-model summary, the appShell sitemap tree, views/charts, per-form
wireframes (reusing preview-form.js), page-intents (purpose/data-sources/navigation graph),
and the page design contract. Shown at design gate #2 + plan mode when attended; written to the
working dir when autopilot. The user approves the whole app shape at once.
13. Verify & evals
13.1 Verify extended to pages
verifySpec has no sa.page branch and never checks page content or unresolved PAGEREF_
(verify-spec.js:39-67); a verify that can't run is only a warning (build-model-app.js:161-175).
Add strict page checks — page exists, GenPageId bound in the sitemap, and (crucially) every
navigation edge resolves to the actual target page's GenPageId, not merely "no PAGEREF_
text remains" (a stale/wrong GUID has no placeholder yet is still broken). This needs the verify
reader to list/download page content (verify-model-app.js:40-46 lacks it today). Make the
verify stage mandatory and fail-closed — it fails if verification cannot run.
13.2 Structural eval oracles — not .tsx snapshots
LLM page output is non-deterministic, so exact snapshots are the wrong oracle (genpage evals
already grade structurally: EVAL_GUIDE.md:43-103). Per-stage offline oracles:
| Stage | Assertion (deterministic) | Primitive |
|---|---|---|
| author | spec shape + lint + profile validation | spec-lint.js, validation profiles |
| plan | phase-grouped plan | planFor (deterministic for fixed spec/opts) |
| data | normalized schema-call facts (create table/column/relationship) | new schema-facts extractor (wire-facts covers forms/views/charts/sitemap only, wire-facts.js:34-99) |
| generate-pages | navigation-graph validity + exact quoted PAGEREF_<key> facts; no dangling targets; TS compile/structure; verified DataAPI columns vs RuntimeTypes.ts; design-token conformance; no forbidden patterns |
new page-facts checks |
| ui | normalized wire-facts | wire-facts.js |
| app | sitemap-facts + PAGEREF_-resolved facts (key→id) |
pageref-resolver.js + facts |
| verify | reconcile { ok, checks, missing } incl. pages |
verifySpec (extended) |
Harness mirrors genpage (evals/model-apps/app-builder/: evals.json + fixtures + TAP runners),
driven in autopilot mode. Keep smoke-eval.js as a thin live tier; add a multi-page live case for
navigation resolution end-to-end.
14. Engine mechanics & module extraction
sdk-build.js is ~1099 lines; the precedent for pure modules is artifact-intent.js. Extract:
stages.js— stage registry + stage→phase-range map + stage metadata; unknown-selector rejection.pageref-resolver.js— purePAGEREF_deployment resolver (§9).op-diff.js— read-only destructive-op classifier (§11).- validation profiles — extend
app-spec.jswithdesign/plan/deploy(§7.1). schema-facts.js— normalized data-model provisioning extractor for evals (§13.2).
Pipeline metadata. The journal is diagnostic, not a replay checkpoint (build-journal.js:1-5),
and each CLI run opens a separate journal (build-model-app.js:232-236). Add a pipeline id
spanning run 1 + code-gen + run 2, with stage-attempt metadata (design hash, code hash,
prerequisite enforcement: "run 2 refuses to start unless every page is implemented"). Recovery
remains idempotent recomputation, not journal replay. Commit the intent→tsx transition only
after all pages validate (§8).
No cross-run DAG. generate-pages (main loop) must fully complete before the single
full run 2; running ui concurrently would require splitting/pausing run 2 and revives the lost-ids hazard of §5. For v1
the only parallelism is within a stage (page-builders run in parallel; the engine already
parallelizes independent artifacts).
--stage is apply-safe only for data. Other stage selectors are dry-run-only or rejected
(their phase ranges aren't dependency-closed — e.g. --stage publish --apply would publish against
an empty result map, sdk-build.js:1083-1093). The pipeline is exactly:
run 1: build --stage data --apply # solution + data-model only (NO --sample-data)
code-gen (main loop)
run 2: build --apply --verify [--sample-data] [--publish] # the full monolithic build
Run 1 omits --sample-data so sample rows are created once in run 2 (dedup via matchOn is
conditional — matchOn can be absent, entity-provision.js — so running sample-data twice is not
safe).
Retry idempotency fix. Because full-build re-run is the recovery mechanism, commands and
dashboards — today re-created without discovery (sdk-build.js:951-975) — must become
discover-reconcile (findArtifact/fetchArtifact + generic mutations by a stable child
identity — commands need an explicit stable key, since the command schema today has label, not
name (app-spec-schema.md:234-243); dashboard tiles keyed by tile identity), or a retried run 2 duplicates them. v1 is
additive-only (discover, add what's missing, never remove) so reconciliation cannot strip
Maker-authored commands or dashboard tiles. Spec-driven removal of a command/dashboard/tile is
deferred and, if added later, routes through op-diff destructive consent (§11) — exactly like
explicit-form field pruning. This is a tightly-coupled correctness fix, in scope here.
15. Blast radius / unchanged
Unchanged: the 13 phase names + order + idempotency, the App Spec core contract,
--only/--skip, create == edit, the parity oracle, the generic SDK mutation surface (no new
artifact-specific SDK mutator — the SDK's generic-mutation tenet holds).
New/changed: stages.js, pageref-resolver.js, op-diff.js, schema-facts.js,
preview-app.js; validation profiles + schemaVersion/discriminated page source + stable keys in
app-spec.js/app-spec-schema.md; appDef resolves sitemap page subareas by key and drops
sitemapSlot; verifySpec page checks; --stage/--non-interactive/--allow-destructive flags
- pipeline id in the CLI/journal; adapted genpage agent contracts +
Taskin the SKILLallowed-tools; round-trip metadata indownload-model-app.js/hydrate-spec.js.
18. SDK-alignment (target after rework)
- Canonical desired state — restored:
sitemapSlotdropped (single source =appShell); canonical page source stays symbolic (no env-specific GUIDs). - Generic mutation — pass (no new artifact-specific SDK mutator).
- Opaque identity — restored: GUID substitution confined to a deployment derivative.
- Serializer boundary — sitemap finalize stays
updateElement('/siteMap'); no raw XML side channel. - App Spec / idempotency / create==edit — restored via §5 full-rebuild execution + preserved design/navigation metadata (§7.3).
19. Open decisions
ai-featuresstays inside theappstage (app-scoped, after app-shell).op-diff.jsv1 scope (decided, §11): unexpected-app collision, explicit-layout form-field removals, sitemap-target removals, andplanTeardownops — reusing existing reconciliation /diffArtifact. Table/column/form deletion is out of scope until the build supports it.- Round-trip persistence (decided, §7.3): a durable
<app>_pagemanifestweb resource (not an ephemeral sidecar), plus retained canonical symbolic source and download reverse-normalization.
20. Testing strategy
- Offline unit tests per new module:
stages/--stageresolution + unknown-selector rejection; validation profiles; discriminated-source lint;op-diffclassification;pageref-resolver(PAGEREF_<key>→id, dangling-target failure);preview-apprender;verifySpecpage checks;schema-factsextractor. Keep the suite green (currently 510). - A staged-vs-monolithic parity test: the two-invocation pipeline must produce the same deployed state as a single full build.
- Data-driven offline harness (
evals/model-apps/app-builder/) with the §13.2 oracles. - Live tier: keep
smoke-eval.js; add a multi-page navigation case.
Part II — --changed-only safe partial apply
Status: implemented; PROD-readiness reviewed; live-verified. The design was adversarially reviewed before implementation, and the implementation was reviewed again with all Critical/High findings fixed and covered by tests. This is the canonical spec for the multi-deliverable build.
v1 scope + contract (READ THIS)
v1 wires exactly ONE convergent shape end-to-end: page-content re-upload (a .tsx byte edit to an
existing page). Everything else — view-append, sitemap, form, or any data-model/AI/chart/command/
dashboard/web-resource change — routes to a full build (always safe; a full build converges the first
four and additive-SKIPS the rest, which then incur sticky debt).
For forms, convergence is limited to the form-layout contract;
it does not include reordering existing fields from a changed fields list.
The user-facing contract:
--changed-onlybootstraps its baseline from a FRESH build. The eligible baseline is written only when the app did not exist when the run started (a first--apply --changed-only). Running the first build with a plain--apply(no snapshot) and then--changed-onlyyields an ineligible baseline (the additive engine may not have converged a pre-existing app) → every run full-builds until a clean teardown+rebuild. Use--changed-onlyfrom the first build to opt in.- Use
--changed-onlyconsistently. A plain--applyin between invalidates the snapshot (→ next--changed-onlyre-baselines via a full build). Mixing the two de-optimizes but never corrupts. - Concurrent Maker edit of the SAME changed page is unsupported (a page write is checked against the page's version only between its own read and its write) — the fast path re-uploads only the changed pages, so an unchanged page is never clobbered; a page you edit in both the spec and Maker is overwritten by the spec (the intended deploy). Documented as a follow-up.
Deferred to follow-ups (v1 does NOT implement; tracked in the capabilities doc)
Pre-mutation live page-content drift verifier; expectedSitemap population + pre/post sitemap projection
equality (sitemap fast shape unwired in v1); a clearDebtMatching production caller (v1 clears debt only
via teardown+rebuild); view/form/sitemap fast submodes. None are reachable on the v1 pages-only fast path.
Page codeFile and web-resource contentPath reads share one app-folder resolver for hashing and
deployment: only relative, regular files inside the app folder are accepted; source symlinks and
junctions are refused. Canonical spelling changes such as Windows 8.3 aliases are allowed when
component link checks and canonical containment succeed.
Off-sitemap page recovery requires a local CREATE receipt, not a remote manifest/name match.
The workspace's page-ownership.created.<hash>.json records bind app unique name, page key, id and
an opaque fingerprint of the normalized target environment origin, without storing its URL,
after an acknowledged create and before placement. Local teardown records preserve verified ownership
before the app is removed; pending page deletions keep those records and the manifest/solution across
retries, including page-less retries. Uncertain CLI creates report candidates for explicit user
resolution instead of updating one automatically. Form-only references are not scanned.
There is one environment-bound receipt format. Unknown versions, malformed or unreadable records
halt with the filename and guidance rather than silently losing identity. Foreign-environment records
never authorize a current-target operation or get consumed there.
Workspace clearing refuses all unconsumed ownership records, naming each file and its retirement
condition (page deletion or confirmed absence), and checking both before
atomic isolation and before removal; a late record keeps the isolated folder for explicit recovery.
Why this is hard
/app-builder's build engine is ADDITIVE, not convergent: existing chart/command/dashboard defs and
web-resource CONTENT are skipped on rebuild (sdk-build.js:685-695,985-996,1114-1153), and the partial-apply guard
(build-model-app.js:149-158) forbids partial --apply because result.created (the artifact-id map)
is per-invocation and phases read each other's ids from it. So a naive "run only changed phases" would
silently bless edits that never deployed. The whole design is therefore fail-closed.
Core invariant (replaces the blanket partial-apply refusal)
A partial --apply is allowed ONLY via --changed-only, and ONLY when: an identity-validated snapshot
exists with eligible:true and empty debt; every consumed id re-resolves live by semantic identity;
the diff is a subset of the four PROVEN-CONVERGENT shapes; no sitemap drift; and — after the apply — an
EXACT projection verifier proves each touched artifact's deployed state equals the spec. Every
state-changing op (full apply, fast apply, teardown) first atomically writes eligible:false
(write-before-mutate) and aborts if that guard write fails. eligible:true is reached again ONLY via a
verified fast run or a proven-fresh/rebaseline full build with empty debt. Anything not provably safe ⇒
full build / HALT.
The four convergent shapes (the ONLY fast-path edits in v1)
- page —
.tsxbyte change to an EXISTING page, unchanged key→pageId map (re-upload only, sitemap write skipped). - form (explicit layout) — field-set add(first-section)/remove, placement-exact (all other tab/ section/cell/isRequired/events/quickView/autoSubgrids/subgrid identical).
- view — pure APPEND of columns (no width/order/filter/sort/removal); default-view enrichment suppressed.
- app-shell sitemap — structural sitemap change only (app.description/icon excluded).
Additions of NEW top-level artifacts, removals, and charts/commands/dashboards/web-resource-content/AI ⇒
full build, and they incur sticky debt.
A spec that declares
commandStates[](2.24.0) is never fast-applied and never a no-op: a full build reads every declared command row and asks for approval of what it finds, which an unchanged snapshot cannot stand in for (COMMAND_STATES_FULL,lib/changed-only-flow.js). A change to them (added, changed or no longer declared, matched by row id) is a full-build reason with no debt: the full build applies it, and an entry no longer declared leaves its row as it is, which no later build could close either.
Snapshot envelope (<workspace>/apply-snapshot.json, schema 3, atomic)
{ schema, orgId (live WhoAmI), envUrl, appUniqueName, appId, solutionUniqueName, generation (uuid), eligible (bool), debt:[{artifactType,identity,reason}], priorSpec (canonical, no rows), expectedSitemap (normalized projection), artifacts:{ pages:{key:{pageId,sourceSha,deployedSha}}, forms:{entity|formType| name:{formId,projSha}}, views:{entity|name:{viewId,projSha}}, app:{sitemapSha}, webResources, entities, charts, commands, dashboards } }. Written temp→fsync→rename, under one build-wide lease + generation CAS,
ONLY after effective success (apply+verify).
Eligibility state machine (durable, fail-closed)
- INVALIDATE (→false) before any write of every full/unsupported/fast apply and teardown; abort if
the invalidation write fails. A
--changed-onlyinvalidate is fenced to the generation its decision was read at: a snapshot tombstoned, rewritten or deleted since that read aborts the run before it writes anything. A run that read no snapshot (a first build) claims one instead — an ineligible, debt-free placeholder written under the lease only while there is still none — so its baseline write has a generation to be fenced by; a claim refused because a snapshot appeared aborts the run the same way. - debt accrues on any unsupported change/removal;
eligible:truerequires empty debt; debt clears ONLY by proven-fresh recreation (artifact absent before build) or an exact verifier — never by a plain full rebuild that re-skips a stale artifact. - teardown TOMBSTONE: teardown writes
eligible:false+teardown-in-progressdebt BEFORE deleting anything, and deletes the envelope ONLY after teardown success + verified live absence; a partial/ crashed teardown leaves the tombstone (so a surviving artifact can't be rebaselined). The tombstone also rotates the generation — without that, a run that read the snapshot first still matched it and re-blessed its stale view over the tombstone — and a teardown that cannot write it deletes nothing. The CAS write takes the workspace lease itself, so a tombstone cannot land between its compare and its write. A workspace with no snapshot gets a fresh tombstone too (creating the folder if needed, and removing it again after a clean teardown): with none, a first build's baseline write expected "none", nothing ever changed that, and the build blessed the app the teardown was deleting. The tombstone lists every teardown in flight (id, pid, start time), and every teardown that finishes removes its own entry, under the lease (retried briefly if another writer holds it): one that failed or threw keeps the tombstone. After a clean teardown the snapshot is deleted when the last live entry goes — whatever it has become by then — and until then it stays tombstoned, its generation rotated, fencing the deletes still running. A--changed-onlybuild that reads a tombstone listing a teardown still running refuses to build until it finishes (the no-identity fallback included, which writes no snapshot and so reads the workspace again before it builds, refusing when the generation moved during identity discovery). A running teardown refreshes its entry every minute, and an entry whose process is gone, or that has not been seen for five minutes, no longer counts — so a killed teardown's entry stops blocking within minutes, even under a reused pid.--clear-workspaceleaves a workspace whose fence is still held. A workspace lease is reclaimed only from a DEAD holder — or, for a lock with no readable token, one older than five minutes — never from a live one however old: a holder paused mid-write would commit its stale view over the fence on resuming. It is reclaimed by one writer only (an exclusive claim file, itself abandoned only once its claimer is dead, and a re-check of the lock); a reclaim that fails after its write releases what it wrote. An old lease whose holder's pid is alive names the file to delete, in case that pid was reused. - overlap: a
--changed-onlyrun whose generation moved while it built, or whose baseline write another writer refused, reports failure whatever its build returned, and invalidates whatever snapshot it then finds (fenced to the generation it read, retried briefly): a baseline another writer blessed meanwhile would certify a state this run may since have changed. When every attempt is refused, the lease held by a live writer or a snapshot there that cannot be read (only a provably absent one leaves nothing to distrust), the refusal is recorded in a distrust marker (<workspace>/apply-snapshot.distrust.<id>.json, one file per refusal), written beside the snapshot and outside the lease. The next--changed-onlyrun builds in full however eligible the snapshot reads; a full build that lands its baseline deletes the markers it found at its start, by name, never one written since; the last clean teardown deletes them all with the snapshot. An unreadable marker still counts. A marker is only ever created or deleted, never moved or rewritten, so a concurrent reader always sees every other run's.
Projection/verifier framework (scripts/lib/projection.js — deliverable #1, DONE)
Pure, id-free, normalized projections that serve as the EXACT post-apply verifiers (static classification
alone is not trusted): formProjection (placement-exact), sitemapProjection (GUID/env-url normalized),
and page source-vs-deployed dual hashing. Adversarial tests: form-placement collision, page dual-hash,
sitemap normalization (scripts/tests/projection.test.js).
Phase submodes + phase-local publish
On --changed-only, phases run in restricted submodes — forms fieldReconcileOnly (no promote/
deactivate/events/quickviews), app-shell prerequisiteResolveOnly/finalizeSitemapOnly (no icon/
sitemap-solution re-ensure), pages selectedKeysOnly (whole-app read-only safety checks retained, only
changed keys uploaded), views append-only. NO whole-spec publish (PublishAllXml) — phase-local publish
of the touched artifacts only. A pre-mutation live-projection equality check refuses to overwrite a
Maker-drifted artifact (a page write is checked against the page's version only between its own read and its write — the residual concurrent-edit race is documented as
unsupported).
The pages-only fast apply checks the bindings of the pages it WRITES before it writes anything: its changed
keys, and a navigation target only when the target is absent (the pages phase creates it from its spec entry,
bindings and all, and leaves an existing one as it is). Whether a target exists the pages phase learns only
after that check, so the flow passes the page keys the snapshot records as deployed (changedOnly.deployedKeys):
a listed target is not read, an unlisted one is checked (fail closed), and a listed one the pages phase finds
absent (deleted in Maker since the last apply) is checked there before it is created — still before any write,
because the fast apply runs the pages phase alone. The two checks share what the attempt has read, so a name is
read once per attempt and a later read can never undo what an earlier one proved.
CONFIRMED landmine (validated against sdk-build.js) — the pages-only fast path MUST skip the sitemap
finalize. The pages phase's finalize (sdk-build.js:1428-1437) rebuilds the WHOLE sitemap via
appDef(spec, result.created) and writes /siteMap + components. In a pages-only run result.created
holds only app+pages, so appDef (a) THROWS on any dashboard subarea (:610-611,
result.dashboards empty) and (b) rebuilds components from empty result.forms/views/charts (:635),
stripping the app's form/view/chart component registrations. A pure page-content re-upload leaves the
key→pageId map unchanged, so the sitemap needs no rewrite — the fast path seeds result.created.app from
live discovery, uploads only the changed page(s) to their existing pageIds, SKIPS the finalize, and
publishes just the page. Two sdk-build seams (flag-gated, full-build path byte-identical): seed
result.created.app from opts.resolvedAppId, and skip :1428-1437 under the changed-only page submode.
Sequenced deliverables
- ✅ Projection/verifier framework + 3 adversarial tests. 2. ✅ Content hashing + fix the shipped
phase-difffoundation (.tsx/contentPathedits visible to the diff, fail-closed). 3. ✅ Envelope — pure state machine (apply-snapshot.js) + I/O store (apply-snapshot-store.js) +indexArtifacts(apply-snapshot-index.js), wired into the live build (persist/invalidate) + teardown (tombstone/delete). - ✅ Phase submodes (v1) — the pages-only sdk-build seams: seed
result.created.appfromopts.changedOnly.resolvedAppId, skip the sitemap finalize, andselectedKeysOnly(upload only changed keys) + measuredpageDeployedShas. (view/sitemap/form submodes deferred — see follow-ups.) - ✅ Classifier (
classify-changes.js) + thebuild-model-app.js --changed-onlyFLOW (changed-only-flow.js):--changed-onlyflag, live identity (WhoAmI orgId + app discovery), snapshot read→eligibility gate→classify→pages-only fast apply via the seams (or full fallback), invalidate-before-write + fresh-create-only baseline + verify-gated re-bless + generation fencing, the partial-apply guard's exception. 6. ✅ Full offline tests (919 green). 7. ✅ Implementation review — adversarial; all Critical/High findings fixed with tests (see this doc's v1 contract/deferred sections). 8. ✅ Live regression PASSED (a scratch environment, 2026-07-27): (1) fresh--apply --changed-only→ full build, verify 9/9, eligible snapshot (orgId/appId bound, debt 0); (2).tsxbyte edit →--apply --changed-only→ FAST pages-only (2 steps not 12, same pageId = UPDATE, new measured deployedSha, verify 9/9, snapshot re-blessed eligible); (3) chart edit →--apply --changed-only→ full-build fallback, verify 9/9, snapshot INELIGIBLE with stickychart-edit-not-convergent+uncertified-baselinedebt; (4)teardown --apply→ app cascade removed, snapshot tombstoned then deleted (0 leftovers). 9. ✅ Docs — design + capabilities + CHANGELOG + AGENTS.md.
Build-time notes
- Live-absence verification covers the UNION of prior-snapshot identities, current spec, generated artifacts, and all debt entries — not merely the current spec.
- Debt-clearing verifiers must match the specific debt reason (placement verify can't clear event/quick-view debt).
- Keep crash/failure-injection tests + a live page-write publication/concurrency test.