# Publishing

> Compile, preview, verify, and explicitly publish a storefront page

Canonical URL: https://c22dfdd27662:3005/pages/publishing

The safe publishing workflow is draft-first:

```text
1. Compile without saving
2. Create or update a draft version
3. Run structural integrity checks
4. Verify the preview in the host agent's browser
5. Publish only after explicit user approval
```

## 1. Compile

```json
{
  "name": "lexsis_pages",
  "arguments": {
    "action": "compile",
    "args": {
      "source": "<!-- section: hero --><section class=\"grid gap-8 lg:grid-cols-2\"><h1>Summer Sale</h1></section>",
      "head": { "title": "Summer Sale" },
      "theme_css": ":root { --lx-accent-color: #c04b2f; }"
    }
  }
}
```

Compilation checks:

- Section structure and unique IDs
- Island names and prop schemas
- Restricted section JavaScript
- Forbidden external CSS
- Publish integrity
- Tailwind candidate generation
- Missing utility classes

Continue only when compilation succeeds and `missing_candidates` is empty.

## 2. Create the draft

```json
{
  "name": "lexsis_page_create",
  "arguments": {
    "action": "create",
    "args": {
      "slug": "summer-sale-2026",
      "source": "<!-- section: hero --><section class=\"grid gap-8 lg:grid-cols-2\"><h1>Summer Sale</h1></section>",
      "head": {
        "title": "Summer Sale"
      },
      "theme_id": "theme-uuid",
      "inherit_header": true,
      "inherit_footer": true,
      "archetype": "landing",
      "workspace_id": "workspace-uuid",
      "store_id": "store-uuid",
      "publish": false
    }
  }
}
```

The consolidated create action always remains draft-only. It rejects
`publish:true`.

The response can include:

```typescript
{
  page_id: string;
  preview_url: string | null;
  url: string | null;
  current_version: number;
  published_version_id: string | null;
  published_version: number | null;
  has_unpublished_changes: boolean;
  status: "draft";
}
```

Use `preview_url` for QA. A public `url` can remain null until a deployment
target exists.

## 3. Run integrity checks

```json
{
  "name": "lexsis_pages",
  "arguments": {
    "action": "integrity",
    "args": {
      "page_id": "page-uuid"
    }
  }
}
```

Integrity checks cover page structure, required commerce islands, URLs,
placeholder content, header/footer configuration, and related source
invariants. They do not replace visual QA.

## 4. Perform responsive browser QA

The MCP returns preview URLs but does not maintain a shared browser-automation
pool. The calling AI agent uses its own browser capability.

Verify at least:

| Width | Purpose |
|---|---|
| 390px | Mobile |
| 768px | Tablet |
| 1280px | Desktop |

Check:

- Horizontal overflow
- Grid and flex column counts
- Unexpected section height
- Overlap and clipping
- Broken or missing images
- Hover, focus, carousel, and accordion behavior
- Console errors
- Background and typography consistency

When screenshots are unavailable, inspect DOM geometry and computed styles.
Always confirm the actual viewport width after changing it.

## 5. Publish after approval

```json
{
  "name": "lexsis_live_ops",
  "arguments": {
    "action": "publish",
    "args": {
      "page_id": "page-uuid"
    }
  }
}
```

`lexsis_live_ops` is a sensitive lifecycle tool. Publishing requires explicit
user approval.

An explicit approval already given for this exact page and version remains
valid. Ask again only when the release scope or reviewed version changes.

## Publishing a quiz with saved responses

Design approval, capture-policy activation, and page publication are separate
decisions. A quiz can be published without response saving.

For a quiz that should save responses:

1. Read the saved draft's immutable page-version UUID. The displayed version
   number is not a `page_version_id`.
2. Use `lexsis_capture.quiz_inspect`, then `lexsis_drafts.quiz_prepare` for that
   version, island instance, and returned definition hash.
3. Review the fields, purpose, disclosure, retention, resume window, and optional
   contact purpose. With explicit approval, use `lexsis_live_ops.quiz_activate`.
4. Publish the same reviewed version with publication approval. Source edits
   require a fresh inspection and matching policy.
5. On the returned published URL, verify saving opt-in and opt-out, analytics
   allowed and denied, edit/back/reload, confirmed save, and the Forms response.

Preview QA covers paths, product resolution, focus, responsive layout, and
transition animations, including reduced motion. It cannot prove production
capture. Record live capture checks after publication; do not block design
review on a response that preview intentionally does not collect. Keep results
in the existing operation record with page/version and response IDs, without
creating local JSON dumps or screenshot reports.

See [Forms and Quiz Responses](/tools/forms) for the exact MCP sequence.

## What publish means

The `publish` action:

- Runs pre-publish validation unless emergency validation bypass is explicitly
  requested
- Promotes the exact reviewed current version to `published_version_id`
- Marks the Lexsis page as published only after external publication succeeds
- Returns publication metadata and any configured public URL

It does not automatically push a page to Shopify.

Keep these operations distinct:

| Operation | Result |
|---|---|
| Draft preview | Inspect an unpublished page/version |
| Lexsis publish | Change the Lexsis page lifecycle status |
| Standalone deployment | Deploy to Lexsis-hosted storefront delivery |
| Shopify push | Create or update Shopify-facing delivery |

Do not claim a Shopify page exists unless the Shopify deployment operation has
completed successfully.

## Editing a published page

The contract is:

1. Read `lexsis_pages` action `edit_context`
2. Create a new non-live version with `lexsis_drafts`
3. Verify the draft version
4. Explicitly publish it

The public renderer remains pinned to `published_version_id` while
`current_version` advances. A failed republish keeps the previous live version
and records the failure without exposing the rejected draft.

## Version conflicts

Every edit should include the version read before editing:

```json
{
  "expected_version": 6
}
```

If the server reports a conflict, re-read the page source and current version.
Do not automatically overwrite the newer version.

## Rollback

Rollback is also a live operation:

```json
{
  "name": "lexsis_live_ops",
  "arguments": {
    "action": "rollback",
    "args": {
      "page_id": "page-uuid",
      "version": 4
    }
  }
}
```

Inspect the diff and obtain explicit approval before rolling back.

## Unpublish and delete

Unpublishing is asynchronous. Wait until the page is no longer published
before deleting it. Published pages are rejected by the delete operation.

## Related

- [Page Management](/tools/page-management)
- [Page Source Contract](/pages/schema)
- [Publish Errors](/troubleshooting/publish-errors)
