14 Commits
Author SHA1 Message Date
Oleg Isonen 75d710e759 fix: Let Editor links patch Content Block text and props (#6575)
Editor links with API access can edit text and editable props inside
Content Blocks through raw CLI/MCP patches. Builder and Viewer
permissions stay unchanged.

UI and API requests use the same Content-mode policy. The API keeps its
narrower text-and-props scope; page, asset, style, expression, and
structure changes remain blocked for raw Editor patches.

### Implementation

- Use the persistence patch engine for instance, prop, and style state
changes. Remove the separate instance patch interpreter and record
writes from permission validation.
- Check prop changes against the resulting state. Image dimensions work
even when their patches appear before the source patch.
- Move Image source, dimensions, and alt updates into the shared
runtime. Video source changes preserve its existing dimensions. The UI
no longer sends separate follow-up writes. Explicit overrides and
expression bindings are preserved.
- Separate capability discovery from transaction validation and move the
server permission adapter out of the router.
- Reject missing replacement targets and protected or renamed prop-ID
reuse. Keep template-copy protections.
- This refactor removes 19 non-test lines. It removes eager
whole-instance cloning, but the server still loads the project and
validates its content tree. Empty transactions skip that validation.

Closes #6573

### Checklist

- [x] Reproduce the Editor-token denial and add regression coverage
- [x] Keep Editor raw patches limited to text and editable props
- [x] Use the existing patch engine and test missing targets, immutable
input, and permission boundaries
- [x] Share media updates between UI and MCP; test atomic updates, patch
ordering, overrides, and bindings
- [x] Separate capability discovery, permission validation, and API
orchestration
- [x] Verify new regression tests fail with the relevant behavior
disabled, then pass after restoration
- [x] Run runtime tests, API/sync tests, typechecks, lint, formatter,
package-boundary, and generated-API checks
- [x] Run Content-mode E2E checks for templates, assets, page creation,
collaboration, and save/reload
- [x] Add a CLI MCP Editor-token save/reload E2E, including protected
template rejection
- [x] Return a structured forbidden error for rejected Editor MCP
content changes
- [x] Run the complete Luna/low evaluation suite; record failures below
- [x] Review documentation and fixture impact: no new API inputs, schema
changes, migrations, or fixture generation changes; existing guidance
remains applicable
- [x] Correct the project-package permission fixture to include its
owning instance and run all package tests
- [x] Cover repeated media source updates and bound namespace batches in
Editor requests
- [x] Preserve stale retry handling before Editor content validation,
with API regression coverage
- [x] Preserve expression-bound media metadata during source replacement
and test saved Content-mode output
- [x] Reuse batch merging so split prop payloads validate against their
final state; test split and combined forms
- [x] Push the refactor and verify required CI completes
- [ ] Deferred: reproduce the separate Builder UI report on a
session-free Editor link
- [ ] Deferred: confirm image-description editing expectations
separately

### Verification

- Full project-build suite: 2,597 tests passed. Focused permission/prop
run: 121 passed.
- All package tests (`pnpm test:packages`) passed after correcting the
project-package fixture. All 1,297 CLI tests passed.
- Builder API and sync authorization: 54 passed; settings-panel tests:
11 passed.
- Content-mode E2E: 9 passed, including setup, plus the earlier focused
Image replacement run.
- Builder/project-build typechecks, lint, formatting, package
boundaries, and generated-API checks passed. The CLI content-runtime
bundle test passed; no generated fixture output changed.
- Earlier full Luna/low evaluations: **7/9 passed**.
`managed-form-runtime-v1` failed `runtimeFormAction`; `markdown-blog-v1`
failed `blogRouteEvidence`. These checks also failed before this
refactor. MDX editing and Markdown-reference discovery passed. Baselines
for this model/effort were incompatible or missing and were not updated.
This suite is not fully green.

- Latest full Luna/low rerun after review fixes: **6/9 passed**. Form
runtime, blog authoring, and MDX editing failed; the MDX fixture passed
in the earlier run. Baselines were not updated. The evaluation suite
remains incomplete.

- Retry follow-up: all 59 API/router tests and 28 persistence patch
tests passed, along with Builder typecheck and lint. Older retries use
existing persistence handling; current and future versions remain
permission-checked.

- Bound-media follow-up: Image and Video source replacement preserves
expression-bound width/alt and still passes shared Content-mode
validation. Full runtime tests, typecheck, and lint passed after this
fix. The agent evaluation results above precede the final retry and
binding guards; those guards have dedicated regression coverage.

- Split-payload follow-up: reuse the existing batch merge helper before
permission validation. Combined and split media patches pass the same
final-state checks. Full runtime tests, 59 API tests, typechecks, and
lint passed. Agent evaluations were not repeated after this follow-up.

- CI passed on `1242ba8344`: all package, Builder, and CLI test jobs;
all six Builder E2E shards; visual regression; typecheck/lint;
generated-file checks; packaged SSG; size; migrations; and submodule
checks. Development deployment checks passed. All review threads are
resolved.

### Final review follow-up (2fbb30ffe6; CI passed)

- [x] Reject future base versions before saving; test an otherwise
allowed Editor patch
- [x] Preserve sequential patch behavior and test
authorization/persistence parity
- [x] Run focused tests, typechecks, lint, and review
documentation/fixture impact
- [x] Commit and push these follow-up fixes, then verify CI

Local follow-up verification: 2,600 project-build tests, 96 project
tests, and 60 API tests passed. Builder/project-build typechecks,
changed-file lint and formatting, package boundaries, and diff checks
passed. Regression tests failed without the fixes and passed with them.
The shared patch engine uses one Immer draft and supports namespace
replacement without mutating input. Net production change: 6 lines. No
documentation, fixture inputs/outputs, schemas, or generated contracts
changed. Browser E2E and agent evaluations were not rerun for this
follow-up; the race and patch-order cases are covered by deterministic
tests.


CI passed on `2fbb30ffe6`: all six Builder E2E shards,
package/CLI/Builder tests, typecheck/lint/generated checks, visual
regression, migrations, SSG build, size, and submodule checks. No new
blocking findings in the follow-up review. Agent evaluations were not
rerun; earlier limitations remain recorded above.

### Asset review follow-up

- [x] Reproduce and block asset-valued design-only props, retaining
matching Image metadata
- [x] Stop generating image metadata for Video source updates
- [x] Verify regression tests, documentation/fixture impact, and CI;
reply to both review threads

Asset follow-up `2ea28028c0`: shared metadata eligibility now checks
asset values and their matching Image source, including MDX
materialization. Video source edits do not generate Image-only metadata.
New and updated regression tests failed without the fixes and pass with
them. All 2,604 runtime tests, 60 API tests, 30 persistence tests, both
typechecks, lint, formatting, and package boundaries passed. No
documentation, schemas, or fixture data changes are needed. Agent
evaluations were not rerun. Both review threads have replies and are
resolved. CI passed on `2ea28028c0`, including all six E2E shards,
visual regression, package/CLI/Builder tests, typecheck/lint/generated
checks, migrations, SSG build, size, and submodules.

- [x] Reproduce repeated source updates without a saved source, coalesce
before ID assignment, and verify regression tests/CI

Final source follow-up `16c1c5f68e`: repeated instance/property updates
are coalesced before assigning IDs, replacing the later source-only
check. Both new Image/Video regression cases failed before the fix and
pass now. All 2,606 runtime tests, typecheck, and lint passed. CI passed
on this commit, including all six E2E shards and visual regression. No
documentation or fixture-data changes were needed; evaluations were not
rerun.


### Coverage audit

- [x] Audit changed behavior against assertions, including UI/API and
persistence boundaries
- [x] Add test assertions for identified coverage gaps; automatic CI
passed
- [x] Review documentation and fixture impact: no product documentation
change; one new SVG used only by browser E2E

Per request, no local tests or agent evaluations were run for this
audit. Automatic CI passed on `4591940169`, including package/API tests,
all six browser-test shards, visual regression, typechecks, lint, and
generated-file checks.

Coverage additions are pushed in `2371d9796a` and `4591940169`: check
actual text sent to persistence; duplicate ordinary props across
instances; rejected edits leaving capabilities reusable; merged patch
ordering and input immutability; accepted/rejected linked Image
dimensions in MDX templates; returned style/source/selection state; and
UI Image dimension changes followed by reload. The previous image E2E
used equal-sized files and could miss broken dimension synchronization.
Its new SVG has different dimensions. Production code is unchanged. No
tests or evaluations were run for this audit, as requested; no new pass
claim is made.

- [x] Inventory every changed/moved/removed production function and map
it to assertions
- [x] Add missing mixed-child and dependent-transaction coverage
- [x] Push inventory follow-up and inspect CI results

### Function-by-function coverage inventory

This inventories production functions changed, moved, or removed by this
PR. “Covered” means the named test asserts the behavior; it does not
claim every possible input or branch is covered. No local tests or
evaluations were run for this inventory.

| Function / handler | Assertions traced |
| --- | --- |
| `renderProperty` and its `onChange` callback | Content-mode props E2E
checks text, href, Image/Video source, alt, protected controls, and
reload. Asset E2E now changes dimensions from 120×80 to 240×160, then
replaces/reloads to 120×80. |
| `createContentModeCapabilitiesFromBuild` (moved unchanged) | API
“commits content-mode mutations with editor api tokens” and “limits
editor api patches to content instances and props” exercise conversion
from saved build data. |
| `assertContentOrBuildTransactions` | Editor vs Builder, design denial,
transaction/payload limits, all-or-nothing rejection; new exact
10-transaction boundary and dependent append-then-edit transactions. |
| `contentOrBuildMutation` | API semantic text edit asserts version,
authorization, actual saved text, unchanged outside content, and
unchanged input. |
| `build.patch` handler | API tests assert allowed text forms, denied
structure/styles/assets/expressions/outside roots, Viewer/no-API denial,
stale retries, current-version validation, and future-version CONFLICT
before persistence. |
| `getContentModePropNamesByTag` (moved unchanged) | Derives names by
tag and merges names for matching tags. |
| `getDefaultContentRootIds` (moved unchanged) | Default vs explicit
roots, Body selection, template exclusion. |
| `getContentModeFrontmatterBoundTargets` (moved unchanged) | Explicit
Body/frontmatter scope, read vs readwrite expressions, recursive
instances. |
| `getContentModeEditableInstanceIds` (moved unchanged) | Outside roots,
nested templates, missing references/roots, non-id children, cycles. |
| `getContentModeEditableInstanceRootIds` and its recursive `visit`
(moved unchanged) | Same traversal cases; transaction tests reject
moving content between roots and duplicate references. |
| `getInstancePropMetas` (moved unchanged) | Tag-derived props,
unknown/design-only/incompatible props, no generic HTML-attribute
permission bypass. |
| `getContentModeEditableStaticPropNames` (moved unchanged) | MDX
template tests assert exact editable names, primitive conversions, and
retained/ignored design-only props. |
| `getContentModePropEligibility` | Matching/missing/different asset
sources, protected asset props, exact primitive types, UI/transaction
parity, Image vs Video. |
| `isContentModeCopyableProp` (moved unchanged) | Editable/copyable
classification and content-mode copy-policy test. |
| `getContentModeCapabilities` | Editable IDs, roots, frontmatter
bindings, asset metadata; shared UI and transaction eligibility test. |
| `isContentModePropTransition` | Schema/id/owner/name checks, unknown
instance, protected existing props, permitted source type changes,
linked dimensions. |
| `validatePropPatches` | Add/replace/remove, new-then-update, missing
replacement target, protected ID reuse, copied template defaults,
final-state media patches in split/reversed order, failed-edit
immutability and retry. |
| `hasSameInstanceMetadata` | Whole-instance text replacement allowed;
tag/name changes and outside references rejected. |
| `validateStyleSourceSelectionPatch` | New content selection allowed;
existing/token misuse and dangling cleanup rejected; now asserts
resulting selection map. |
| `validateStyleSourcePatch` | New local source allowed; token,
duplicate/unused source and incomplete cleanup rejected; now asserts
resulting source map. |
| `validateStylePatch` | New local declarations allowed; existing design
styles, missing breakpoint and incomplete cleanup rejected; now asserts
resulting declaration map. |
| `validateMapChange` | Above three map paths, invalid patch targets,
resulting state and input immutability. |
| `validatePatchChange` | Instance/prop/style/asset/page paths and
rejected design namespaces through transaction tests. |
| `preservesNonTextChildren` and local `keepNonText` | Text-only changes
allowed; insertion/deletion/reordering of instance references and
expression changes denied; new mixed text/reference positional cases. |
| `applyContentModeTransaction` | Authorization/persistence parity,
split batches, empty transactions, scoped permissions, copy protections,
roots, cleanup, and immutable input on success/failure. |
| `materializeMdxAuthoredContent`, its `visit`, and `overlayChildren` |
MDX-source “round-trips an authored Asset Image through a styled
composite descendant” asserts src/width/height and styles after reload;
“serializes an Asset selected on an inserted Image template” asserts all
four linked props; nested and standalone component-permission tests
reject protected props. |
| `getMdxPropEligibility` | Template tests check allowed/ignored props,
aliases, incompatible types; new matching vs mismatched Image dimension
asset test exercises passed asset values. |
| `materializeMdxTemplates` | New linked-dimension test plus existing
copied-fragment, unchanged-input, authored-prop, diagnostic, and alias
tests. |
| `appendBuilderPatchChanges` | Mutation accumulator test asserts
sequential state and combined payload; merge test asserts ordering and
input preservation. |
| `mergeBuilderPatchChanges` | New repeated/interleaved namespace, empty
input, repeat-call and patch-array immutability assertions; permission
tests exercise split payload integration. |
| `getMediaAssetPropNames` | Image generates width/height/alt; Video and
unrelated components do not; explicit overrides and expression-bound
metadata retained. |
| `getPropIdsToDelete` | Image src removes dimensions; non-Image removes
only requested prop; resource cleanup and missing-instance cases. |
| `updateProps` | Atomic Image/Video updates, repeated sources
with/without saved props, overrides, bindings, original-state
preservation; new ordinary prop deduplication across names and
instances. |
| `getPatchParent` (type-only change) | Mutable nested patch and
missing-path tests. |
| `assertReplacePatchTargetsExistingPath` (type-only change) | Missing
target rejected; preceding add/root replacement makes later replacement
valid; preceding remove makes it invalid. |
| `applyBuilderNamespacePatches` | Sequential/root replacements, append
then edit, remove then replace, immutable state, permission/persistence
parity. |

Removed functions are covered through their replacements:
`shouldSyncMediaAssetProps` → shared `updateProps` plus UI E2E;
`assertContentOrBuildPayload` → transaction adapter;
`isContentModePropForInstance` → eligibility;
`isContentModePropPatchValue`/`validatePropPatch` → transition/batch
validation; `applyValidatedInstancePatch` → shared patch engine. No
behavior test is needed for import-only changes, type declarations,
public-entry exports, or regenerated metadata/docs; their callers and
contracts retain tests.

The original reporter-specific UI reproduction and image-description
product question remain separate limitations. This inventory does not
claim either is resolved.


### Latest review follow-up

- [x] Reject fresh prop IDs that shadow existing instance/property
records; cover protected bindings and valid edits
- [x] Coalesce updates in linear time while preserving last-update order
and input immutability
- [x] Check documentation/fixture impact, push, inspect CI, and reply to
both review threads


Review fixes pushed in `5dd03135e7`: 10 net production lines. Added
binding-shadow and batch-work regression assertions; no local tests or
evaluations were run, per request. Formatting and diff checks passed.
Documentation and generated fixture inputs/outputs are unchanged.
Automatic CI is pending.


- [x] Reject duplicate fresh props within the same transaction and test
split/combined batches
- [x] Preserve resource and parameter media bindings using the existing
dynamic-type check
- [x] Bound total Editor patches before validation; test the boundary
and unchanged Builder access


Review follow-up `d478446eb1`: all package, Builder, and CLI CI test
jobs and typecheck/lint/generated checks passed. Five addressed review
threads are resolved. Browser CI checks are still running. One newly
posted review about non-image assets assigned to Image sources remains
open pending the user's behavior choice. No local tests or agent
evaluations were run; local typechecks passed.


### Shared asset constraints

- [x] Reuse component file-control metadata and the UI MIME matcher in
shared property writes; preserve manually entered URLs and pending
uploads
- [x] Generate linked Image metadata only when the selected asset
supports it; cover legacy file-backed images
- [x] Add shared-runtime coverage for accepted/rejected Image and Video
assets, custom props, URLs, and atomic rejection
- [x] Review documentation, generated contracts, fixture impact, and
diff size; verify typechecks and CI (no local tests or evaluations, as
requested)


Shared asset follow-up `5f0054edd7`: property writes use the UI's
existing file-control `accept` metadata and MIME matcher. Known
incompatible assets are rejected with the approved message. Legacy image
files remain selectable without generating unsupported metadata. URLs,
custom asset props, and unresolved uploads keep their existing behavior.
Asset records are now loaded before CLI/MCP property writes; this may
require an asset-list request when not already loaded. This change does
not add asset-file downloads. Net handwritten production change: 24
lines. Builder/project-build typechecks, changed-file lint, formatting,
and diff checks passed. No local tests or evaluations were run.
Regression and runtime-entry tests were added; CI is pending. Reviewed
Image/Video docs: no guidance change needed. No fixture inputs or
generated fixture bundles changed; regenerated runtime contract metadata
only.

- [x] Keep Editor permission checks when a shared edit operation loads
assets; add an API regression test before final CI verification


Follow-up `d33b70e1c7` preserves Editor authorization when property
writes load assets. The API regression test asserts a valid Image source
reaches persistence, incompatible files are rejected, and
outside-content edits remain forbidden. This reuses the existing asset
loader and permission adapters (3 net production lines). CI found and
corrected an old session namespace expectation and a mistaken test
assumption: Video's existing unsupported `.mpg`/`.mpeg` accept entries
cause the shared matcher to allow all assets. This PR preserves that UI
behavior; it does not tighten Video formats. Total handwritten
production increase for this asset follow-up: 27 lines. Builder
typecheck/lint and server metadata generation passed; metadata output
was unchanged. CI is rerunning.


Final asset follow-up verification (`8b2efd8508`): all package, CLI,
Builder API/unit, and six browser E2E jobs passed, together with
lint/typechecks, generated checks, visual regression, migrations, size,
packaged SSG, and branch deployment. The direct API test now checks the
typed authorization cause, not an HTTP status that this test caller does
not map. All review threads are resolved. No local tests or agent
evaluations were run for this follow-up; CI provided execution coverage.
The separate Video filter limitation noted above remains unchanged.


### Shared write-boundary validation

- [x] Reuse one asset-property validator in UI/MCP property updates and
raw patch persistence, independent of permission level
- [x] Cover whole-property and field patches, component changes, invalid
metadata, final-state validation, unchanged legacy data, and stale
retries
- [x] Review documentation/fixture impact, typecheck and lint, then
verify CI; no local tests or evaluations per the earlier request

Expected change: about 70–90 net production lines. Patch saves load only
referenced asset metadata; no asset-file downloads.

Shared-save follow-up: 133 net production lines, above the initial
estimate because one save can replace an asset file and its references
together. The save validator reuses the asset writer’s canonical file
preparation rather than trusting client-declared asset types. It also
checks asset-only replacements, before folder or Build writes, while
leaving unchanged legacy references alone. Ordinary property writes load
only referenced asset metadata; asset-changing saves with references
additionally prepare the full asset map, then the writer repeats that
metadata preparation. No file contents are downloaded by the new check.
This does not change schemas, migrations, generated contracts,
documentation, or fixture inputs/outputs. Added regression coverage; no
local tests/evaluations were run, per the earlier request. Independent
Astra review found no remaining defect after the projection fix. CI
pending.

- [x] Fix selective UI sync loading to include asset-validation
dependencies; add selection regression coverage and rerun CI

The first browser run caught missing props/instances in selectively
loaded UI saves. Package/API tests passed but their fixtures provided
complete build rows. The development deployment succeeded; its
status-reporting step failed with GitHub HTTP 500.

Final verification on `a22d059717`: all package, CLI, Builder unit/API,
six browser shards, visual regression, typecheck/lint/generated checks,
migrations, size, packaged SSG, development deployment, and
Ubuntu/Windows deployment fixtures passed. Browser shard 3 passed on one
retry after a page-drag ordering assertion; the save/parsing errors were
fixed by loading the required fields. No local tests or evaluations were
run. The added persistence suite has 46 passing tests and runtime props
has 74; selective-sync tests now omit unselected fields. No unresolved
review threads. Total net production increase across this follow-up: 134
lines.


### Deep review follow-up

- [x] Make MDX linked-image validation independent of authored attribute
order; cover changed sources, mismatches, and the affected
materialization paths
- [x] Review DRY and diff size, documentation/fixture impact, and
independent review findings
- [x] Verify typechecks/lint and CI; no local tests or evaluations per
the earlier request

Review found that linked dimensions can be checked against the old
template source before the new source is applied. Fix should reuse the
shared eligibility rule with the final source, without another property
parser. Initial estimate: under 60 added non-test lines; revisit the
approach if it needs more.


Deep-review fix `f7c3d805a8`: apply Image sources before linked metadata
in all three MDX materialization paths, keeping original attribute
indexes for asset references. Reuses the existing eligibility checks and
parser; 23 net production lines. Regression cases cover source order,
changed sources, mismatched dimensions, and nested overlays. Independent
Astra review, project-build typecheck, focused lint, formatting, and
diff checks passed. No schema, documentation, generated contract, or
fixture-data changes. Local tests/evaluations have not run; focused-test
permission was requested. CI pending.


Final deep-review verification on `f7c3d805a8`: all package/CLI/Builder
test jobs, all six browser shards, visual regression,
typechecks/lint/generated checks, migrations, packaged SSG, size,
submodules, and development deployment/fixtures passed. CI ran 60
authored-content and 24 template-materialization tests successfully. No
local tests or evaluations ran; fail-before/pass-after was not executed
locally. All review threads are resolved and the worktree is clean. No
further actionable defect was found in the independent reviews. Known
remaining cost: asset-changing saves can prepare metadata twice;
removing that safely would expand this fix into persistence changes.


### Editor MCP browser E2E follow-up

`0ee978e465` adds a real CLI/MCP Editor-token round trip: insert content
into a Content Block, reload through a fresh CLI process, verify it in
the Builder canvas, and reject a protected template insertion without
changing the saved Build. A direct API denial now returns `FORBIDDEN`
instead of a generic internal error. The focused E2E and API tests,
typecheck, lint, formatting, and diff checks passed locally.
Fail-before/pass-after was verified by temporarily disabling Editor
fragment access, then restoring it. The full Luna/low evaluation run was
attempted but did not pass: the form-runtime fixture received 503
responses. The suite is not claimed green. CI for this push passed on
`0ee978e465`, including all six Builder E2E shards, package/CLI/Builder
tests, visual regression, typecheck/lint/generated checks, migrations,
size, SSG build, and submodules.


Live MCP permission probe against the branch deployment: Builder,
Editor, and Viewer role metadata matched their tokens. Editor content
text, rich text, fragment, link href, and compatible Image source edits
committed and survived a fresh MCP session. Outside-root,
protected-template, design-only prop, mismatched Image width, and
incompatible asset writes were denied without persistence. The updated
deployment returned structured `FORBIDDEN` for protected content writes
even when `contentMode` was false or omitted. Mixed valid/invalid writes
were atomic; stale Editor writes refreshed and retried. Viewer MCP could
not be exercised beyond the API gate because this Viewer token has API
access disabled. MDX frontmatter, token revocation, and UI-only
scenarios were not tested. A wrong-project token was rejected but
surfaced `INTERNAL_SERVER_ERROR`, which is a diagnostic-quality gap, not
an authorization bypass. The isolated probe page
`/codex-permission-probe-6575` remains: cleanup was stopped after a
concurrent-edit `CONFLICT`, to avoid deleting another session's work.


### Fixture-based parity follow-up

- [ ] Verify the full Content-mode UI/MCP parity matrix with an isolated
MDX/template/media/page fixture, excluding publishing and token/plan
changes
- [x] Fix the reproduced Editor MCP template/page-settings gap and cover
fail-before/pass-after routing
- [x] Verify a real CLI Editor-token create-from-template call, fresh
readback, Builder reload, allowed settings, and protected-setting
rejection
- [x] Update MCP guidance, review fixture impact, and verify required CI

The UI already allows an Editor to create a page from a template and
edit allowed page settings. MCP incorrectly required Builder permission,
and a separate MCP-only legacy Webhook Form copy guard blocked the
seeded template. Those restrictions are corrected. The server now
derives Content-mode page copying from Editor permission even when
`contentMode` is omitted or false; Builder copies retain their existing
behavior. Editor semantic commands use the server's shared Content-mode
validator, while raw Editor patches stay limited to text and editable
props. This adds a named server call and refetch for Editor semantic
edits; the existing initial project sync still occurs.

The new isolated E2E passed on `03e7ca6953`, including flag-free
template creation, settings edit, fresh CLI readback, Builder reload,
and a denied protected setting without a saved change. All required CI
passed on that commit: all six Builder E2E shards, package/CLI/Builder
tests, generated checks, typecheck/lint, visual regression, migrations,
packaged SSG, size, and submodules. Focused local runtime/API tests,
typechecks, lint, formatting, and generated-doc checks passed. Browser
E2E and full agent evaluations were not run locally; the requested
browser approval and a fresh evaluation approval were not received. The
full UI/MCP parity matrix remains open; Editor asset operations are a
separately identified gap, not claimed fixed here.


### Exploratory permission coverage follow-up

- [x] Inventory observed Builder/Editor/Viewer UI and MCP permission
scenarios against existing tests
- [x] Add fail-before/pass-after regression tests for confirmed
uncovered failures
- [x] Run focused tests, typechecks, lint, and fixture checks; verify
required CI
- [x] Record unsupported UI/MCP parity as open product work, without
calling the matrix complete

The UI share-link E2E already checks Viewer read-only controls, Editor
text editing, and Builder design controls. Existing MCP E2E checks
Editor content/template writes, page creation, asset upload, and
protected edits. This follow-up adds one real CLI/MCP flow with
API-enabled Viewer and Builder tokens: Viewer can list pages but cannot
create a page or asset folder or upload a file; Builder can change an
HTTP status setting that Editor cannot. The test checks the denied page
writes leave the build unchanged and the Builder setting survives
readback.

The run exposed two diagnostic bugs: local permission denial and REST
asset-upload denial reached MCP as generic failures. Both now retain
`FORBIDDEN`. Focused unit tests failed before these changes and pass
after; the full local browser/MCP test passes. The only non-test change
is three net lines. No fixture data, schemas, generated contracts, or
product docs changed. Local checks passed: 2,654 project-build tests, 48
HTTP-client tests, the focused Builder E2E (2 tests including setup),
affected typechecks, lint, formatting, and package boundaries.
`check:fixture-sizes` could not run locally because the SSG fixture's
built `dist/client` is absent; CI builds that fixture before checking
its size.

The full UI/MCP parity matrix remains open. In particular, Editor UI
asset update/replacement/duplication/deletion and collection-entry
creation still lack equivalent MCP support until the UI's collection
protections are enforced at the shared server boundary. Publishing and
token/plan changes were outside this test scope.

CI passed on `6490efc838`: all six Builder E2E shards,
package/CLI/Builder tests, visual regression, typecheck/lint/generated
checks, migrations, packaged SSG, size, and submodules. Shard 3 first
hit Playwright's 120-second limit under four-worker load; its logic
passed locally. The longer role flow now uses the same 240-second
per-test limit as other MCP E2E tests, and shard 3 passed in the final
run.

### Final UI/MCP parity audit

- [x] Trace Editor UI asset and folder actions through REST, runtime,
and persistence
- [x] Reproduce Editor MCP upload and folder-create denials; add
fail-before/pass-after permission tests
- [x] Add isolated Editor MCP upload/folder and UI folder-reload browser
regressions
- [x] Keep collection-sensitive asset/folder mutations Builder-only
until UI collection protections are shared at the server boundary
- [x] Review docs and fixture impact: MCP guidance is updated; no
fixture input or bundle changes
- [x] Restrict Editor folder saves to new IDs; test overwrite and delete
denials at both UI and API boundaries
- [x] Reject folder-add collisions at persistence and test the
mixed-writer/stale-snapshot case
- [x] Keep exact Editor folder retries authorized after a partial save;
add fail-before/pass-after coverage
- [x] Verify the new browser E2E in required CI
- [ ] Run the full Luna/low agent evaluations after fresh approval (not
granted for this follow-up)
- [x] Verify required CI for `6fd3beefc8`

The safe scope is small: the Assets REST upload path already authorizes
Editor tokens and enforces collection rules, but the MCP catalog
incorrectly required Builder access. Creating an ordinary asset folder
is available in the Editor UI, but the shared Content-mode save check
rejected it. Both now use Editor permission. The isolated browser tests
check fresh MCP readback and Builder reload; they have not run yet.

Further parity work remains open: Editor UI allows updates, replacement,
duplication, deletion, and collection-entry creation in cases MCP cannot
currently perform. These need the UI's collection protections enforced
at the shared server boundary before their MCP permits can be widened.
Raw Editor `apply-patch` stays text-and-props-only. This PR does not
claim the full matrix is complete.


Asset/folder follow-up `6fd3beefc8`: Editor semantic tools now share the
UI's edit permission for uploads and ordinary folder creation. Folder
saves reject same-ID changes, allow identical retries after a lost
response, and use insert for add-only persistence. The retry regression
failed before the fix and passes with JSON-normalized parent
IDs/timestamps. Independent Astra review found no remaining concrete
defect. Focused runtime (86), asset persistence (52), protocol (14), and
API/sync (71) tests passed; Builder/project-build/asset-uploader
typechecks, lint, package boundaries, formatting, generated API, and MCP
docs checks passed. Full project-build, protocol, and CLI suites passed
earlier in this follow-up; Builder core had resource-contention failures
but its affected tests passed in isolation. The new browser E2E and
agent evaluations were not run locally pending fresh approval; CI is
running them automatically.

CI passed on `6fd3beefc8`: all six Builder browser shards,
package/CLI/Builder tests, generated checks, typechecks, lint, visual
regression, migrations, packaged SSG, size, and submodules. The new
Editor MCP asset round trip and UI folder-reload tests ran in the
passing browser shards.
2026-10-23 14:40:26 +02:00
Oleg Isonen 13eb7527ef fix: route deprecated Webhook Forms through Form backend (#6553)
Deprecated Webhook Forms reuse the existing Form execution pipeline
without teaching the modern backend about WebhookForm.

## User-facing behavior and how to test it
- Existing saved Webhook Forms keep their markup, action settings, and
success/error feedback. Submit a published Webhook Form and check both
outcomes.
- URL and Resource actions preserve configured methods, headers,
dependencies, body overrides, and the last submitted value for repeated
field names. Test a configured action and inspect the received request.
- Default owner notifications use the Email Worker, including submitted
files. Submit a Webhook Form without a custom action and inspect the
owner email and attachment.
- Configured Email actions validate recipients and retain threading
metadata. Test valid recipients and a rejected recipient limit.

## Implementation
- One deprecated Webhook Form adapter calls existing bot validation,
Email preparation, recipient validation, resource loading, and response
handling.
- Both generated route templates call that adapter. Both paths reuse an
internal resource-graph traversal helper; modern submission behavior is
unchanged.
- Root actions use the protected, uncached request override.
Dependencies reuse existing generated Assets and Resource caching
behavior.
- Keep reachable-resource filtering because Email preparation runs
before loading: unrelated Email settings must not break the selected
action.
- Remove dead `getDefaultActionResource` wiring from generated
templates.

## Verification
- Focused SDK tests: 116 passed (11 deprecated Webhook Form adapter and
105 modern submission, Email, and handler tests), including unrelated
resources, missing dependencies, cycles, Email preflight/threading, and
single-attempt Email failures.
- Resource generator tests: 26 passed.
- Full CLI prebuild suite: 139 passed after tracked fixture
regeneration; focused deprecated Webhook Form adapter tests: 9 passed.
- Repository fixture pipeline (`pnpm -r fixtures:build`) passed. All
tracked generated `getDefaultActionResource` references were removed,
and no Builder `N8N_FORM_EMAIL_HOOK` reference remains.
- Final MCP-generated local Preview E2E rerun: 3/3 passed.
- Focused saved Webhook Form custom-action E2E rerun: 2/2 passed (setup
and test), including a single POST through the protected test receiver
after Builder reload.
- SDK, CLI, and Builder typechecks, focused lint and formatting, and
`git diff --check` passed.
- Deprecated component picker regression test passed (2/2); verified it
fails when WebhookForm deprecation is disabled, then passes with
deprecation restored.
- Independent Astra review found no blocker, including the 62 generated
fixture changes. No production deployment or live secret change was
performed.
- Required staging CI checks passed on previous head `15635fc` (Main
workflow, visual regression, submodules, and lint). An unrelated
existing MCP success-redirect E2E assertion failed once in shard 5,
passed in a focused local rerun (2/2 including setup), then shard 5
passed on GitHub rerun without code changes.
- Terminology pass (`4a69ab573`): renamed the dedicated SDK adapter and
migration helper, updated both route templates and generated fixtures,
corrected the active identity migration marker comments, and
synchronized docs and test names. Focused tests passed: SDK 35, CLI
prebuild 12 plus 2 after final title change, MCP 7, migrations 8, React
browser 7, CLI docs 9. Seven affected package typechecks, fixture
builds, formatting, and `git diff --check` passed. That historical head
was superseded; latest-head CI results are recorded below.

- ResourceForm identity migration (`29a21edbb`): focused migration (23),
DB patch (25), project-build DB/session (93), Builder
API/import/auth/patch (60), React SDK (162), runtime/MCP (239), registry
(11), CLI evaluation (90), CLI session/sync (55), and protocol (15)
tests passed; full CLI prebuild (139) passed. Affected typechecks, lint,
formatting, and `git diff --check` passed. Independent Astra review
found no blocker. No deployment was performed.

- Prepublish Webhook Form warning (`25855e8f00`): audit checks every
non-draft published page and links nested/shared instances to the
correct page; modern ResourceForm, native forms, draft-only forms, and
orphans are excluded. Focused audit tests (13), Builder navigation tests
(6), project-build and Builder typechecks, lint, formatting, and `git
diff --check` passed. Independent Astra review found no blocker;
publishing remains nonblocking. No deployment was performed.

- ResourceForm test and CI expectation repair (`e1a527fbcc`): focused
React SDK (24), Builder preview/registry (38), project-build pages (1),
and CLI fixture API (8) tests passed; Remix and React Router targeted
browser suites, affected package typechecks, full formatting (3375
files), lint, and `git diff --check` passed. Astra review found no
blocker. Persisted identity and runtime exports were unchanged.

- Project bundle fixture repair (`70889ef27d`): eight bundles now carry
the current contract version; the two unmarked historical Form instances
in `webstudio-features` normalize to WebhookForm. Protocol fixture tests
(17), protocol typecheck, CLI fixture build, formatting, lint, and diff
check passed. Independent Astra review found no blocker.

- Story/MCP E2E CI repair (`483614e6c5`): SDK CLI story tests (7),
ResourceForm fragment tests (34), and focused local managed-form E2E (4
including setup) passed. SDK CLI and Builder typechecks, lint,
formatting, and diff check passed. Astra review found no blocker. The
initial local Preview build used an ignored stale React Router `lib`
artifact; rebuilding it restored the passing E2E run.
- Latest PR head `483614e6c5`: Main workflow [run
39317777032](https://github.com/webstudio-is/webstudio/actions/runs/39317777032)
passed, including all package matrices and six Builder E2E shards.
Visual regression [run
39317796922](https://github.com/webstudio-is/webstudio/actions/runs/39317796922),
submodules, and PR lint checks passed. The overlapping unapproved visual
run was cancelled by the approved rerun.

- Shared bot-value generator (`ecc4cad1e9`): SDK helper tests (3), React
Router WebhookForm/ResourceForm browser tests (5), SDK/Router/Remix
typechecks and builds, SDK browser-boundary check, formatting, and diff
check passed. Brave bypasses media queries, working media queries
produce a fresh timestamp per submission, and failed queries produce
`jsdom`; each managed/legacy submission has one bot field. Independent
Astra review found no blocker. Latest-head Main workflow [run
39325677117](https://github.com/webstudio-is/webstudio/actions/runs/39325677117)
passed, including all six Builder E2E shards; approved visual regression
[run
39325702835](https://github.com/webstudio-is/webstudio/actions/runs/39325702835),
submodules, and PR lint passed. The superseded visual run was cancelled
by the approved rerun.\n\n- Historical Form clipboard guard
(`e864283d1c`): instance/page transfer parsers reject ambiguous legacy
`Form` before asset import; direct fragment/page/folder mutations
preflight before changes. Canonical ResourceForm, WebhookForm, and
NativeForm remain accepted. Project-build tests (89), Builder paste
browser tests (69), both typechecks, focused lint/formatting, and diff
check passed. Independent Astra review found no blocker. Latest-head
Main workflow [run
39329184890](https://github.com/webstudio-is/webstudio/actions/runs/39329184890)
passed, including all six Builder E2E shards; approved visual regression
[run
39329562692](https://github.com/webstudio-is/webstudio/actions/runs/39329562692),
submodules, and PR lint passed. The earlier unapproved visual run
reported two expected story differences.\n\n## Compatibility notes
- Root HTTP actions reject private and same-origin destinations.
Dependencies retain their existing fetch/cache behavior.
- Routes retain the 25 MiB request limit. Shared execution applies bot
validation, a 10-second Resource timeout, and one retry for eligible
HTTP failures; an ambiguous failure can duplicate an HTTP action. Email
actions are not retried.
- Default email uses the Email Worker's sender, plain text, recipient
limits, and attachment limits instead of the legacy n8n HTML/basic-auth
path.
- Self-hosted sites need normal Email sender configuration. Direct
Builder draft Preview handling is outside this published-route change.
- Coordinate this CLI release with [SaaS PR
#669](https://github.com/webstudio-is/webstudio-saas/pull/669), which
removes the n8n helper and `N8N_FORM_EMAIL_HOOK` from new published-site
builds. Publish with a CLI artifact containing this adapter. Existing
deployed workers retain their bundled code and injected hook until
republished, so keep the actual n8n endpoint available while those sites
remain active.

## Implementation checklist
- [x] Align saved Webhook Form custom-action E2E with the protected
receiver and verify one submission.
- [x] Regenerate tracked published-site fixtures with the updated CLI
and confirm no `getDefaultActionResource` or `N8N_FORM_EMAIL_HOOK`
references remain in Builder source/config/fixtures.
- [x] Review authoritative `docs/` impact of removing the obsolete
Builder hook wiring; related deprecation and integration docs were
updated.
- [x] Route deprecated Webhook Form submissions through the shared
execution pipeline with one adapter.
- [x] Preserve configured actions, dependencies, repeated fields, body
overrides, and saved feedback.
- [x] Prepare and validate Email actions using existing shared logic.
- [x] Remove duplicated orchestration and dead generated context wiring.
- [x] Verify generated routes and MCP-generated Preview submissions.
- [x] Mark the Webhook Form component and its dedicated dependencies
visibly deprecated, while leaving shared Form infrastructure active.
- [x] Group Webhook Form-only SDK code for straightforward removal while
preserving public APIs and generated output.
- [x] Use deprecated terminology consistently for Webhook Form-only PR
code, and clarify the active identity migration marker.
- [x] Confirm required staging CI checks.
- [x] Use ResourceForm as the one active modern component identity
across Builder, SDK, runtime, templates, generated code, and docs.
- [x] Migrate historical Form, NativeForm, ResourceForm, and WebhookForm
identities in one idempotent pass using the historical pages marker.
- [x] Remove the marker from ordinary project and snapshot APIs while
preserving historical input readers.
- [x] Persist pages and instances together when a historical marked
project is saved, including a pages-only edit.
- [x] Verify migration, export/reimport, old CLI and server snapshots,
page-only save, generation, and affected typechecks.
- [x] Complete an independent architecture review before commit or push.

- [x] Warn at prepublish for deprecated Webhook Forms on published
pages, with a link to each affected element.
- [x] Verify modern ResourceForm is excluded and nested/shared Webhook
Forms navigate to the correct page.
- [x] Complete independent review, focused tests, and affected
typechecks before push.

- [x] Remove local `ResourceForm as Form` aliases from React SDK tests
and fixtures; use the canonical component name throughout.
- [x] Fix stale identity expectations found in CI and verify affected
tests/typechecks.
- [x] Complete independent review before push.

- [x] Refresh tracked project bundle fixtures to the current bundle
contract and canonical WebhookForm identity; verify protocol and
affected CLI flows.

- [x] Align SDK CLI story assertions and MCP E2E fragment fixtures with
the persisted ResourceForm component name; rerun affected checks.

- [x] Share one browser bot-value generator across ResourceForm
submission and deprecated Webhook Form wrappers, preserving field
ownership and behavior.
- [x] Verify bot timestamps, Brave/media failure handling, repeated
submissions, affected typechecks, and independent review before push.

- [x] Reject ambiguous historical `Form` clipboard fragments before any
insertion or transfer mutation, with clear recopy guidance; preserve
canonical ResourceForm action remapping.\n- [x] Verify
instance/page/template/folder paste regressions, independent review, and
latest-head CI.\n\n
- [x] Explain Email attachment size limits in the Email action UI and
give a useful error when the aggregate encoded attachments exceed the
local guard.
- [x] Check Preview and published behavior, boundary tests, and
authoritative Form docs; verify the focused change and get independent
review.

Ref #4093
- [x] Preserve safe email codes/messages through MCP, including local
attachment and upload limit errors.
- [x] Correct Form documentation for each enforced limit and verify
Preview/published/MCP paths.
- [x] Verify Builder SDK and MCP focused tests, typechecks, and
independent review before push.

- Email limits and failure copy (`6d215f3ec3`): the shared SDK checks 32
attachments and 7 MiB aggregate Base64 data before dispatch; the 25 MiB
multipart response and Email action guidance use approved copy. Managed
Email error codes pass through Form and MCP results with resource IDs,
while MCP still omits resource bodies. Form docs distinguish the Worker
7 MiB JSON cap from Cloudflare's 5 MiB complete message and
verified-destination exception, and correct the no-retry behavior.
Focused SDK tests 89, Builder API tests 44, UI browser tests 42,
SDK/Builder/CLI/docs typechecks, lint, formatting, and generated MCP
docs check passed. Astra found no blocker. No real email or production
deployment occurred.

- Latest Email limits head `6d215f3ec3`: Main workflow [run
39393037290](https://github.com/webstudio-is/webstudio/actions/runs/39393037290)
passed on rerun, including all six Builder E2E shards; approved visual
regression [run
39393456618](https://github.com/webstudio-is/webstudio/actions/runs/39393456618),
submodules, and PR lint passed. The initial unapproved visual run showed
the same two previously accepted story differences.

- [x] Address review: normalize previous-Builder `Form` instance patches
before persistence, preserve historical WebhookForm identity, and cover
marked/unmarked cases. Documentation impact reviewed: this restores
intended save behavior, so no user guide change is needed.

- Review finding follow-up (`ce05dd733a`): three Form identity patch
regressions passed red/green; full project build-patch tests 28/28,
project typecheck, lint, formatting, and diff check passed. Independent
Astra review found no blocker. Incoming PATCH `Form` is treated as the
immediately previous Builder's modern form alias; already stored
unmarked historical `Form` continues to migrate to WebhookForm. The old
patch protocol has no client-release identifier, so pre-October-14 live
clients adding new ambiguous IDs cannot be identified separately.

- Latest review-fix head `ce05dd733a`: Main workflow [run
39397337356](https://github.com/webstudio-is/webstudio/actions/runs/39397337356)
passed, including six E2E shards after a targeted shard-4 rerun for an
unrelated MDX slash-menu timeout. Approved visual regression [run
39397395206](https://github.com/webstudio-is/webstudio/actions/runs/39397395206),
submodules, and PR lint passed. The unapproved synchronize visual run
was cancelled by the approved rerun.
2026-10-21 00:25:55 +02:00
Oleg Isonen e69a3d2f8e feat: Create structured MDX entries from collection folders (#6317)
## Paragraph editing follow-up — 42a16db02c (September 9)

Nested formatted paragraphs now retain their text, links, styling
identity, and existing labels during editing and saving. No database
migration.

- [x] Review all four changed text-editor files.
- [x] Preserve text before and after nested links inside emphasis,
strong text, and spans.
- [x] Preserve existing instance labels on save and keep inherited
formatting from overwriting a link's styling identifier.
- [x] Demonstrate regression failures without each fix, then pass all 41
focused text-editor and MDX synchronization tests.
- [x] Pass Builder typecheck, lint, formatting, and diff checks.
- [x] Verify the reported paragraph in Design and Content modes: edits
reach MDX and survive reload; original text restored. Verify matching
link color and underline inside and outside editing.
- [x] Review documentation and fixture impact: this restores existing
documented behavior; no fixture inputs, generated output, or
documentation changes are needed.
- [x] Commit and push the reviewed fixes.
- [ ] Confirm CI on this commit before merging.

Full E2E and agent evaluations were not rerun for this focused
follow-up. Earlier CI and suite results below apply to their recorded
commits, not this new head.

---

## Final verification — 50093ed2b7 (September 9)

Article edits now retain inline formatting and save newly inserted
custom components reliably. Saving a file no longer sends a second
project-sync write that could restore an older revision. No database
migration.

- [x] Fix iframe-blur saves, inherited template defaults, unused
resolved assets, and stale template tag metadata.
- [x] Remove duplicate server writes for already saved file revisions;
share the result with the canvas using the existing external-content
sync channel.
- [x] Demonstrate new regression tests fail without their fixes and pass
with them. Keep E2E file-write, content-order, and reload assertions;
remove the obsolete duplicate metadata-write wait.
- [x] Pass all 2,955 Builder tests, all 2,409 Project Build tests, and
all 8 focused MDX E2E checks.
- [x] Pass Builder and Project Build typechecks, lint, formatting, and
diff checks.
- [x] Run the complete fixture pipeline with no generated changes. The
later Builder-only save-acknowledgment changes affect no fixture inputs
or outputs.
- [x] Verify live article fields, hero replacement/save/reload/restore,
Accordion text edits, and YouTube URL edits. Verify UI edits reach MDX
and MDX edits persist after reload. Restore original article content.
- [x] Review documentation impact: these fixes restore the documented
Content Block editing behavior; no further documentation change is
needed.
- [x] Apply `visual-change-approved` after the user's explicit approval
of the 24 reviewed intended visual changes.
- [x] Commit and push the reviewed changes; worktree is clean.
- [x] Confirm CI and mergeability on this final commit: all 19 Main
workflow jobs passed, including all six E2E shards; PR lint and
submodule checks passed. Visual approval run 34383497017 passed. Its
predecessor reported the 24 intended differences; all 24 current images
were byte-identical to the reviewed report, with zero capture errors.
GitHub reports no merge conflict.

Agent evaluations were explicitly skipped for these final runtime fixes,
as requested. Earlier evaluation results below apply to their recorded
commits, not this final commit. This summary supersedes historical
pending-check notes below. The PR has not been merged.

---

## Final merge check — 9bc31ca679 (September 9)

- [x] Merge main without rewriting branch history. Preserve main's
image-picker fix and description-list validation.
- [x] Reset inherited HTML parent context at template boundaries. All
four new regressions fail without the fix and pass with it.
- [x] Fix shared navigation style composition and alignment; verify the
browser regression fails before and passes after. Review focused
screenshots.
- [x] Pass 2,408 Project Build tests, 251 design-system tests, and 3
image-picker tests; Builder, Project Build, and design-system
typechecks; lint, formatting, and diff checks.
- [x] Run the complete fixture pipeline with no generated changes.
- [x] Rerun all six agent evaluation scenarios on the merged code with
GPT-5.5. All functional checks pass; incompatible/missing token-baseline
comparison remains explicitly disabled.
- [x] Review documentation impact: this merge preserves documented
behavior; the image-editing guidance was already updated in f90e39cfcc.
- [x] Commit and push; worktree is clean and GitHub reports no merge
conflict.
- [x] Confirm Main CI on 9bc31ca679: all 19 jobs passed, including all
six E2E shards.
- [x] Review final visual artifact 10110845203 from run 34367911826: 24
added/changed stories, zero capture errors. Reviewed collection dialogs
and icons, light/dark login gradients, dashboard and project-settings
navigation, panel spacing, button variants, inset lists, and resettable
labels. Fourteen captures are byte-identical to the previously inspected
CI images. Updated navigation and collection-settings captures were
inspected; the formerly blank story renders normally. Pixel measurements
confirm the columns story retains its intended column positions (second
column x=261, third around x=388).
- [x] Apply visual approval after renewed explicit user approval.
Final-head CI is tracked above.

The live hero replacement and article/custom-component checks below are
now complete. The PR has not been merged.

---

## Merge-readiness follow-up — September 9

- [x] Remove contradictory image guidance and add an executable
writable-source/read-only-alt binding recipe. Regenerate CLI/MCP docs.
- [x] Verify the recipe regression fails with the old guidance and
passes with the new guidance. All 10 focused documentation tests, 2
content-reference tests, CLI/docs typechecks, lint, formatting, and
generated-documentation checks passed.
- [x] Rerun all six agent evaluation scenarios with GPT-5.5: all
functional checks passed. The incompatible/missing token-baseline gate
was explicitly disabled; existing baselines are unchanged.
- [x] Commit the documentation follow-up as f90e39cfcc.
- [x] Review existing CI screenshots and identify unintended shared-list
alignment changes. Implement a local shared-style composition/alignment
fix with a regression test demonstrated failing before and passing
after; all 251 design-system tests and its typecheck passed.
- [x] Visually verify and push the shared list fix in 9bc31ca679. The
focused run compared 28 stories; navigation is left aligned, column
layouts remain intact, and the previously blank collection-settings
story rendered normally. No product fix was inferred from that one blank
capture.
- [x] Review and approve the intended visual differences. See the
current final-head CI status above.
- [x] Verify these changes affect no fixture inputs or generated fixture
output. No database migration.

The previously pending live hero-swap and article/custom-component
checks are now complete. See the current verification summary above.

---

## Article editing follow-up — d307c8ba3d (September 9)

The target blog's hero source was incorrectly marked read-only. It now
uses the existing writable image picker. Reading time and the author URL
also use direct writable values. Time properties now have native
date/date-time controls. No database migration.

- [x] Fix the target's hero source, reading-time structure, and author
URL bindings while preserving the current content and link destination.
- [x] Verify Content-mode category, title, excerpt, date, reading-time,
shared image Description, author name/URL, MDX heading, and list-item
edits reach their source files. Check reloads and restore test values.
- [x] Add date-only, local timestamp, UTC timestamp, empty-value, and
legacy-value regression coverage; demonstrate failure without the date
control and passing results with it.
- [x] Fix the macOS Bash runner's empty-argument failure. Demonstrate
default invocation and argument-forwarding regressions fail without
their behavior and pass afterward.
- [x] Update authoritative Content Block/Time docs and generated CLI/MCP
guidance: inventory every article field, use direct writable bindings
and appropriate controls, check saved source and reload, and never infer
full editability from one heading.
- [x] Pass 291 date/text/Time/design-system tests (one existing skip), 2
runner tests, and 9 documentation tests; relevant typechecks, lint,
package boundaries, formatting, and diff checks.
- [x] Run the complete fixture pipeline: no generated fixture changes.
The later runner/docs-only edits do not affect fixture inputs or
outputs.
- [x] Run the full Builder E2E suite: 82 passed. This used an explicit
reporter; the default invocation correction was then covered by the
runner tests.
- [x] Run all six agent evaluation scenarios on gpt-5.5 after the final
image guidance correction. All functional checks passed. The older-model
token-baseline gate was disabled explicitly; accepted baselines were not
changed.
- [x] Review, commit, and push code and generated documentation.
- [x] With explicit approval, replace the live hero image through
Content mode, verify the MDX reference and reload, then restore and
verify the original image.
- [x] Complete the article-field checks listed above. Insert Accordion
and YouTube from templates; verify UI edits reach MDX and MDX edits
persist after reload. Restore the original article content.
- [x] Inspect CI for 7834d90a61: formatting, lint, typechecks, generated
docs, package/Builder tests, build checks, and five E2E shards passed.
The long MDX lifecycle exhausted its total 120-second budget at its
final assertion; the trace showed completed edits and reloads, not a
stalled save.
- [x] Give only that lifecycle a 180-second total budget; leave
individual save waits and assertions unchanged. Both local repeats
passed (plus setup). Push d307c8ba3d; this test-timeout-only follow-up
affects no fixture inputs or generated output.
- [x] Verify Main CI for d307c8ba3d: all 19 jobs passed, including all
six E2E shards. Visual approval remains separate.
- [x] Finish visual review and approval after correcting navigation
alignment and verifying the collection-settings story renders. The user
approved the reviewed 24 intended differences.
- [x] Recheck target publication preparation: seven documents included,
zero omitted, zero missing-template omissions. No deployment.
- Deferred: manual Storybook/screenshots; not authorized for this pass.

These results supersede the earlier pending image-product decisions and
live-check notes. Evaluation status for the latest fixes is recorded
above.

---

## Blog authoring fixes — 6359f979a3 (September 9)

This review fixes failed UI-to-MDX saves, missing source Undo/Redo,
editor recovery and focus, and publication preparation for the migrated
blog. No database migration.

- [x] Stop treating template-record ordering as a style edit; still
reject actual style changes that cannot be saved in MDX.
- [x] Share save-preparation errors with property controls across the
canvas frame.
- [x] Keep malformed MDX as an unsaved draft, with repair and discard
paths; focus the source editor when opened from the Navigator.
- [x] Enable supported Content-mode Move actions using the existing
central permission rules.
- [x] Keep source Undo/Redo separate from transient rendering history.
Serialize rapid commands, wait for pending canvas edits, reject
stale-source conflicts, and retain the last 20 edits per project
session.
- [x] Fix publication candidate discovery for projected documents and
unrelated author references; keep rejecting unsupported references used
as the actual MDX source.
- [x] Demonstrate regression tests failing without their fixes and
passing afterward.
- [x] Run the complete Builder (2,938), Content Engine (559), and
Project Build (2,395) suites: 5,892 tests passed.
- [x] Pass relevant package typechecks, root lint, formatting, package
boundaries, and diff checks.
- [x] Run the full fixture pipeline; no generated fixture changes.
- [x] Review documentation impact and document draft recovery and source
Undo/Redo.
- [x] Verify live heading edits, author-file edits, malformed-draft
recovery, and immediate delete/Undo/Redo; restore test content and
confirm persisted source.
- [x] Verify target publication preparation: seven documents included,
zero omitted, no missing-template omissions. This did not deploy the
site.
- [x] Review, commit, and push.

### Remaining verification and decisions

- [x] Correct the target's read-only Image source binding. The existing
Content-mode picker replaces the article reference; shared Description
edits use Asset settings. No new image-editing API or data model is
needed. See the latest verification limits above.
- [x] Repeat the full E2E and agent evaluation suites after these
changes: 82 E2E tests and all six evaluation scenarios passed.
- [x] Repeat the live Accordion/YouTube insertion and editing flow after
the save fixes, including UI-to-MDX saves and MDX edits surviving
reload.
- Historical note: this round did not run CI or Storybook checks; later
results are recorded above.

Unknown JSX already has source-range lint diagnostics; it remains an
editable missing-template placeholder, not an unconditionally blocked
save. The target author's binding was also repaired through the UI so
Content mode can edit its referenced author file. Shared resolved URLs
remain read-only text; the image picker changes the article reference,
and Asset settings edits the shared Description.

This section supersedes earlier claims of complete verification for the
latest code; historical results below remain records of earlier runs.

---

## Sync and import verification — a2a567551c (September 9)

Ordinary `link` → `sync` → `import` now exports the current saved
Builder project with its current assets. It no longer mixes an older
published build with current files. Import uploads assets before
assigning their source folders, then restores those assignments when
importing the bundle.

- [x] Fix foldered asset imports without a database migration.
- [x] Preserve file formats, folder assignments, build metadata, and
stable repeat-sync output.
- [x] Keep explicit `--buildId` export behavior unchanged; default sync
does not require publishing.
- [x] Review implementation and demonstrate regression tests failing
before the fixes and passing afterward.
- [x] Update protocol test servers for the current Builder data
endpoint.
- [x] Review documentation impact and update CLI documentation and
README.
- [x] Run all 1,121 CLI tests and 43 HTTP-client tests, both package
typechecks, root lint, package boundaries, formatting, and diff checks.
- [x] Run the full fixture pipeline and include expected current-build
fixture changes.
- [x] Verify the real source through the local CLI: repeated sync gives
identical output; import into the supplied target succeeds. Blog listing
and article rendering were also checked during the import investigation.
- [x] Commit and push the fix.
- Deferred at user request: agent evaluations for this round. Later CI
results are recorded above.

Sync still downloads the project and missing asset files and builds the
content index locally. This is not a transfer-free operation. Default
sync exports editable-build metadata rather than published deployment
metadata; use the explicit build option when selecting a particular
build.

---

## Final review and verification — ab3a6b7c55 (September 9)

Existing entries now use the same field controls as New entry. The
author-name permission fix, field-level validation, publishing warnings,
and final cache fixes are included. No database migration.

### Completed

- [x] Review all 38 local files, including entry autosave, revision
conflicts, permissions, shared fields, collection discovery, and
publishing diagnostics.
- [x] Allow existing-folder setup without rewriting entries or rejecting
unconfigured frontmatter.
- [x] Add Entry settings with autosave, repairable invalid fields,
immutable filename slugs, and preserved MDX body/unknown properties.
- [x] Warn before publication when missing or ambiguous custom templates
omit content, including discovered dynamic sources.
- [x] Allow authorized frontmatter writes to referenced Markdown author
files and preserve error messages across the canvas-frame boundary.
- [x] Reject impossible integer limits, slugless generated-filename
patterns, and slug maximum length zero. Existing raw configurations
remain readable for repairs.
- [x] Share collection discovery across Assets, file editors, and
property controls. Builder first synchronizes project asset metadata
into the browser. The browser then groups that metadata once per update
and shares configuration/template reads, instead of repeating them for
each control. This does not remove initial synchronization or
entry-frontmatter reads. Preserve project/access isolation, refresh
retries, stale-response protection, and duplicate-filename invalidation.
- [x] Demonstrate new regressions fail before fixes and pass afterward.
- [x] Correct the folder-drag E2E's obsolete root-folder assumption and
verify remembered-folder persistence.
- [x] Review and update authoritative Content Engine and Content Block
documentation.
- [x] Merge current main and regenerate the conflicting CLI
documentation from its source.
- [x] Fix generated previews with shared development dependencies:
invoke React Router binaries through Node, isolate each preview's Vite
cache, and forward script options correctly through npm and pnpm.
- [x] Fix a false MDX conflict when a new edit arrives immediately after
the previous save is acknowledged. Advance the local revision before
asynchronous parsing and ignore stale refresh results.
- [x] Run the full fixture link/sync/build pipeline. Generated changes
contain only the expected React Router scripts and Vite cache location.
No database migration.
- [x] Review the final diff and scan added lines for credential
patterns.

### Verification results

- Builder: **2,934 tests passed**. CLI: **1,120 tests passed**.
- Content Engine: **559 passed**; Asset Uploader: **291 passed**;
Project Build: **2,394 passed**; Design system: **250 passed**.
- The clean full workspace run passed all 35 non-CLI packages. Its two
CLI failures exposed pnpm argument forwarding; the complete CLI rerun
passed after that fix. Earlier load-related test timeouts did not recur
in the clean run.
- All workspace typechecks passed. Builder and CLI typechecks and
repository lint were repeated after their final changes. Package
boundaries, generated API checks, and the complete
generated-documentation gate passed. Documentation was regenerated from
source; the post-commit clean-file check passed.
- Full Builder E2E: **82 passed** from a fresh build, including
generated previews, collection creation/reload, MDX editing, stale
revisions, and permission checks. The isolated disposable test database
was cleaned up afterward; development data was untouched.
- Full agent evaluations: **all six scenarios passed on gpt-5.5**,
including every functional check for Markdown blogs, reference
discovery, MDX article editing, authentication, fonts, and design input.
The account cannot use the old **gpt-5.4-mini** baseline model. Five
baseline comparisons are incompatible and the MDX scenario has no
accepted baseline; token-baseline gating was disabled explicitly.
Accepted baselines are unchanged.
- New preview and MDX regressions were demonstrated failing before their
fixes and passing afterward.
- Working-tree/diff checks passed. Main was merged without rewriting
branch history. CI was not checked, as requested.

### Final delivery checklist

- [x] Finish the full Builder E2E rerun.
- [x] Finish the full agent evaluation rerun with the authorized
accessible model.
- [x] Commit, verify the clean generated-documentation gate, and push.
GitHub reports the branch mergeable with current main.

No known code or functional-test blocker remains from this review. CI
was not checked at the user's request. Manual Storybook/screen-reader
checks remain deferred; the automated E2E and agent visual checks above
passed.

The historical review sections below retain their original run results.
This section supersedes earlier claims about strict entry validation,
entry editing, browsing reads, and evaluation authorization.

## Outcome

Content editors can create structured MDX entries from a collection
folder without writing frontmatter. Designers configure flat fields,
limits, optional slug behavior, and the Markdown template in the
Builder.

## High-level goals

- [x] Keep folders ordinary in the database and derive collection
behavior from a direct **collection.json**.
- [x] Add **Use as content collection** to folder creation.
- [x] Give designers a visual configurator for the JSON Schema and MDX
template.
- [x] Show a collection badge and a generic **New entry** action.
- [x] Generate independent MDX entries from the configured schema and
template.
- [x] Keep the current page unchanged after creating an entry; no
automatic preview navigation.
- [x] Select direct MDX entries with URLPattern filename rules; keep
ignored files as ordinary supporting assets.
- [x] Keep reserved collection files out of collection query results and
generated content indexes.
- [x] Preserve broken collections as visible, repairable collection
folders.
- [x] Restore normal folder behavior when **collection.json** is
removed.

## Implementation todos

- [x] Add the Content Engine collection contract, default
schema/template, slug normalization, validation, serialization, and
entry generation.
- [x] Discover collections from Assets files without a database folder
type or migration.
- [x] Create **template.mdx** and **collection.json** when the folder
checkbox is selected.
- [x] Add basic field controls for text, long text, slug, number,
integer, and Boolean values.
- [x] Support required fields, string length limits, numeric limits,
template defaults, and generated slugs.
- [x] Add designer collection settings and template editing.
- [x] Remove dynamic preview-page configuration and ignore its legacy
metadata.
- [x] Add the schema-generated **New entry** form and creation endpoint.
- [x] Preserve reserved-file portability in authenticated export/import
while excluding it from content query and generated-index results.
- [x] Document the feature in the authoritative Content Engine guide.

## Deep review checklist

A checked item means the area was inspected and evidence was recorded.
It does not mean the behavior passed. Unresolved defects and product
decisions remain listed in **Review findings**.

### 1. Product contract

- [x] Decide whether the collection checkbox creates defaults
immediately or opens the configurator first.
- [x] Decide whether existing folders can be converted through the UI.
- [x] Define collection activation when **collection.json** exists but
is invalid.
- [x] Define an entry: every valid direct MDX child or only files
created through **New entry**.
- [x] Confirm collection membership is direct-child only and nested
folders can define their own collections.
- [x] Define designer, content editor, viewer, service, CLI/MCP,
old-client, and direct-API authority.
- [x] Decide whether content mode is simplified UI or a server
authorization boundary.
- [x] Decide whether slugs are permanently immutable.
- [x] Decide whether schema changes may invalidate existing entries or
must migrate them.
- [x] Decide whether invalid unused collections block unrelated queries
or whole-project publication.
- [x] Decide what happens to the preserved template after collection
removal.
- [x] Define the promised JSON Schema dialect and supported subset.
- [x] Decide whether temporary invalid collection states are admitted
for repair.
- [x] Define duplicate-request semantics: no duplicates, exactly one
success, and retry behavior.
- [x] Decide whether entries require valid frontmatter only or valid
complete MDX.

### 2. State machine

- [x] Review ordinary folders and root-level **collection.json**.
- [x] Review empty-folder, template-only, config-uploading, and
config-loading initialization states.
- [x] Review ready collections.
- [x] Review invalid JSON, UTF-8, size, schema, and duplicate-config
states.
- [x] Review missing, duplicate, wrong-type, oversized,
invalid-frontmatter, and invalid-MDX template states.
- [x] Review forbidden direct files, invalid entries, and slug/filename
mismatches.
- [x] Distinguish transient read/network failures from persistent
invalid content.
- [x] Review removing, removed, moved, renamed, restored, duplicated,
and deleted collection states.
- [x] For every state, inspect visibility, allowed actions, server
admission, query/publish behavior, recovery, and concurrent-client
behavior; record recovery behavior.

### 3. Activation and deactivation paths

- [x] Review checkbox creation.
- [x] Review create/upload/rename/move/paste/duplicate of
**collection.json**.
- [x] Review restore, import, project duplication, and sync behavior.
- [x] Review delete/rename/move/replace of **collection.json**.
- [x] Verify all activation paths produce the same state and validation.
- [x] Verify all deactivation paths restore ordinary-folder behavior
without accidental data loss.

### 4. Folder membership and nested collections

- [x] Verify only direct children are collection entries or reserved
files.
- [x] Verify a nested folder with its own direct config becomes its own
collection.
- [x] Verify parent rules do not leak into nested folders.
- [x] Define filename and extension case sensitivity.
- [x] Define duplicate logical-name behavior over generated storage
names.
- [x] Define how uploading, deleted, and stale assets affect folder
state.
- [x] Review moving entries out and between collections with different
schemas.
- [x] Review ordinary subfolders with arbitrary files inside a
collection.
- [x] Review template behavior after collection removal.

### 5. Roles and authorization

- [x] Review config/template listing and download for every role.
- [x] Review config/template content edits for every role.
- [x] Review config/template rename, move, restore, and deletion for
every role.
- [x] Review entry create/edit/rename/move/delete/restore for every
role.
- [x] Review generic upload and subfolder operations for every role.
- [x] Review collection removal and repair for every role.
- [x] Verify server enforcement separately from hidden or disabled
controls.
- [x] Recheck permission changes while operations are in flight.

### 6. Mutation surfaces

- [x] Review REST upload-ticket creation and upload completion.
- [x] Review asset-content replacement and asset metadata changes.
- [x] Review runtime add/update/duplicate operations.
- [x] Review sync patches and direct persistence helpers.
- [x] Review clipboard, drag/drop, move, rename, and duplicate paths.
- [x] Review import/export, restore, and project/folder duplication
paths.
- [x] Review delete-unused-assets and recursive folder deletion.
- [x] Verify invariants at the final persistence boundary, not only in
UI preflight.

### 7. Concurrent operations

- [x] Review create entry against schema save, template save, raw config
edit, and collection removal.
- [x] Review edit/delete/restore entry against schema and template
changes.
- [x] Review two collection-settings editors and raw editor versus
configurator.
- [x] Review schema writer A interleaved with template writer B.
- [x] Review upload/move/rename against collection activation and
removal.
- [x] Review template/config deletion against creation and publication.
- [x] Review folder deletion/move and project switch against all async
operations.
- [x] Review final validity, conflict detection, cleanup, user outcome,
cache invalidation, and publish behavior across the implemented
intersections; record conflict and recovery behavior.
- [x] Review retry after the server commits but the HTTP response is
lost.

### 8. Collection initialization and recovery

- [x] Review project switch, permission revocation, dialog close, folder
rename/move/delete, and conflicting uploads during initialization.
- [x] Verify retry is idempotent and does not duplicate reserved files.
- [x] Verify partial setup has a visible finish, retry, or cleanup path.
- [x] Verify generic actions cannot corrupt the initialization window.
- [x] Verify project and folder identities are captured for the whole
operation.
- [x] Review asset-count, storage, filename, and folder limits with
cleanup.

### 9. JSON Schema conformance

- [x] Confirm the exact draft and validate configs against its
meta-schema.
- [x] Review unknown dialects, boolean schemas, malformed keyword types,
and duplicate JSON keys.
- [x] Review refs/defs, recursion, composition, conditionals,
dependencies, and nullable/multiple types.
- [x] Review enum, const, format, pattern, patternProperties, and
additionalProperties.
- [x] Review min/max properties, array constraints, contains, and
uniqueItems.
- [x] Review exclusive numeric bounds and all string/number/integer
limits.
- [x] Differential-test validation against an independent draft 2020-12
implementation.
- [x] Verify unsupported keywords are rejected or explicitly documented,
never silently ignored.

### 10. Schema resource limits and hostile input

- [x] Bound schema bytes, depth, field count, enum size, and reference
depth.
- [x] Bound validator compilation and validation time.
- [x] Review recursive references and excessive composition branches.
- [x] Review catastrophic patterns and regex denial of service.
- [x] Review huge labels, keys, defaults, and values.
- [x] Review prototype-sensitive and structurally awkward field names.
- [x] Review memory and CPU amplification across many collections.

### 11. Configurator ownership and round trips

- [x] Define owned, preserved, read-only, and rejected schema paths.
- [x] Verify parse/save/parse semantic equivalence and repeated-save
idempotence.
- [x] Verify a UI edit changes only explicitly owned schema paths.
- [x] Review property/form order and required-array order.
- [x] Review unknown root, property, and Webstudio extension metadata.
- [x] Review editable primitive fields that also contain enum, const,
format, composition, readOnly, or custom constraints.
- [x] Review type changes for incompatible preserved or removed
keywords.
- [x] Review rename/removal collisions with unsupported properties and
requirements.
- [x] Surface hidden preserved rules that can cause unexplained
validation errors.
- [x] Review field ordering/reordering.
- [x] Review choosing/changing slug field, slug source, and template
filename.
- [x] Review turning newly added fields into slug or slug-source fields.

### 12. Required/default/unset semantics

- [x] Review absent, empty string, false, zero, null, default, and
user-cleared values for every field type.
- [x] Define required-property versus non-empty-value behavior.
- [x] Verify required Boolean false remains valid and understandable.
- [x] Review optional Boolean absence versus explicit false.
- [x] Review explicitly clearing template-backed values.
- [x] Review JSON Schema default as annotation versus persisted entry
value.
- [x] Verify precedence among template values, schema defaults,
generated slug, and user values.
- [x] Review hidden/non-renderable required fields and template
requirements.
- [x] Verify a collection cannot be ready when every entry form must
fail.

### 13. Schema evolution and migration

- [x] Review add/remove optional and required fields.
- [x] Review field rename and label-only changes.
- [x] Review type changes and tightened/relaxed limits.
- [x] Review enum option, default, slug field/source, template name, and
additionalProperties changes.
- [x] Verify compatible save ordering and identify impossible two-write
migrations.
- [x] Decide whether entries are rewritten and whether migration is
atomic.
- [x] Review entry changes after validation but before schema commit.
- [x] Ensure designers see all incompatible entries or an actionable
summary.

### 14. Template, YAML, and MDX

- [x] Review absent/empty frontmatter and empty YAML.
- [x] Review BOM, CRLF, final-newline, and alternate YAML delimiter
behavior.
- [x] Review duplicate keys, anchors, aliases, tags, comments, quoting,
and multiline strings.
- [x] Review Unicode and byte limits.
- [x] Verify frontmatter and starter-body preservation.
- [x] Review invalid MDX bodies, imports, exports, expressions, and
unsafe nodes.
- [x] Review missing, renamed, duplicate, wrong-type, and oversized
templates.
- [x] Verify template changes affect future entries only.
- [x] Review reserved template exposure through direct asset URLs and
build copying.

### 15. New-entry form and creation

- [x] Verify every required field is renderable or supplied safely.
- [x] Verify deterministic field order and correct controls/constraints.
- [x] Compare client and authoritative server validation.
- [x] Prevent submitted values from overwriting protected hidden fields.
- [x] Preserve values and focus after failed creation.
- [x] Review per-field errors, error summary, and first-error focus.
- [x] Prevent duplicate submission and define lost-response recovery.
- [x] Verify local sync, reload persistence, and project-switch
handling.
- [x] Review no/stale preview page, query delay, and draft-filtered
entries.
- [x] Review large forms and narrow/mobile layouts.

### 16. Entry editing and lifecycle

- [x] Review body-only, frontmatter-only, and combined edits.
- [x] Review invalid intermediate frontmatter and invalid complete MDX.
- [x] Review slug change, filename rename, and reference consequences.
- [x] Review delete, restore, move out, move between collections,
duplicate, paste, and undo.
- [x] Review slug reuse after delete and restore collision.
- [x] Review edits concurrent with schema/template changes.
- [x] Review repair of legacy invalid entries and blocked intermediate
saves.
- [x] Decide whether existing entries receive a generated settings form
or raw MDX editing.

### 17. Slug and filename identity

- [x] Review slug source selection, same slug/source field, manual
override, and visible final normalization.
- [x] Enforce lowercase-dash identity independently of editable schema
metadata.
- [x] Review empty normalized slugs and template/schema slug defaults.
- [x] Review diacritics, non-Latin scripts, and emoji-only sources.
- [x] Use locale-independent case comparison and Unicode normalization.
- [x] Review character/byte limits and case-insensitive filesystems.
- [x] Review collisions with reserved config/template filenames.
- [x] Review concurrent creation, stale reservations, deletion, reuse,
restoration, and URL encoding.

### 18. Collection-root restrictions

- [x] Review upload, external drop, internal drag, generic text
creation, paste, duplicate, move, rename, and extension changes.
- [x] Review runtime add, sync patch, import, and restore bypasses.
- [x] Review upload tickets completed after activation.
- [x] Review moving or renaming **collection.json** through metadata
changes.
- [x] Review dedicated entry creation, initialization, repair, body
editing, and collection removal exceptions.
- [x] Verify subfolder creation and arbitrary files inside subfolders
remain allowed.

### 19. Storage, database, idempotency, and cleanup

- [x] Review object-without-File, File-without-Asset, stale UPLOADING,
and soft-deleted states.
- [x] Review storage success/database failure and database
success/storage failure.
- [x] Review postcheck failure, object cleanup, row cleanup, and cleanup
failure.
- [x] Verify cleanup preserves the original error and cannot delete
another request's asset.
- [x] Review timeout/lost response after commit and safe retries.
- [x] Review reservation lookup/cleanup failure and expiration.
- [x] Review failed creation cleanup and distinguish incomplete uploads
from existing entries with repairable field errors. Existing field
errors do not hide entries or block publication.
- [x] Verify orphan reclamation and project-scoped cleanup.

### 20. Query, build, and publication

- [x] Verify config/template exclusion only for an identified
collection.
- [x] Verify ordinary root-level **collection.json** remains ordinary
content.
- [x] Review template queryability after collection removal.
- [x] Validate actual entry frontmatter and decide complete-MDX
requirements.
- [x] Review invalid content versus transient read failure.
- [x] Decide invalid-collection blast radius across queries, field
catalog, build, and publish.
- [x] Review direct asset IDs, document references, build copying, and
public URLs for reserved-file leakage.
- [x] Verify preview and publish use the same collection rules.

### 21. Cache and snapshot consistency

- [x] Verify config, template, entries, filenames, folder movement,
activation, and removal affect source revision.
- [x] Verify immutable/revision-pinned reads under concurrent swaps.
- [x] Verify config and template come from one logical version.
- [x] Review revision consistency between entry reads and indexing.
Queries do not require entry-schema validation.
- [x] Review rejected-promise caching and retry after repair.
- [x] Verify no cross-project cache collision.

### 22. Performance and availability

- [x] Review sequential versus bounded parallel reads.
- [x] Review request cancellation and repeated preview-query work.
- [x] Review rate limits and resource-exhaustion protection.
- [x] Review progress/cancellation and actionable limit errors.

### 23. Invalid-state repair

- [x] Review repair for every config, template, forbidden-file, entry,
and slug mismatch state.
- [x] Show exact folder, file, field, and rule.
- [x] Distinguish retryable transport errors from content errors.
- [x] Provide missing-template creation despite normal root
restrictions.
- [x] Provide duplicate-file deletion and forbidden-file move recovery.
- [x] Preserve raw repair when the configurator cannot parse the schema.
- [x] Show collection health after repair.
- [x] Prevent custom-template leakage to content editors when config
cannot identify it.

### 24. Entry navigation

- [x] Remove dynamic preview configuration and automatic navigation
after entry creation.
- [x] Verify entry creation leaves the selected page unchanged, with or
without a slug field.

### 25. Accessibility and responsive behavior

- [x] Review native form submission and required semantics beyond an
asterisk.
- [x] Review linked errors, error summary, live announcements, and busy
state.
- [x] Review focus after errors, add/remove field, key edits,
confirmation transitions, and dialog close.
- [x] Review dirty-close warning, explicit cancel/retry, and durable
feedback beyond toasts.

### 26. Portability, compatibility, and rollback

- [x] Review export/import, folder/project duplication, and restore
ordering.
- [x] Verify logical filenames, not storage names, define the portable
contract.
- [x] Review case-insensitive filesystem behavior.
- [x] Review rollback after collection files already exist.
- [x] Verify removal or rollback leaves content recoverable.
- [x] Confirm database/migration assumptions.

### 27. Observability and supportability

- [x] Review state-transition and validation diagnostics.
- [x] Track cleanup failures and orphaned reservations.
- [x] Make publish errors actionable without logging private content.
- [x] Ensure client errors do not expose stack traces or sensitive
internals.

### 28. Verification strategy

- [x] Unit-test schema, slug, merge, serialization, and validators.
- [x] Demonstrate each new regression test fails without its fix.
- [x] Run affected unit suites, typechecks, lint, docs checks, E2E,
fixture-impact review, and final diff review.
- [x] Review authoritative documentation impact.

## Persistence and recovery

No database migration is needed. Folders remain ordinary database rows;
their direct **collection.json** activates collection behavior. This PR
adds no table, column, index, RPC, folder type, or backfill.

- Setup writes the template first and **collection.json** last.
Interrupted setup leaves an ordinary folder and can be retried.
- Existing immutable File revisions, conditional Asset updates, and
upload reservations provide conflict detection and retry-safe entry
creation.
- Settings saves validate the intended template and schema together,
then write only the files that changed. Existing entry field errors stay
repairable and do not block unrelated saves, queries, or publication.
New entry creation remains strict.
- Invalid or interrupted collections remain visible and repairable.
Configuration/template structure errors remain distinct from entry-field
errors; entry-field errors do not invalidate the entire collection.
- Public/service publication excludes configuration and template files.
Authenticated CLI exports retain them for lossless import.

## Review findings

The implementation review is complete. Confirmed defects were fixed and
the following tradeoffs remain explicit.

### Fixed

- Enforced collection structure and permissions across REST, runtime
patches, import, query, and publication, while keeping existing
entry-field errors non-blocking for queries and publication.
- Preserved Undo/Redo, including restoring shared File revisions in
cloned projects.
- Rejected forged shared-file metadata while preserving metadata edits
on legacy files with null uploader provenance.
- Added retry and recovery behavior for setup, settings saves, lost
responses, and transient reads.
- Moved collection setup into one retry-safe server operation and kept
the local Builder update as one Undoable transaction.
- Centralized collection inspection and limited schemas to the flat
fields the configurator can represent. Opening a collection still reads
its entries in the background to report field errors.
- Guarded stale dialogs and deferred saves against permission changes,
protected files, project switches, and replaced revisions.
- Kept Asset settings open while choosing nested folders; the existing
browser regression fails before the fix and passes afterward.
- Preserved required Boolean false values, field-level errors,
dirty-close prompts, and inline Markdown editing.
- Separated authenticated portable exports from public runtime assets.
- Updated the authoritative Content Engine guide.

### Known tradeoffs

- A failure after template content saves but before configuration saves
can temporarily leave an invalid collection. Retrying the settings save
completes it; otherwise the visible files allow repair. The
template/config rename endpoint remains retry-safe and rolls back a
rename when its config write fails.
- Cloned-project Undo can retain an unused prior File revision. Separate
read-then-delete cleanup could race with another restore, so this path
retains the revision.
- Build/asset persistence and import already use multiple calls. This PR
validates before writes and provides retry/conflict handling; it does
not provide a transaction spanning every resource or a global collection
lock.
- Opening a collection loads its configuration and template through
shared Builder discovery, then checks entry frontmatter in the
background for field errors. Unchanged configuration/template content is
reused across controls and entry edits. Frontmatter checks still require
entry reads; ordinary folder browsing does not discover every
collection’s file content.

## Latest unstaged-change review — 2026-09-07

- [x] Review collection settings, validation, autosave/error recovery,
entry creation, reserved-file actions, and conversion flows.
- [x] Review shared labels, list keyboard handling, dialog focus/Escape,
buttons, and panel spacing migrations.
- [x] Fix Enter/Space list activation lost when arrow navigation
replaced the existing press handler.
- [x] Recognize historical generated ASCII/Unicode slug patterns, use
the bundled Unicode slug schema, and save a locally resolved $ref
without changing existing filenames.
- [x] Prevent duplicate slugless entries after a lost response: New
entry sends a stable UUID per attempt, reused by the repository's
existing filename/content retry checks. No database migration. Callers
omitting the optional requestId retain the previous behavior.
- [x] Preserve Content Block template validation independently of page
HTML placement, without accepting invalid rendered nesting.
- [x] Demonstrate the new review regressions fail without their fixes
and pass afterward.
- [x] Review authoritative documentation and update legacy slug
behavior.
- [x] Run fixtures and inspect generated changes: none.
- Deferred manual verification: Storybook screenshots were not
authorized for this pass.
- Historical evaluation status: not run in this pass; superseded by the
final verification section above.

## Verification

Local checks for commit **2b8195692e**:

- Builder app: 1,739 tests; Builder core: 1,150 tests. After the final
fixes, entry/settings tests and shared asset REST checks also passed,
including the added stable-retry test.
- Content Engine: 535 tests.
- Asset Uploader: 279 tests.
- Design system: 249 tests.
- Project Build: 2,392 tests.
- All five affected package typechecks, changed-file lint/formatting,
package boundaries, and Content Engine documentation tests passed.
- Complete fixture link/sync/build pipeline passed with no tracked
fixture changes.
- Staged diff and credential-pattern checks passed. No database schema,
migration, or generated database type changes. The lockfile includes the
collection validator and filename matcher dependencies.
- CI for this commit is pending. Builder E2E, manual
screen-reader/mobile checks, Storybook screenshots, and agent
evaluations were not run in this pass.

## MDX editing review — commit c3702a7238

- [x] Review all 36 local changed files: MDX parsing/materialization,
template enforcement, mutation commits, persistence, Assets refresh,
Navigator, source binding, editor diagnostics, dialogs, and query menus.
- [x] Validate new custom components at the shared Builder mutation
commit before applying tree changes. Cover move, reparent, paste, nested
paste, duplicate, and batched operations; preserve unchanged authored
content.
- [x] Match template names and component structure, including renamed
templates, instead of accepting any component type found in Templates.
- [x] Remove the registered-component fallback from MDX materialization
and completion; report untemplated JSX in the editor.
- [x] Preserve unresolved JSX until its placeholder is deleted, then
persist its removal without clearing the Assets resource during refresh.
- [x] Keep custom designer content outside the MDX body; omit the extra
body for fresh unconnected Content Blocks.
- [x] Resolve Navigator's MDX-file action from the active content root
for dynamic sources.
- [x] Fix the first dialog drag jump while honoring subsequent explicit
size changes; contain long query menus and prevent editor Backspace from
deleting instances.
- [x] Demonstrate new review regression failures before the fixes and
passing results afterward.
- [x] Review and update authoritative Content Block documentation.
- [x] Run the complete fixture pipeline; no generated fixture changes.
- Historical evaluation status: deferred in this pass; superseded by the
final verification section above.
- Historical verification limits: no Storybook screenshots, Builder E2E,
or manual accessibility checks in this pass. See the final verification
section for the current E2E result; manual checks remain deferred.

### Latest verification

- Builder affected suites: **624 tests passed**.
- Project Build full suite: **2,394 tests passed**.
- Design system full suite: **250 tests passed**.
- Query Builder React full suite: **14 tests passed**.
- Component Registry full suite: **7 tests passed**.
- All five affected package typechecks, repository lint, changed-source
formatting, staged diff checks, and credential-pattern scan passed.
- Fixture link/sync/build passed without generated changes. No database
migration.
- CI for this commit has not yet been verified.

The new mutation-commit check covers Builder operations affecting loaded
external content roots. It is not a claim that every remote API mutation
is now guarded by this client-side check.

Closes #6316


## Local-change review — 2026-09-08

- [x] Review all 47 changed files and trace collection setup, filename
filters, public metadata/upload APIs, sync patches, Content-mode write
targets, local folder persistence, and MCP downloads.
- [x] Fix ignored MDX files being renamed into entries through the
metadata API. Selected filenames require New entry.
- [x] Fix supporting-asset moves/renames being blocked by unrelated
invalid entries. Configuration/template checks still run. The later
entry-repair work also removed entry-field validation as a blocker for
unrelated writes and publication.
- [x] Validate frontmatter directly with Ajv, resolve the bundled slug
$ref without network fetching, preserve the flat schema contract, and
avoid retaining old validator instances.
- [x] Verify Unicode generation, legacy-pattern upgrades, sibling
constraints, field error paths, optional binding paths, referenced-file
permissions, and independent queued edits.
- [x] Review authoritative documentation, correct contradictory
referenced-write guidance, and regenerate CLI/MCP documentation.
- [x] Demonstrate new review regression failures with the fixes
disabled, then restore and pass them.
- [x] Pass Content Engine (553), asset uploader (284), SDK (570),
project-build (2,394), MCP command (61), and collection/Content-mode
browser tests (279), plus expression tests and documentation checks.
- [x] Pass seven affected package typechecks, repository lint,
formatting, package boundaries, and fixture link/sync/build. No
generated fixture changes or database migration.
- Historical evaluation status: deferred in this pass; the user
subsequently authorized the full suite. See the final verification
section above.
- Historical verification limits: no Builder E2E or manual
visual/accessibility checks in this pass. See the final verification
section for the current E2E result; manual checks remain deferred.
2026-09-09 21:31:04 +02:00
Oleg Isonen efbc3098c4 feat: add queryable Assets resources (#5946)
Closes #5919
Ref #5920

## Outcome

Extend the existing Assets system resource with optional queries for
Markdown, JSON, and standard file metadata. Unconfigured Assets
resources retain the existing fetch-all behavior and activate none of
the content-query infrastructure.

Files are the authoring model. A standalone content engine converts an
immutable snapshot of only the files required by configured queries into
one bounded, deterministic runtime database. Builder preview, SSR, and
SSG use the same query semantics without requiring a database service
for a published site.

## Final architecture

```text
Markdown / JSON files
        │
        ▼
ContentSource adapter
(FS or Webstudio Assets)
        │ immutable snapshot
        ▼
ContentCompilationPlan
(union of configured query requirements)
        │
        ▼
ContentCompiler
(parse, normalize, discover fields, enforce budget)
        │
        ▼
ContentArtifact
(bounded, deterministic, immutable JSON)
        │
        ▼
ContentDatabase
(filter, OR groups, sort, paginate, project, read content)
        │
        ├── Builder preview
        ├── SSR runtime
        └── SSG build only
```

The authoring/storage layer owns mutable files. The content engine
consumes immutable snapshots and produces immutable, disposable
artifacts.


Query authoring is a separate OpenAPI-driven path:

```text
Assets REST OpenAPI operation
+ standard request JSON Schema
+ dynamic field paths
        │
        ▼
Generic OpenAPI adapter
        │ resolved schemas, controls, paths, and transport mapping
        ▼
Generic query-builder core and React renderer
        │ arbitrary provider-defined value
        ▼
Assets REST request adapter
        │
        ▼
{ query: value }
```

The selected standard OpenAPI operation is the only source of query UI
semantics. Request parameters and JSON Schema describe the editable
data; the generic renderer derives controls and owns layout.

### Activation and compilation

- The compiler does not index every asset. It combines all reachable
configured Assets-resource queries into one `ContentCompilationPlan`.
- Static constraints such as folder, path, and file type select
candidate files. Dynamic values such as a route-bound slug cannot reduce
the build-time candidate set.
- The plan contains the union of fields used by filtering, sorting,
routing, projection, excerpts, and requested full content.
- Documents shared by multiple resources are stored once in one
deployment-wide runtime database.
- Markdown/frontmatter, JSON properties, excerpts, and full bodies are
prepared only when required.
- No configured content query means no parsing, artifact, or shipped
runtime dependency. Fresh generated apps need no content-runtime
cleanup; incremental generation removes stale integration if a
previously configured query is deleted.

### Runtime database limit

- `CONTENT_DATABASE_MAX_BYTES` limits the complete serialized runtime
database, not source files, images, or unrelated assets.
- The default is `500 * 1024` bytes and is presented as 500 KiB.
- Counted data includes indexed metadata, frontmatter/JSON properties,
excerpts, the field catalog, serialization overhead, and full Markdown
bodies only when requested.
- Prepublish validation builds and serializes the exact database that
will be attached to the immutable build, so it knows the unbounded size,
bounded size, included documents, omitted documents, and affected
resources.
- Overflow never stores partial documents. Candidates are ordered by
`createdAt` descending, canonical path ascending, and stable document ID
ascending. Missing dates follow dated documents. A document that does
not fit is skipped while smaller later documents are still considered.
- Exceeding the limit warns but does not block publishing.
- Builder preview can report exact bounded versus unbounded results when
dynamic expressions have concrete preview values. Prepublish warnings
remain conservative for future route values.

### Snapshot consistency

The source contract guarantees a consistent compilation, while adapters
provide the mechanism:

- Webstudio Assets captures asset metadata and immutable content
references.
- Filesystem sources capture file identity and verify files did not
change before accepting the artifact.
- A changed source retries once, then fails clearly instead of producing
a mixed-revision database.
- This requires no universal snapshot service, source-tree copy, or new
versioned-asset infrastructure.

### Package ownership

- `@webstudio-is/content-engine`: runtime artifact schema, query
execution, field catalog, compact runtime statistics.
- `@webstudio-is/content-engine/compiler`: source snapshots, compilation
plans, Markdown/JSON parsing, deterministic compilation, byte
accounting, and compiler diagnostics. This entry exists to keep
Remark/YAML/future MDX dependencies out of runtime bundles.
- `@webstudio-is/query-builder`: resolves standard OpenAPI operation
schemas into an internal provider-neutral editor model, validation,
mutations, and source serialization. It owns no Assets,
provider-authored UI contract, or fixed REST-query semantics.
- `@webstudio-is/query-builder/react`: container-neutral schema renderer
whose layout is renderer policy. It remains separate from the content
engine.
- SDK: Webstudio Assets/Resource domain models and mapping Webstudio
expressions into generic content requirements.
- Protocol: external Assets REST/OpenAPI transport contracts.
- Asset uploader/repository: asset and folder mutations, generic
metadata, immutable byte references, and storage access. Its hosted
adapter supplies Webstudio Assets snapshots and parsed-metadata cache
persistence to the content engine; parsing, artifact creation, and query
semantics remain engine-owned.
- Builder and generated-app integrations decide when to compile, cache,
embed, load, or discard a database.

### Runtime lifecycle

- Builder caches immutable `ContentDatabase` instances by source
revision plus compilation-plan hash and coalesces concurrent
compilation. Matching operations reuse the same instance; field
discovery uses a dedicated minimal all-properties plan that excludes
excerpts and bodies.
- SSR attaches the validated bounded database to the build and includes
the small runtime only when required.
- SSG uses the database only while generating pages and omits it and the
runtime from final output unless a future runtime-query feature requires
them.
- Local development compiles from the filesystem and uses identical
query semantics.
- Published pages query their local artifact; they do not call Builder
REST endpoints.
- Published artifacts need no external index store, invalidation,
garbage collection, SaaS content proxy, new bucket, or new environment
variable.

## Implemented foundation

These existing parts remain useful and should be moved behind the final
ownership boundaries rather than reimplemented.

- [x] Upgrade the existing Assets system resource in place and preserve
unconfigured fetch-all behavior.
- [x] Implement typed filtering, nested boolean groups, deterministic
sorting, pagination, projections, dynamic values, and content hydration.
- [x] Add Markdown frontmatter, excerpt, JSON-property, and
field-catalog extraction.
- [x] Add reusable query-control implementations and a separately
imported React UI as a foundation for the final OpenAPI-driven contract.
- [x] Add Assets query authoring and dynamic field discovery as existing
behavior to migrate into the Assets OpenAPI operation.
- [x] Add synchronized visual and editable expression authoring.
- [x] Unify Assets REST operations under `/rest/assets/*`.
- [x] Define authenticated collection, item, content, upload, folder,
query, field-catalog, and OpenAPI operations.
- [x] Support Builder cookie authentication and public API token
authentication.
- [x] Add Builder preview, MCP/CLI operations, SSR execution, SSG path
generation, and conditional activation.
- [x] Add revision-keyed parsed metadata persistence for the hosted
Builder.
- [x] Add focused query, API, authorization, Builder, CLI, SSR, SSG,
migration, and fixture coverage.

## Remaining implementation plan

### 1. Establish the content engine

- [x] Rename the generic `@webstudio-is/asset-resource` implementation
to `@webstudio-is/content-engine`.
- [x] Move existing behavior instead of creating a parallel
implementation.
- [x] Keep the primary entry runtime-only and add only the compiler
entry needed for bundle separation.
- [x] Remove the old package after all consumers migrate.
- [x] Ensure the engine has no Builder, SDK, asset-uploader, PostgreSQL,
R2, or deployment-target dependency.

### 2. Define source snapshots and compilation plans

- [x] Introduce `ContentSource.openSnapshot()` and a revision-bearing
`ContentSourceSnapshot`.
- [x] Include canonical path, stable document ID, content type,
immutable content reference, size, and optional `createdAt`.
- [x] Implement Webstudio Assets and filesystem snapshot guarantees
using their adapter-specific mechanisms.
- [x] Introduce `ContentCompilationPlan` for the union of reachable
configured resource requirements.
- [x] Separate statically selectable candidates from dynamic runtime
predicates.
- [x] Add mutation-during-compilation tests for replacement, deletion,
folder movement, and filesystem changes.

### 3. Separate storage from content processing

- [x] Keep upload, replacement, folders, byte storage, revisions, and
generic metadata in the Assets repository/uploader.
- [x] Move parsing, excerpts, field discovery, query execution, and
artifact creation into the content engine.
- [x] Remove content-index coordination from asset mutation business
logic.
- [x] Preserve original source `createdAt` across content replacement
and expose it as optional queryable metadata.
- [x] Keep hosted parsed-document persistence behind the content
compiler's optional cache interface.

### 4. Build deterministic compilation

- [x] Move the existing Markdown, frontmatter, JSON, canonicalization,
hashing, document-building, and tests into the compiler.
- [x] Keep frontmatter behind a dedicated module and continue using the
existing Remark/Micromark pipeline.
- [x] Parse only candidate files and only the tiers required by the
compilation plan.
- [x] Deduplicate documents and fields required by multiple resources.
- [x] Define a versioned, deterministic `ContentArtifact` with integrity
information.
- [x] Keep verbose parse and omission diagnostics outside the runtime
artifact.
- [x] Reject incompatible artifact versions cleanly.

### 5. Enforce the deployment-wide database budget

- [x] Replace the old asset-index limit with
`CONTENT_DATABASE_MAX_BYTES`, defaulting to 500 KiB.
- [x] Have applications read configuration and pass the byte limit into
the compiler.
- [x] Measure the exact serialized database, including selected bodies
and overhead.
- [x] Implement deterministic skip-and-continue packing of complete
documents.
- [x] Return compiler diagnostics with unbounded/bounded bytes,
included/omitted counts, omitted identities, largest contributors, and
affected resources.
- [x] Expose only compact artifact statistics at runtime through
`ContentDatabase.getStats()`.
- [x] Add exact boundary, deterministic ordering, deduplication, and
oversized-document tests.

### 6. Finalize the runtime database

- [x] Define `ContentDatabase` over an immutable artifact.
- [x] Preserve filtering, nested AND/OR groups, sorting, offset/limit,
projection, field references, and content retrieval.
- [x] Expose `getFieldCatalog()` and compact `getStats()`.
- [x] Keep Markdown/YAML/compiler dependencies out of the runtime entry.
- [x] Add execution guards and maximum-size runtime benchmarks.

### 7. Make query authoring OpenAPI-driven

The selected standard OpenAPI operation is the complete query-authoring
contract. The query builder resolves parameters and request-body JSON
Schema, derives its internal editor model, and applies renderer-owned
layout policy. It must not embed or fetch a second capabilities/UI
language through `x-webstudio-query` or another side channel.

- [x] Remove `x-webstudio-query` and all vendor query-definition
metadata from the Assets OpenAPI operation.
- [x] Resolve local OpenAPI references and derive the editable request
value, defaults, validation, labels, choices, arrays, objects, and
unions solely from standard operation parameters and request-body JSON
Schema.
- [x] Represent dynamic Assets field paths with standard JSON Schema
vocabulary in the `queryAssets` request schema.
- [x] Keep the normalized editor representation internal to
query-builder; do not expose another provider-authored capabilities
contract.
- [x] Remove provider-controlled layout metadata such as `group`; make
compact scalar packing and all other layout renderer policy.
- [x] Keep Webstudio expression binding as a consumer/editor concern
layered over schema values, not part of the OpenAPI contract.
- [x] Preserve the existing Assets filter, sort, output selection,
full-content/range selection, limit/offset, editable source, and
configured-field behavior.
- [x] Keep the Assets resource adapter responsible for serializing the
edited query into its request body.
- [x] Remove the obsolete Assets query-capabilities endpoint, URL, and
UI-side capability parsing.
- [x] Add a non-Assets OpenAPI proof with differently named parameters
and no vendor metadata.
- [x] Verify the generic packages contain no Assets imports, fixed
Assets property contract, or provider-authored layout model.
- [x] Update focused core, React, SDK, protocol/OpenAPI, Builder, and
source round-trip tests.

### 8. Manage ContentDatabase lifecycle in Builder

- [x] Cache databases by source revision plus normalized
compilation-plan hash.
- [x] Coalesce concurrent compilation requests.
- [x] Reuse cached database instances across field discovery,
autocomplete, query preview, and response preview when their normalized
compilation plans match.
- [x] Replace it when source revision or query requirements change.
- [x] Preserve the optional revision-keyed hosted parsed-document cache
without making it a source of truth.
- [x] Show exact preview warnings when concrete values reveal missing
bounded results.

### 9. Materialize and verify immutable builds

- [x] Compile and serialize the exact deployment-wide database during
prepublish validation.
- [x] Attach that validated bounded database to the immutable build
without rebuilding it from later asset state.
- [x] Show non-blocking prepublish warnings with database bytes,
omissions, and potentially affected resources.
- [x] Avoid claiming exact future route matches when dynamic values are
unknown.
- [x] Include the database/runtime only when a reachable configured
query requires them.
- [x] Ensure detail resources requesting Markdown content include all
statically eligible bodies needed by dynamic routes.

### 10. Integrate all targets

- [x] SSR: load the build's bounded database and conditionally include
the small runtime.
- [x] SSG: query the same database during generation, then omit
database/runtime output when no runtime query is needed.
- [x] Local/CLI: compile from the filesystem source with the same
semantics.
- [x] Preserve overview pagination, alternative route fields,
draft-as-user-data behavior, and full article rendering.
- [x] Verify ordinary Assets and fresh query-free sites perform no
parser, artifact, content-runtime dependency install, or cleanup work.

### 11. Correct API and package ownership

- [x] Move external Assets REST/OpenAPI contracts to
`@webstudio-is/protocol`.
- [x] Keep Webstudio domain models and Assets system-resource
configuration in the SDK.
- [x] Keep both cookie and token authentication behavior on the unified
Assets REST surface.
- [x] Remove pass-through route wrappers/reexports that add no transport
behavior.
- [x] Keep published runtime queries local to the artifact rather than
routing them through Builder REST.

### 12. Remove superseded deployment infrastructure

- [x] Remove external deployment-index upload, fetch, invalidation,
cleanup, and garbage-collection code.
- [x] Remove the SaaS asset-origin adapter requirement; close
webstudio-is/webstudio-saas#652 as superseded because it has no
independent purpose.
- [x] Remove index-bucket compatibility configuration and avoid adding
Infisical variables.
- [x] Remove obsolete external-index paths, package dependencies,
routes, scripts, and tests.
- [x] Consolidate unreleased intermediate migrations where safe and
retain only schema required by the final hosted cache/API design.

### 13. Verification and release readiness

- [x] Move and preserve existing tests while changing ownership; add new
tests only for changed contracts and behavior.
- [x] Run content-engine compiler/runtime tests, query-builder tests,
SDK/protocol/API tests, Builder tests, CLI tests, and affected
typechecks.
- [x] Run formatting, generated-file idempotence, fixtures, clean
Supabase-compatible migrations, E2E shards, and complete agent
evaluations.
- [x] Verify SSR and SSG conditional inclusion and query-free generated
package manifests.
- [x] Run the five-article MCP blog workflow: authoring, field
discovery, overview, dynamic detail routes, full Markdown rendering,
publishing, and published-site verification.
- [x] Run a maximum-budget database test and a
mutation-during-compilation test.
- [x] Perform a final architecture, security, API compatibility,
migration, bundle, correctness, and DRY review.
- [x] Reconcile every checkbox and replace the verification section with
results from the final architecture before release.

## Future MDX work

MDX is intentionally separate from this release.

- The compiler contract should allow a future build-only MDX parser.
- MDX compilation must not enter the published runtime.
- Embedded JSX must use an explicit compiled representation rather than
runtime source evaluation.
- Webstudio components, tokens, styles, and component allowlists remain
Webstudio integration concerns.
- The future MDX work should reuse `ContentArtifact` and
`ContentDatabase` where practical.

## Superseded design

The following earlier design choices are no longer the target
architecture:

- GROQ or GraphQL as the Assets query language.
- One external or long-lived index object per resource/query.
- A deployment index fetched by the Worker from SaaS/CDN infrastructure.
- Lazy production reads of source Markdown bodies.
- A separate index bucket, asset origin, invalidation service, or
garbage collector.
- A 4 MiB published index limit.
- Rebuilding an old build's database from the current mutable asset set.
- Bundling query infrastructure into projects without a configured
content query.

## Verification baseline

The embedded runtime-database architecture previously passed the checks
below. The OpenAPI-driven query-authoring change additionally passed:

- Query-builder core: 4 files / 19 tests.
- Query-builder React: 1 file / 7 tests.
- SDK Assets source/config: 1 file / 7 tests.
- Protocol Assets OpenAPI: 1 file / 9 tests, including independent
OpenAPI validation.
- Builder Assets OpenAPI description: 1 file / 5 tests.
- Query-builder, React, SDK, protocol, and Builder typechecks.
- Package-boundary validation and formatting of every affected file.

Local verification baseline:

- Content engine: 15 files / 104 tests.
- Asset uploader: 24 files / 175 tests.
- Builder: 204 files / 2,423 tests.
- CLI: 54 files / 866 tests.
- Complete workspace typecheck, formatting, lint, package boundaries,
generated fixtures, and fixture builds.
- The complete migration history applied successfully to a fresh
Supabase-compatible database, including every migration after the
consolidated Assets migration.
- Builder production build and full local E2E suite passed.
- Complete agent evaluations passed: authenticated page (170,859 ms),
design input (207,101 ms), and font assets (67,050 ms).
- Final review additionally verified correct REST edit/view/build
permits, cookie and public-token read paths, immutable snapshot retries,
exact database budgeting, query-free dependency omission, and SSR/SSG
conditional runtime inclusion.

Final staging verification passed against the embedded runtime-database
architecture: MCP uploaded and updated five Markdown articles,
discovered dynamic frontmatter fields, previewed a five-item sorted
overview and one full-body slug query, updated both Assets resources,
found zero binding issues, rendered `/blog` and `/blog/dynamic-routes`
at HTTP 200, published build version 266, and verified both published
routes at HTTP 200 with the expected article metadata and Markdown body.
The workflow also found and fixed offset-form asset timestamps failing
canonical datetime validation and made MCP `preview.start({ port: 0 })`
correctly select an available local port.

## Release constraints

- No new SaaS content service, bucket, or environment variable.
- No published-site database dependency.
- No parser/compiler dependency in query-free sites or runtime-only
bundles.
- The validated content database is immutable build output.
- Publishing warnings do not block deployment.
- The selected standard OpenAPI operation and its request JSON Schema
are the only source of query UI semantics.
2026-07-31 00:17:46 +02:00
Oleg Isonen 878d6f1de1 feat: Add asset folders to asset manager and improve asset manager UX (#5892)
Closes https://github.com/webstudio-is/webstudio/issues/5877
Closes https://github.com/webstudio-is/webstudio/issues/4775


- Organize assets into nested folders.
- Navigate folders with breadcrumbs and Back controls.
- Select and manage multiple assets and folders at once.
- Drag, copy, cut, paste, duplicate, move, and delete items.
- Use context menus and familiar keyboard shortcuts for common actions.
- Search and sort assets and folders, with folders grouped first.
- Upload files directly into the active folder.
- Manage folder placement from asset and folder settings.
- Automate asset and folder management through MCP.
2026-07-17 23:39:14 +02:00
Oleg Isonen dde30ffb54 feat: Improve MCP authoring, compact output, and agent onboarding (#5883)
## Summary

This improves how agents discover, author, inspect, and verify Webstudio
projects while reducing unnecessary MCP context usage.

## What changed

- Adds an **Agents** section to Project Settings with ready-to-run setup
commands and client configuration for Claude Code, Codex, Cursor, and VS
Code.
- Makes large list and schema responses compact and paginated by
default, with **verbose** available when complete records or diagnostics
are needed.
- Applies consistent compact output to assets, instances, styles, design
tokens, CLI schemas, and project-session metadata.
- Returns actionable expression warnings for props, resources, and
Collection bindings, including unknown variables and risky render-time
mutation resources.
- Improves Collection expression guidance so agents can bind array items
with the correct scoped variables.
- Reports rendered audit outcomes explicitly as complete, partial,
confirmation-required, or failed.
- Expands runtime output schemas so MCP clients can validate responses
reliably.
- Strengthens the packaged CLI smoke workflow with a realistic
seven-page stdio MCP scenario.

## Architecture

- Consolidates `project-build` from 65 file-oriented entrypoints to 11
architecture-owned surfaces.
- Separates the core model, contracts, runtime authoring, transfer,
state, project sessions, MCP, visual tooling, persistence codecs, and
authenticated server services.
- Isolates Node-only JSX evaluation from browser-safe transfer utilities
and authenticated server modules.
- Keeps persistence codecs independent from authenticated database
services, preventing unrelated module initialization.
- Defines shared instance-path types once and reuses them across runtime
modules.
- Preserves Immer initialization through explicit package side-effect
metadata.
- Adds package tests that prevent a return to source-file entrypoints or
generic exposure of Node-only surfaces.

## Validation

- Full repository checks, tests, typechecks, generated-file checks, and
fixtures
- All 163 Builder test files and 2,141 tests
- All 71 project-build test files and 1,794 tests
- Lint and package-boundary validation
- Full packed CLI release smoke test, including install, preview, agent
setup, seven-page stdio MCP workflow, rendered audit, and structured
commands
2026-07-15 18:11:28 +02:00
Oleg IsonenandClaude Fable 5 071a4d9a85 feat: MCP update 3 (#5864)
## Summary

This update adds new MCP and CLI capabilities for project auditing,
structured data, project-specific agent instructions, focused project
search, safer bulk editing, image descriptions, font discovery, visual
verification, and external registry inspection.

## New Capabilities

### Audit projects

- Run a single `audit` command across accessibility, SEO, security,
assets, styles, and performance.
- Limit an audit to selected scopes, pages, or severity levels.
- Receive stable findings with locations and suggested fixes.
- Run rendered audits across desktop, mobile, and Builder breakpoint
widths.
- Detect horizontal overflow, broken images, oversized images, eager
below-fold images, render-blocking resources, and legacy font formats.
- Identify unused assets, tokens, CSS variables, local styles, and
breakpoints.
- Identify duplicate token declarations.
- Detect accessibility issues involving names, labels, headings,
landmarks, IDs, keyboard focus, ARIA, iframes, and autoplaying media.
- Detect SEO issues involving titles, descriptions, language, social
images, and structured data.
- Detect unsafe new-tab links and write resources exposed during page
rendering.

### Search an entire project

- Search project text, labels, props, resources, assets, and styles
through `search-project`.
- Find relevant records without downloading and reparsing the full
project snapshot.
- Scope searches to the relevant project-data areas.

### Add validated JSON-LD

- Add structured data with a dedicated JSON-LD component.
- Place JSON-LD inside the page Head Slot.
- Edit JSON in a purpose-built code editor.
- Prevent structurally invalid JSON-LD from being saved.
- Validate Schema.org types, properties, and values.
- Find invalid, missing, unknown, deprecated, or incompatible structured
data through the SEO audit.
- Let agents discover the correct JSON-LD workflow without using page
custom metadata or a generic HTML embed.

### Configure project-specific agent instructions

- Add AI-agent instructions from the new **Agents** section in Project
Settings.
- Synchronize those instructions into a managed root `AGENTS.md`.
- Update or remove the managed file automatically during project sync.
- Protect existing user-owned `AGENTS.md` files from being overwritten.
- Share the instructions with authenticated CLI and MCP agents.
- Keep agent instructions out of publicly readable production bundles.

### Generate and manage image descriptions

- Audit image assets for missing descriptions.
- Let a vision-capable agent inspect each image in its rendered context.
- Save generated descriptions to multiple image assets in one operation.
- Mark images as intentionally decorative.
- Reuse the saved asset description wherever the image is used.
- Re-run the audit to verify that missing-description findings are
resolved.

### Perform bounded bulk replacements

- Replace matching literal text across selected pages with
`replace-text`.
- Replace matching fixed prop text with `replace-prop-text`.
- Replace matching resource names or URLs with `replace-resource-text`.
- Restrict replacements by page, instance, prop, resource, field, match
mode, and maximum change count.
- Leave dynamic expressions unchanged.

### Inspect element ancestry

- Return an element’s direct parent in instance listings.
- Request the complete ancestor chain when inspecting an element.
- Understand tree placement without rebuilding the instance hierarchy
from raw project data.

### Discover available fonts

- List uploaded font families through `list-fonts`.
- Discover available system font stacks.
- Inspect font family, style, weight, format, and associated asset
information before applying typography.

### Inspect external component registries

- Inspect a local or remote shadcn-style registry item.
- Read its description, files, dependencies, targets, and documentation.
- Receive an explicit Webstudio compatibility report.
- Inspect registry metadata without installing or executing external
code.

### Capture generated project routes directly

- Run `webstudio screenshot --path /route` against the configured
project.
- Generate a temporary production-style preview automatically.
- Capture the requested route.
- Stop the temporary preview after capture.
- Avoid manually building and starting a preview for a single
screenshot.

### Assert visual changes

- Add expected text to screenshot comparisons.
- Set maximum pixel mismatch limits.
- Set minimum or maximum changed-region counts.
- Assert whether overall brightness or a color channel moved in the
expected direction.
- Use these assertions as pass/fail evidence for visual changes.

### Require compatible CLI versions

- Send the project-bundle contract version with CLI synchronization
requests.
- Stop incompatible CLI versions before they receive incomplete project
data.
- Tell users exactly how to update the CLI or run the latest version
once.
- Prevent older clients from silently dropping project settings.

## Upgrade Note

This branch introduces a new synchronized project-bundle contract. Older
CLI versions must update before synchronizing against the new API.

```sh
npm install -g webstudio@latest
```

Or run the latest version once:

```sh
npx webstudio@latest <command>
```

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 11:27:58 +02:00
Oleg Isonen d291e4b671 feat: Builder api runtime contracts guardrails for MCP (#5857)
This PR expands Webstudio MCP and CLI into a more complete agent
authoring interface. Agents can discover project capabilities, edit real
Webstudio content, use data/resources, verify visual output, and report
useful issues when workflows fail.

## MCP User Capabilities

- Create, update, duplicate, reorder, and delete pages.
- Create pages from templates and manage reusable page templates.
- Inspect project pages, instances, props, styles, assets, variables,
resources, and metadata.
- Insert Webstudio components and authored JSX fragments into pages.
- Edit text, props, styles, breakpoints, design tokens, and CSS
variables.
- Update page metadata, SEO fields, redirects, marketplace metadata, and
project settings.
- Create and use static data variables.
- Create and use dynamic resources fetched over HTTP.
- Use REST, GraphQL, and built-in system resources in authored pages.
- Bind data variables and resources to visible page content.
- Create resource-backed pages such as sitemap XML, structured SEO data,
and API-driven content sections.
- Preview current project state without requiring a publish step.
- Capture screenshots for visual verification.
- Verify responsive designs across desktop, tablet, and mobile
breakpoints.
- Use screenshot diff and OCR-style checks to inspect rendered output.
- Reset and refresh local MCP project state when needed.
- Discover available CLI/MCP commands from generated manuals.
- Use clearer examples for resources, data variables, JSX authoring,
previewing, and visual checks.
- Read marketplace product metadata without requiring a full project
snapshot.
- Get safer guidance when using low-level patch tools.
- Get a ready-to-copy Discord report template when MCP/CLI behavior is
confusing or broken.
2026-07-10 02:13:22 +02:00
Oleg Isonen 1ddf6b02c9 feat: API and CLI for everything (#5838)
Closes #5287
2026-07-01 01:20:50 +02:00
Oleg Isonen e7b7faeca5 fix: performance optimizations (#5827) 2026-06-19 12:23:44 +02:00
Oleg Isonen 392c9089be fix: content mode permissions (#5795)
**Summary**

Fixes content-mode edit permissions so editor-only users can perform
allowed content workflows without backend “build permission” failures.

**Changes**

- Added shared content-mode permission validation used by backend
authorization.
- Aligned content-mode capabilities around editable props, editable
instances, content roots, pages, assets, and template insertion.
- Allowed content-safe instance/text/page/template/style changes while
keeping design/data/resource changes build-only.
- Updated template insertion to preserve content-safe local styles and
reuse tokens by id.
- Added accessible `SyncStatusDot` for e2e-visible sync state without
replacing the existing sync status UI.
- Added builder e2e setup with Postgres/PostgREST and a first
content-mode browser test:
  - edit existing text as an editor-only user
  - wait for saved state via the sync status dot
  - reload and verify persistence

**Verification**

- `pnpm --filter=@webstudio-is/builder test -- sync-status.test.tsx`
- `pnpm --filter=@webstudio-is/builder typecheck`
- `git diff --check`
- `pnpm e2e:builder`
2026-06-09 01:48:23 +02:00
Oleg Isonen cc26648519 fix: Fix page template editor permissions (#5793)
Adds permission protection around page templates so content editors can
create pages from templates without being able to open, edit, or patch
template pages directly.
2026-06-04 22:34:56 +02:00
Oleg Isonen a2cfcbb7be feat: WIP Multiplayer (#5733) 2026-04-28 03:38:12 +02:00
Oleg Isonen b006947a85 feat: WIP realtime collaboration to builder (#5726)
https://github.com/webstudio-is/webstudio/issues/46
2026-04-27 23:19:21 +02:00