@zero2webmaster/starter-kit 0.19.1 → 0.23.0

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.
@@ -224,21 +224,24 @@ dist
224
224
  `;
225
225
  function buildEnvExample(usesNeon, sendsEmail) {
226
226
  const dbLine = usesNeon
227
- ? `# Neon Postgres pooled connection string (required). Per [[neon-postgres]],
228
- # use the POOLED URL and keep /health DB-free so the compute scales to zero.
229
- DATABASE_URL=postgresql://user:pass@host/db?sslmode=require
227
+ ? `DATABASE_URL=postgresql://user:pass@host/db?sslmode=require
228
+
229
+ # DATABASE_URL — required. Per [[neon-postgres]], use the POOLED URL and keep
230
+ # /health DB-free so the compute scales to zero.
230
231
  `
231
- : `# Database URL (only if this service uses a database). For Neon Postgres, use
232
+ : `# DATABASE_URL=postgresql://user:pass@host/db?sslmode=require
233
+
234
+ # DATABASE_URL — only if this service uses a database. For Neon Postgres, use
232
235
  # the pooled connection string per [[neon-postgres]].
233
- # DATABASE_URL=postgresql://user:pass@host/db?sslmode=require
234
236
  `;
235
237
  return `# {{slug}} — example environment variables.
236
238
  # Copy to \`.env\` (gitignored) and fill in real values. Do NOT commit \`.env\`.
237
239
 
238
- # Port the service listens on. Cloud Run overrides this at runtime; 8080 is the
239
- # Cloud Run default and a sensible local default.
240
240
  PORT=8080
241
241
 
242
+ # PORT — Cloud Run overrides this at runtime; 8080 is the Cloud Run default and
243
+ # a sensible local default.
244
+
242
245
  ${dbLine}${sendsEmail ? EMAIL_ENV_BLOCK : ""}`;
243
246
  }
244
247
  const DRIZZLE_CONFIG_TEMPLATE = `import { defineConfig } from "drizzle-kit";
