Skip to content

Latest commit

 

History

History
156 lines (129 loc) · 7.69 KB

rendering-reproducibility.md

File metadata and controls

156 lines (129 loc) · 7.69 KB

Rendering and Reproducibility Contract

This exemplar has one rendering paradigm: authored fragments and configuration produce deterministic data, figures, composed Markdown, hydrated Markdown, PDF, web, and copied root outputs. Do not hand-edit generated artifacts to make a claim pass; regenerate the producer that owns the artifact.

Authored surfaces

  • docs/manuscript/sections/imrad/** contains editable section fragments.
  • docs/manuscript/sheaf/tracks.yaml declares fragment types, renderers, and order.
  • docs/manuscript/sheaf/manifest.yaml binds fragments to IMRAD rows.
  • tracks.yaml declares pipeline tracks, gates, and extension artifacts.
  • figures.yaml is the source of truth for figure ids, captions, alt text, widths, and section bindings.
  • docs/manuscript/refs/labels.yaml is intentionally absent; it was a stale second figure registry. Figure labels are declared only by figures.yaml and materialized in output/figures/figure_registry.json.
  • pymdp.yaml, domain_profile.yaml, and data/claim_ledger.yaml define deterministic runtime, domain, and claim-evidence contracts.

Generated artifacts

  • output/data/*.json and output/reports/*.json are produced by project scripts and validation-spine modules.
  • docs/manuscript/0*.md, except hand-authored front/back matter, are composed from sheaf fragments by scripts/compose_manuscript.py.
  • output/manuscript/*.md is hydrated from composed manuscript sections plus output/data/manuscript_variables.json.
  • output/figures/* comes from scripts/generate_figures.py and scripts/render_animation.py.
  • output/pdf/* and output/web/* are render outputs, not sources of truth.
  • Template-root output/working/active_inference_on_policy_distillation/** is copied from the project-local output/** by the root pipeline.

After a successful standalone PDF render, src/manuscript/pdf_render.py writes ../reproducibility/render-receipt.json outside ignored output/. Commit that receipt with render evidence: it records the repository-relative PDF path, exact byte count, SHA-256, source HEAD, and the version output of pandoc, XeLaTeX, and pandoc-crossref when used. The source_worktree_changes field records tracked changes at render time (excluding the receipt itself), so source_commit is not misread as a clean-tree attestation. The PDF itself remains ignored; a later render replaces the receipt.

Single hydration boundary

The single hydration boundary is scripts/z_generate_manuscript_variables.py. Composition may emit {{token}} placeholders, but only hydration substitutes them. Unknown placeholders and single-brace token typos fail closed. Volatile counts, run facts, semantic restrictions, and figure captions must enter through output/data/manuscript_variables.json, never hard-coded prose.

Producer order

The following full-surface recipe requires its actual environment and scientific prerequisites. scripts/run_full_chain.py encodes producer order and structural fixed-point convergence; this is not proof of observed negative controls or release-green status:

uv run python scripts/compose_manuscript.py
uv run python scripts/run_analytical_sweep.py
uv run python scripts/simulate_si_tmaze.py
uv run python scripts/simulate_si_graph_world.py
uv run python scripts/compute_statistics.py
uv run python scripts/generate_validation_spine.py
uv run python scripts/generate_toy_sweep_tracks.py
uv run python scripts/generate_firstprinciples.py
uv run python scripts/generate_formal_interop_tracks.py
uv run python scripts/generate_integration_audit.py
uv run python scripts/generate_sheaf_tracks.py
uv run python scripts/generate_figures.py
uv run python scripts/render_animation.py
uv run python scripts/z_generate_manuscript_variables.py

This mirrors analysis.scripts in docs/manuscript/config.yaml exactly (generate_method_inventory.py is a docs-maintenance step, not a pipeline stage — see "Method inventory" below).

generate_sheaf_tracks.py is the canonical consolidation pass. It rewrites the semantic certificate, dependency graph, provenance, replay, counterexample, evidence-field, release-bundle, theorem-traceability, gate-index, diffoscope, proof-extraction, state-space, causal-ablation, license, release-note, proof-dependency, transition-table, ablation-sensitivity, release-attestation, track-improvement, blocked-scope, section-status, and render-log artifacts.

The shared first-principles write_complete API/CLI requires genuine upstream inputs. It produces measured statistics and privilege artifacts before the final ledger. Primitive, validation-spine, toy, first-principles and promoted inputs precede the first full figure pass; later figure refresh and hydration consume those actual outputs. --no-classroom removes the stale classroom-dependent outputs rather than recycling a previous run.

All writers hold physical-root artifact custody. Subprocess writers receive the explicit environment plus inherited-descriptor handoff; inherited leases are close-only. Ordinary generation never invokes receipt tests. Only the explicit recorder can create current per-case observation receipts, and neither structural convergence nor source-consistent deferred release notes satisfy default release acceptance.

Hydration derives freshness from rendered bytes, then resolves its own freshness variable until the variable map agrees with the newly derived report. Repeated variable states are an explicit cycle error, not a forced all_fresh value. Semantic/provenance validation follows hydration; missing observation or release evidence remains red in the default acceptance gates.

Figure rendering contract

Every figure id must exist in figures.yaml, have a generator in src/visualizations/figures.py, write through figure_io.save_figure_png, and appear in output/figures/figure_registry.json. Figure captions and alt text may use hydration tokens, but figure numbering belongs to pandoc-crossref. Reused figures must use unlabeled references rather than duplicate labels. The appendix theorem-traceability graph and causal-ablation heatmap are generated from JSON rows and validated by the same figure registry contract as the main figures.

Sheaf reproducibility

The sheaf claim is finite and falsifiable:

  • registry tracks must be known and typed by renderer;
  • manifest bindings must resolve to existing fragments or generated renderers;
  • coverage must have zero gray cells on a clean tree;
  • semantic gluing must record shared symbols, claim evidence, artifact producers, consumers, validation gates, and manuscript variables;
  • every promoted artifact must have a producer, a bound manuscript track, a typed claim, a validation restriction, and a negative-control test.

Project render and optional Root output parity

Project-local outputs are authoritative during generation. The default PDF render gate is the project-local convergent chain:

uv run python scripts/run_full_chain.py --render
uv run python scripts/validate_outputs.py

When you also run the optional sibling-template polish pipeline, verify copied root output parity as well:

cd ../../../template
uv run python -m infrastructure.orchestration link-projects
uv run python scripts/03_render_pdf.py --project working/active_inference_on_policy_distillation
cd projects/working/active_inference_on_policy_distillation   # linked copy inside the template checkout
uv run python scripts/validate_outputs.py

The semantic and release-bundle reports allow render-deferred PDF/web rows before copy, but a template-polish acceptance must inspect both output/** inside the project and ../../../template/output/working/active_inference_on_policy_distillation/** from the sibling template checkout.