mosaic-headless 1.38.1 → 1.38.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/SKILL.md CHANGED
@@ -6,7 +6,7 @@ license: "MIT"
6
6
  user-invocable: true
7
7
  metadata:
8
8
  author: "moksa (https://moksaweb.com)"
9
- version: "1.38.1"
9
+ version: "1.38.3"
10
10
  homepage: "https://github.com/Moksa1123/mosaic-headless"
11
11
  ---
12
12
 
@@ -138,6 +138,7 @@ fits, and say in the spec which native path was checked.
138
138
  | **Site menu** | `dropdown` with `openOn: hover`; phone drawer = `modal` opened by `modalOpen` | `verify_menus.py` exit 0 |
139
139
  | **Animation / interaction** | `tools/interactions.py` (meta-uuid keys, CSS-string values); never `@keyframes` in a code node | `verify_recipes.py` exit 0 (or `verify_intro.py` / `verify_loop.py` for that shape) |
140
140
  | **Form with a Select** | 1.0.12: `select > select-toggle + select-options > select-option`; `select-input` no longer exists | `verify_components.py` exit 0 |
141
+ | **Delete a root, or change a component, on a site with content** | back up `wp_mosaic_nodes`; export every instance of the component with its override nodes; make the change; render the pages; run `tools/override_health.sql` ([facts.md](references/facts.md)) | no instance newly `all_shells = 1`; any that is, written back from the export |
141
142
  | **Move a theme** | `theme_zip.py export` / `import` (test mode unless `--activate`), or `theme_export.php` / `theme_import.php`; prune unbound masters first | `theme_zip_compare.php` all PASS |
142
143
  | **Plugin upgrade** | `data_upgrade.py`; re-extract (`extract_*.py`, `check_tables.py`); re-run the verifiers | [upgrading.md](references/upgrading.md) checklist; `scan_inline_tags.py` finds nothing |
143
144
  | **Elementor → Mosaic** | `from_elementor.py --strict`; build; check | `verify_conversion.py` exit 0 |
@@ -153,7 +154,7 @@ Five facts that cause most broken pages (the rest: [facts.md](references/facts.m
153
154
 
154
155
  - A `button`'s words go in a `text` node (`build_page.py` wraps them); only four types take a `url`.
155
156
  - A `wysiwyg-text` run prints tags literally since 1.0.11: inline formatting is `wysiwyg-span` / `-link` / `-linebreak`.
156
- - One root per document, or every instance renders empty; `build_site.py` stops on a duplicate root.
157
+ - One root per document, or every instance renders empty; `build_site.py` stops on a duplicate root. But deleting a root (or re-keying a component) makes heal empty that component's overrides in every other document: export them first. Empty roots come from a front-end render's heal reading a lost database connection as "no root"; blocking front-end writes to `wp_mosaic_nodes` prevents it ([facts.md](references/facts.md)).
157
158
  - `@media(` in a `code` node is a function call and returns HTTP 500 after a clean commit; write `@media (`.
158
159
  - `scrollDepth`'s action slot is `reached` since 1.0.10; the old slot name is stored and never runs.
159
160
 
@@ -177,6 +178,7 @@ Every validator below exits 1 on any FAIL.
177
178
  | slider, tabs, accordion, forms, map | `verify_slider.py`, `verify_components.py` | exit 0 |
178
179
  | Elementor conversion | `verify_conversion.py` | exit 0: every string, image, link and heading level found |
179
180
  | theme move | `wp eval-file tools/theme_zip_compare.php <src> <copy> out.csv` | no FAIL row |
181
+ | component instances | `wp db query < tools/override_health.sql` (read only) | no instance newly all shells, no duplicate override nodes |
180
182
  | this skill | `python tools/test_mosaic.py` | all pass (offline) |
181
183
 
182
184
  Read the page **logged out** (an admin sees a test-mode theme and 406
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "metadata": {
23
23
  "author": "moksa (https://moksaweb.com)",
24
- "version": "1.38.1",
24
+ "version": "1.38.3",
25
25
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
26
26
  }
27
27
  },
@@ -24,7 +24,7 @@
24
24
  "user-invocable": true,
25
25
  "metadata": {
26
26
  "author": "moksa (https://moksaweb.com)",
27
- "version": "1.38.1",
27
+ "version": "1.38.3",
28
28
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
29
29
  }
30
30
  },
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "metadata": {
23
23
  "author": "moksa (https://moksaweb.com)",
24
- "version": "1.38.1",
24
+ "version": "1.38.3",
25
25
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
26
26
  }
27
27
  },
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "metadata": {
23
23
  "author": "moksa (https://moksaweb.com)",
24
- "version": "1.38.1",
24
+ "version": "1.38.3",
25
25
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
26
26
  }
