@aotter/mantle 0.0.11-alpha.62 → 0.0.11-alpha.64

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.
Files changed (52) hide show
  1. package/README.md +96 -11
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +52 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/generate.d.ts +2 -0
  7. package/dist/generate.d.ts.map +1 -0
  8. package/dist/generate.js +181 -0
  9. package/dist/generate.js.map +1 -0
  10. package/dist/harness-cli.d.ts +3 -0
  11. package/dist/harness-cli.d.ts.map +1 -0
  12. package/dist/harness-cli.js +209 -0
  13. package/dist/harness-cli.js.map +1 -0
  14. package/dist/runtime-testing.d.ts +2 -0
  15. package/dist/runtime-testing.d.ts.map +1 -0
  16. package/dist/runtime-testing.js +2 -0
  17. package/dist/runtime-testing.js.map +1 -0
  18. package/dist/skills.d.ts +2 -0
  19. package/dist/skills.d.ts.map +1 -0
  20. package/dist/skills.js +80 -0
  21. package/dist/skills.js.map +1 -0
  22. package/dist/update.d.ts +2 -0
  23. package/dist/update.d.ts.map +1 -0
  24. package/dist/update.js +387 -0
  25. package/dist/update.js.map +1 -0
  26. package/docs/adapter-guide.md +8 -0
  27. package/docs/adr/0001-four-atom-manifest-model.md +6 -7
  28. package/docs/adr/0007-ai-as-primary-author.md +100 -138
  29. package/docs/adr/0008-structured-diagnostic-shape.md +79 -99
  30. package/docs/adr/0009-consumer-supplied-manifests.md +101 -228
  31. package/docs/adr/0012-views-as-public-rest.md +43 -15
  32. package/docs/adr/0014-auth-better-auth-and-multi-tenant-mcp.md +43 -17
  33. package/docs/adr/0018-core-starters-repository-boundary.md +155 -0
  34. package/docs/adr/README.md +8 -6
  35. package/docs/cloudflare-low-level-composition.md +94 -0
  36. package/docs/design-atoms.md +59 -57
  37. package/docs/design-references/editorial-blog-2026-05-05.md +7 -7
  38. package/docs/labels.md +1 -1
  39. package/docs/media-uploads.md +1 -1
  40. package/docs/performance-harness.md +104 -0
  41. package/docs/release-process.md +156 -523
  42. package/docs/schema-indexes.md +14 -1
  43. package/package.json +16 -6
  44. package/skills/README.md +20 -16
  45. package/skills/develop/SKILL.md +42 -4
  46. package/skills/install/SKILL.md +16 -2
  47. package/skills/plugin/SKILL.md +1 -1
  48. package/skills/provision/SKILL.md +1 -1
  49. package/skills/theme/SKILL.md +12 -10
  50. package/skills/update/SKILL.md +31 -19
  51. package/skills/customize-design/SKILL.md +0 -215
  52. package/skills/extend/SKILL.md +0 -257
