Chapter 12 — Authoring a playbook: heal → draft → lint → save¶
Mental model¶
The loop has a human-shaped hole in the middle.
occam_playbook_heal returns DOM skeleton + selector candidates—not finished playbook JSON. You draft the recipe. occam_playbook_lint is advisory. occam_playbook_save(verify:true) is the gate that persists a signed portable JSON file.
Only run this loop on genuine extraction failures (thin_extract, etc.)—not on short_quality successes (Chapter 2).
Explanation¶
Heal → draft → lint → save¶
occam_playbook_heal(url)— Browser-backed skeleton capture, candidate selectors, optional mechanicaldraftPlaybookJsonstub. Does not LLM-author a recipe; review the stub (or write your own) before save.--consent-aggressiveworker flag unreachable from MCP.- Draft — Prefer editing
draftPlaybookJsonwhen present; otherwise write playbook JSON from candidates (selectors, interaction steps, schema hooks). occam_playbook_lint(playbook_json)— Structural/advisory checks via the same schema gate as save (hard errors = save would reject before verify). Warnings/infos are quality nudges only.occam_playbook_save(..., verify:true)— Re-checks the schema gate, then runs the live dry-run gate (verify.score,passesGate, noise leakage). Signs on success.
Re-test with Chapter 11 comparison (auto vs prior off).
Playbook signatures v1 vs v2 (OD-4)¶
| Version | Signed bytes | Honest reading |
|---|---|---|
| v1 (legacy) | Recipe body hash only; whole top-level provenance excluded |
verify.score, passesGate, keyId, signedAt unsigned—editable without invalidating v1 verify |
| v2 (new saves) | Domain-separated preimage covers keyId, alg, contentHash, signedAt, and verify{score,passesGate,noiseLeakage} |
Gate snapshot is tamper-evident relative to key—not a proof of objective quality |
Never call verify.score a quality proof—even when signed in v2, it is a local heuristic gate snapshot.
Signing policy¶
occam_playbook_savealways signs, ignoringOCCAM_RECEIPTS.- Signature proves integrity relative to local key, not author identity or marketplace trust.
PlaybookCommunitySanitizeris not on the local save path—nothing publish-sanitizes automatically.
Task R step 9¶
Pricing page still thin_extract after browser → heal → draft → lint → save → re-transcode with playbook_policy=auto.
CHECK¶
LOCAL
- Save a playbook with
verify:true. - On disk, edit
provenance.verify.score(v1) or signed verify block fields (v2—should break verify). - Re-inspect with resolve/save verify path:
- v1: score edit still "verifies" — proves score was never in v1 signed bytes.
- v2: tamper should surface
invalid/ failed inspect.
Also: editing unsigned provenance.keyId on v1 self-signed playbooks could downgrade tamper to innocuous unknown_key before verify runs—treat inspect verdicts carefully.
Common misconception¶
"Heal produces a finished playbook and save stores it."
Heal emits skeleton + candidates and may attach a mechanical draftPlaybookJson stub. The stub is not verified — lint and occam_playbook_save(verify:true) remain the gate.¶
Limitations¶
- Playbooks can execute page JS—untrusted URLs + untrusted recipes = code execution risk (trust-and-safety).
- Schema gate is shared with save (missing selectors / secrets / non-1.x fail both). Live verify score is still save-only — lint never fetches.
- Marketplace CI auto-merge is not trusted validation (OD-1).
- Healing a
short_qualitypage wastes resources and may harm good extracts.
Links¶
Public docs: Structured extraction · Tools: occam_playbook_heal · Tools: occam_playbook_save · Tools: occam_playbook_lint
Next chapter: Chapter 13 — Typed field extraction