# Publishing

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

Canonical URL: https://fa7e86e3d553: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.

## 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)
