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.
JavaScript claude-code-pluginclaude-code-skillscode-appsgithub-copilot-pluginpower-appspower-pagespower-platform
model-apps 2.20.4: a coded refusal for deeply nested pages; model guidance; page-push docs (#782)
Akshay Malooc159268b994b
diff --git a/evals/model-apps/genpage/lib/tsx-structure.js b/evals/model-apps/genpage/lib/tsx-structure.jsindex c7bc4c710..7b6030f19 100644--- a/evals/model-apps/genpage/lib/tsx-structure.js+++ b/evals/model-apps/genpage/lib/tsx-structure.js@@ -321,8 +321,15 @@ function closingTag(code, name, from, openings = []) {const re = new RegExp(`</${name.replace(/[.$]/g, '\\$&')}(?=[\\s/>])`, 'g');re.lastIndex = from;let depth = 1;- let next = openings.findIndex((tag) => tag.start >= from);- if (next < 0) next = openings.length;+ // The first opening at or after `from`, by a lower-bound binary search: `openings` is in strictly increasing `start` order,+ // as openingTags yields its tags (its pattern's lastIndex only moves forward), so this costs log n per element instead of+ // a scan from the first opening, which made a page of n same-name siblings (`<div></div>` × n) cost n² / 2 visits.+ let next = 0;+ for (let high = openings.length; next < high;) {+ const mid = (next + high) >>> 1;+ if (openings[mid].start < from) next = mid + 1;+ else high = mid;+ }for (let m = re.exec(code); m; m = re.exec(code)) {for (; next < openings.length && openings[next].start < m.index; next += 1) {const tag = tagEnd(code, openings[next].open.attrsFrom);@@ -673,4 +680,6 @@ module.exports = {namedFunctions, nestedDefinitionProblems, withoutComments,// Exported so that a check needing a page's function scopes reads them through this reader instead of a second one.functionScopes,+ // Exported for its test, which counts the openings it reads to pin that finding a closing tag is not quadratic.+ closingTag,};diff --git a/evals/model-apps/genpage/tests/page-expectations.test.js b/evals/model-apps/genpage/tests/page-expectations.test.jsindex 1a14b0abc..b6f85e20c 100644--- a/evals/model-apps/genpage/tests/page-expectations.test.js+++ b/evals/model-apps/genpage/tests/page-expectations.test.js@@ -143,6 +143,27 @@ test('tsx structure: a name inside another tag\u2019s type arguments never countassertPass(grade(LABELS, inline(page)));});+// closingTag finds the first opening of the name after an element's opening tag by a binary search over the source-ordered+// openings: a scan from the first opening read n² / 2 openings for n flat siblings (2,100,223 for 2,048 `<div></div>`).+// The count of openings read, through a proxy, is the measure, not the time.+test('tsx structure: finding the closing tags of n same-name siblings reads about n log n openings, not n squared', () => {+ const { closingTag, sourceView } = require('../lib/tsx-structure.js');+ for (const n of [512, 1024, 2048]) {+ const page = `const P = () => <>${'<div></div>'.repeat(n)}</>;`;+ const { code } = sourceView(page);+ const openings = [...code.matchAll(/<div>/g)].map((m) => ({ start: m.index, open: { attrsFrom: m.index + 4 } }));+ let reads = 0;+ const counted = new Proxy(openings, { get: (target, key, receiver) => { if (/^\d+$/.test(String(key))) reads += 1; return Reflect.get(target, key, receiver); } });+ const ends = openings.map((tag) => closingTag(code, 'div', tag.start + 5, counted).end);+ assert.deepEqual(ends, openings.map((tag) => tag.start + 11), `n = ${n}: each div closes itself`);+ assert.deepEqual(jsxElements(page, /^div$/).map((e) => e.end), ends, `n = ${n}: jsxElements finds the same ends`);+ assert.ok(reads <= n * (Math.log2(n) + 3), `n = ${n}: ${reads} openings read`);+ }+ // Nested same-name elements, and a same-name opening inside another tag's type arguments, keep their exact bounds.+ const bounds = (page, name) => jsxElements(page, new RegExp(`^${name}$`)).map((e) => [e.start, e.openEnd, e.childrenEnd, e.end]);+ assert.deepEqual(bounds('<L<T>><L>x</L><L<U> /><L<V>>y</L></L>', 'L'), [[0, 6, 33, 37], [6, 9, 10, 14], [14, 22, 22, 22], [22, 28, 29, 33]]);+});+// A tag's name may start with `_` or `$`, as any identifier may: such a tag is read, or reported, like any other.test('tsx structure: a tag whose name starts with _ or $ is read or reported like any other', () => {const { unreadableElements } = require('../lib/tsx-structure.js');diff --git a/plugins/model-apps/.claude-plugin/plugin.json b/plugins/model-apps/.claude-plugin/plugin.jsonindex 829591486..383bc2e14 100644--- a/plugins/model-apps/.claude-plugin/plugin.json+++ b/plugins/model-apps/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "model-apps",- "version": "2.20.3",+ "version": "2.20.4","description": "Build model-driven Power Apps end to end: /app-builder authors whole apps (tables, relationships, forms, views, charts, security roles, app + sitemap) from a natural-language intent, and /genpage builds generative pages with specialist agents for planning, entity creation, and parallel code generation. Requires PAC CLI > 2.10.0 and Azure CLI (`az`). See CHANGELOG.md for v1.x -> v2.x migration.","author": {"name": "Microsoft",diff --git a/plugins/model-apps/.plugin/plugin.json b/plugins/model-apps/.plugin/plugin.jsonindex 829591486..383bc2e14 100644--- a/plugins/model-apps/.plugin/plugin.json+++ b/plugins/model-apps/.plugin/plugin.json@@ -1,6 +1,6 @@{"name": "model-apps",- "version": "2.20.3",+ "version": "2.20.4","description": "Build model-driven Power Apps end to end: /app-builder authors whole apps (tables, relationships, forms, views, charts, security roles, app + sitemap) from a natural-language intent, and /genpage builds generative pages with specialist agents for planning, entity creation, and parallel code generation. Requires PAC CLI > 2.10.0 and Azure CLI (`az`). See CHANGELOG.md for v1.x -> v2.x migration.","author": {"name": "Microsoft",diff --git a/plugins/model-apps/AGENTS.md b/plugins/model-apps/AGENTS.mdindex 4ad9ff319..1da1e4ce0 100644--- a/plugins/model-apps/AGENTS.md+++ b/plugins/model-apps/AGENTS.md@@ -540,7 +540,7 @@ the pipeline and delegates each script's **behavioral spec** to the entries belofiles, its conversation messages) that the SDK writes as **one atomic `$batch` change set**, so a write either landed whole or wrote nothing, and the SDK compiles the page itself (a pagethat does not compile is refused before anything is written). What a write that cannot say what it did leaves behind follows from that.A **create** mints the page's id on the client before anything is sent, so what it did can always be found out by reading that id. Only a failure that PROVES nothing was written is reported as `nothing` and- not sent again: a typed refusal the SDK raises before it sends a write request (`PRE_WRITE_REFUSALS` in the module lists each, and where the SDK raises it — a page that does not compile, a write plan it cannot+ not sent again: a typed refusal the SDK raises before it sends a write request (`PRE_WRITE_REFUSALS` in the module lists each, and where the SDK raises it — a page that does not compile or whose elements nest too deeply to compile (`PAGE_NESTING_TOO_DEEP`: split the page into components), a write plan it cannotmake, a workspace copy that cannot be pushed) or a 4xx the service answered (a change set is atomic, so a rejected one leaves nothing). Any other error at or after the send is *unknown*: a reset, a 5xx from anintermediary, an answer the SDK cannot account for — and an error that merely has a string `code`, since a full disk (`ENOSPC`) is raised by the SDK's own workspace write AFTER the service committed the changeset. It is settled by reading the id: present — it landed (published, and said so in a warning); absent — nothing has landed *yet*, so it is sent **once more under the same id**: a first send that lands late@@ -579,6 +579,17 @@ the pipeline and delegates each script's **behavioral spec** to the entries belobundle pins that. What it sends you to look at depends on the caller (`update()`'s `caller`): the upload script'smessage names `genpage-base.js check` (the deployed page against the file and the base marker beside it), and a re-run goes back through the script's own guards; the **build** keeps nobase marker and reads every page again when it runs, so its message says to run the build again. A `VERSION_CONFLICT` on the first send is a known answer: nothing was written (on a resend it settles nothing).+ **What a push's identities and version check do and do not guarantee.** Each push of a page is a new *checkpoint* in one sense only: it has identities of its own. The SDK mints the change-set id (`uxagentproject_<guid>`) for every push, and an update's turn id+ (`newTurn.id`) is minted by the backend once per `update` call. A create's turn is given no id by the backend; the SDK mints one during push preparation (it keeps a GUID it is given and otherwise adds one to its copy of the page), so a create's turn has an identity of the SDK's too,+ and the fixed identity a create's resend relies on is the page id. No supported page operation (`create`, `update`, and the scripts and build phases over them) takes a change-set, checkpoint or turn id from its caller, so a caller cannot pin one so that a retry of the whole call reuses it, and cannot bind an+ approval to one: a second call of `update` is a new push with new ids, and only the resends *inside* one call share a turn id. (The lower-level SDK, and the `newTurnId` seam the tests use, can be given a turn id; that is not a way to retry a page operation.) Do not treat these ids as an idempotency key or as the identity of a reviewed change.+ The version check is **not an atomic expected-version save**. Before each push the SDK reads the page's row and its file rows again and compares their version tokens with the ones the operation read (a page or file that moved, was+ added or was deleted is refused as `VERSION_CONFLICT`, nothing written); but the writes that follow are separate requests that carry `If-Match: *`, because these rows accept no version validator. A writer that saves+ the page *between those reads and the change set* is therefore overwritten without a conflict. The check narrows the window to the length of one push; it does not close it. What it does guarantee is that a page changed+ *before* the push's reads is never written over, and that the compile (including `PAGE_NESTING_TOO_DEEP`, a page whose elements nest too deeply for the compiler's stack), the typed refusals and the error validation all come before any write, so a refused push writes nothing to the service (it may already have made its reads) and leaves the service's copy of the page as it was+ (the SDK's local workspace copy, and the build's own record that it is about to push, are not the service's). What none of this establishes: that the page *works* (the compile is a transpile that reports syntax errors, not a type check, and the error validation checks the shape of what is written, not what the page does when it runs);+ that a conversation turn is *retained* (deleting the page removes it, and nothing here promises it is kept); or that a landed push can be *rolled back* — the change set is all-or-nothing, but nothing restores a page to an earlier push. Do not describe an update as "saved only if the page is still at version N".+ The page's *name* in a refusal is the backend's to give: the compiler is handed only the page's source, so the SDK that `createMakerSdk` makes, used directly (`createArtifact` and then `pushArtifact`, as a test might), refuses a too-deeply nested page with the same code and the generic message, naming no page; `makeGenpageSdk`'s `create` and `update` (the only way a plugin script writes a page) name it. The checks the page files go through before a push — `genpage-worker-output.js` and `promote-intent-pages.js` — refuse such a page with the same code too, where their parse runs out of stack on it (`lib/page-structure.js`), naming the page file or the page; they do not compile, so a page that is merely too deep for a compile is first refused at the push.**A first send the service refuses with a throttle (HTTP 429) is waited out and sent again** (`pushThroughThrottle`), where any other 4xx is final. A 429 is the service declining to *start* the request, so the atomic change set committednothing; and sending it again cannot write a page twice: a create's ids are minted before the first send (a send that was in fact processed meets itself on them and is rolled back whole), and an update's turn carries one identity from whichthe SDK derives its messages' ids. An update's send goes through the SDK's version check again, so a page someone saved during the wait is refused as `VERSION_CONFLICT` and not written over — which is why the backend sends it again one push at a time and the@@ -2845,7 +2856,7 @@ scripts/private-folder.js ← a folder, and a file in it, that only the current user can use — the copy of a settings file that `pac solution import` is given: POSIX modes 0700 and 0600, set and read back; Windows an access list with the current user's SID as its ONE entry (`icacls /reset`, `/inheritance:r`, `/grant:r *<SID>:(OI)(CI)F`, read back as SDDL through `icacls /save`, the file's too before a byte is written; the SDDL aliases of the system accounts are compared as the SIDs they stand for, and `LA`/`LG` — the machine's own Administrator and Guest — only when the machine itself writes the user's SID that way, `spellingOf`), `whoami` and `icacls` looked up in the Windows folder's System32 alone through `process-runner.js`; whatever cannot be set or read back is an error with a `reason` (a tool, a step, a number — never a path or a value) and nothing is writtenexit-cleanup.js ← a synchronous cleanup that runs if the process ends while a run's work is going — `process.exit`, an uncaught error, SIGINT, SIGTERM, SIGHUP, SIGBREAK — after which the process ends as it would have: BY the signal on POSIX (raised again once our listeners are off), with STATUS_CONTROL_C_EXIT (0xC000013A, 3221225786) on Windows, where a Ctrl+C is a console event and `process.kill` would end it with the status 1 of a failure; a program that has a handler of its own for the signal — one-shot and self-removing ones included, however they were put on the list — keeps the decision (ours is first in line, so that it sees them all, and stays first: a handler the program PREPENDS later is put behind it again before the call returns, `keepFirst`, which never puts back a cleanup that was released while it was being moved); a KILLED process runs nothing, which is its stated limittypescript-compiler.js ← loads the vendored TypeScript 5.8.3 compiler (vendor/typescript/) for the SDK's page compile: lazily, once, only after its bytes match PROVENANCE.json- typescript-views.js ← the parser check: where the lexer guessed, the lexer's views of a page built from that compiler's parse (no view where it reports a diagnostic, or where another parser reads the page differently or refuses it), read by the navigation oracle and the structure gate alike (`guessedPageViews`) — see "The parser check" below+ typescript-views.js ← the parser check: where the lexer guessed, the lexer's views of a page built from that compiler's parse (no view where it reports a diagnostic, or where another parser reads the page differently or refuses it; and `tooDeep` where its parse ran out of stack, which the structure gate refuses as `PAGE_NESTING_TOO_DEEP` and not as a cut-off page), read by the navigation oracle and the structure gate alike (`guessedPageViews`) — see "The parser check" belowspec-lint.js / app-spec.js ← App Spec guardrail lint + validationlookup-labels.js ← a lookup column's default label, environment-facing half: the parent table's label read, the old-default repair's column-label read (one per child table) (the pure rule is `lookupLabelFor`, app-spec.js); `lookup-cell-labels.js` repairs the form cellview-filter-labels.js ← resolves a view filter's Choice labels against the environment's option metadata; the build's pre-flight (skipped for a spec with a localized label) and views-phase gate, the dry run, verify and lint all use itdiff --git a/plugins/model-apps/CHANGELOG.md b/plugins/model-apps/CHANGELOG.mdindex e92a4eb81..28e340469 100644--- a/plugins/model-apps/CHANGELOG.md+++ b/plugins/model-apps/CHANGELOG.md@@ -5,6 +5,20 @@ All notable changes to the **model-apps** plugin.Entries are deliberately short: what changed and why it matters to you. The reasoning,evidence and trade-offs behind a change live in its PR, in `docs/`, or in the linked issue.+## [2.20.4]++The bundled SDK is unchanged (power-platform-ux a3443479).++### Fixed++- **A page whose elements nest too deeply to compile is refused with `PAGE_NESTING_TOO_DEEP`**, naming the page; the refused+ page is not written to the service. It used to fail with a misleading error.++### Changed++- **The README recommends a general-purpose coding or advanced reasoning model for `/app-builder` and `/genpage`.** On a+ lightweight model, each skill says so once in its first message and continues.+## [2.20.3]The bundled SDK is unchanged (power-platform-ux a3443479).diff --git a/plugins/model-apps/README.md b/plugins/model-apps/README.mdindex db952b057..85388411d 100644--- a/plugins/model-apps/README.md+++ b/plugins/model-apps/README.md@@ -94,6 +94,12 @@ Custom API discovery omits private APIs and APIs with Entity/EntityCollection inLookup input names stay available to the author separately from the primitive-only wire`parameterKinds`; see [the Custom API contract](references/custom-api.md).+## Model selection++Use a general-purpose coding model or an advanced reasoning model. Lightweight models optimized+primarily for fast, simple tasks aren't recommended for `/app-builder` or `/genpage` because both+skills require multistep planning, tool use, code generation, and validation.+## SkillsPCF code components ship in the separate preview [pcf plugin](../pcf/README.md).diff --git a/plugins/model-apps/scripts/genpage-worker-output.js b/plugins/model-apps/scripts/genpage-worker-output.jsindex 07dd22a19..13122aa58 100644--- a/plugins/model-apps/scripts/genpage-worker-output.js+++ b/plugins/model-apps/scripts/genpage-worker-output.js@@ -10,7 +10,7 @@const fs = require('node:fs');const path = require('node:path');// The structural gate is shared with promote-intent-pages.js (see lib/page-structure.js).-const { pageStructureProblems: structuralProblems } = require('./lib/page-structure.js');+const { pageStructure, pageStructureProblems: structuralProblems } = require('./lib/page-structure.js');// A worker that returns without writing leaves whatever was at its path before, and a complete page an// earlier attempt left there passes every content check: the stale page was deployed instead of taking@@ -116,7 +116,9 @@ function validatePageOutput({ filePath }) {}// Written since the stamp (or no stamp at all): the stamp has done its job.if (stamp) consumeStamp(abs);- const problems = structuralProblems(bytes.toString('utf8'));+ const { problems, code } = pageStructure(bytes.toString('utf8'));+ // A valid page nested too deeply for the parser is refused with the compile's own code and the page's file, not as the cut-off page the lexer's guess made of it.+ if (code) return { ok: false, filePath: abs, code, problems: problems.map((p) => `page file "${path.basename(abs)}": ${p}`) };return { ok: problems.length === 0, filePath: abs, problems };}diff --git a/plugins/model-apps/scripts/lib/genpage-sdk.js b/plugins/model-apps/scripts/lib/genpage-sdk.jsindex d3c7c837b..dd1f760a3 100644--- a/plugins/model-apps/scripts/lib/genpage-sdk.js+++ b/plugins/model-apps/scripts/lib/genpage-sdk.js@@ -120,6 +120,9 @@ const codeOf = (error) => (error && typeof error.code === 'string' && error.code// resolve, a module that does not satisfy the page contract// GENPAGE_COMPILER_UNAVAILABLE / _VERSION / _INVALID, GENPAGE_RUNTIME_TYPES_INVALID// no usable TypeScript compiler, or the page's RuntimeTypes could not be built+// PAGE_NESTING_TOO_DEEP the page's elements nest so deeply that the compiler ran out of stack space (lib/page-nesting.js raises it from the+// compiler the SDK is given; the SDK compiles ahead of every write, so a push that raises it wrote nothing to the+// service, though its metadata reads may already have been made)// GENPAGE_CONTENT_WRITE_UNSUPPORTED, GENPAGE_TURN_NOT_ATOMIC// the transport cannot write this page as one change set (assertContentWritable / assertTurnWritable)// GENPAGE_TURN_CONFLICT the pending turn's id is already recorded as a different message (`unrecordedTurn`, a read)@@ -132,7 +135,7 @@ const codeOf = (error) => (error && typeof error.code === 'string' && error.code// be one of these, on an SdkError.const PRE_WRITE_REFUSALS = new Set(['VALIDATION_ERROR',- 'GENPAGE_COMPILER_UNAVAILABLE', 'GENPAGE_COMPILER_VERSION', 'GENPAGE_COMPILER_INVALID', 'GENPAGE_RUNTIME_TYPES_INVALID',+ 'GENPAGE_COMPILER_UNAVAILABLE', 'GENPAGE_COMPILER_VERSION', 'GENPAGE_COMPILER_INVALID', 'GENPAGE_RUNTIME_TYPES_INVALID', 'PAGE_NESTING_TOO_DEEP','GENPAGE_CONTENT_WRITE_UNSUPPORTED', 'GENPAGE_TURN_NOT_ATOMIC', 'GENPAGE_TURN_CONFLICT','GENPAGE_RETAIN_ON_CREATE', 'GENPAGE_RETAINED_ROW_MISSING', 'GENPAGE_CONTENT_NOT_TEXT', 'GENPAGE_WRITE_UNKNOWN','ARTIFACT_NOT_FOUND', 'ARTIFACT_LANGUAGE_MISMATCH', 'ARTIFACT_PROJECTION_STALE',diff --git a/plugins/model-apps/scripts/lib/maker-sdk.js b/plugins/model-apps/scripts/lib/maker-sdk.jsindex a07fa0316..d5240a5ea 100644--- a/plugins/model-apps/scripts/lib/maker-sdk.js+++ b/plugins/model-apps/scripts/lib/maker-sdk.js@@ -33,6 +33,7 @@// land in a file. The folder, the paths and every other member are the storage's own: the wrapper has it for a prototype, so a caller's `instanceof` and the SDK's own look for a file-system storage still hold.const bundle = require('../vendor/cds-maker-sdk.cjs');const { loadVendoredTypeScript } = require('./typescript-compiler.js');+const { guardPageNesting } = require('./page-nesting.js');const { guardTableLists } = require('./collection-answers.js');const { guardAppHeaderWrites } = require('./app-header-text.js');const { guardWorkspaceStorage } = require('./output-redaction.js');@@ -42,7 +43,8 @@ const { guardWorkspaceStorage } = require('./output-redaction.js');function withVendoredCompiler(create) {return (options) => {const { connectivity, ...forSdk } = options || {};- const made = { typescript: () => loadVendoredTypeScript(), ...forSdk };+ // The compiler goes to the SDK through guardPageNesting (lib/page-nesting.js): a page nested too deeply for it to compile is refused with a code (PAGE_NESTING_TOO_DEEP), not a bare RangeError.+ const made = { typescript: () => guardPageNesting(loadVendoredTypeScript(), (code, message) => new bundle.SdkError(code, message)), ...forSdk };if (made.httpClient) made.httpClient = guardTableLists(made.httpClient, (code, message) => new bundle.SdkError(code, message));if (made.httpClient) made.httpClient = guardAppHeaderWrites(made.httpClient, (code, message) => new bundle.SdkError(code, message));if (made.workspaceStorage) made.workspaceStorage = guardWorkspaceStorage(made.workspaceStorage);diff --git a/plugins/model-apps/scripts/lib/page-nesting.js b/plugins/model-apps/scripts/lib/page-nesting.jsnew file mode 100644index 000000000..1260d82af--- /dev/null+++ b/plugins/model-apps/scripts/lib/page-nesting.js@@ -0,0 +1,62 @@+'use strict';+// A coded refusal for a page whose elements nest too deeply to compile.+//+// TypeScript parses and transforms a page with recursive functions, one level of recursion per nested JSX element (and one more per nested+// expression). Around a thousand nested elements exhaust V8's default stack, and the compiler then throws+// RangeError: Maximum call stack size exceeded+// out of `transpileModule`. The SDK compiles a page on every push that changes its source and does not catch that, so without this module the+// maker was shown a bare RangeError — or, through the page backend's own settling of a push that "got no usable answer", a message about a+// create that "was sent twice", although the SDK compiles BEFORE it writes anything: the page was not written to the service (its metadata reads+// may already have been made).+//+// The depth that overflows is not a fixed number: the first compile in a process runs in the interpreter, whose frames are larger, so it+// overflows at roughly two thirds of the depth that a later, optimised, compile reaches (measured: a page nested 600 deep overflowed a cold+// Node 22 compile and compiled once warm). Hence no depth is checked here — the refusal follows what the compiler actually did.+//+// The overflow is attributed to the compile by wrapping the compiler itself: only a stack overflow thrown out of one of the compiler's own parse+// entry points is turned into the refusal. A RangeError from anywhere else — and every other error from the compiler — passes through untouched,+// as does every result, so a page that compiles is compiled exactly as before.++const PAGE_NESTING_TOO_DEEP = 'PAGE_NESTING_TOO_DEEP';++const PAGE_NESTING_MESSAGE = 'the elements of the page nest too deeply to compile (the compiler ran out of stack space) — '+ + 'split the page into components, so that no element sits inside hundreds of others';++// V8's stack overflow is `RangeError: Maximum call stack size exceeded`, in English whatever the locale (it is not a localised message). The error+// is recognised by its name and message, not by `instanceof RangeError`: a compiler evaluated in another realm throws that realm's RangeError.+function isStackOverflow(error) {+ return Boolean(error) && typeof error === 'object' && error.name === 'RangeError'+ && typeof error.message === 'string' && error.message.startsWith('Maximum call stack size exceeded');+}++// The compiler's entry points that recurse over a page's syntax: the transpile (which also runs the SDK's own walk over the tree, as a transformer),+// the parse and the program (the checker) the SDK builds to resolve enum names.+const GUARDED = ['transpileModule', 'createSourceFile', 'createProgram'];++// The compiler as the SDK is given it: the same object for every member except the entry points above, which throw `makeError(code, message)` when+// they overflow the stack. An object that INHERITS from the compiler, so a read of any other member (the SDK reads a few per syntax node) is the+// compiler's own and costs nothing; own properties are defined, not assigned, because the compiler's exports are getters without a setter.+// The compiler's functions use no `this`, so each is called with the compiler itself as before.+function guardPageNesting(ts, makeError) {+ const guarded = Object.create(ts);+ for (const name of GUARDED) {+ const original = ts[name];+ if (typeof original !== 'function') continue;+ Object.defineProperty(guarded, name, {+ enumerable: true,+ configurable: true,+ writable: true,+ value: function guardedEntryPoint(...args) {+ try {+ return original.apply(ts, args);+ } catch (error) {+ if (isStackOverflow(error)) throw makeError(PAGE_NESTING_TOO_DEEP, PAGE_NESTING_MESSAGE);+ throw error;+ }+ },+ });+ }+ return guarded;+}++module.exports = { PAGE_NESTING_TOO_DEEP, PAGE_NESTING_MESSAGE, isStackOverflow, guardPageNesting };diff --git a/plugins/model-apps/scripts/lib/page-structure.js b/plugins/model-apps/scripts/lib/page-structure.jsindex e0181cd47..4e25cef5a 100644--- a/plugins/model-apps/scripts/lib/page-structure.js+++ b/plugins/model-apps/scripts/lib/page-structure.js@@ -20,6 +20,7 @@// const prose = "export default GeneratedComponent"; -> acceptedconst { blankLiterals, endsMidStatement, findElisionMarker, hasDefaultExport, hasUnbalancedBrackets, trimTrivia, WS } = require('./source-literals.js');const { guessedPageViews } = require('./typescript-views.js');+const { PAGE_NESTING_TOO_DEEP, PAGE_NESTING_MESSAGE } = require('./page-nesting.js');// A line that opens a markdown fence, after the white space TypeScript skips (source-literals.js, isTrivia): U+0085 and the zero-width space before a fence are white space to it.const MARKDOWN_FENCE = new RegExp(`^${WS}*(\`\`\`|~~~)`, 'm');@@ -30,14 +31,13 @@ const MARKDOWN_FENCE = new RegExp(`^${WS}*(\`\`\`|~~~)`, 'm');// where it does report one, or did not need to be asked, the lexer's views stand — and so they do where another reader reads the page differently or refuses it// (a JSX attribute string after trivia, grammar only TypeScript's parser takes), decided by guessedPageViews exactly as the navigation oracle decides it. Every// check is the same either way: only the views they read differ.-function parsedViews(text) {- return guessedPageViews(text).views;-}--function pageStructureProblems(code) {+// A page whose parse ran out of stack space (`tooDeep`) is a valid page nested too deeply for the parser, and the lexer's view of it, which stands, is the wrong one: its+// guess made a complete page look cut off. It is refused for that, with the code the compile's refusal has (page-nesting.js), and not for the symptoms of the guess.+function pageStructure(code) {const text = String(code == null ? '' : code);- if (!trimTrivia(text)) return ['file is empty'];- const views = parsedViews(text);+ if (!trimTrivia(text)) return { problems: ['file is empty'], code: null };+ const { views, tooDeep } = guessedPageViews(text);+ if (tooDeep) return { problems: [PAGE_NESTING_MESSAGE], code: PAGE_NESTING_TOO_DEEP };const problems = [];// hasDefaultExport also refuses a file cut off INSIDE its export (`export default function P(props)`// with no body), so the message says so: the fix is to write the whole page, not to add an export.@@ -57,7 +57,12 @@ function pageStructureProblems(code) {// Elided code (`// TODO: …`, `// ...`, "omitted for brevity"), the same rule the genpage evals apply.const elision = findElisionMarker(text, views);if (elision) problems.push(`contains ${elision} — the page is incomplete`);- return problems;+ return { problems, code: null };+}++// The problems alone, for the callers that have no use for the code.+function pageStructureProblems(code) {+ return pageStructure(code).problems;}-module.exports = { pageStructureProblems };+module.exports = { pageStructure, pageStructureProblems };diff --git a/plugins/model-apps/scripts/lib/typescript-views.js b/plugins/model-apps/scripts/lib/typescript-views.jsindex 7460b9544..4c5ee953a 100644--- a/plugins/model-apps/scripts/lib/typescript-views.js+++ b/plugins/model-apps/scripts/lib/typescript-views.js@@ -28,6 +28,7 @@// type (`asserts x`); `readonly` before a type that is no array or tuple; and an empty list of type arguments or type parameters (`A<>`).const { loadVendoredTypeScript } = require('./typescript-compiler.js');const { blankNonCodePreservingTemplateExpressions, isLineTerminator } = require('./source-literals.js');+const { isStackOverflow } = require('./page-nesting.js');// The views of the last sources asked about: the oracle lexes one source several times per call (resolve, stray, residual), and each would parse it again.const CACHE_LIMIT = 8;@@ -47,23 +48,32 @@ function setParserCheck(enabled) {* @param {{ ts?: object }} [options] `ts`: a TypeScript namespace to parse with (a test seam; the vendored compiler otherwise)* @returns {null | { literal: string, keep: string, comments: Array<{ start: number, end: number, text: string }>, regexEnds: Set<number>, jsxTagEnds: Set<number> }}*/-function typescriptViews(src, { ts = null } = {}) {- if (!ts && !parserCheck) return null;+function typescriptViews(src, options) {+ return parseViews(src, options).views;+}++// typescriptViews, and whether the parse work failed for want of stack (`tooDeep`) — the one failure told apart from the others, because it is the page's fault and the+// maker can fix it (page-nesting.js). The caller that has no use for the difference reads `views`, which is null for it as for every other failure.+function parseViews(src, { ts = null } = {}) {+ if (!ts && !parserCheck) return NO_VIEWS;const text = String(src == null ? '' : src);if (!ts && cache.has(text)) return cache.get(text);- let views = null;+ let result;try {- views = buildViews(ts || loadVendoredTypeScript(), text);- } catch {+ result = { views: buildViews(ts || loadVendoredTypeScript(), text), tooDeep: false };+ } catch (error) {// Fail closed: a compiler that cannot be loaded (its provenance check failed) or a parse that cannot be walked vouches for nothing, and the lexer's guesses stand.- views = null;+ // A stack overflow in the parse or in the walk over it (one level of recursion per nested element) is the same failure, but is kept apart: it says the page nests+ // too deeply, not that it is cut off. It is recognised by what was thrown, not by a depth, as the compile's is (page-nesting.js).+ result = { views: null, tooDeep: isStackOverflow(error) };}if (!ts) {if (cache.size >= CACHE_LIMIT) cache.delete(cache.keys().next().value);- cache.set(text, views);+ cache.set(text, result);}- return views;+ return result;}+const NO_VIEWS = Object.freeze({ views: null, tooDeep: false });function buildViews(ts, src) {const sf = ts.createSourceFile('page.tsx', src, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);@@ -201,9 +211,10 @@ function readAnotherWay(ts, src, sf, node) {* The lexer's executable view of `src` and its first guess (`onAmbiguity`: { at, kind }, or null), and — where it guessed — the parser's views of the page* (typescriptViews), which settle the guess: null where the lexer did not guess, where it guessed a JSX attribute string after trivia (no parser settles that one), and* where typescriptViews has none. The one place the navigation oracle (pageref-resolver.js) and the structure gate (page-structure.js) decide which reading stands,- * so the two never decide it differently.+ * so the two never decide it differently. `tooDeep` is true where that parse ran out of stack space (page-nesting.js): the page is valid, and the lexer's view of it,+ * which stands, is the wrong one — the gates say the page nests too deeply, not that it is cut off.* @param {string} src- * @returns {{ keep: string, frontier: null | { at: number, kind: string }, views: null | object }}+ * @returns {{ keep: string, frontier: null | { at: number, kind: string }, views: null | object, tooDeep: boolean }}*/function guessedPageViews(src) {let frontier = null;@@ -214,7 +225,8 @@ function guessedPageViews(src) {if (!frontier || at < frontier.at) frontier = { at, kind };},});- return { keep, frontier, views: frontier !== null && !jsxAttribute ? typescriptViews(src) : null };+ const parsed = frontier !== null && !jsxAttribute ? parseViews(src) : NO_VIEWS;+ return { keep, frontier, views: parsed.views, tooDeep: parsed.tooDeep };}-module.exports = { typescriptViews, guessedPageViews, setParserCheck };+module.exports = { typescriptViews, parseViews, guessedPageViews, setParserCheck };diff --git a/plugins/model-apps/scripts/promote-intent-pages.js b/plugins/model-apps/scripts/promote-intent-pages.jsindex 7db16a92f..9a7da55fe 100644--- a/plugins/model-apps/scripts/promote-intent-pages.js+++ b/plugins/model-apps/scripts/promote-intent-pages.js@@ -25,7 +25,7 @@ const { pageKey, pageFile } = require('./lib/page-plan.js');const { navReferencedKeys, navMalformedRefs, navTargetParity, strayPageRefs, describePageRefLocations, pageRefAdvice, frontierNote, PAGEREF_RULE } = require('./lib/pageref-resolver.js');// The structural gate (empty, truncated, prose, elided) is shared with genpage-worker-output.js, so a// page one gate refuses the other refuses too. See lib/page-structure.js for each check and why.-const { pageStructureProblems: structuralProblems } = require('./lib/page-structure.js');+const { pageStructure, pageStructureProblems: structuralProblems } = require('./lib/page-structure.js');function validatePage(page, absWorkingDir) {const key = pageKey(page);@@ -43,7 +43,10 @@ function validatePage(page, absWorkingDir) {if (!fs.existsSync(abs)) return { key, file, problems: ['file was never written'] };const code = fs.readFileSync(abs, 'utf8');- const problems = structuralProblems(code);+ const { problems, code: refusalCode } = pageStructure(code);+ // A valid page nested too deeply for the parser is refused with the compile's own code and the page's name, and nothing else is said of it: what the navigation+ // checks below would find is read from the lexer's wrong view of it.+ if (refusalCode) return { key, file, code: refusalCode, problems: problems.map((p) => `page "${page.name || key}" (${file}): ${p}`) };// Cross-page nav must be exactly what the spec declares, checked BEFORE promotion. The build// HALTs on a malformed PAGEREF or a nav parity mismatch, so catching it here keeps the failurediff --git a/plugins/model-apps/scripts/tests/genpage-page-nesting.test.js b/plugins/model-apps/scripts/tests/genpage-page-nesting.test.jsnew file mode 100644index 000000000..2692902ab--- /dev/null+++ b/plugins/model-apps/scripts/tests/genpage-page-nesting.test.js@@ -0,0 +1,197 @@+'use strict';+// A page whose elements nest too deeply to compile is refused with a code, and nothing is written (lib/page-nesting.js).+// V8's default stack runs out in TypeScript's recursive parse at roughly a thousand nested elements (fewer on the first compile of a process, whose frames are+// larger), and the compiler then throws a bare `RangeError: Maximum call stack size exceeded` out of `transpileModule`. These tests drive the REAL SDK bundle and+// the vendored compiler over the fake of the tables behind a page (helpers/fake-genpage-server.js), so what is proven is what a push does, on whichever runtime runs them.+// This file checks where lib/temp-workspace.js makes a workspace, so it works in a temp folder of its own (helpers/own-temp-folder.js), required first.+require('./helpers/own-temp-folder.js');+const { test } = require('node:test');+const assert = require('node:assert');+const { makeGenpageSdk, writeOutcome, PRE_WRITE_REFUSALS } = require('../lib/genpage-sdk.js');+const { guardPageNesting, isStackOverflow, PAGE_NESTING_TOO_DEEP, PAGE_NESTING_MESSAGE } = require('../lib/page-nesting.js');+const { SdkError, createMakerSdk, createNodeWorkspaceStorage } = require('../lib/maker-sdk.js');+const { pageStructure, pageStructureProblems } = require('../lib/page-structure.js');+const { guessedPageViews, parseViews } = require('../lib/typescript-views.js');+const { validatePageOutput } = require('../genpage-worker-output.js');+const { validatePage } = require('../promote-intent-pages.js');+const { makeTempDir } = require('./helpers/temp-dirs.js');+const fs = require('node:fs');+const path = require('node:path');+const { FakeGenPageServer, INSTANCE, ACCOUNT_TABLE } = require('./helpers/fake-genpage-server.js');++// A page whose root element holds `depth` nested elements. 5,000 overflows the stack on a cold or a warm compile alike, on Node 20 and 22; 100 is well inside it.+const nested = (depth) => `import * as React from 'react';\nexport default function Page() { return ${'<div>'.repeat(depth)}x${'</div>'.repeat(depth)}; }\n`;+const TOO_DEEP = nested(5000);+const DEEP_BUT_FINE = nested(100);+// A generic call signature is a guess for the lexer (an element or type parameters?), so such a page goes to TypeScript's parser — which, on 5,000 nested elements, runs out of stack.+const GENERIC_SIGNATURE = 'interface Api { <U>(x: U): U; }\n';+const GUESSED_TOO_DEEP = GENERIC_SIGNATURE + TOO_DEEP;+// The same guess, on a page that really is cut off: the parser reports a diagnostic, and today's messages stand.+const GUESSED_CUT_OFF = `${GENERIC_SIGNATURE}export default function Page() { return <div>`;+const stackOverflow = () => new RangeError('Maximum call stack size exceeded');++function makeServer() {+ const server = new FakeGenPageServer();+ server.serveTable(ACCOUNT_TABLE);+ return server;+}+async function withBackend(server, fn) {+ const genpage = makeGenpageSdk(INSTANCE, { httpClient: server.http() });+ try {+ return await fn(genpage);+ } finally {+ await genpage.dispose();+ }+}+const changeWrites = (server) => server.writes().filter((w) => !/PublishXml/.test(w));++test('a push of a page nested too deeply to compile is refused with PAGE_NESTING_TOO_DEEP, naming the page, and writes nothing — on create and on update', async () => {+ const server = makeServer();+ await withBackend(server, async (genpage) => {+ await assert.rejects(+ genpage.create({ name: 'Overview', source: TOO_DEEP, dataSources: 'account', prompt: 'p' }),+ (e) => {+ assert.strictEqual(e.code, PAGE_NESTING_TOO_DEEP);+ assert.strictEqual(e.outcome, 'nothing', 'the compile comes before any write: nothing was sent');+ assert.strictEqual(e.transient, false, 'a run again would meet the same page');+ assert.ok(!(e instanceof RangeError) && !/Maximum call stack/.test(e.message), 'no bare RangeError reaches the caller');+ assert.match(e.message, /^generative page "Overview" was not created \(nothing was written\): the elements of the page nest too deeply to compile .* split the page into components/);+ return true;+ },+ );+ assert.deepStrictEqual(changeWrites(server), [], 'not one request was written');+ assert.strictEqual(server.state.projects.size, 0, 'no page, no half page');++ const { pageId } = await genpage.create({ name: 'Overview', source: DEEP_BUT_FINE, dataSources: 'account', prompt: 'p', agentMessage: 'ok' });+ const before = server.writes().length;+ await assert.rejects(+ genpage.update(pageId, { source: TOO_DEEP, prompt: 'p2', agentMessage: 'a2' }),+ (e) => e.code === PAGE_NESTING_TOO_DEEP && e.outcome === 'nothing' && e.pageId === pageId+ && /^the update of generative page "Overview" \(.+\) failed and wrote nothing: the elements of the page nest too deeply to compile/.test(e.message)+ && !/Maximum call stack/.test(e.message),+ );+ assert.strictEqual(server.writes().length, before, 'the refused update wrote nothing');+ assert.strictEqual((await genpage.read(pageId)).source, DEEP_BUT_FINE, 'the page still holds what it held');+ });+});++test('a deep page that compiles is pushed exactly as before, and a compile that fails for another reason is still the SDK\'s own refusal', async () => {+ const server = makeServer();+ await withBackend(server, async (genpage) => {+ const out = await genpage.create({ name: 'Deep', source: DEEP_BUT_FINE, dataSources: 'account', prompt: 'p' });+ assert.strictEqual(out.publish.kind, 'verified');+ assert.strictEqual((await genpage.read(out.pageId)).source, DEEP_BUT_FINE);+ await assert.rejects(+ genpage.create({ name: 'Bad', source: 'export default function Page() { return <div>; }', dataSources: 'account', prompt: 'p' }),+ (e) => e.code === 'VALIDATION_ERROR' && e.outcome === 'nothing',+ );+ });+});++test('the guard turns only a stack overflow out of the compiler\'s own entry points into the refusal; every other error, result and member is the compiler\'s own', () => {+ const calls = [];+ const SyntaxKind = { A: 1 };+ // Exports as the bundled compiler has them: getters without a setter, so an assignment to the guarded object must not be what installs the wrapper.+ const ts = Object.defineProperties({}, {+ version: { get: () => '5.8.3', enumerable: true },+ SyntaxKind: { get: () => SyntaxKind, enumerable: true },+ transpileModule: { get: () => (...args) => { calls.push(args); return { outputText: 'compiled' }; }, enumerable: true },+ createSourceFile: { get: () => () => { throw stackOverflow(); }, enumerable: true },+ createProgram: { get: () => () => { throw new RangeError('Invalid array length'); }, enumerable: true },+ forEachChild: { get: () => () => { throw stackOverflow(); }, enumerable: true },+ });+ const made = [];+ const guarded = guardPageNesting(ts, (code, message) => { made.push(code); return new SdkError(code, message); });+ assert.deepStrictEqual(guarded.transpileModule('src', { a: 1 }), { outputText: 'compiled' });+ assert.deepStrictEqual(calls, [['src', { a: 1 }]], 'the arguments are the compiler\'s');+ assert.throws(() => guarded.createSourceFile('x'), (e) => e instanceof SdkError && e.code === PAGE_NESTING_TOO_DEEP);+ assert.throws(() => guarded.createProgram({}), (e) => e instanceof RangeError && e.message === 'Invalid array length', 'another RangeError is not a nesting problem');+ assert.throws(() => guarded.forEachChild({}, () => {}), (e) => e instanceof RangeError && /Maximum call stack/.test(e.message), 'an entry point that is not guarded is not touched');+ assert.strictEqual(guarded.version, '5.8.3');+ assert.strictEqual(guarded.SyntaxKind, SyntaxKind, 'a member that is not an entry point is the compiler\'s own object');+ assert.deepStrictEqual(made, [PAGE_NESTING_TOO_DEEP]);+});++test('only V8\'s stack overflow counts, and an overflow that did not come out of the compiler is an unknown outcome as before', () => {+ assert.strictEqual(isStackOverflow(stackOverflow()), true);+ for (const other of [new RangeError('Invalid array length'), new Error('Maximum call stack size exceeded'), new TypeError('Maximum call stack size exceeded'), null, undefined, 'Maximum call stack size exceeded']) {+ assert.strictEqual(isStackOverflow(other), false, String(other && other.message || other));+ }+ assert.strictEqual(writeOutcome(stackOverflow()), 'unknown', 'a RangeError from anywhere else proves nothing about a write');+ assert.strictEqual(writeOutcome(new SdkError(PAGE_NESTING_TOO_DEEP, 'x')), 'nothing');+ assert.ok(PRE_WRITE_REFUSALS.has(PAGE_NESTING_TOO_DEEP));+ assert.strictEqual(writeOutcome(Object.assign(new Error('looks typed'), { code: PAGE_NESTING_TOO_DEEP })), 'unknown', 'only an SdkError counts: the code alone is not the proof');+});++test('a parse that runs out of stack is told apart from every other parse failure, and only on the page it ran out on', () => {+ // buildViews reads the enum members before it calls the parser, so the fake carries them.+ const throwing = (error) => ({ ScriptTarget: { Latest: 99 }, ScriptKind: { TSX: 4 }, createSourceFile: () => { throw error; } });+ assert.deepStrictEqual(parseViews('x', { ts: throwing(stackOverflow()) }), { views: null, tooDeep: true });+ for (const other of [new Error('boom'), new RangeError('Invalid array length'), new TypeError('Maximum call stack size exceeded')]) {+ assert.deepStrictEqual(parseViews('x', { ts: throwing(other) }), { views: null, tooDeep: false }, String(other));+ }+ assert.strictEqual(guessedPageViews(GUESSED_TOO_DEEP).tooDeep, true, 'the real parse of the real page');+ assert.strictEqual(guessedPageViews(GUESSED_TOO_DEEP).views, null);+ assert.strictEqual(guessedPageViews(GUESSED_CUT_OFF).tooDeep, false, 'a page the parser reports a diagnostic on is not a nesting problem');+ assert.strictEqual(guessedPageViews(TOO_DEEP).tooDeep, false, 'the lexer did not guess, so no parse was asked for, and none ran out');+ assert.strictEqual(guessedPageViews(DEEP_BUT_FINE).tooDeep, false);+});++function writePage(dir, name, text) {+ fs.writeFileSync(path.join(dir, name), text);+ return path.join(dir, name);+}++test('/genpage\'s output gate and the promotion gate refuse a valid page that the parser cannot read for want of stack with the compile\'s code and the page\'s name, not as a cut-off page', () => {+ const dir = makeTempDir('nest-gates-');+ const file = writePage(dir, 'Nested page.tsx', GUESSED_TOO_DEEP);+ const worker = validatePageOutput({ filePath: file });+ assert.strictEqual(worker.ok, false);+ assert.strictEqual(worker.code, PAGE_NESTING_TOO_DEEP);+ assert.strictEqual(worker.problems.length, 1, JSON.stringify(worker.problems));+ assert.match(worker.problems[0], /^page file "Nested page\.tsx": the elements of the page nest too deeply to compile .* split the page into components/);+ assert.ok(!/truncated|default export|mid-statement/.test(worker.problems.join('\n')), 'no symptom of the lexer\'s wrong reading');++ // The promotion gate reads the same page and, being asked about navigation as well, says nothing of it: what it would find is read from the same wrong view.+ const promoted = validatePage({ key: 'overview', name: 'Overview', source: { kind: 'tsx', codeFile: 'Nested page.tsx' }, navigatesTo: ['other'] }, dir);+ assert.strictEqual(promoted.code, PAGE_NESTING_TOO_DEEP);+ assert.strictEqual(promoted.key, 'overview');+ assert.strictEqual(promoted.file, 'Nested page.tsx');+ assert.strictEqual(promoted.problems.length, 1, JSON.stringify(promoted.problems));+ assert.match(promoted.problems[0], /^page "Overview" \(Nested page\.tsx\): the elements of the page nest too deeply to compile .* split the page into components/);+ assert.deepStrictEqual(pageStructure(GUESSED_TOO_DEEP), { problems: [PAGE_NESTING_MESSAGE], code: PAGE_NESTING_TOO_DEEP });+});++test('the gates keep today\'s answers for every page that is not one the parser ran out of stack on', () => {+ const dir = makeTempDir('nest-gates-');+ // The same deep page without a guess is read whole by the lexer: complete, nothing refused, no code.+ assert.deepStrictEqual(pageStructure(TOO_DEEP), { problems: [], code: null });+ const plain = validatePageOutput({ filePath: writePage(dir, 'plain.tsx', TOO_DEEP) });+ assert.deepStrictEqual({ ok: plain.ok, code: plain.code, problems: plain.problems }, { ok: true, code: undefined, problems: [] });+ assert.deepStrictEqual(validatePage({ key: 'plain', name: 'Plain', source: { kind: 'tsx', codeFile: 'plain.tsx' } }, dir), { key: 'plain', file: 'plain.tsx', problems: [] });++ // A guessed page that really is cut off: the parser reports a diagnostic (no stack overflow), and the lexer's messages stand, with no code.+ const cut = pageStructure(GUESSED_CUT_OFF);+ assert.strictEqual(cut.code, null);+ assert.ok(cut.problems.length > 0 && cut.problems.some((p) => /truncated|default export/.test(p)), JSON.stringify(cut.problems));+ assert.deepStrictEqual(pageStructureProblems(GUESSED_CUT_OFF), cut.problems);+ const refused = validatePageOutput({ filePath: writePage(dir, 'cut.tsx', GUESSED_CUT_OFF) });+ assert.strictEqual(refused.ok, false);+ assert.strictEqual(refused.code, undefined);+ assert.deepStrictEqual(refused.problems, cut.problems, 'no page name is added to a problem that is not the nesting one');+ assert.strictEqual(pageStructure('').code, null);+ assert.deepStrictEqual(pageStructureProblems(''), ['file is empty']);+ // A small page with a generic signature that parses is read as the parser reads it, as before.+ assert.deepStrictEqual(pageStructure(`${GENERIC_SIGNATURE}${DEEP_BUT_FINE}`), { problems: [], code: null });+});++test('a push through the factory\'s own SDK, with no page backend over it, is refused with the same code and nothing is written; the page\'s name is the backend\'s to add', async () => {+ const server = makeServer();+ const folder = makeTempDir('nest-direct-');+ const sdk = createMakerSdk({ workspaceStorage: createNodeWorkspaceStorage(folder), instanceUrl: INSTANCE, httpClient: server.http() });+ await sdk.initWorkspace();+ const page = await sdk.createArtifact('genPage', { name: 'Direct', source: TOO_DEEP, dataSources: ['account'], newTurn: { prompt: 'p' } });+ await assert.rejects(sdk.pushArtifact('genPage', page.id), (e) => e instanceof SdkError && e.code === PAGE_NESTING_TOO_DEEP && !(e instanceof RangeError) && !/Maximum call stack/.test(e.message));+ assert.deepStrictEqual(changeWrites(server), [], 'the compile comes before every write');+ assert.strictEqual(server.state.projects.size, 0);+});diff --git a/plugins/model-apps/scripts/tests/genpage-sdk.test.js b/plugins/model-apps/scripts/tests/genpage-sdk.test.jsindex e74983c40..1d8d428ee 100644--- a/plugins/model-apps/scripts/tests/genpage-sdk.test.js+++ b/plugins/model-apps/scripts/tests/genpage-sdk.test.js@@ -89,7 +89,7 @@ test('writeOutcome: what a failed SDK send says it did — nothing, or unknown'ARTIFACT_LANGUAGE_MISMATCH', 'ARTIFACT_NOT_FOUND', 'ARTIFACT_PROJECTION_STALE','GENPAGE_COMPILER_INVALID', 'GENPAGE_COMPILER_UNAVAILABLE', 'GENPAGE_COMPILER_VERSION', 'GENPAGE_CONTENT_NOT_TEXT', 'GENPAGE_CONTENT_WRITE_UNSUPPORTED','GENPAGE_RETAINED_ROW_MISSING', 'GENPAGE_RETAIN_ON_CREATE', 'GENPAGE_RUNTIME_TYPES_INVALID', 'GENPAGE_TURN_CONFLICT', 'GENPAGE_TURN_NOT_ATOMIC', 'GENPAGE_WRITE_UNKNOWN',- 'VALIDATION_ERROR',+ 'PAGE_NESTING_TOO_DEEP', 'VALIDATION_ERROR',]);for (const code of PRE_WRITE_REFUSALS) assert.strictEqual(writeOutcome(sdkError(code, 'refused')), 'nothing', code);// A typed error that is not one of them is no proof: it may come from the SDK's step after the commit.diff --git a/plugins/model-apps/skills/app-builder/SKILL.md b/plugins/model-apps/skills/app-builder/SKILL.mdindex 2fa6a8d51..0d245dc3e 100644--- a/plugins/model-apps/skills/app-builder/SKILL.md+++ b/plugins/model-apps/skills/app-builder/SKILL.md@@ -10,6 +10,8 @@ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Task, AskUserQuestion, Enter> **Plugin check**: Run `node "${PLUGIN_ROOT}/scripts/check-version.js"` — if it outputs a message, show it to the user before proceeding.+> **Model check (lightweight models only)**: If you are a lightweight model optimized for fast, simple tasks, tell the user in your first message that `/app-builder` works best on a general-purpose coding model or an advanced reasoning model — designing the App Spec, reasoning about the dependencies between tables, relationships and artifacts, orchestrating the build and reconciling what already exists take multistep planning, tool use and validation — and recommend switching; then continue. On any other model, skip this note and say nothing about it.+# app-builder — intent → model-driven appTurn a natural-language intent into a deployed model-driven app. You author a reviewable **App Spec**diff --git a/plugins/model-apps/skills/genpage/SKILL.md b/plugins/model-apps/skills/genpage/SKILL.mdindex 811d6d71a..2fb2473d9 100644--- a/plugins/model-apps/skills/genpage/SKILL.md+++ b/plugins/model-apps/skills/genpage/SKILL.md@@ -11,6 +11,8 @@ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, WebFetch, Task, AskUserQuest> **Plugin check**: Run `node "${PLUGIN_ROOT}/scripts/check-version.js"` — if it outputs a message, show it to the user before proceeding.+> **Model check (lightweight models only)**: If you are a lightweight model optimized for fast, simple tasks, tell the user in your first message that `/genpage` works best on a general-purpose coding model or an advanced reasoning model — planning the page, generating its React/TypeScript, binding it to data, deploying it and verifying it take multistep planning, tool use and validation — and recommend switching; then continue. On any other model, skip this note and say nothing about it.+# Power Apps Generative Pages Builder**Triggers:** genpage, generative page, create genpage, genux page, build genux, power apps page, model page