Skip to main content

Runnable AGENT.md compile loop for scriptorium: drives `scrip` via subprocess + Claude. Not part of the deterministic scrip core.

Project description

scrip-harness — the runnable compile loop

The deterministic scrip keeper does staleness, provenance, and queries. It never calls a model. scrip-harness is the optional judgment layer that makes the AGENT.md COMPILE step runnable: it asks Claude to synthesize a wiki page from a source, then hands every verifiable step back to scrip.

The dependency points one way only: the harness depends on scrip (and the Anthropic SDK); scrip depends on neither. Removing this directory leaves a fully valid, fully deterministic vault and CLI behind.

How a compile runs

scrip-harness compile <slug> (for vault/raw/<slug>.md):

  1. Draft — Claude (claude-opus-4-8, adaptive thinking, structured output) returns a DraftPage: a title, markdown prose with footnote markers [^a1], [^a2], …, and one verbatim quote per marker.
  2. Mint — each quote goes through scrip anchor, which fails the compile if the quote isn't present in the source or isn't unique. A hallucinated or paraphrased quote cannot get past this step.
  3. Scaffold + fillscrip new writes the frontmatter; the harness fills the body with the prose + the minted footnote definitions.
  4. Stamp + verifyscrip stamp records provenance hashes; scrip verify proves every citation resolves. If verify fails, the compile errors out rather than leaving a stamped-but-broken page.

So the model owns what to say; scrip owns what is true on disk.

How an extract runs

scrip-harness extract <slug> (for vault/raw/<slug>.md):

  1. Draft — Claude returns a DraftExtraction: structured claims, each with a verbatim quote, a subject/predicate/object triple, and a polarity.
  2. Mint + append — the claims go to scrip fact add --stdin, which verifies every quote (minting anchors), assigns ids and timestamps, skips exact duplicates, and appends all-or-nothing under the write lock.
  3. Retry — if quotes come back BROKEN/AMBIGUOUS, the failures go back to Claude for one replacement per failure (lengthened until unique, or an empty quote to drop the claim); bounded retries, then the extract fails cleanly.
  4. Stamp + verifyscrip stamp vault/facts/_meta.yaml, then scrip verify; contradiction candidates from scrip query contradictions are surfaced for the operator to RECONCILE per AGENT.md.

Install & run

Both packages are on PyPI. scrip-harness bundles scriptoria as a dependency and drives it through its own interpreter, so it is self-sufficient — install scriptoria as a tool too only if you want the scrip command on PATH for direct use:

uv tool install scrip-harness            # this package → `scrip-harness` (pulls scriptoria)
uv tool install 'scriptoria[ingest]'     # optional: `scrip` on PATH + HTML/PDF ingest
export ANTHROPIC_API_KEY=...              # the harness calls Claude; scrip never does

scrip-harness compile article            # synthesize + verify a page from raw/article
scrip-harness extract article            # pull claims into facts/
scrip ingest <url> --slug article        # bring a source in (needs the install above)

(From a checkout, uv tool install ./scrip and uv tool install ./harness install the local versions instead.)

Develop / test

cd harness && uv run pytest        # hermetic: the model is stubbed; scrip runs for real

The tests inject a stub draft function (no network, no API key) and drive the real scrip subcommands over a temp vault, asserting the result is stamped and verified.

Scope & limits (v1)

  • Covers COMPILE (one source → one wiki page) and EXTRACT (one source → claims in facts/, with the bounded quote-retry loop). Entities/edges go through scrip fact add --table entities|edges by hand; PROMOTE (merge/dedup) and RECONCILE (contradictions) are not yet automated here — drive them with scrip directly per AGENT.md.
  • Single source per page/extract. Multi-source synthesis, and adopting the quote-retry loop in COMPILE too, are future work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scrip_harness-0.3.0.tar.gz (54.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scrip_harness-0.3.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file scrip_harness-0.3.0.tar.gz.

File metadata

  • Download URL: scrip_harness-0.3.0.tar.gz
  • Upload date:
  • Size: 54.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for scrip_harness-0.3.0.tar.gz
Algorithm Hash digest
SHA256 82ed9021ce106b5304bfeedf45cc383078fa7345454149bdd9d96dc80f82ad38
MD5 bd28132832969c1e5effaa301a066bdf
BLAKE2b-256 fb1533b046ff5a4f2187ad45b83bdfc095593a062c6a9ecd5c692e8751868444

See more details on using hashes here.

File details

Details for the file scrip_harness-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: scrip_harness-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for scrip_harness-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0cebc8d77e685aa85f079d8f06dab80b318f1fa2c26a4c951ec9dfaaac7e3d7
MD5 fbf531864b4bb51583040814a5d7c319
BLAKE2b-256 0a1007b1bc5cc64750ae2252d0c2108f8ef5a6ce4329ab71c2726a870e7317e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page