anthology-engine

The Anthology Engine, the per-client orchestrator that turns ONE participant's universal Convert and Flow form submission into ONE gated, quality-controlled 2,000 to 3,500 word anthology chapter (neve

SKILL.md

GitHub

Anthology Engine (Skill 59)

The per-client orchestrator for a MULTI-CONTRIBUTOR anthology: many external co-authors each contribute ONE chapter around a shared theme, and a producer (the OpenClaw box owner) curates, gates, and assembles them. This skill owns ALL external input and output and the durable state; it CALLS Skill 54 as its authoring core and never re-authors the chapter pipeline. It is INTEGRATION plus HARDENING of assets the fleet already owns, not a from-scratch build, and reuse fidelity is a scored requirement of the build gate.

An anthology is many authors writing ONE chapter each, curated by an editor. That is why Skill 53 (single author, twelve chapters) stays untouched, why Skill 54 (the per-chapter writer) is the authoring core, and why the genuinely new surface is the curation-and-assembly layer (S9) plus the multi-participant orchestration around it.

The silence doctrine and the responsibility boundary (binding)

Move in silence. Every code path honors these:

  1. ZERO client-facing messages except the three sanctioned nudge templates in config/nudge-templates/. The recipient is ALWAYS resolved from the ledger row for the given contact_id (participant gates) or the producer record (producer gates); NO literal recipient exists anywhere in the engine.
  2. OPERATOR-VERBOSE, CLIENT-SILENT. Operator and founder surfaces are rich; client surfaces are silent. Delivery reports and alerts go to the OPERATOR channel only.
  3. NEVER print, echo, grep, or paste a secret value. Credentials are documented by LABEL and LOCATION only; a check reports SET or NOT SET plus a behavior probe.
  4. NEVER commingle clients. Only the NAMED client's OWN accounts and keys are ever used. Per-client isolation is structural (physical box separation, tenant check, private integration token fingerprint, per-client secrets, contact_id keying).
  5. CONFIG WRITES RUN AS THE NODE USER, never root. A root-owned config freezes the gateway.
  6. The client-facing platform name is Convert and Flow, on every surface.
  7. The client's own model chain only: every tier resolves to a model the client configured. There is NO rule against Anthropic-family models (Trevor order 2026-10-29): preflight.sh and model_router.py never refuse one, and no static scan of the shipped files checks for one.
  8. CANARY, THEN HOLD. The engine is proven on the operator box first; fleet rollout is HELD at repo-only until the operator gives the explicit OK. No client box is touched by the build.

Per-client GHL (Convert and Flow) authentication (binding constraint)

Every Anthology engine instance authenticates to a SINGLE client's Convert and Flow account using that CLIENT's OWN private integration token (PIT) and Location ID. This is a per-client authentication architecture -- NOT a single shared credential across clients.

What makes it per-client

Aspect Architecture
Credential pair CONVERT_AND_FLOW_PIT + CONVERT_AND_FLOW_LOCATION_ID -- one pair per client box
Gate token secret ANTHOLOGY_GATE_TOKEN_SECRET -- per-client 64-char hex HMAC secret for minting/verifying scoped participant gate tokens and PINs; resolved from the client env stores and required by caf_credential_gate.py
Owner The CLIENT's own GoHighLevel sub-account, provisioned in their own Convert and Flow instance
Never An operator-level, shared, fleet, or master API key. No single key drives multiple clients
Resolution Resolved per-box at install time by caf_credential_gate.py (W2.3), live process env first, then the three client env stores
Enforcement caf_credential_gate.py AF-AE-COMMINGLE -- the resolved value is fingerprinted (unsalted sha256) and compared against operator-namespaced labels and foreign-client labels. A collision exits 4 (violation)
Model-map tiers Resolved per-box by preflight.sh against the CLIENT's OWN configured models in their openclaw.json, never a shared or operator provider key