@@ -0,0 +1,104 @@
1
+ # Data access, cache policy, and performance harness
2
+
3
+ Mantle site code declares intent; Core owns the shared storage layout and the
4
+ Cloudflare adapter owns provider bindings. A site-building agent should not
5
+ need Mantle table names, generated-column names, KV prefixes, or D1 APIs to
6
+ make a normal content/API/page change.
7
+
8
+ ## Ownership
9
+
10
+ | Read or state | Owner | Notes |
11
+ |---|---|---|
12
+ | Entry get/list and public slug/data-field/published reads | `DatabaseEntryRepository` through `EntryRepository` / `EntryReader` | Schema-aware field resolution is shared here. |
13
+ | Manifest View execution | `ExecuteViewUseCase` + `ViewSqlCompiler` | The deliberate compiled-query exception; it still resolves declared Schema indexes. |
14
+ | Editable settings and code-owned locale/media policy | `DatabaseSiteConfigRepository` | Editable values and dynamic media tool policy are read fresh; boot-seeded locale policy may be memoized within the runtime instance. |
15
+ | Pending media uploads | `DatabasePendingUploadRepository` | Canonical, read-after-write D1 state; never publish-cache state. |
16
+ | Rendered HTML, Markdown, and `llms.txt` | `HtmlPublishOrchestrator` plus the Cloudflare public-route cache policy | Reproducible derivatives live in KV. Settings updates invalidate through a runtime use case. |
17
+ | D1/KV transport and optional query metrics | Cloudflare bindings | Bindings stay thin. Query/cache policy does not belong in a generic provider `BaseRepository`. |
18
+
19
+ `CmsRuntime.db` remains deprecated compatibility surface. New site code uses
20
+ Manifests, runtime use cases, `entryReader`, and `siteConfig`. A site may own
21
+ additional tables behind its own repository at the composition root, but it
22
+ must not query Mantle-owned tables through `runtime.db`.
23
+
24
+ ## Cache contract
25
+
26
+ - D1 is canonical for entries, site settings, media metadata, and pending
27
+ uploads. KV contains only reproducible public artifacts.
28
+ - A public KV hit checks the cache before loading full editable site settings.
29
+ Locale policy is the small boot-seeded exception. A warm entry/page artifact
30
+ therefore performs zero D1 queries.
31
+ - A safe cache miss renders from canonical state and schedules KV write-back
32
+ with the request execution context. It waits inline only when no execution
33
+ context exists, such as a direct unit call.
34
+ - Site-setting writes call the runtime settings use case, which completes
35
+ public-artifact invalidation before reporting success. HTTP routes do not
36
+ scan/delete KV prefixes themselves.
37
+ - Do not cache every repository read. Cross-isolate correctness for editable
38
+ data wins unless a read has a measured hot-path contract and explicit
39
+ invalidation.
40
+
41
+ ## Index coverage
42
+
43
+ The Node harness uses the real canonical migrations, generated Schema DDL,
44
+ real View compiler, deterministic skewed rows, and SQLite
45
+ `EXPLAIN QUERY PLAN`:
46
+
47
+ ```bash
48
+ pnpm exec mantle-harness indexes --manifests ./manifests --format text
49
+ pnpm exec mantle-harness indexes --require-public --format json
50
+ pnpm exec mantle-harness indexes --require account-members --format json
51
+ ```
52
+
53
+ Without `--require-public` or `--require`, findings are advisory. A required
54
+ path fails on an `entries` table scan, a temporary ORDER BY B-tree, or a
55
+ data-field predicate/order that does not use a declared Schema index.
56
+ Projection alone does not require an index. `mantle validate` remains a pure
57
+ correctness check; no performance grammar or manifest atom was added.
58
+
59
+ Use the machine report in CI. It includes the compiled SQL and parameters,
60
+ query-plan details, named indexes, scan/sort flags, result count, SQLite
61
+ version, fixture row count, and required-failure summary.
62
+
63
+ ## Worker/API/page sampling
64
+
65
+ Sample any running environment with the public HTTP helper:
66
+
67
+ ```bash
68
+ pnpm exec mantle-harness http \
69
+ --base-url http://127.0.0.1:8787 \
70
+ --route recent=/api/views/recent-posts \
71
+ --route page=/en/posts/hello \
72
+ --rounds 20 --warmup 2 --format json
73
+ ```
74
+
75
+ Timing always reports p50/p95/max. A test-only Worker wrapper may also return
76
+ `x-mantle-query-count` and `x-mantle-rows-read`; those become distributions in
77
+ the same report. Do not expose these diagnostic headers in production.
78
+
79
+ Core CI runs `pnpm bench:wrangler` against real Wrangler-local D1, KV, Worker
80
+ HTTP routing, View execution, and live page rendering. It compares 100 and
81
+ 10,000 row fixtures, then samples page MISS and HIT separately. CI gates
82
+ row-read scaling, endpoint query budgets, and zero-D1 warm hits, not absolute
83
+ milliseconds.
84
+
85
+ ## Seven findings: measured disposition
86
+
87
+ Measured on the deterministic 2026-08-01 Wrangler-local fixture; timings are
88
+ diagnostic, while query/row counts are the stable assertions.
89
+
90
+ | Finding | Disposition |
91
+ |---|---|
92
+ | Public KV hits read D1 first | Fixed. A 10,000-row warm page measured 0 queries / 0 rows read. |
93
+ | Slug/locale reads bypass generated indexes | Fixed by the shared schema-aware entry-read boundary. A 10,000-row page MISS measured 2 queries / 5 rows read. |
94
+ | OFFSET pagination | Accepted for the v0.1 bounded-result surfaces: every response is capped at 500 rows and public hot paths must stay shallow. Deep/export workloads require a purpose-shaped cursor API before they are declared hot. |
95
+ | Admin substring search scans | Accepted only for the authenticated Admin collection browser, with a 500-row response cap. Large/search-heavy sites should add a purpose-shaped indexed View or dedicated search service; do not expose this scan publicly. |
96
+ | Published list/sitemap/llms paths lack system indexes | Fixed with measured partial indexes for published global, locale, collection, and collection+locale ordering. The 100-row and 10,000-row API runs both measured 1 query / 20 rows read. |
97
+ | Page MISS waits for KV write-back | Fixed. Reproducible artifacts write through `waitUntil`; regression coverage proves response completion does not await KV. |
98
+ | Benchmark stops at fake in-process dispatch | Fixed by the Node planner and Wrangler-local Worker/API/page layers. The old dispatch microbenchmark remains a narrow CPU signal only. |
99
+
100
+ The retained OFFSET and substring-search trade-offs are visible exceptions,
101
+ not patterns for new public APIs. Re-measure before widening either scope.
102
+
103
+ See also [Schema indexes](./schema-indexes.md) and the official Cloudflare
104
+ [D1 index guidance](https://developers.cloudflare.com/d1/best-practices/use-indexes/).