feat(seo-data): schema_gen verb — generate JSON-LD, not just audit it

Cherry-picked from claude-seo (github.com/AgriciDaniel/claude-seo, MIT)
schema_generate.py, rewritten to the lib/seo-data contract per BDR-070 — adapt,
never copy. The system audited JSON-LD but could not generate it; geo-analyzer's
G2 batch hand-wrote markup. Now it calls the verb.

fetch.sh schema_gen {reservation|order|discussion|profile} → fail-open envelope
{"status":"ok","source":"schema_gen","type":…,"jsonld":{…}}. Types: Reservation
(7 subtypes), OrderAction, DiscussionForumPosting, ProfilePage (sameAs/knowsAbout
for the entity graph). Stdlib only (import argparse, json — zero third-party),
_strip_nones so a null is never emitted, --script-tag wraps for direct paste.

Fail-open mirrors score.py's _cli exactly (the contract's named pattern): a
flag-omitted required field → argparse exit 2 + {"status":"error","bad_usage"};
a flag-present-but-empty field → {"status":"degraded","reason":"missing required
field: …"} exit 0. Never a traceback, never empty stdout (LRN-133: the
can't-generate case stays legible).

geo-analyzer G2 wiring preserves the data-integrity rule — the verb generates
STRUCTURE, unknown values stay [À COMPLÉTER], never invented.

Verified: GATE 1 verifier CONFORME 10/10 (exercised the fail-open edge cases +
diffed field surface against the source); GATE 2 self-scan clean (no
network/shell/secret/eval sink); seo-data 167 → 190 pass, 0 fail; full suite
green; shellcheck + py_compile clean.
This commit is contained in:
Bastien Chanot
2026-07-17 14:30:31 +02:00
parent 92301fe1c8
commit cfdd89e73b
5 changed files with 404 additions and 2 deletions
+8 -1
View File
@@ -813,7 +813,14 @@ to act without your audit context. Embed per item:
- **Templates + context** — G2/G6 paste the expected JSON-LD from
`geo-schemas.md` + business context (entity name, sameAs, @id canonical)
+ framework note. G4 follows `llms-txt-template.md` exactly. G1 pastes
the correct variant from `ai-crawlers-2026.md`.
the correct variant from `ai-crawlers-2026.md`. When a G2 item needs a
`Reservation`/`OrderAction`/`DiscussionForumPosting`/`ProfilePage` block,
generate the skeleton via `fetch.sh schema_gen
<reservation|order|discussion|profile> [flags]`
(`~/.claude/lib/seo-data/fetch.sh`) and fill in the real values, rather
than hand-writing that markup. The data-integrity rule still applies on
top of it: `schema_gen` only generates STRUCTURE — unknown field values
stay `[À COMPLÉTER]`, never invented to fill a flag the verb needs.
- **PERMISSIVE default** on G1 unless the client flagged premium/regulated.
### Output shape