27
27
  },
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "metadata": {
23
23
  "author": "moksa (https://moksaweb.com)",
24
- "version": "1.38.1",
24
+ "version": "1.38.3",
25
25
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
26
26
  }
27
27
  },
package/data/pending.csv CHANGED
@@ -8,3 +8,5 @@ date,question,why_not_found,asked_by,status
8
8
  2026-11-16,Is a top-level user-invocable key accepted by the claude.ai skill upload,scripts/check-release.mjs notes the Agent Skills spec allows only six top-level keys; Claude Code reads user-invocable and the claude-code platform template now writes it; the other platform templates do not; the claude.ai upload path is untested,mosaic skill (SOP item 0),open
9
9
  2026-11-17,"Mosaic 1.0.13 editor features the skill cannot write yet: new collection-variable types (background/gradient, box/text shadow, nested; font size and line height as variables); List classes; pageLoad delay; scroll-direction offset; Hide/Show in Editor actions; accordion all-open; External Styles / Gutenberg Styles","they live in the editor JavaScript, not in the PHP the extractors read; each needs one editor-authored example read back from the row on a 1.0.13 site (references/upgrading.md)",user (Mosaic 1.0.13 release),open
10
10
  2026-11-17,Demo verifiers and sweeps not yet re-run on Mosaic 1.0.13,"the demo site was upgraded on 2026-11-17 and passed the page health check (90/90, no duplicate roots); the browser verifiers were held back because the shared host was under heavy load",user (Mosaic 1.0.13 release),open
11
+ 2026-11-18,"Demo site: 7 component instances (case-card x3, service-row x4) in two unbound templates have all 70 override nodes emptied to originalID-only shells","not a gap in the data but a known state: written 2026-11-04 18:05 UTC after a component rebuild re-keyed the components; the templates serve no post so no visitor sees it. Left as is (read-only check); prune_unbound.php would remove the templates, or the instances can be re-filled from a spec. Whether to delete the two unbound templates is the user's decision",skill 總機 (em925 override incident follow-up),waiting (user decision)
12
+ 2026-11-18,"Install the front-end write block for wp_mosaic_nodes on the demo site (references/facts.md, empty-root prevention)","a decision, not a gap: the block is measured on another live site; installing it on the shared demo site waits for the user",skill 總機 (em925 empty-root root cause),waiting (user decision)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mosaic-headless",
3
- "version": "1.38.1",
3
+ "version": "1.38.3",
4
4
  "description": "AI-agent skill: build Mosaic Pro (Nextend) WordPress sites by writing the underlying data model directly - 23 custom tables, no visual editor, no DOM. Every node type, style property and node property swept against a live install and asserted on the delivered HTML and compiled CSS. Installs into Claude Code, Cursor, Codex CLI, Gemini CLI, Copilot, Continue, Windsurf and Claude.ai.",