@@ -54,7 +54,7 @@ function jsonLdHelpers() {
54
54
  //
55
55
  // Usage (Next.js App Router):
56
56
  //
57
- // import { articleJsonLd } from "@/seo/json-ld";
57
+ // import { articleJsonLd, serializeJsonLd } from "@/seo/json-ld";
58
58
  // export default function Page() {
59
59
  // const ld = articleJsonLd({
60
60
  // headline: "Post title",
@@ -63,8 +63,47 @@ function jsonLdHelpers() {
63
63
  // image: "https://example.com/og.png",
64
64
  // url: "https://example.com/posts/post-title",
65
65
  // });
66
- // return <>{/* page body */}<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(ld) }} /></>;
66
+ // return <>{/* page body */}<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: serializeJsonLd(ld) }} /></>;
67
67
  // }
68
+ //
69
+ // 🔴 SERIALIZE WITH \`serializeJsonLd\`, NEVER WITH BARE \`JSON.stringify\`. These
70
+ // builders are fed CONTENT -- \`headline: post.title\`, an author name, a product
71
+ // description -- so they are fed DATABASE CONTENT, which makes them
72
+ // user-controlled by construction rather than by accident.
73
+ //
74
+ // \`JSON.stringify\` escapes what JSON needs escaped and does NOT escape \`<\`,
75
+ // correctly, because \`<\` is legal in a JSON string. But the HTML parser does not
76
+ // parse JSON: inside a <script> element it scans the raw bytes for \`</script\` and
77
+ // ENDS the element the moment it finds one, parsing the rest as markup. A headline
78
+ // containing that sequence closes the tag and runs whatever follows it.
79
+ // \`z2w-social\` found exactly this live on 2026-08-14 -- stored XSS reachable by
80
+ // any signed-in member against every visitor, admins included -- and it had passed
81
+ // a typecheck, a build, unit tests on the JSON-LD content, and a 200 response,
82
+ // because a serializer inside a script tag reads as the handled path.
83
+ //
84
+ // A CSP does not save you: \`'unsafe-inline'\` permits it by definition, and even a
85
+ // nonce does not, because the payload runs as MARKUP rather than as a script.
86
+ // Escaping is the control. See [[json-stringify-is-not-html-escaping]].
87
+
88
+ /**
89
+ * Serialise a JSON-LD object for embedding in a <script> tag.
90
+ *
91
+ * Each replacement is an equivalent encoding of the same character inside a JSON
92
+ * string, so \`JSON.parse\` round-trips identically and crawlers, unfurlers and
93
+ * schema validators read exactly what they read before. There is no SEO cost,
94
+ * which is why there is no reason to defer it.
95
+ *
96
+ * U+2028/U+2029 are legal in JSON but are line terminators to a JavaScript
97
+ * parser. Written as escapes, never as literal characters: a raw U+2028 ends the
98
+ * line as far as esbuild is concerned, and the error it reports points at a line
99
+ * that looks completely fine because the character is invisible.
100
+ */
101
+ export function serializeJsonLd(data: unknown): string {
102
+ return JSON.stringify(data)
103
+ .replace(/</g, "\\\\u003c")
104
+ .replace(/\\u2028/g, "\\\\u2028")
105
+ .replace(/\\u2029/g, "\\\\u2029");
106
+ }
68
107
 
69
108
  export interface ArticleJsonLdInput {
70
109
  headline: string;
@@ -713,7 +752,7 @@ Add the following to your \`package.json\` scripts:
713
752
  ${inputs.projectType === "nextjs"
714
753
  ? `\`\`\`tsx
715
754
  // app/posts/[slug]/page.tsx
716
- import { articleJsonLd } from "@/seo/json-ld";
755
+ import { articleJsonLd, serializeJsonLd } from "@/seo/json-ld";
717
756
 
718
757
  export default async function PostPage({ params }: { params: { slug: string } }) {
719
758
  const post = await loadPost(params.slug);
@@ -727,9 +766,12 @@ export default async function PostPage({ params }: { params: { slug: string } })
727
766
  return (
728
767
  <article>
729
768
  {/* ... post body ... */}
769
+ {/* serializeJsonLd, never bare JSON.stringify: \`post.title\` is database
770
+ content, and JSON.stringify does not escape the \`</script\` sequence
771
+ that ends the element. See the note in src/seo/json-ld.ts. */}
730
772
  <script
731
773
  type="application/ld+json"
732
- dangerouslySetInnerHTML={{ __html: JSON.stringify(ld) }}
774
+ dangerouslySetInnerHTML={{ __html: serializeJsonLd(ld) }}
733
775
  />
734
776
  </article>
735
777
  );
@@ -111,9 +111,10 @@ def test_health_returns_ok(client: TestClient) -> None:
111
111
  const ENV_EXAMPLE_TEMPLATE = `# {{slug}} — example environment variables.
112
112
  # Copy to \`.env\` and fill in real values. Do NOT commit \`.env\`.
113
113
 
114
- # Database URL (only if db_strategy is non-none). For Neon Postgres, use the
115
- # pooled connection string per [[neon-postgres]].
116
114
  # DATABASE_URL=postgresql://user:pass@host/db
115
+
116
+ # DATABASE_URL — only if db_strategy is non-none. For Neon Postgres, use the
117
+ # pooled connection string per [[neon-postgres]].
117
118
  `;
118
119
  export function scaffoldPythonService(inputs, opts) {
119
120
  const spec = resolveBrandSpec(inputs);
@@ -1,13 +1,40 @@
1
1
  import type { ProjectType, ScaffoldInputs } from "./index.js";
2
2
  import { type SubstitutionOptions } from "./substitute.js";
3
3
  export type StandardKey = "skill-vault" | "portable-stack" | "fathom" | "uptime-kuma" | "sentry" | "service-hosting" | "neon-careful" | "temp-files" | "agent-coordination" | "seo-baseline" | "email-service" | "moderation" | "card-path-bot-protection" | "text-size" | "test-count";
4
- export type StandardDecisionState = "inserted-inline" | "skipped-not-applicable";
4
+ export type StandardDecisionState = "inserted-inline" | "skipped-not-applicable"
5
+ /**
6
+ * Applicable, rendered — and then removed again, because the audience gate
7
+ * dropped the whole `## ` section it lives in for `audience: "external"`.
8
+ *
9
+ * 🔴 **A third state, rather than leaving it `inserted-inline`, because the
10
+ * two-state version made a consumer's UI tell a customer something false.**
11
+ * `resolveStandards()` is a pure function that runs BEFORE the gate, so its
12
+ * verdict is "this standard applies and was rendered into the body" — true
13
+ * when written and still true. The gate then removes the section holding it.
14
+ * Neither half is individually wrong, which is exactly why no unit test
15
+ * caught it: `project-creator`'s preview screen reported an outside customer
16
+ * *"Skill Vault awareness"* — a standard whose entire content is "there is a
17
+ * private Z2W skill library at this path" — for a `CLAUDE.md` that no longer
18
+ * mentions it (filed 2026-08-19).
19
+ *
20
+ * Set by the writer from the gate's ACTUAL `dropped` list, never recomputed
21
+ * from the audience — a second derivation of the same fact is a second thing
22
+ * to drift.
23
+ */
24
+ | "removed-by-audience-gate";
5
25
  export interface StandardDecision {
6
26
  key: StandardKey;
7
27
  title: string;
8
28
  state: StandardDecisionState;
9
29
  /** Why the conditional matched (or didn't). */
10
30
  reason: string;
31
+ /**
32
+ * For `removed-by-audience-gate` only: the `## ` heading the gate dropped
33
+ * that took this standard's text with it. Named rather than implied, so a
34
+ * consumer can say *which* section went and does not have to know the
35
+ * standards→section mapping to render an honest log.
36
+ */
37
+ removedFromSection?: string;
11
38
  }
12
39
  export interface ResolveStandardsOptions extends SubstitutionOptions {
13
40
  /**
package/dist/summary.js CHANGED
@@ -61,8 +61,21 @@ function installCommandFor(projectType) {
61
61
  return null;
62
62
  }
63
63
  }
64
+ /**
65
+ * True iff the standard APPLIED to this project — which is the question the
66
+ * next-actions checklist is asking, and it is NOT the same question as "is its
67
+ * prose in the emitted CLAUDE.md".
68
+ *
69
+ * 🔴 `removed-by-audience-gate` counts as applied, deliberately. The gate drops
70
+ * DOCTRINE from `CLAUDE.md`; it does not touch the emitted CODE. An external
71
+ * Fathom-enabled scaffold still ships the Fathom wiring, so the customer still
72
+ * has to create a Fathom site and set `NEXT_PUBLIC_FATHOM_SITE_ID` — dropping
73
+ * that next-action because the explanatory section went would hand them an app
74
+ * with a dangling env var and no instruction anywhere to fill it.
75
+ */
64
76
  function isDecisionInserted(decisions, key) {
65
- return decisions.some((d) => d.key === key && d.state === "inserted-inline");
77
+ return decisions.some((d) => d.key === key &&
78
+ (d.state === "inserted-inline" || d.state === "removed-by-audience-gate"));
66
79
  }
67
80
  function buildNextActions(inputs, result, repoAutoCreated) {
68
81
  const actions = [];
@@ -152,6 +165,30 @@ function renderInsertedSection(chalk, result) {
152
165
  }
153
166
  return lines.join("\n");
154
167
  }
168
+ /**
169
+ * Standards that applied and were then removed with their host section by the
170
+ * external audience gate.
171
+ *
172
+ * Rendered as its own group rather than folded into either neighbour: they are
173
+ * not "inserted" (the text is not in the file) and they are not "skipped" (they
174
+ * DID apply, and their next-actions still stand). Collapsing them into either
175
+ * one is the false claim this section exists to stop — silence would be the
176
+ * same bug in the other direction, so the group prints whenever it is non-empty.
177
+ */
178
+ function renderGatedSection(chalk, result) {
179
+ const gated = result.decisions.filter((d) => d.state === "removed-by-audience-gate");
180
+ if (gated.length === 0)
181
+ return null;
182
+ const heading = chalk.hex(Z2W_GREEN).bold;
183
+ const lines = [heading("Standards applied but NOT written to CLAUDE.md:")];
184
+ lines.push(` audience="external" drops the section(s) these live in, so the emitted CLAUDE.md does not describe them.`);
185
+ lines.push(` The emitted CODE is unaffected — the next actions below still apply.`);
186
+ for (const d of gated) {
187
+ const from = d.removedFromSection ? ` (was in \`## ${d.removedFromSection}\`)` : "";
188
+ lines.push(` - ${d.title}${from}`);
189
+ }
190
+ return lines.join("\n");
191
+ }
155
192
  function renderSkippedSection(chalk, result) {
156
193
  const heading = chalk.hex(Z2W_GREEN).bold;
157
194
  const skipped = result.decisions.filter((d) => d.state === "skipped-not-applicable");
@@ -229,8 +266,14 @@ export function renderSummary(inputs, result, opts = {}) {
229
266
  const sections = [
230
267
  renderBanner(chalk, inputs, result),
231
268
  renderInsertedSection(chalk, result),
232
- renderSkippedSection(chalk, result),
233
269
  ];
270
+ // Between "inserted" and "skipped", because that is where a reader scanning
271
+ // for "what happened to standard X" looks — and the whole point of the group
272
+ // is that it is neither of its neighbours.
273
+ const gated = renderGatedSection(chalk, result);
274
+ if (gated !== null)
275
+ sections.push(gated);
276
+ sections.push(renderSkippedSection(chalk, result));
234
277
  const promotions = renderPromotionsSection(chalk, result);
235
278
  if (promotions !== null)
236
279
  sections.push(promotions);
package/dist/writer.d.ts CHANGED
@@ -83,6 +83,20 @@ export interface AudienceGateReport {
83
83
  readonly heading: string;
84
84
  readonly line: number;
85
85
  }[];
86
+ /**
87
+ * Surviving lines that INSTRUCT the reader into a private Z2W resource — a
88
+ * worse class than a dangling reference, because the reader is being told to
89
+ * go do something in a library they cannot open. See
90
+ * `AudienceGateResult.privateReferences` in src/audience.ts for the full note.
91
+ *
92
+ * Reported, never auto-edited: the sentence lives inside the canonical AGENTS
93
+ * body, and the durable fix is upstream in `cursor-project-templates`.
94
+ */
95
+ readonly privateReferences: readonly {
96
+ readonly resource: string;
97
+ readonly line: number;
98
+ readonly text: string;
99
+ }[];
86
100
  }
87
101
  export declare class WriterError extends Error {
88
102
  constructor(message: string);
package/dist/writer.js CHANGED
@@ -23,7 +23,7 @@
23
23
  import { promises as fs } from "node:fs";
24
24
  import * as path from "node:path";
25
25
  import fsExtra from "fs-extra";
26
- import { EXTERNAL_DROPPED_SECTIONS, gateSectionsForAudience, resolveAudience, stripVaultPointers, } from "./audience.js";
26
+ import { applyGateToDecisions, classifyUnfoundSections, EXTERNAL_DROPPED_SECTIONS, GATE_MIN_TEMPLATES_VERSION, gateSectionsForAudience, resolveAudience, stripVaultPointers, } from "./audience.js";
27
27
  import { AGENT_COORDINATION_BLOCK_MARKER, AGENTS_BODY_MARKER, STANDARDS_BLOCK_MARKER, } from "./scaffolders/common.js";
28
28
  import { buildProSeoExtension, proSeoApplies, } from "./scaffolders/pro-seo-extension.js";
29
29
  import { scaffoldByType } from "./scaffolders/index.js";
@@ -250,12 +250,37 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
250
250
  // no-silent-zero shape this repo has now hit three times. If a heading is
251
251
  // renamed upstream the section is still being emitted, and the customer
252
252
  // scaffold ships the doctrine while every signal reports success.
253
+ //
254
+ // 🔴 But "absent" has TWO causes, and until 2026-08-20 this message named
255
+ // only one of them. A version-PINNED Templates consumer (`project-creator`)
256
+ // hits the other one every time: the heading did not exist yet. Classify
257
+ // against the resolved Templates version so the error names the real cause
258
+ // — a message that confidently states the wrong cause is worse than a vague
259
+ // one, because it is actionable in the wrong direction.
260
+ const unfound = classifyUnfoundSections(gate.notFound, frameworkVersion);
261
+ const skew = unfound.filter((u) => u.cause === "version-skew");
262
+ const unexplained = unfound.filter((u) => u.cause === "unexplained");
263
+ const detail = [];
264
+ if (skew.length > 0) {
265
+ detail.push(`VERSION SKEW — the Templates body in use is AGENTS v${frameworkVersion}, ` +
266
+ `which predates ${skew.length === 1 ? "this section" : "these sections"}: ` +
267
+ `${skew.map((u) => `"${u.heading}" (since v${u.sinceTemplatesVersion})`).join(", ")}. ` +
268
+ `Nothing is leaking — the section is not in the document to leak — but this ` +
269
+ `gate has never been verified against a body that old, so it refuses rather ` +
270
+ `than guesses. Fix: point the scaffold at Templates v${GATE_MIN_TEMPLATES_VERSION} ` +
271
+ `or newer (upgrade --templates-path, or republish the pinned @zero2webmaster/templates package).`);
272
+ }
273
+ if (unexplained.length > 0) {
274
+ detail.push(`UNEXPLAINED — ${unexplained.map((u) => `"${u.heading}"`).join(", ")} ` +
275
+ `should be present at AGENTS v${frameworkVersion} and is not, so the heading ` +
276
+ `was renamed upstream or the body changed shape. The section is probably still ` +
277
+ `being emitted under a different name. Fix: update EXTERNAL_DROPPED_SECTIONS ` +
278
+ `in src/audience.ts to match.`);
279
+ }
253
280
  throw new WriterError(`Audience gate could not find ${gate.notFound.length} of ` +
254
281
  `${EXTERNAL_DROPPED_SECTIONS.length} section(s) it must drop for ` +
255
- `audience="external": ${gate.notFound.join(", ")}. ` +
256
- `Refusing to emit a customer scaffold that may still contain them. ` +
257
- `A heading was probably renamed upstream in Templates — update ` +
258
- `EXTERNAL_DROPPED_SECTIONS in src/audience.ts to match.`);
282
+ `audience="external". Refusing to emit a customer scaffold that may ` +
283
+ `still contain them. ${detail.join(" ")}`);
259
284
  }
260
285
  if (audience === "external" && gate.danglingReferences.length > 0) {
261
286
  // Report, never auto-edit — rewriting a sentence inside the canonical
@@ -273,6 +298,21 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
273
298
  ` Lines: ${gate.danglingReferences.map((d) => d.line).join(", ")} of ` +
274
299
  `the emitted CLAUDE.md.\n`);
275
300
  }
301
+ if (audience === "external" && gate.privateReferences.length > 0) {
302
+ // Louder than the dangling-reference warning above, and separate from it,
303
+ // because it is a different failure: the customer is being INSTRUCTED into
304
+ // a library they cannot open, not merely pointed at a missing section.
305
+ output.write(`\n🔴 audience="external": ${gate.privateReferences.length} surviving line(s) ` +
306
+ `instruct the reader to use a PRIVATE Z2W resource ` +
307
+ `(${[...new Set(gate.privateReferences.map((p) => p.resource))].join(", ")}).\n` +
308
+ ` This is a leak, not a dangling reference — but the text is inside the ` +
309
+ `canonical framework body,\n` +
310
+ ` which this CLI does not edit. The durable fix is upstream in ` +
311
+ `cursor-project-templates.\n` +
312
+ gate.privateReferences
313
+ .map((p) => ` line ${p.line}: ${p.text.slice(0, 120)}\n`)
314
+ .join(""));
315
+ }
276
316
  // Capture the gate's findings for the RETURN VALUE as well as the terminal —
277
317
  // see the `audienceGate` docblock. Built here rather than at the return site
278
318
  // so it cannot drift from the `gate` that was actually applied.
@@ -281,8 +321,14 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
281
321
  dropped: gate.dropped,
282
322
  bytesDropped: gate.bytesDropped,
283
323
  danglingReferences: gate.danglingReferences,
324
+ privateReferences: gate.privateReferences,
284
325
  }
285
326
  : undefined;
327
+ // Restate the decision log against what the gate REMOVED. Built here, from
328
+ // the same `gate` object that produced the emitted bytes, so the log and the
329
+ // file cannot disagree; used at BOTH return sites below (the dry-run branch
330
+ // is the one `previewScaffold()` takes, which is the consumer that hit this).
331
+ const gatedDecisions = applyGateToDecisions(resolution.decisions, gate.dropped);
286
332
  claudeContent = stripVaultPointers(gate.content, audience);
287
333
  checkNoUnfilledMarkers(claudeContent, "CLAUDE.md");
288
334
  files[claudeIdx] = { path: claudeFile.path, content: claudeContent };
@@ -348,7 +394,7 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
348
394
  output.write(`\n# End dry run — ${files.length} files, CLAUDE.md is ${claudeContent.length} bytes.\n`);
349
395
  return {
350
396
  filesWritten: files,
351
- decisions: resolution.decisions,
397
+ decisions: gatedDecisions,
352
398
  promotions,
353
399
  targetPath: resolvedTarget,
354
400
  dryRun: true,
@@ -370,7 +416,7 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
370
416
  }
371
417
  return {
372
418
  filesWritten: files,
373
- decisions: resolution.decisions,
419
+ decisions: gatedDecisions,
374
420
  promotions,
375
421
  targetPath: resolvedTarget,
376
422
  dryRun: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zero2webmaster/starter-kit",
3
- "version": "0.19.1",
3
+ "version": "0.23.0",
4
4
  "description": "Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.",
5
5
  "author": {
6
6
  "name": "Dr. Kerry Kriger",
@@ -251,12 +251,42 @@ function cleanSlug(raw) {
251
251
  * But every project that adopted the section first wrote something else, and a parser
252
252
  * that only accepts the canonical form reports ZERO matches — which looks exactly like
253
253
  * "already in sync" (see `zeroEdges` handling in main(); 2026-07-25). So we also accept
254
- * the two variants seen in the wild, while keeping the canonical form primary:
254
+ * the variants seen in the wild, while keeping the canonical form primary:
255
255
  * - `file-server` — campaign cover images (bullet under a **Consumes** heading)
256
256
  * - **consumes:** `a` (why), `b` (why), `c` (inline comma list)
257
+ * | `file-server` (85, Live) | uploads | note | (MARKDOWN TABLE row — 2026-08-17)
258
+ *
259
+ * TABLES (2026-08-17, filed by `z2w-agent-coordination`). Four of the six zero-edge
260
+ * sections on the live bulletin — `forms-engine`, `los-osititos`, `marketing-engine`,
261
+ * `support-desk` — put their edges in a markdown table, and every bullet branch below
262
+ * keys on `^\s*[-*]`, so a `|`-row was invisible and the ENTIRE table was skipped. That
263
+ * is ~20 real edges on `file-server`, `contact-registry`, `z2w-ai-engine` and `org-hq`
264
+ * that the registry never recorded, reported as "0 edges" rather than "unreadable".
265
+ *
266
+ * The table branch is deliberately no less conservative than the prose-bullet one: a
267
+ * first-column target is accepted only when it is a real registry slug or carries an
268
+ * explicit `:qualifier`. Two extra guards a bullet does not need:
269
+ * · DIRECTION. `**Consumed by:**` and a `| Direction |` column both mean PROVIDES, and
270
+ * provides is DERIVED from reverse `consumes`, never stored. `forms-engine` has a
271
+ * `**Consumes:**` table immediately followed by a `**Consumed by:**` table, so a
272
+ * parser that ignored direction would have written `site-control` and
273
+ * `contest-management` in backwards — worse than the miss it was fixing.
274
+ * · STRIKETHROUGH. `~~Airtable~~ | ~~consumes~~` in `los-osititos` is a RETIRED edge
275
+ * the agent struck out rather than deleted. A struck row is skipped whole.
257
276
  */
258
277
  export function parseSection(section, knownSlugs = new Set()) {
259
- const result = { liveStatus: null, statusDeclared: false, statusQualifier: null, asOf: null, consumes: [] };
278
+ const result = {
279
+ liveStatus: null, statusDeclared: false, statusQualifier: null, asOf: null,
280
+ consumes: [],
281
+ // TRUE only when a LABELLED consumes line resolved to the §8.10 empty marker
282
+ // (`- consumes: (none — no Z2W edges)`). This is the "genuinely empty" signal that
283
+ // lets the caller stop reporting a deliberate zero as a parse failure — `main()`
284
+ // used to test the WHOLE SECTION for `/\(none/i`, which is true of any parenthetical
285
+ // beginning "none" anywhere in it, including one under **Provides**. That is the
286
+ // silent-zero rule failing one level up: it could neither see a deliberate empty
287
+ // CONSUMES declaration nor avoid being fooled by an unrelated one. [[zero-is-not-a-pass]]
288
+ declaredNoConsumes: false,
289
+ };
260
290
 
261
291
  // The label is matched on its own, SEPARATELY from the value, so the caller can tell
262
292
  // "declared but unreadable" (a defect) from "never declared" (a young project, and
@@ -304,9 +334,25 @@ export function parseSection(section, knownSlugs = new Set()) {
304
334
  // Track which half of the section we're in, so a bare-slug bullet under **Provides**
305
335
  // is never mistaken for a consumes edge (provides is DERIVED, never stored).
306
336
  let inConsumes = false;
337
+ // Column index of a `| Direction |` header, when the current table has one. It OVERRIDES
338
+ // the heading state per row, because `los-osititos` puts both directions in ONE table.
339
+ let directionCol = -1;
340
+ // Direction inferred from a table's own header when no heading preceded it — see
341
+ // TABLE_CONSUMES_HEADERS. `marketing-engine` has no `**Consumes**` heading at all.
342
+ let tableConsumes = null;
343
+
307
344
  for (const line of section.split("\n")) {
308
- if (/^\s*\*{0,2}Consumes\b/i.test(line.replace(/^[-*]\s*/, ""))) inConsumes = true;
309
- else if (/^\s*\*{0,2}Provides\b/i.test(line.replace(/^[-*]\s*/, ""))) inConsumes = false;
345
+ const heading = line.replace(/^[-*]\s*/, "");
346
+ // PROVIDES-side patterns are tested FIRST: `Consumed by` must not fall through to the
347
+ // consumes test, and `Consumes?\b` does not match it (no word boundary before `d`)
348
+ // only by luck — relying on that would be a trap for whoever loosens this next.
349
+ if (/^\s*\*{0,2}(?:We\s+)?(?:Consumed\s+by|Provides?|Provided\s+to|Used\s+by)\b/i.test(heading)) {
350
+ inConsumes = false; directionCol = -1; tableConsumes = null;
351
+ } else if (/^\s*\*{0,2}(?:We\s+)?Consumes?\b/i.test(heading)) {
352
+ // `We CONSUME:` is `file-server`'s form — the leading pronoun is why their section
353
+ // read zero, and `Consumes?` (optional s) is why the imperative "CONSUME" now lands.
354
+ inConsumes = true; directionCol = -1; tableConsumes = null;
355
+ }
310
356
 
311
357
  // (a) canonical: `- consumes: slug — why` / (b) inline list: `- **consumes:** a, b, c`
312
358
  const labelled = line.match(/^\s*[-*]\s*\*{0,2}consumes:?\*{0,2}:?\s*(.+)$/i);
@@ -314,6 +360,8 @@ export function parseSection(section, knownSlugs = new Set()) {
314
360
  // Strip parentheticals BEFORE splitting: the per-edge "(why…)" notes contain
315
361
  // commas of their own, and splitting first shreds every slug after the first.
316
362
  // Also cut at "Later phases:" — those are aspirational, not current edges.
363
+ // The `(none…)` marker is read BEFORE that strip, since stripping erases it.
364
+ if (/^[`*_"'\s]*\((?:none|n\/a)\b/i.test(labelled[1])) result.declaredNoConsumes = true;
317
365
  const body = labelled[1]
318
366
  .replace(/\([^)]*\)/g, "")
319
367
  .split(/\bLater phases?\b\s*:?/i)[0];
@@ -325,6 +373,40 @@ export function parseSection(section, knownSlugs = new Set()) {
325
373
  continue;
326
374
  }
327
375
 
376
+ // (d) MARKDOWN TABLE row. Same conservatism as the prose bullet in (c): the target is
377
+ // taken from the FIRST cell and accepted only if it is a known registry slug or
378
+ // carries a `:qualifier`, so a header cell ("Engine", "Depends on") and a non-Z2W
379
+ // vendor ("**Neon Postgres**", "**Murf AI**") both fall out on their own.
380
+ if (/^\s*\|/.test(line)) {
381
+ const cells = line.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((c) => c.trim());
382
+ // The `|---|:--:|` delimiter row carries no data and must not reset anything.
383
+ if (cells.every((c) => /^:?-{2,}:?$/.test(c) || c === "")) continue;
384
+ // A struck-through row is an edge the agent RETIRED in place rather than deleting.
385
+ if (cells.some((c) => /^~~.*~~$/.test(c))) continue;
386
+
387
+ const headerDir = cells.findIndex((c) => /^\**\s*directions?\s*\**$/i.test(c));
388
+ if (headerDir !== -1) { directionCol = headerDir; tableConsumes = null; continue; }
389
+ // A header row naming its own direction, for tables that follow no heading.
390
+ // Deliberately a CLOSED list, and deliberately not "Engine": `forms-engine` heads
391
+ // BOTH its `Consumes` and its `Consumed by` table with `| Engine |`, so that word
392
+ // carries no direction and guessing from it would invert half the edges.
393
+ if (/^\**\s*(?:depends\s+(?:on|upon)|consumes|dependenc(?:y|ies))\s*\**$/i.test(cells[0])) {
394
+ tableConsumes = true; continue;
395
+ }
396
+
397
+ const consumesHere = directionCol !== -1
398
+ ? /^\**\s*consumes?\s*\**$/i.test(cells[directionCol] ?? "") // "consumed by" is NOT this
399
+ : (tableConsumes ?? inConsumes);
400
+ if (!consumesHere) continue;
401
+
402
+ const head = cells[0].split(/\s+[—–-]\s+/)[0].replace(/\([^)]*\)/g, "");
403
+ const slug = cleanSlug(head);
404
+ if (slug && (knownSlugs.has(slug.split(":")[0]) || slug.includes(":"))) {
405
+ result.consumes.push(slug);
406
+ }
407
+ continue;
408
+ }
409
+
328
410
  // (c) prose bullet under the **Consumes** heading: "- `file-server` — why".
329
411
  // CONSERVATIVE: an unlabelled bullet is inference, not a declaration, so accept it
330
412
  // only when the target is a real registry slug or carries a `:qualifier` (a
@@ -539,6 +621,7 @@ async function main() {
539
621
  let parsed = 0, skippedNoSection = 0, skippedUnknown = 0, changed = 0;
540
622
  const plan = [];
541
623
  const zeroEdges = [];
624
+ const declaredEmpty = []; // zero edges, DECLARED so via the §8.10 marker — legitimate
542
625
  const unreadableStatus = []; // line present, value unreadable — a DEFECT
543
626
  const noStatusLine = []; // no line at all — legitimate; skip and report
544
627
 
@@ -550,7 +633,7 @@ async function main() {
550
633
  parsed++;
551
634
  if (!known.has(slug)) { skippedUnknown++; console.warn(` ⚠ ${slug}: has ## Integrations but no registry row — skipped (never auto-inserted).`); continue; }
552
635
 
553
- const { liveStatus, statusDeclared, statusQualifier, asOf, consumes } = parseSection(section, known);
636
+ const { liveStatus, statusDeclared, statusQualifier, asOf, consumes, declaredNoConsumes } = parseSection(section, known);
554
637
 
555
638
  // NO SILENT ZERO, STATUS HALF (2026-08-02). The `zeroEdges` counter below has caught
556
639
  // an inert EDGE pipeline since 2026-07-25; the STATUS field had no equivalent, so a
@@ -574,9 +657,22 @@ async function main() {
574
657
  // declaration — either way it must NOT be reported the same as "already in sync."
575
658
  // (2026-07-25: all 4 adopting projects wrote a non-canonical edge form, so the
576
659
  // rollup printed "0 rows would change" for five days while the pipeline was inert.)
577
- if (consumes.length === 0 && !/\(none/i.test(section)) {
660
+ //
661
+ // "GENUINELY EMPTY" IS A DECLARATION, NOT A SUBSTRING (2026-08-17). The old test was
662
+ // `!/\(none/i.test(section)` — the whole section, so ANY parenthetical starting "none"
663
+ // suppressed the warning, including `- provides: (none yet)`, which says nothing about
664
+ // consumes. It could not do the job it was there for either: `kuma-watchdog` consumes
665
+ // only Uptime Kuma, Neon and Slack — no Z2W coupling BY DESIGN — and was reported as a
666
+ // parse failure every run, i.e. a false red under `--strict`. `declaredNoConsumes` is
667
+ // set only by a labelled CONSUMES line carrying the §8.10 empty marker, so the two
668
+ // cases the header's own NO SILENT ZERO rule conflates — "unreadable" and "deliberately
669
+ // empty" — are finally distinguishable. Absence is still never a value: a section that
670
+ // declares nothing at all remains a defect and still warns. [[zero-is-not-a-pass]]
671
+ if (consumes.length === 0 && !declaredNoConsumes) {
578
672
  zeroEdges.push(slug);
579
- console.warn(` ⚠ ${slug}: ## Integrations present but ZERO edges parsed — check the line form (expected \`- consumes: {slug} — {why}\`).`);
673
+ console.warn(` ⚠ ${slug}: ## Integrations present but ZERO edges parsed — check the line form (expected \`- consumes: {slug} — {why}\`, or \`- consumes: (none — no Z2W edges)\` if that is deliberate).`);
674
+ } else if (consumes.length === 0) {
675
+ declaredEmpty.push(slug);
580
676
  }
581
677
 
582
678
  const [current] = await sql`SELECT production_status, status_qualifier, consumes FROM projects WHERE slug = ${slug}`;
@@ -662,6 +758,10 @@ async function main() {
662
758
  console.log(` ⚠ sections with ZERO edges parsed: ${zeroEdges.length} (${zeroEdges.join(", ")})`);
663
759
  console.log(` A zero here is NOT "in sync" — it means the section's line form didn't match. Fix the bulletin or the parser.`);
664
760
  }
761
+ // Printed unconditionally, at zero as well, for the same reason as the two below: this
762
+ // is the count of sections that were READ and found deliberately empty, and folding it
763
+ // into either "changed" or "zero edges" would re-create the ambiguity it resolves.
764
+ console.log(` ⓘ zero edges, DECLARED so (read, legitimate): ${declaredEmpty.length}${declaredEmpty.length ? ` (${declaredEmpty.join(", ")})` : ""}`);
665
765
  // Report BOTH, always, even at zero — the count is the coverage number, and a silent
666
766
  // absence is the thing this whole block exists to make impossible.
667
767
  console.log(` ⚠ Live status declared but UNREADABLE: ${unreadableStatus.length}${unreadableStatus.length ? ` (${unreadableStatus.join(", ")})` : ""}`);