Domain-skin variant of
template_madlib. This exemplar reuses the same deterministic token-injection composition core astemplate_madlib(src/composition.py,src/config.py,src/manuscript_variables.py, and a near-identicaldocs/manuscript/config.yamlschema) and shows how to specialize that mega-madlib engine to a concrete domain. The metallurgy skin (src/assay.py,src/purity.py,src/refinery.py,src/domain_adapter.py) maps the abstract composition pipeline onto a real refinement sequence: ore → smelting → assaying → cupellation → certification. Readtemplate_madlibfirst for the generic engine; read this template to see a worked domain specialization of it.
Use this template for analogical manuscript composition research: projects
that map a scientific domain onto a refinement pipeline and generate the
manuscript through deterministic mega-madlib token injection. The gold-refining
analogy (ore → smelting → assaying → karat grading) models manuscript purity
from rough draft through nine-nines certification, with each stage operationalized
by template infrastructure. If your project is primarily numerical optimization,
prose review, or layout, see template_code_project, template_prose_project,
or template_newspaper instead.
The publishing metadata and per-platform status below are compiled from
docs/manuscript/config.yaml by infrastructure.publishing.status_report — do not
hand-edit between the markers; update the config and regenerate (see the legend).
Refinement of Gold: A Metallurgical Analogy for Scientific Manuscript Composition · v0.1.0 · MIT · Daniel Ari Friedman
Concept DOI: 10.5281/zenodo.20931955 | Version DOI: 10.5281/zenodo.20938523 | Repository: docxology/template_gold_refinement
Publishing surface — 20 platforms, 7 published:
| Platform | Tier | Status | Reference | Credentials |
|---|---|---|---|---|
| zenodo | first-class | ✅ published | 10.5281/zenodo.20931955 | ZENODO_API_TOKEN |
| github | first-class | ✅ published | docxology/template_gold_refinement | GITHUB_TOKEN |
| arxiv | first-class | ⚪ available | — | — |
| pypi | first-class | ✅ published | https://test.pypi.org/project/template-gold-refinement/0.1.0/ | PYPI_TOKEN, TESTPYPI_TOKEN |
| ipfs_pinata | first-class | ✅ published | https://gateway.pinata.cloud/ipfs/QmQBXK5qoGv5NSWC8mzcx22AgkHeqBJL8z8HrCgEy7nzio | PINATA_JWT |
| ipfs_web3storage | first-class | ⚪ available | — | WEB3_STORAGE_TOKEN |
| software_heritage | first-class | ✅ published | https://archive.softwareheritage.org/browse/origin/?origin_url=https://github.com/docxology/template_gold_refinement | — |
| github_pages | first-class | ⚪ available | docxology/template_gold_refinement | GITHUB_TOKEN |
| cloudflare_pages | first-class | ⚪ available | — | CLOUDFLARE_API_TOKEN |
| netlify | first-class | ⚪ available | — | NETLIFY_AUTH_TOKEN |
| huggingface_hub | first-class | ✅ published | https://huggingface.co/datasets/ActiveInference/template_gold_refinement | HUGGINGFACE_TOKEN, HF_TOKEN |
| osf | first-class | ✅ published | https://osf.io/u485p/ | OSF_TOKEN |
| amazon_kdp | documented | 🟡 planned | — | AMAZON_KDP_EMAIL, AMAZON_KDP_PASSWORD |
| google_play_books | documented | 🟡 planned | — | GOOGLE_PLAY_BOOKS_SERVICE_ACCOUNT_JSON |
| gumroad | documented | 🟡 planned | — | GUMROAD_ACCESS_TOKEN |
| leanpub | documented | 🟡 planned | — | LEANPUB_API_KEY |
| lulu | documented | 🟡 planned | — | LULU_CLIENT_KEY, LULU_CLIENT_SECRET |
| draft2digital | documented | 🟡 planned | — | DRAFT2DIGITAL_API_TOKEN |
| stripe | documented | 🟡 planned | — | STRIPE_SECRET_KEY, STRIPE_PUBLISHABLE_KEY |
| ingramspark | documented | 🟡 planned | — | INGRAMSPARK_CLIENT_ID, INGRAMSPARK_CLIENT_SECRET |
Keywords: gold refining, manuscript composition, mega-madlib, token injection, scientific purity, assaying, karat grading, security assay, supply-chain provenance.
Status legend: ✅ published (durable identifier recorded in config.yaml) · 🔵 reserved (identifier reserved but not yet registered by final publication) · ⚪ available (adapter implemented and locally verifiable) · 🟡 planned. This block is generated — edit docs/manuscript/config.yaml, then regenerate with uv run python -m infrastructure.publishing.status_report --project <path> --write.
- Canonical renderer: docxology/template with
--project templates/template_gold_refinement - Tracked outputs:
output/in this project andoutput/templates/template_gold_refinement/in the monorepo; public output files above 50 MB stay out of git.
See the documentation index for setup, configuration, the authored manuscript, and instructions for rebuilding this standalone checkout.
All rendered artifacts are source-owned and disposable. Do not hand-edit
output/; regenerate it through Stage 02/03/04 or the project scripts.
| Artifact | Source owner | Purpose |
|---|---|---|
output/data/refinery_results.json |
src/refinery.py, src/purity.py |
Canonical purity sequence and certification result |
output/reports/token_plan.json |
src/composition.py, docs/manuscript/config.yaml |
Deterministic mega-madlib token choices and provenance |
output/reports/claim_support_registry.json |
src/evidence.py |
Project-local contribution-claim assay |
output/reports/evidence_registry.json |
template evidence validator | Shared evidence facts consumed by validation gates |
output/figures/figure_registry.json |
src/figures/_common.py::FIGURE_SPECS |
Figure label/path/caption/source registry |
output/reports/figure_quality_report.json |
src/figures/registry.py::write_figure_quality_report |
PNG/SVG existence, dimensions, nonblank pixels, color variance, and registry parity |
output/figures/cover_visualization.png |
src/cover_visualization.py::generate_cover_visualization |
Standalone publication cover visual; not part of the stable 12-figure manuscript registry |
output/reports/cover_visualization.json |
src/cover_visualization.py::write_cover_visualization |
Cover dimensions, byte sizes, nonwhite fraction, and color variance |
The visualization layer is a technical contract, not a decorative export.
The src/figures/ package defines a single FIGURE_SPECS registry for all 12 stable
figure labels and writes both PNG and SVG files for every figure. Manuscript
Markdown variables continue to reference PNGs for PDF compatibility; SVG files
are companion artifacts for inspection and reuse.
Graph-like figures use deterministic NetworkX-backed source graphs:
| Figure | Technical encoding |
|---|---|
fig:provenance_sankey |
Directed stage flow with edge width proportional to purity gain |
fig:formalism_traceability |
Formalism → equation label → source-owner graph |
fig:implementation_circuit |
Config/code/artifact/manuscript/validator/publication circuit |
fig:claim_evidence_assay |
Claim-support bars plus claim → evidence → boundary topology |
Quantitative figures expose late-stage or integrity-relevant structure:
fig:purity_progression includes a nines transform, fig:integrity_risk_matrix
colors points by source tier and sizes them by residual risk, and
fig:evidence_tier_ladder reports source-tier counts and percentages. The
quality report must pass before the visuals should be treated as publication
artifacts.
Gold refining provides a load-bearing pipeline — not merely a rhetorical frame — for manuscript composition:
| Metallurgical stage | Manuscript operation | Purity target |
|---|---|---|
| Ore (raw material) | Draft prose, raw claims | ~37.5% (9K) |
| Smelting (separation) | Remove dross: filler, unsupported claims | ~75% (18K) |
| Assaying (testing) | Validate claims against evidence | ~91.7% (22K) |
| Refining (cupellation) | Cross-reference resolution, citation audit | ~99.0% (24K) |
| Certification (karat grading) | Full pipeline validation, reproducibility | ~99.9%–99.9999999% (nine-nines) |
Each stage increases purity monotonically. The mega-madlib token engine selects
domain vocabulary deterministically (seeded SHA-256 digest over category
inventories), and every manuscript {{TOKEN}} is generated by a single Python
function cross-checked by a live regression test.
Runtime and development dependencies are declared in pyproject.toml and pinned
by uv.lock. See the quickstart for installation and
the native test command.
- Refinery pipeline: ore → smelting → assaying → karat grading with monotone purity increase
- Mega-madlib token injection: deterministic, seeded, config-owned lexicon
- Karat grading: maps purity fractions to standard gold karat grades (9K–24K)
- Continuity and reverse assay: rejects disconnected stages and returns the shortest ordered prefix reaching a declared target
- Multi-objective purity: keeps stage completion, claim support, token provenance, and figure quality separate without compensatory averaging
- Nine-nines certification: extends purity to 99.9999999% for the final stage
- Manuscript variable generation: every prose number is a
{{TOKEN}}from one Python function - Source-owned formalisms: auto-numbered equation blocks from
src/formalisms.py - Scientific-integrity gates: claim support, evidence tiers, source owners, and risk dimensions from source registries
- Technical visualization QA: PNG+SVG generation, registry parity, nonblank pixel checks, and color-variance checks
- Zero-mock test suite: real data, real computation, real files
See AGENTS.md for technical documentation.
- Forward backlog:
TODO.md. - Copy-and-customize configuration:
docs/manuscript/config.yaml.example. - Standalone fork guide:
STANDALONE.md. - Verification: native coverage and pinned manuscript stages.
Navigation links to in-tree documents (keeps them discoverable):