5
5
  "keywords": [
6
6
  "wordpress",
@@ -47,6 +47,7 @@
47
47
  "sites/_tokens.py",
48
48
  "tools/*.py",
49
49
  "tools/*.php",
50
+ "tools/*.sql",
50
51
  "SKILL.md",
51
52
  "README.md",
52
53
  "README.zh-TW.md",
@@ -37,6 +37,65 @@ Platform and rendered-tag facts, each measured. Moved out of SKILL.md on 2026-11
37
37
  failed query as "no root" and wrote a new empty one, with no REST write in the
38
38
  log. A site that sees this needs the load handled (bot rate limits, MySQL
39
39
  capacity) as much as the roots repaired.
40
+
41
+ **Why a lost connection becomes an empty root.** Found by the em925 site's
42
+ session reading Mosaic 1.0.12 and WordPress (2026-11-18), re-read here against
43
+ Mosaic 1.0.13 and WordPress 7.1.4:
44
+ - every front-end render builds its document with `load()` then `heal()`, and heal
45
+ may write (`Mosaic/Builder/AbstractDocument.php`, `createEditorInstance()` at line
46
+ 376, `load()` / `heal()` at 380-381 in 1.0.13 - the file is byte-identical to 1.0.12);
47
+ - when the connection has gone away (errno 2006) and `check_connection()` cannot
48
+ reconnect, `wpdb::query()` returns `false` WITHOUT setting `last_error`
49
+ (`wp-includes/class-wpdb.php` lines 2282-2288 on 7.1.4), so `get_results()` hands
50
+ back the empty `last_result` that `flush()` left (lines 1921-1927);
51
+ - `MosaicDB::get_results()` treats an empty array with an empty `last_error` as
52
+ success (`Mosaic/Database/MosaicDB.php` line 25; identical in 1.0.12 and 1.0.13),
53
+ so "the database was unreachable" reads as "this document has no root", and heal
54
+ writes a new empty one - with empty instance overrides beside it.
55
+ The more nodes a page has, the more queries a render makes, and the more uncached
56
+ bot traffic a site gets, the likelier it is. A small site is less likely to hit it,
57
+ not immune.
58
+
59
+ **Prevention, measured on one live site (2026-11-18):** block front-end writes to
60
+ `wp_mosaic_nodes`. A `query` filter refuses `INSERT` / `REPLACE` / `DELETE` on that
61
+ table during an ordinary front-end request, while `UPDATE` passes and wp-admin,
62
+ admin-ajax, REST (the editor and these tools), WP-CLI and cron are untouched; form
63
+ submissions live in another table and are untouched too. When it blocks, the page
64
+ is marked uncacheable, logged and reported. Before switching it on, the site ran it
65
+ log-only over 34 pages: a normal render made 0 writes to `wp_mosaic_nodes`, so
66
+ blocking costs nothing. It is the lightest safe fix found so far and applies to any
67
+ Mosaic site; whether a site installs it is that site's owner's decision. The
68
+ implementation belongs to that site and is not shipped here - the description above
69
+ is enough to write one (a must-use plugin with a `query` filter and a log-only
70
+ switch).
71
+ - **Changing a component's roots or its node ids empties its instances' overrides
72
+ everywhere else.** An instance in another document (a template, the master) keeps
73
+ one override node per component node, and heal re-syncs those nodes to the
74
+ component on the next render that touches them. When the component's root or
75
+ internal ids changed, heal rebuilds each override as a shell -
76
+ `{"override":{"originalID":"<new id>"}}` - and the instance's text, links and
77
+ images fall back to the definition's. Measured twice:
78
+ - 2026-11-17, a live site: two components' extra empty roots were deleted by hand;
79
+ the first front-end requests afterwards turned every override of their instances
80
+ in the master into shells, and the footer's links and the header's cards lost all
81
+ their text and URLs until the overrides were rewritten.
82
+ - 2026-11-04, the demo site: rebuilding a component (which re-keys its internals)
83
+ turned all 70 override nodes of 7 instances in two older, unbound templates into
84
+ shells, every one pointing at the component's new ids; the bound templates were
85
+ rebuilt in the same run and kept theirs (which is why `build_site.py` rebuilds
86
+ every page that uses a component together).
87
+
88
+ So before deleting any root-type node (`master-root`, `component-internal`,
89
+ `template-internal`) or rebuilding a component on a site with content:
90
+ 1. back up the whole node table: `wp db export pre-change.sql --tables=wp_mosaic_nodes`;
91
+ 2. export every instance of that component and its override nodes:
92
+ `SELECT * FROM wp_mosaic_nodes WHERE parentType='override' AND parentID IN
93
+ (SELECT ID FROM wp_mosaic_nodes WHERE type='component-instance/<componentID>')`;
94
+ 3. make the change, render the affected pages once, then run
95
+ `wp db query < tools/override_health.sql`: an instance with `all_shells = 1` that
96
+ was not all shells in the export lost its content - write it back from the
97
+ export (`build_site.py`'s override pass, or the saved rows).
98
+ `tools/override_health.sql` also lists duplicate override nodes. It is read only.
40
99
  - **`modified_gmt` is server-assigned.**
41
100
  - **Styling hangs on the generated `._<token>` class, not your `attrID`**, and the
42
101
  token (`_a`, `_b`, ... `_ba`: a base-38 per-document counter) is not stable. The
@@ -49,6 +49,7 @@ Every tool in `tools/`, and where the REST session comes from. Moved out of SKIL
49
49
  | `bootstrap_probe_theme.php` | a licence-free scratch theme |
50
50
  | `mint_session.php` | a matching cookie + `wp_rest` nonce from WP-CLI |
51
51
  | `mosaic_config.py` | the one place a tool resolves the site URL and session - environment (`MOSAIC_SITE_URL` / `MOSAIC_REST_COOKIE` / `MOSAIC_REST_NONCE`) over `--config` file, so a credential never has to be written to disk |
52
+ | `override_health.sql` | read only, `wp db query < tools/override_health.sql`: component instances whose override nodes heal emptied into `{"override":{"originalID":…}}` shells, and duplicate override nodes. Run it before and after deleting a root or changing a component (references/facts.md) |
52
53
  | `check_tables.py` | re-extract all eleven source-derived tables and diff them against the shipped ones - the check for a table that is not wrong but STALE, which nothing else can see |
53
54
 
54
55
  ## The session, and where it comes from
@@ -0,0 +1,43 @@
1
+ -- override_health.sql - read only. Component instances whose override nodes were emptied.
2
+ --
3
+ -- wp db query < tools/override_health.sql
4
+ --
5
+ -- An instance (a node whose type starts with component-instance/) owns one override node
6
+ -- per node of its component: parentType 'override', parentID = the instance, and
7
+ -- data.override.originalID = the component node it shadows. A SHELL is an override node
8
+ -- whose data is nothing but {"override":{"originalID":...}}: no text, no url, no attrID.
9
+ -- build_site.py writes an attrID into every override node, so on a site built by this
10
+ -- skill a shell means heal rebuilt the node and dropped its content. Measured on a live
11
+ -- site (2026-11-17): deleting a component's extra empty root made the next front-end
12
+ -- render's heal turn every override of that component's instances in the master into a
13
+ -- shell, and the header and footer lost all their text and links.
14
+ --
15
+ -- Result 1: per instance, how many override nodes and how many are shells.
16
+ -- all_shells = 1 is the failure signature. Some shells on an instance whose component
17
+ -- has nodes with nothing to override can be normal on a hand-built site; compare with
18
+ -- the export taken before the change.
19
+ -- Result 2: duplicate override nodes (the same instance shadowing the same component
20
+ -- node twice).
21
+ SELECT LEFT(o.themeID, 8) AS theme, o.documentType, LEFT(o.documentID, 8) AS doc,
22
+ LEFT(o.parentID, 8) AS instance, i.type AS instance_type,
23
+ COUNT(*) AS overrides,
24
+ SUM(JSON_LENGTH(o.data) = 1 AND JSON_LENGTH(o.data, '$.override') = 1
25
+ AND JSON_CONTAINS_PATH(o.data, 'one', '$.override.originalID')) AS shells,
26
+ SUM(JSON_LENGTH(o.data) = 1 AND JSON_LENGTH(o.data, '$.override') = 1
27
+ AND JSON_CONTAINS_PATH(o.data, 'one', '$.override.originalID')) = COUNT(*) AS all_shells
28
+ FROM wp_mosaic_nodes o
29
+ LEFT JOIN wp_mosaic_nodes i ON i.ID = o.parentID AND i.themeID = o.themeID
30
+ WHERE o.parentType = 'override' AND JSON_VALID(o.data)
31
+ GROUP BY o.themeID, o.documentType, o.documentID, o.parentID, i.type
32
+ HAVING shells > 0
33
+ ORDER BY all_shells DESC, shells DESC;
34
+
35
+ SELECT LEFT(themeID, 8) AS theme, LEFT(parentID, 8) AS instance,
36
+ JSON_UNQUOTE(JSON_EXTRACT(data, '$.override.originalID')) AS original, COUNT(*) AS n
37
+ FROM wp_mosaic_nodes
38
+ WHERE parentType = 'override' AND JSON_VALID(data)
39
+ GROUP BY themeID, parentID, original
40
+ HAVING n > 1;
41
+
42
+ SELECT COUNT(*) AS override_nodes, COUNT(DISTINCT parentID) AS instances
43
+ FROM wp_mosaic_nodes WHERE parentType = 'override';
@@ -388,7 +388,11 @@ class SkillDoc(unittest.TestCase):
388
388
 
389
389
  def test_referenced_tools_exist(self):
390
390
  text = read("SKILL.md")
391
- for name in set(re.findall(r"\b([a-z_]+\.(?:py|php))\b", text)):
391
+ # the override check is documented as read only: keep it that way
392
+ sql = read("tools/override_health.sql")
393
+ body = "\n".join(l for l in sql.splitlines() if not l.lstrip().startswith("--"))
394
+ self.assertIsNone(re.search(r"\b(DELETE|UPDATE|INSERT|REPLACE|DROP|ALTER|TRUNCATE)\b", body, re.I))
395
+ for name in set(re.findall(r"\b([a-z_]+\.(?:py|php|sql))\b", text)):
392
396
  hits = [os.path.join(d, name) for d in ("tools", "sites", "evals")
393
397
  if os.path.exists(os.path.join(ROOT, d, name))]
394
398
  self.assertTrue(hits, name)