The binding constraints

  1. PER-CLIENT PAIR, NEVER SHARED. Every client box carries its OWN CONVERT_AND_FLOW_PIT (the private integration token, pit- prefix) and its OWN CONVERT_AND_FLOW_LOCATION_ID. These are resolved per-box at install time. The engine never falls back to an operator-level or shared integration token.

  2. ANTI-COMMINGLING FINGERPRINT (AF-AE-COMMINGLE). The credential gate (caf_credential_gate.py) computes an unsalted sha256 fingerprint of the resolved PIT and Location values and checks them against:

    • Any operator/shared/fleet-namespaced label on the same box (config-free collision).
    • Any foreign-client/tenant-namespaced label (another client's key).
    • An expected-own fingerprint from a prior clean provisioning.
    • A denylist of known operator/other-client fingerprints. A collision exits 4 and STOPS provisioning. A clean verdict means the credential belongs to THIS client, not the operator and not another client.
  3. PIT SCOPE (AF-AE-PIT-SCOPE). The client's own PIT must be able to READ pipelines in that client's own Convert and Flow Location. A token that cannot even READ pipelines STOPS setup with an operator surface. Pipeline FIND-AND-BIND always uses the CLIENT's own PIT, never an operator token with cross-tenant scope.

  4. MODEL SOVEREIGNTY IS SEPARATE BUT PARALLEL. The client's OWN model provider keys (OLLAMA_CLOUD_API_KEY, OPENROUTER_API_KEY, GEMINI_API_KEY, etc.) are resolved per-box by preflight.sh against the CLIENT's own openclaw.json. These are also authenticated per-client and never shared. Model id resolution is fail-closed (AF-AE-UNRESOLVED-MODELMAP).

  5. CREDENTIALS NEVER COMMITTED. No key value, no PIT, no Location ID, no model provider key ever lives in a committed file. Credentials are referenced by LABEL only. The repo ships model-map.template.json with <CLIENT_*> placeholders; the per-box resolved copy is written at install time and never committed.

  6. NO FALLBACK TO OPERATOR CREDS. If a client's PIT cannot be resolved (all three env stores consulted, live-process-first), the engine FAILS PROVISIONING (exit 2) rather than falling back to any operator/shared/default credential. There is no "default GHL API key" anywhere in the engine.

Why this matters for builders

A builder extending the Anthology engine must never:

  • Write code that assumes a single shared GHL API key lives on the operator box.
  • Hardcode a PIT, Location ID, or provider key literal anywhere in the runtime.
  • Use an operator-level or fleet-level credential to authenticate Convert and Flow operations for a client -- the CLIENT's own PIT is always required.
  • Create a credential resolver that falls back to a shared default when the client-specific credential is absent. Absence must fail closed.
  • Commit a resolved credential value or a resolved model-map.json to the repository.

The credential resolution pipeline is: live process env -> three client env stores (~/.openclaw/secrets/.env, ~/.openclaw/workspace/.env, ~/clawd/secrets/.env) -> fail closed (do not substitute a default). This chain is implemented in caf_credential_gate.py and preflight.sh, and every credential-dependent operation should delegate to these modules rather than implementing its own resolution.

See also INSTALL.md in this directory for the full provisioning procedure including per-client credential resolution and the anti-commingling fingerprint.

The four layers

Convert and Flow universal form (visible: name, email, phone, Q1 ideal avatar,
Q2 niche, Q3 primary goal; hidden: contact_id, anthology_id, stage)
  -> POST inbound webhook (Cloudflare Tunnel -> OpenClaw gateway route
     /hooks/anthology-intake, per-client secret ANTHOLOGY_INTAKE_HOOK_SECRET)
    -> LAYER 2 ORCHESTRATION: intake_router.py (deterministic, no model call,
       acknowledges in under 2 seconds) -> anthology_state.py (the SOLE ledger
       writer, keyed contact_id plus anthology_id) -> advance exactly ONE stage
      -> LAYER 1 AUTHORING CORE: Skill 54, invoked as a LOCAL subprocess through
         54-anthology-writer/anthology-entry.sh with a run dir per participant
         per stage; model chain per the tier map; measured provers; budget 2
        -> LAYER 3 DELIVERY ADAPTERS: drive_adapter.py (direct Drive and Docs
           API, existing service account, existing shared root); pdf_render.py
           (deterministic HTML-to-PDF, 14-point floor); caf_delivery.py (media
           upload, exact-key field writes by contact_id, read-back, control
           fields, per-gate pipeline-stage update); cover_render.py (Kie.ai
           portrait); nudge_send.py; alerts through the gateway only
          -> LAYER 4 SURFACES, ALL INSIDE THE CLIENT'S OWN COMMAND CENTER: the
             seeded Anthology department board (cards via mc_board.py -> POST
             /api/tasks/ingest, HMAC plus Bearer, fail-soft; review column is
             the approval queue; the QC scorer at or above 8.5 promotes review
             to done; an Assembly card for the S9 trigger and sign-off); the
             home-screen tiles; the NEW participant token page

Layer boundaries as code contracts: Layer 2 is the ONLY layer that touches the ledger, the model router, and the gates. Layer 1 (Skill 54) never performs network I/O beyond its own model calls and returns artifacts on disk plus its run ledger and prover verdicts; its certification model (hash gate, nonce, fail-closed provers) is preserved untouched. Layer 3 adapters are stateless functions whose every external write is followed by a read-back in the same job. Layer 4 holds NO base credential; its only write path is shelling anthology_state.py.

Deliberate omission: fleet CONTROL files

This engine does NOT ship SESSION-LOG, DIGEST, RULEBOOK, or INDEX files. That omission is by design. The SQLite ledger (anthology_state.py, sole writer) and ENGINE-MANIFEST.json serve as the dispatch and integrity source of truth in their place. The ledger holds every participant row, stage cursor, artifact record, and gate state; the manifest holds the per-stage contract, autofail table, and artifact map. Together they provide the same dispatch, audit, and reconciliation surface that CONTROL files supply in other fleet projects, tuned for a multi-tenant anthology scheduler that may pause for months between stages.

The canonical pipeline S0 to S9

Every stage is ONE idempotent job: an event arrives, the router advances exactly one stage, persists, and stops. No stage ever blocks waiting for a human; the ledger holds the cursor for weeks or months at zero cost. At EVERY gate the registry-bound Convert and Flow pipeline-stage update fires.

Stage What it does Gate
S0 intake and routing create or advance the participant (contact_id plus anthology_id); provision the Drive path; card the participant onto the board; unroutable submissions go to the exceptions queue with the raw payload none (deterministic)
S1 avatar the Skill 52 handoff (Questions 1 to 30, then 31 and 32 with the auto-detected web search, then Rewrite, then Primary Goal extraction); Avatar Doc plus PDF producer, board review column
S2 tone the shared tone core 04 to 08 byte-identical; Write Tone Style 1 to 4 and Blended Tone; 3,000 measured words; Tone Doc plus PDF producer
S3 title Suggested Titles; the participant picks title and subtitle on the token page; TITLE LOCK byte-exact, one-way participant selection
S4 blurb and outline Book Blurb then single-chapter Create Outline placing every personal story; Docs plus PDFs producer, then participant outline approval
S5 chapter ONE complete chapter, 2,000 to 3,500 measured stripped words, title locked, every story placed; full Gate B battery BEFORE the gate opens participant: Approve as-is OR Request rewrite with notes
S6 chapter rewrite optional, budget 2; notes become chapter_updates; the Thornfield persona rewrites inside the band; re-enters the S5 gate re-enters S5
S7 cover image the cover prompt generator, then Kie.ai GPT-Image 2.6 PORTRAIT 1024x1536 via Skills 07 and 46 against the verified text-to-image portrait endpoint; PNG to Drive none
S8 package and deliver Google Doc plus 14-point-floor PDF; Convert and Flow media upload; exact-key field writes by contact_id read back byte-for-byte; control fields; per-gate pipeline-stage update; signed certificate; card to review card to review (QC scorer owns review to done)
S9 anthology assembly fired ONLY by the producer ready-to-assemble trigger; order curation, editor's introduction in the producer's voice, front and back matter, contributor bios; compile from FROZEN approved chapters byte-identical; full manuscript Doc plus PDF; producer sign-off closes it s9_ready then s9_producer

The complete stage contract lives in ENGINE-MANIFEST.json (per-stage produces_artifact, gate, tier, provers, and the AF-AE-* autofail table). The per-stage thin runners are scripts/stage_s0_intake.py through scripts/stage_s9_assembly.py; each composes the pinned prompts, calls Layer 1 or the router, runs its provers, records artifacts, and opens its gate.

The Skill 54 call contract (Layer 1)

Layer 1 authoring is invoked as a LOCAL subprocess. A stage runner builds a run dir per participant per stage, stages the intake and prior artifacts into working/, and calls the Skill 54 sanctioned entry:

bash 54-anthology-writer/anthology-entry.sh --run-dir <RUN_DIR>

Skill 54 walks P0 to P7 fail-closed and returns artifacts on disk plus working/RUN-LEDGER.json and its prover verdicts; a signed process certificate is issued only on a full pass. The engine never bypasses this entry and never re-implements a Skill 54 phase. The ENGINE itself is run through its OWN sanctioned entry:

bash 59-anthology-engine/anthology-engine-entry.sh --stage sN --participant-key KEY [--run-dir DIR]
bash 59-anthology-engine/anthology-engine-entry.sh --stage s9 --anthology-id ID  [--run-dir DIR]
bash 59-anthology-engine/anthology-engine-entry.sh --plan
bash 59-anthology-engine/anthology-engine-entry.sh --self-test

The engine entry runs four fail-closed gates (deps, model-map pre-gate, run-dir bypass scan, enforcement hash pin), mints a run-scoped nonce, and dispatches the stage runner. Skipping a gate requires a logged owner token in working/checkpoints/process_manifest.json.

The two quality gates (never conflated)

GATE A (build/merge) is the fleet 10-category rubric at 8.5, administered per feature by an independent QC agent; it decides whether work merges. GATE B (content) ships INSIDE the skill and decides whether a deliverable reaches a producer or participant: Tier 1 deterministic hard-fail checks (qc-tier1-anthology.py), then the ten-dimension rubric at 8 or higher per dimension on the JUDGE tier (judge_harness.py, never the drafting tier), then the strike cap (qc-strike-gate.py: rewrite budget 2, three internal QC attempts). The independent QC scorer's promotion of a board card from review to done is Gate B's verdict surfacing on the board. A 9.0 build unit says nothing about a chapter, and a perfect chapter says nothing about merge readiness.

Sibling boundaries: Skills 53 and 54

Skill 54 (Anthology Writer) and Skill 53 (Book Writer) are SEPARATE skills sharing the ONE shared-utils/tone-writing-core. The anthology is many contributors, one chapter each; the book is one author, many chapters. This engine PROMOTES Skill 54 to its authoring core and extends it by exactly three bounded extensions (the Skill 52 avatar handoff, the newly pinned prompts, the intake fields); it builds NO duplicate anthology skill (a duplicate is a build failure) and DEPRECATES NEITHER sibling (the stale "deprecate BookWriter" directive is a scored build failure). A change to the shared tone core flags both siblings and this engine for review; forking the tone core is a build failure.

Verify

bash 59-anthology-engine/verify.sh       # read-only, idempotent; exits nonzero on drift
bash 59-anthology-engine/verify-deps.sh  # dependency check (python3)

verify.sh proves the house layout and the interface contracts this skill establishes (the stage machine, the field-map keys, the model-map tiers, the em-dash-free and fence-free nudge templates, the 14-point PDF floor, every stage runner byte-compiling and passing its self-test). It is scoped so it stays green as the sibling modules land.