← Browse

@docxology/template-10

A

πŸ€– AGENTS.md - System Documentation

instructionscodexclaude

Install

agr install @docxology/template-10 --target claude

Writes 1 file into .claude/skills/, pinned to git-beb3f748.

  • .claude/skills/template-10/AGENTS.md

Document

πŸ€– AGENTS.md - System Documentation

🎯 System Overview

This document provides documentation for the Research Project Template system, ensuring understanding of all functionality, configuration options, and operational procedures.

πŸ“„ Publication

Title: A template/ approach to Reproducible Generative Research: Architecture and Ergonomics from Configuration through Publication DOI: 10.5281/zenodo.19139090 Β· Record: zenodo.org/records/19139090

template/ applies Infrastructure as Code to the research lifecycle: version-controlled manuscripts, tests, provenance, and a declared pipeline DAG. Layer 1 (infrastructure/) is separated from Layer 2 (self-contained projects under projects/). Current measured counts and stage facts live in docs/_generated/COUNTS.md; re-derive them instead of copying literals into prose. Each directory carries README.md + AGENTS.md; infrastructure packages usually add SKILL.md for agent routing. Full paper, metrics, and claims: Zenodo record above and root README.md.

Documentation map

EntryRole
README.mdOnboarding, documentation hub links, exemplar table
.cursorrulesCursor agents: layer rules, CI scope, editing discipline
CLAUDE.mdCommand cheat sheet, patterns; keep in sync with this file for pipeline wording
This file (AGENTS.md)Full reference: stages, validation, modules, troubleshooting
docs/documentation-index.mdFlat index of long-lived docs
docs/_generated/active_projects.mdAuthoritative public CI/documentation project names β€” never hard-code rotating private paths in docs
docs/_generated/COUNTS.mdMeasured coverage and counts; refresh after changing gates or discovery
.github/README.mdGitHub: CI overview, templates, Dependabot
.github/AGENTS.mdActions job names, coverage gates, local reproduction commands
TO-DO.mdCurrent backlog, scoped by acceptance line
CHANGELOG.mdRelease history

For assistants and automation

Read order: README.md β†’ CLAUDE.md β†’ this file for anything not covered there.

Ground truth: Public CI/documentation project names come from docs/_generated/active_projects.md (infrastructure.project.public_scope). Runtime discover_projects() remains broader for local private symlinked workspaces. Measured numbers for documentation claims belong in docs/_generated/COUNTS.md; avoid inventing statistics.

Definition of done (code): Ruff clean on the full public lint surface from uv run python -m infrastructure.project.public_scope lint-paths, and mypy clean on the import-safe source paths from ... source-paths; tests exercise real behaviour, introduce no prohibited mock framework, and do not increase semantic dependency-replacement debt; coverage still meets 60% (infra) / 90% (project src/) unless CI documents a rotating-project exception (.github/AGENTS.md).

Hooks: .pre-commit-config.yaml β€” commit stage runs Ruff and mypy; pre-push adds no-mocks verification, a short pytest smoke module, Bandit (-c bandit.yaml, exclusions in YAML), and infrastructure.skills check + check-all-exports. Install: pre-commit install and pre-commit install --hook-type pre-push after uv sync.

Architecture: Business logic only in infrastructure/ or projects/{name}/src/. Scripts orchestrate; violating this breaks the test and documentation contract (Thin orchestrator pattern).

Optional CodeGraph: CodeGraph may be used as a local agent navigation index for source-code questions and impact analysis. It is not a dependency, pipeline stage, CI requirement, or manuscript evidence source. .codegraph/ is ignored and rejected by the generated-artifact guard if force-added. Use docs/guides/codegraph-local.md and uv run python scripts/maintenance/codegraph_local.py commands .; initialize private associated projects from their canonical private checkout, not through public template/projects/<name> symlinks.

Optional LEANN: LEANN may be used as a local semantic-retrieval companion for agent navigation. It is not a dependency, pipeline stage, CI requirement, MCP default, or manuscript evidence source. .leann/ is ignored and rejected by the generated-artifact guard if force-added. Use docs/guides/leann-local.md; build indexes from tracked public files or from the canonical private checkout, not through public template/projects/<name> symlinks.

Local agent memory (gitignored): When present, read .cursor/hooks/state/continual-learning-memory.json for durable user preferences and workspace facts. Never commit this file or write Learned sections into root AGENTS.md. Schema: .cursor/hooks/state/continual-learning-memory.example.json. Load/save helpers: infrastructure.core.agent_memory.

Public output hygiene: Canonical public exemplars may track deterministic publication evidence and release contracts under projects/templates/<name>/output/: final PDFs, figures, analysis data, hydrated manuscripts, and stable validation/publication registries. Runtime checkpoints, .pipeline/ state, logs, telemetry, stage snapshots, pipeline reports, and LaTeX/slide build intermediates are local-only and ignored. Recreate them through the canonical pipeline when diagnosing or rendering; do not publish them as exemplar evidence.

Template authoring & operational notes

Generic, Layer-1 facts for working in this repository.

  • Manuscript variables are injected, not hand-authored. Per-project metrics, counts, and variables come from output/data/manuscript_variables.json at render time. For template_code_project, the default pipeline calls generate_variables(..., require_analysis_outputs=True) via projects/{name}/scripts/z_generate_manuscript_variables.py and fails when output/data/optimization_results.csv is absent; pass --allow-draft only for intentional early drafts. PDF Publishing Information reads publication.doi, optional publication.repository_url, and publication.repository_label from projects/{name}/manuscript/config.yaml via infrastructure/rendering/_pdf_latex_helpers.py.
  • Validation & rendering pitfalls. Content-validation diagnostics use stable dotted IDs from infrastructure/validation/content/diagnostic_codes.py (MarkdownCode, BibtexCode); every new DiagnosticEvent must pass code=…, and renaming an existing code is a breaking change for downstream jq/rg filters. Fast manuscript pre-flight: uv run python -m infrastructure.validation.cli prerender projects/<project>/manuscript --repo-root .. Multi-pass PDF rendering continues when pass 1 wrote output despite recoverable Missing $ errors so later passes resolve forward references. Mermaid: unquoted // line comments; stadium nodes [/label/] close with /]; combined-PDF Mermaid via Chrome headless or mmdc, else verbatim figure fallback. FIGURE_WIDTH_* values must be bare fractions (e.g. 0.9); the alt-text comment belongs before \begin{figure}; prefer inline $...$ over \(...\) in Markdown list items.
  • Entry points & gates. run.sh and secure_run.sh source only scripts/shell/shell_bootstrap.sh; menu and argparse live in infrastructure.orchestration. scripts/shell/bash_utils.sh serves backup/health scripts and tests, not pipeline entrypoints. Exemplar doc/code drift: scripts/audit/check_template_drift.py β†’ infrastructure.project.drift.run_drift_checks() on PUBLIC_PROJECT_NAMES (--project, --strict). Layer 1 module size: scripts/gates/module_line_count_check.py and uv run python -m infrastructure.core.health (module-line-count). The health registry also runs the executable methods contract and scripts/gates/public_capabilities.py across the canonical public roster. Opt-in gates under scripts/gates/ report status: "skipped" under skipped_tools when tools are missing. bandit.yaml exclude_dirs skips rotating/private trees so CI stays strict on infrastructure/, scripts/, and public exemplars.

Confidentiality invariant (this is a PUBLIC repo)

.gitignore ignores projects/* and negates only the public canonical exemplar trees under projects/templates/ (plus the repo-level projects/*.md docs). The public exemplar roster is derived from infrastructure.project.public_scope.PUBLIC_PROJECT_NAMES and documented in docs/_generated/active_projects.md; do not hand-maintain a second allowlist in prose. Those public canonical exemplars are the only project trees ever git-tracked/pushed. Confidential/private work lives in a separate, external private repository whose location is configured with TEMPLATE_PRIVATE_PROJECTS_ROOT or .private_projects_root; the simplified sidecar normally has working/ and archive/, with optional ongoing/ (long-lived projects with no publication target) plus legacy active/, published/, and other/ folders still supported by the linker. run.sh/infrastructure.orchestration sync existing lifecycle folders into matching typed subfolders under projects/: working/* β†’ projects/working/*, ongoing/* β†’ projects/ongoing/*, archive/* β†’ projects/archive/*, and optional active/* β†’ projects/active/* (rendered). Only projects/templates/* and optional projects/active/* are discovered/rendered by default.

Every path under projects/ other than templates/ β€” especially the local-only working/, archive/, optional active/, published/, other/ mirrors β€” is local-only and must never be committed. This is enforced, not conventional: scripts/audit/check_tracked_all.py fails the CI lint job and the pre-push pre-push-quick hook if any non-template project path is tracked (a git add -f cannot slip past it). Consult docs/_generated/active_projects.md before hard-coding any project path in docs.

The same invariant covers three sibling top-level resource-pool directories β€” fonds/, rules/, tools/ (each analogous to projects/: only their templates/ subfolder is git-tracked, working//archive/ are LOCAL-ONLY, and each gets the same run.sh/infrastructure.orchestration sidecar auto-sync, independently overridable via TEMPLATE_FONDS_ROOT/TEMPLATE_SKIP_FOND_LINK_SYNC, TEMPLATE_RULES_ROOT/TEMPLATE_SKIP_RULE_LINK_SYNC, TEMPLATE_TOOLS_ROOT/TEMPLATE_SKIP_TOOL_LINK_SYNC). scripts/audit/check_tracked_all.py runs all four confidentiality checks (offending_tracked_projects/fonds/rules/tools in infrastructure/project/git_guards.py) in one pass; the narrower scripts/audit/check_tracked_projects.py still runs standalone but is no longer wired into CI or pre-commit.

Operational gotchas: running all projects/*/tests/ in one pytest process fails when projects each ship tests/conftest under the tests.conftest package name β€” run one project test directory per pytest invocation (with --cov-append to merge coverage), or follow .github/workflows/ci.yml. resolve_project_root accepts a qualified <subfolder>/<name> path (e.g. templates/template_code_project, active/demo) and resolves it directly under projects/. For a bare name it prefers projects/active/<name>/ (the hot seat) when that tree has project markers, then projects/working/<name>/, then a flat standalone projects/<name>/, falling back to projects/active/<name>/ for error messages.

Agent skills hub: docs/prompts/SKILL.md (template-workflows); regenerate via uv run python -m infrastructure.skills write and uv run python -m infrastructure.skills write-index. Repository-scoped context-engineering skills live under .agents/skills/ with a pinned source lock and cross-runtime sync/check command. Each canonical exemplar under projects/templates/ also ships its own .agents/skills/<name>/SKILL.md; both public lanes are included in .cursor/skill_manifest.json, the generated skills index, MCP list_skills, and Hermes/agentskills.io runtimes.

πŸ“‹ Table of Contents

Assistants: For assistants and automation

  1. Core Architecture
  2. Directory-Level Documentation
  3. Configuration System
  4. Rendering Pipeline
  5. Validation Systems
  6. Testing Framework
  7. Output Formats
  8. Advanced Modules
  9. Troubleshooting
  10. Maintenance

πŸ—οΈ Core Architecture

Two-Layer Architecture

Layer 1: Infrastructure (Generic - Reusable)

  • infrastructure/ - Generic build/validation tools (reusable across projects)
  • scripts/ - Entry point orchestrators (core pipeline or full pipeline via ./run.sh)
  • tests/ - Infrastructure and integration tests

Layer 2: Projects (Project-Specific - Customizable)

  • projects/{name}/src/ - Research algorithms and analysis (domain-specific per project)
  • projects/{name}/tests/ - Project test suite
  • projects/{name}/scripts/ - Project analysis scripts (thin orchestrators)
  • projects/{name}/manuscript/ - Research manuscript
  • projects/{name}/output/ - Working outputs during pipeline execution
  • output/{name}/... - Final deliverables after pipeline completion

Thin Orchestrator Pattern

CRITICAL: All business logic resides in projects/{name}/src/ modules. Scripts are thin orchestrators that:

Root Entry Points (Generic):

  • Coordinate build pipeline stages
  • Discover and invoke projects/{name}/scripts/ for specified project
  • Handle I/O, orchestration only
  • Work with ANY project structure (single or multi-project)

Project Scripts (Project-Specific):

  • Import from projects/{name}/src/ for computation
  • Import from infrastructure/ for utilities
  • Orchestrate domain-specific workflows
  • Handle I/O and visualization

Violation of this pattern breaks the architecture.

Multi-Project Support

The template now supports multiple independent projects within a single repository:

Project Discovery:

  • Projects are discovered automatically from projects/ directory
  • Each project must have src/ and tests/ directories
  • Projects are validated for structural completeness

Project Isolation:

  • Each project has its own source code, tests, manuscript, and scripts
  • Working outputs are stored in projects/{name}/output/
  • Final deliverables are organized in output/{name}/...

Orchestration Options:

  • Run individual projects: --project {name}
  • Run all projects sequentially: --all-projects
  • Interactive project selection menu
  • Backward compatibility with single-project workflows

Active projects (under projects/): the set rotates as workspaces are promoted, archived, or moved. Authoritative names at any moment are only in docs/_generated/active_projects.md (regenerate after layout changes). The only path guaranteed to remain the control-positive exemplar for docs and commands is projects/templates/template_code_project/ (optimization research exemplar).

Private projects normally live in a separate external private repository (location configurable via TEMPLATE_PRIVATE_PROJECTS_ROOT or .private_projects_root) and are symlinked by lifecycle into matching typed subfolders under projects/. The simplified private sidecar uses working/ and archive/ by default; optional ongoing/ (long-lived projects with no publication target) plus legacy active/, published/, and other/ folders are still recognized when present. working/* mirrors into projects/working/*, ongoing/* into projects/ongoing/*, and archive/* into projects/archive/* for explicit inspection/rendering; optional active/* mirrors into projects/active/* for discovery/rendering. Use uv run python -m infrastructure.orchestration link-projects --dry-run to inspect the planned links, TEMPLATE_PRIVATE_PROJECTS_ROOT or .private_projects_root to override the sibling repo, and TEMPLATE_SKIP_LINK_SYNC=1 to disable auto-sync for a command.

Note: Exemplars such as blake_bimetalism, traditional_newspaper, area_handbook, density_bioscales may live under projects/archive/. In-progress trees live under projects/working/ until retired or explicitly rendered. Active names are listed in docs/_generated/active_projects.md.

πŸ“‚ Project Organization: Rendered vs Non-Rendered Subfolders

Rendered Projects (projects/templates/ + projects/active/)

Projects under projects/templates/ (tracked exemplars) and projects/active/ (hot-seat set) are actively discovered and executed by infrastructure:

  • Discovered by infrastructure.project.discovery.discover_projects() with qualified names templates/<name> and active/<name>
  • Listed in run.sh interactive menu
  • Executed by the canonical pipeline stages under scripts/pipeline/ (for example, stage_01_test.py and stage_02_analysis.py)
  • Outputs generated in projects/<subfolder>/{name}/output/ and copied to output/<subfolder>/{name}/

Non-Rendered Projects (working/, ongoing/, archive/, optional legacy mirrors)

Projects under projects/working/, projects/ongoing/, and projects/archive/ are preserved for explicit targeted work but not executed by default. Optional legacy projects/published/ and projects/other/ mirrors are treated the same way when present:

  • NOT discovered by default infrastructure discovery functions
  • NOT listed in the normal run.sh menu
  • NOT executed by all-project pipeline scripts
  • Preserved for in-progress work, long-lived no-publication-target work (ongoing/), historical reference, and explicit qualified commands such as --project working/<name> or --project ongoing/<name>

Project Lifecycle

Retiring in the sidecar: Move working/{name}/ β†’ archive/{name}/ Resuming in the sidecar: Move archive/{name}/ β†’ working/{name}/ Explicit render: From the template checkout, run uv run python scripts/pipeline/stage_03_render.py --project working/{name} after link-projects.

Projects are automatically discovered when a deliberately restored sidecar active/{name} entry is synced into projects/active/{name}. Normal sidecar work can also be rendered explicitly with a qualified name such as working/{name} without moving it into the default render set.

In-Progress Projects (projects/working/)

An intermediate staging area for projects that are under active development but not yet ready to run through the full pipeline. Projects here:

  • NOT discovered by infrastructure discovery functions
  • NOT listed in run.sh menu
  • NOT executed by any pipeline scripts
  • Useful for drafting new project scaffolding before explicitly rendering with a qualified name or deliberately restoring into optional projects/active/

Current in-progress projects: the roster rotates every checkout, so it is deliberately not hard-coded here β€” run ls projects/working/ for the live set (not executed by default by ./run.sh; render explicitly with a qualified project name such as working/<name>). Rendered projects are listed only in docs/_generated/active_projects.md.

To render by default: restore/sync the project through the sidecar's optional active/{name} folder so it appears as projects/active/{name}. Keep ordinary backburner work in sidecar working/ or archive/.

πŸ“š Repository Structure

The template separates generic infrastructure from project-specific code:

flowchart TB
    ROOT[template<br/>Generic template repository]

    ROOT --> INFRA[infrastructure<br/>Layer 1 Β· generic build Β· validation tools]
    ROOT --> SCRIPTS[scripts<br/>Pipeline stage orchestrators 00–07]
    ROOT --> TESTS[tests<br/>Infrastructure test suite]
    ROOT --> DOCS[docs<br/>Documentation hub Β· 300+ files]
    ROOT --> PROJECTS[projects<br/>Typed subfolders Β· templates+active rendered]
    ROOT --> OUT[output<br/>Final deliverables Β· organized by project]

    INFRA --> I_DOCS[AGENTS.md Β· README.md Β· SKILL.md]
    INFRA --> I_CONFIG[config<br/>Repo-wide configuration]
    INFRA --> I_DOCKER[docker<br/>Container specs]
    INFRA --> I_SUB[Layer 1 packages listed in<br/>`infrastructure/AGENTS.md` β€”<br/>counts from COUNTS.md]

    PROJECTS --> P_README[README.md Β· multi-project guide]
    PROJECTS --> P_STUB[_test_project<br/>Stub Β· output/ only Β· not discovered]
    PROJECTS --> P_CODE[template_code_project<br/>Guaranteed control-positive exemplar]
    PROJECTS --> P_OTHER[&lt;name&gt;<br/>Additional discovered projects]

    P_CODE --> P_C_SRC[src Β· tests Β· scripts Β· manuscript Β· output<br/>+ pyproject.toml]

    OUT --> O_CODE[template_code_project<br/>Project outputs]
    OUT --> O_DOTS[&lt;other projects&gt;]

    classDef root fill:#0f172a,stroke:#0f172a,color:#fff
    classDef l1 fill:#1e3a8a,stroke:#0f172a,color:#fff
    classDef l2 fill:#0f766e,stroke:#0f172a,color:#fff
    classDef gen fill:#7c2d12,stroke:#0f172a,color:#fff
    class ROOT root
    class INFRA,SCRIPTS,TESTS,DOCS,I_CONFIG,I_DOCKER,I_SUB,I_DOCS l1
    class PROJECTS,P_CODE,P_OTHER,P_STUB,P_README,P_C_SRC l2
    class WIP,ARCH,OUT,O_CODE,O_DOTS gen

πŸ“š Directory-Level Documentation

Each directory contains documentation for easy navigation:

Generic Infrastructure (Reusable)

DirectoryAGENTS.mdREADME.mdPurpose
infrastructure/AGENTS.mdREADME.mdGeneric build/validation tools (Layer 1)
scripts/AGENTS.mdREADME.mdGeneric entry point orchestrators
tests/AGENTS.mdREADME.mdInfrastructure test suite

Project-Specific (Customizable)

DirectoryAGENTS.mdREADME.mdPurpose
projects/templates/template_code_project/AGENTS.mdREADME.mdCode-centric exemplar (canonical, always present)
projects/templates/template_prose_project/AGENTS.mdREADME.mdProse-centric exemplar (canonical, always present)
projects/templates/template_active_inference/AGENTS.mdREADME.mdActive Inference multi-track exemplar (canonical, always present)
projects/templates/template_advanced_literature_review/AGENTS.mdREADME.mdAdvanced multi-phase literature-review exemplar with phase provenance and offline replay (canonical, always present)
projects/templates/template_autopoiesis/AGENTS.mdREADME.mdCombinatoric-grammar project-generation exemplar (canonical, always present)
projects/templates/template_autoresearch_project/AGENTS.mdREADME.mdAutoResearch exemplar (canonical, always present)
projects/templates/template_autoscientists/AGENTS.mdREADME.mdAutoScientists coordination-mechanism testbed exemplar (canonical, always present)
projects/templates/template_data_descriptor/AGENTS.mdREADME.mdDataset descriptor/data-paper exemplar with schema, provenance, and quality gates (canonical, always present)
projects/templates/template_eda_notebook/AGENTS.mdREADME.mdEDA notebook exemplar with notebook-to-src binding and deterministic analysis outputs (canonical, always present)
projects/templates/template_formal/AGENTS.mdREADME.mdStrongly typed multiagent colony exemplar with session-typed protocols and Lean/TLA+ formal side-specs (canonical, always present)
projects/templates/template_gold_refinement/AGENTS.mdREADME.mdGold-refining metallurgical analogy for manuscript composition (ore β†’ nine-nines, mega-madlib token injection) (canonical, always present)
projects/templates/template_literature_meta_analysis/AGENTS.mdREADME.mdLiterature meta-analysis exemplar β€” multi-engine retrieval, de-dup, full-text, embeddings, bibliometrics; default term modafinil (canonical, always present)
projects/templates/template_madlib/AGENTS.mdREADME.mdConditional token-injection manuscript exemplar with QA probes and authoring contract (canonical, always present)
projects/templates/template_methods_paper/AGENTS.mdREADME.mdMethods-paper exemplar β€” controlled-method specification DSL, staged validation, deterministic compilation, informed by BPL (canonical, always present)
projects/templates/template_newspaper/AGENTS.mdREADME.mdNewspaper layout-engine exemplar (canonical, always present)
projects/templates/template_pitch_deck/AGENTS.mdREADME.mdPitch deck / slide deck scaffold exemplar (canonical, always present)
projects/templates/template_pools_rules_tools/AGENTS.mdREADME.mdFonds/rules/tools resource-pool integration exemplar (canonical, always present)
projects/templates/template_redacted_report/AGENTS.mdREADME.mdFormal redaction and release-review exemplar with authority, ledger, and mosaic-risk gates (canonical, always present)
projects/templates/template_registered_report/AGENTS.mdREADME.mdRegistered-report/preregistration exemplar with locked hypotheses, outcomes, analysis plan, and deviation ledger (canonical, always present)
projects/templates/template_sia/AGENTS.mdREADME.mdSIA harness exemplar (canonical, always present)
projects/templates/template_storybook/AGENTS.mdREADME.mdFull-page illustrated storybook exemplar (canonical, always present)
projects/templates/template_template/AGENTS.mdREADME.mdMeta-template exemplar (canonical, always present)
projects/templates/template_textbook/AGENTS.mdREADME.mdModular fillable-textbook scaffold exemplar (canonical, always present)
projects/templates/template_search_project/AGENTS.mdREADME.mdLiterature-search exemplar (canonical, always present)
Rotating projects (e.g. actinf_policy_entanglement_lean, private symlinked workspaces)see project tree when checked out under a typed subfoldersee project tree when checked out under a typed subfolderSee docs/_generated/active_projects.md for current rendered roster; ordinary sidecar work rotates between projects/working/ and projects/archive/

In-progress projects live under projects/working/ and are not executed by default pipeline discovery. Render one explicitly with a qualified project name such as working/<name>, or deliberately restore it through optional sidecar active/ only when it should enter default discovery. The roster rotates every checkout, so it is deliberately not hard-coded here (cf. the rotation rule above β€” hard-coding rotating project paths is the recurring staleness defect this guidance prevents): run ls projects/working/ for the live set, and see docs/_generated/active_projects.md for the rendered roster.

Ongoing projects live under projects/ongoing/ when present β€” long-lived work with no publication target, not discovered or executed by default. Render one explicitly with a qualified project name such as ongoing/<name>. The roster rotates every checkout and is deliberately not hard-coded here: run ls projects/ongoing/ for the live set.

Archived projects live under projects/archive/ when present, but the roster is checkout-specific and is not discovered or executed by default. Resume by moving them back to sidecar working/, render explicitly with archive/<name> when appropriate, or deliberately restore through optional sidecar active/ for default discovery. Use ls projects/archive/ for local inspection. The authoritative list of rendered projects is in docs/_generated/active_projects.md. Regenerate it after layout changes: uv run python scripts/docgen/active_projects.py.

Documentation Directories

DirectoryAGENTS.mdREADME.mdPurpose
docs/AGENTS.mdREADME.mdProject documentation hub

Documentation Navigation

For detailed information:

  • Read directory-specific AGENTS.md files for details
  • Each AGENTS.md covers architecture, usage, and best practices

For quick reference:

  • Check directory-specific README.md files for fast answers
  • Each README.md provides quick start and essential commands

Root documentation:

  • This file (root AGENTS.md) - System overview
  • README.md - Project quick start and introduction

Directory Structure

flowchart TB
    ROOT[template<br/>Generic Template]

    ROOT --> INFRA[infrastructure<br/>Layer 1 Β· generic build/validation tools]
    ROOT --> DOCS[docs<br/>Documentation hub]
    ROOT --> CUR[.cursor<br/>Editor configuration]
    ROOT --> SCR[scripts<br/>Pipeline stage entry points]
    ROOT --> TS[tests<br/>Infrastructure tests]
    ROOT --> PR[projects<br/>Typed subfolders Β· templates+active rendered]
    ROOT --> OUT[output<br/>Final deliverables Β· disposable]
    ROOT --> PYPROJ[pyproject.toml<br/>Root configuration]

    INFRA --> I_DOCS[AGENTS.md Β· README.md Β· SKILL.md]
    INFRA --> I_CFG[config<br/>.env.template Β· secure_config.yaml]
    INFRA --> I_DOCKER[docker<br/>Dockerfile Β· docker-compose.yml]
    INFRA --> I_MODULES[build_verifier.py Β· figure_manager.py Β· ...]

    DOCS --> D_FILES[AGENTS.md Β· README.md Β·<br/>CLOUD_DEPLOY.md Β· PAI.md Β· RUN_GUIDE.md]

    CUR --> C_FILES[.cursorrules Β· .cursorignore Β· README.md]

    SCR --> S_DOCS[AGENTS.md Β· README.md]
    SCR --> S_STAGES[scripts/pipeline/stage_00_setup.py<br/>stage_01_test.py<br/>stage_02_analysis.py<br/>stage_03_render.py<br/>stage_04_validate.py<br/>stage_05_copy.py]

    TS --> T_FILES[AGENTS.md Β· README.md Β· test_*.py]

    PR --> PR_CODE[template_code_project<br/>Optimization exemplar Β· active]
    PR --> PR_OTHER[&lt;name&gt;<br/>additional discovered projects]
    PR_CODE --> PRC_LAYOUT[src Β· tests Β· scripts Β·<br/>manuscript Β· output<br/>+ pyproject.toml]

    classDef root fill:#0f172a,stroke:#0f172a,color:#fff
    classDef l1 fill:#1e3a8a,stroke:#0f172a,color:#fff
    classDef l2 fill:#0f766e,stroke:#0f172a,color:#fff
    classDef gen fill:#7c2d12,stroke:#0f172a,color:#fff
    class ROOT,PYPROJ root
    class INFRA,DOCS,CUR,SCR,TS,I_DOCS,I_CFG,I_DOCKER,I_MODULES,D_FILES,C_FILES,S_DOCS,S_STAGES,T_FILES l1
    class PR,PR_CODE,PR_OTHER,PRC_LAYOUT l2
    class WIP,ARC,OUT gen

Documentation in each directory:

  • AGENTS.md - Detailed directory-specific documentation
  • README.md - Quick reference and navigation

Note on src/ directory:

  • Root src/ no longer exists (was empty shells)
  • All code is in infrastructure/ (generic) or projects/{name}/src/ (project-specific)
  • This separation enables reusability across projects

βš™οΈ Configuration System

Configuration File (Recommended)

The system supports configuration through a YAML file, providing a centralized, version-controllable way to manage all paper metadata.

Location: projects/{name}/manuscript/config.yaml Template: projects/{name}/manuscript/config.yaml.example

Example configuration:

paper:
  title: "Novel Optimization Framework"
  subtitle: ""  # Optional
  version: "1.0"

authors:
  - name: "Dr. Jane Smith"
    orcid: "0000-0000-0000-1234"
    email: "jane.smith@university.edu"
    affiliation: "University of Example"
    corresponding: true

publication:
  doi: "10.5281/zenodo.12345678"  # Optional
  journal: ""  # Optional
  volume: ""  # Optional
  pages: ""  # Optional

keywords:
  - "optimization"
  - "machine learning"

metadata:
  license: "Apache-2.0"
  language: "en"

# LLM Review Settings (optional)
llm:
  reviews:
    enabled: true
    types:
      - executive_summary  # Default: single review
      # Uncomment to enable additional reviews:
      # - quality_review
      # - methodology_review
      # - improvement_suggestions
  translations:
    enabled: true  # Set to false to disable translation generation
    languages:
      - zh  # Default: single translation (Chinese Simplified)
      # Uncomment to enable additional languages:
      # - hi  # Hindi
      # - ru  # Russian

Benefits:

  • βœ… Version controllable (can be committed to git)
  • βœ… Single file for all metadata
  • βœ… Supports multiple authors with affiliations
  • βœ… Structured format (YAML)
  • βœ… Easy to edit and maintain

Environment Variables (Alternative Method)

Environment variables are supported as an alternative configuration method and take precedence over config file values:

VariableDefaultDescription
AUTHOR_NAME"Project Author"Primary author name
AUTHOR_ORCID"0000-0000-0000-0000"Author ORCID identifier
AUTHOR_EMAIL"author@example.com"Author contact email
DOI""Digital Object Identifier (optional)
PROJECT_TITLE"Project Title"Project/research title
LOG_LEVEL1Logging verbosity (0=DEBUG, 1=INFO, 2=WARN, 3=ERROR)

Priority order:

  1. Environment variables (highest priority - override config file)
  2. Config file (projects/{name}/manuscript/config.yaml)
  3. Default values (lowest priority)

Configuration Examples

Using Configuration File (Recommended)

# Edit projects/{name}/manuscript/config.yaml with your information
vim projects/{name}/manuscript/config.yaml

# Build with config file values
uv run python scripts/pipeline/stage_03_render.py --project {name}

Using Environment Variables

export AUTHOR_NAME="Dr. Jane Smith"
export PROJECT_TITLE="Novel Optimization Framework"
export AUTHOR_EMAIL="jane.smith@university.edu"
export AUTHOR_ORCID="0000-0000-0000-1234"
export DOI="10.5281/zenodo.12345678"  # Optional

uv run python scripts/pipeline/stage_03_render.py

Verbose Logging

export LOG_LEVEL=0  # Show all debug messages
uv run python scripts/pipeline/stage_03_render.py

Runtime Configuration

Configuration is read at runtime by scripts/pipeline/stage_03_render.py and applied to:

  • PDF metadata (title, author, date)
  • LaTeX document properties
  • Generated file headers
  • Cross-reference systems
  • Title page generation

πŸš€ Rendering Pipeline

Pipeline Execution

The template provides three entry points for pipeline execution:

Main Entry Point (Recommended)

# Routes to manuscript operations
./run.sh

Manuscript Operations

# Interactive menu with manuscript operations
./run.sh

# Non-interactive: default full pipeline β€” 10 core+LLM stages; pipeline.yaml declares four additional opt-in ebook/metadata/bundle/archival stages. --core-only drops LLM and opt-in stages and leaves 8.
./run.sh --pipeline

LLM review stages use the local Ollama workflow documented in infrastructure/llm/README.md. Canonical smoke commands:

ollama serve
ollama pull gemma3:4b
uv run pytest tests/infra_tests/llm/ -m requires_ollama -v

Secure Pipeline (secure_run.sh)

Two steps: (1) Pipeline run β€” the same DAG as the normal pipeline through Python PipelineRunner / PipelineExecutor β€” not by shelling out to ./run.sh; (2) Steganography pass β€” run SteganographyProcessor on the resulting PDFs.

Pipeline run is skipped when --steganography-only. When the pipeline run executes, --project <name> is required (single project per invocation). For steganography-only with no --project, PDFs for all discovered projects are processed.

For argv shaping into the secure subcommand from the same thin shell as ./run.sh, use ./run.sh --secure-run (see run.sh). ./secure_run.sh always execs python -m infrastructure.orchestration secure and does not replicate the full interactive main menu by itself.

Steganography pass: post-processes PDFs (companion *_steganography.pdf, .hashes.json manifest). Original PDFs stay untouched.

# Interactive path that forwards to the secure subcommand (same orchestration CLI as ./run.sh)
./run.sh --secure-run

# Full pipeline + steganography for one project
./secure_run.sh --project template_code_project

# Core DAG only (no LLM stages) + steganography
./secure_run.sh --project template_code_project --core-only

# Re-process existing PDFs only (omit --project to cover every discovered project)
./secure_run.sh --steganography-only --project template_code_project

# Multi-project: run pipelines separately, then harden all PDFs without re-running pipelines
./secure_run.sh --steganography-only

Output files:

flowchart LR
    PDF[projects/&lt;name&gt;/output/pdf]
    PDF --> A[&lt;name&gt;_combined.pdf<br/>Standard output Β· untouched]
    PDF --> B[&lt;name&gt;_combined_steganography.pdf<br/>Steganographically hardened copy]
    PDF --> C[&lt;name&gt;_combined.hashes.json<br/>SHA-256/SHA-512 integrity manifest]

    classDef d fill:#0f172a,stroke:#0f172a,color:#fff
    classDef f fill:#0f766e,stroke:#0f172a,color:#fff
    class PDF d
    class A,B,C f

Steganographic techniques: diagonal watermark overlays, QR + barcode strips, PDF metadata/XMP injection, SHA-256/SHA-512 hash manifests, invisible text layers, optional AES-256 password encryption.

Configuration (infrastructure/config/secure_config.yaml):

Controls all steganography settings. Any steganography: block in a project's manuscript/config.yaml overrides these repo-level defaults. Key fields:

steganography:
  overlays_enabled: true       # Diagonal watermark
  barcodes_enabled: true       # QR + Code128 strip
  metadata_enabled: true       # PDF metadata + XMP
  hashing_enabled: true        # SHA-256/512 manifest
  encryption_enabled: false    # AES-256 password (set pdf_password to enable)
  overlay_mode: "text"         # "text" | "qr" | "none"
  overlay_text: "CONFIDENTIAL"
  overlay_opacity: 0.08        # 0.02 subtle β†’ 0.30 strong
  output_suffix: "_steganography"

See also: scripts/AGENTS.md Β· infrastructure/steganography/

Entry Point Comparison

  • ./run.sh: Main entry point β€” interactive menu or pipeline run. Bash progress: [0/9] clean, then [1/9]–[9/9] for nine tracked steps (labels from STAGE_NAMES, kept in sync with pipeline.yaml).
  • ./run.sh --pipeline: Non-interactive full DAG; optional LLM stages may skip if Ollama is unavailable.
  • ./run.sh --secure-run: Forwards to the secure orchestration subcommand (same Python CLI as bare ./run.sh; use when you want argv shaping from the main shell).
  • ./secure_run.sh: Ensures steganography extras (uv sync --group steganography), then python -m infrastructure.orchestration secure. --project is required when running the pipeline phase (omit only for --steganography-only across all projects). See Secure Pipeline above.
  • uv run python scripts/runner/execute_pipeline.py --project {name} --core-only: Core DAG only β€” 8 stages in default infrastructure/core/pipeline/pipeline.yaml (LLM-tagged stages excluded); no LLM dependencies.

Pipeline Stages

Full Pipeline Stages β€” the default pipeline.yaml declares 16 named stages: 8 core stages, 2 optional LLM stages, 2 opt-in ebook/metadata stages, 2 opt-in bundle/archival stages, and 2 opt-in science/provenance stages (Connector Search, Provenance Record). Default full runs include the 10 core+LLM stages (Clean Output Directories plus nine numbered stages). run.sh displays that default path as [0/9] for clean and [1/9]–[9/9] for the nine numbered stages. --core-only runs 8 stages by excluding LLM-tagged and opt-in stages.

  • [0/9] Clean Output Directories - Clean working and final output directories (pre-step)
  1. Environment Setup - Verify system requirements and dependencies
  2. Infrastructure Tests - Run the focused pipeline-smoke infrastructure contract (may be skipped; full coverage gate is explicit)
  3. Project Tests - Run project test suite (90% coverage minimum)
  4. Project Analysis - Execute projects/{name}/scripts/ analysis workflows
  5. PDF Rendering - Generate manuscript PDFs and figures
  6. Output Validation - Validate all generated outputs
  7. LLM Scientific Review - AI-powered manuscript analysis (optional, requires Ollama)
  8. LLM Translations - Multi-language technical abstract generation (optional, requires Ollama)
  9. Copy Outputs - Copy final deliverables to root output/ directory

Opt-in long-horizon stages (added 2026-05-20; NOT in default core or --core-only runs β€” enable via --tags ebook, --tags metadata, --tags bundle, or --tags archival):

  1. Ebook Generation (scripts/pipeline/stage_11_ebook.py, tag ebook) β€” Generate EPUB, MOBI, and DOCX ebooks from the combined markdown manuscript. Gracefully skips (exit 2) when the combined markdown is absent. Invoke: uv run python scripts/pipeline/stage_11_ebook.py --project <name>.
  2. Metadata Package (scripts/pipeline/stage_12_metadata.py, tag metadata) β€” Generate ONIX 3.0 XML, metadata.json, and OPF skeleton from manuscript/config.yaml. Gracefully skips (exit 2) when config.yaml is absent. Invoke: uv run python scripts/pipeline/stage_12_metadata.py --project <name>.
  3. Executable Bundle (scripts/runner/bundle_executable.py, tag bundle) β€” Produce a container + lockfile + agent-runnable manifest.json for the project, parallel to PDF as the durable artifact. Design: docs/maintenance/stage-10-executable-bundle.md.
  4. Archival Publication (scripts/runner/archive_publication.py, tag archival) β€” Mirror the executable bundle to multiple independent archival targets (Zenodo, Software Heritage, IPFS via Pinata/Web3.Storage). Defaults to dry-run; pass --commit to actually deposit. Design: docs/maintenance/archival-targets.md.

Infrastructure Tests Behavior:

  • Single project pipeline mode: Stage 2 runs scripts/pipeline/stage_01_test.py --infra-only --infra-scope pipeline-smoke, a focused real suite for DAG execution, advisory controls, evidence/profile/benchmark extension points, doc invariants, and tracked-artifact guards. This keeps project rebuilds fast without hiding the full repo gate.
  • Full infrastructure gate: Run uv run python scripts/pipeline/stage_01_test.py --infra-only --infra-scope full (or the direct pytest command in the verification guide) for the coverage-bearing repository suite.
  • Multi-project mode (--all-projects): Infrastructure tests run once for all projects at the start, then are skipped for individual project executions to avoid redundant testing. This is shown in logs as "Running infrastructure tests once for all projects..." followed by "Skipping stage: Infrastructure Tests" for each project.

Multi-Project Executive Reporting (--all-projects mode only):

  • Executive Reporting - Cross-project metrics, summaries, and visual dashboards (generated after all projects, not as a numbered stage)

Stage numbering (canonical phrasing β€” keep in sync with CLAUDE.md and README.md):

The default pipeline.yaml declares 16 named stages: 8 core stages, 2 optional LLM stages, 2 opt-in ebook/metadata stages, 2 opt-in bundle/archival stages, and 2 opt-in science/provenance stages (Connector Search, Provenance Record). Default full runs include the 10 core+LLM stages (Clean Output Directories plus nine numbered stages). --core-only runs 8 stages by excluding LLM-tagged and opt-in stages. Ebook, metadata, bundle, archival, science, and provenance stages are declared for contracts but invoked separately when needed (directly via their scripts/pipeline/stage_*.py entry points).

Manual Execution Options

Individual Stage Execution:

# Environment setup
uv run python scripts/pipeline/stage_00_setup.py --project {name}

# Test execution (combined infra + project)
uv run python scripts/pipeline/stage_01_test.py --project {name}

# Project analysis scripts
uv run python scripts/pipeline/stage_02_analysis.py --project {name}

# PDF rendering
uv run python scripts/pipeline/stage_03_render.py --project {name}

# Output validation
uv run python scripts/pipeline/stage_04_validate.py --project {name}

# Copy outputs
uv run python scripts/pipeline/stage_05_copy.py --project {name}

# LLM manuscript review (optional, requires Ollama)
uv run python scripts/pipeline/stage_06_llm_review.py --project {name}

# Generate executive report (multi-project only)
uv run python scripts/pipeline/stage_07_executive_report.py --project {name}

Validation Tools:

# Validate markdown files
uv run python -m infrastructure.validation.cli markdown projects/{name}/manuscript/

# Validate PDF outputs
uv run python -m infrastructure.validation.cli pdf output/{name}/pdf/{name}_combined.pdf

Validation Systems

PDF Validation

# Validate generated PDF for issues (per-project)
uv run python -m infrastructure.validation.cli pdf output/{name}/pdf/{name}_combined.pdf

# With verbose output
uv run python -m infrastructure.validation.cli pdf output/{name}/pdf/{name}_combined.pdf --verbose

# Specific PDF file
uv run python -m infrastructure.validation.cli pdf output/{name}/pdf/{name}_combined.pdf

Validation Checks:

  • Unresolved references (??)
  • Missing citations ([?])
  • LaTeX warnings and errors
  • Document structure integrity
  • Word count and content preview

Markdown Validation

# Validate all markdown files
uv run python -m infrastructure.validation.cli markdown projects/{name}/manuscript/

# Strict mode (fail on any issues)
uv run python -m infrastructure.validation.cli markdown projects/{name}/manuscript/ --strict

Validation Checks:

  • Image reference resolution
  • Cross-reference integrity
  • Equation label validation
  • Link formatting
  • Mathematical notation

Test Coverage

See docs/_generated/COUNTS.md for current status from live test runs.

# Run via orchestrator
uv run python scripts/pipeline/stage_01_test.py --project {name}

# Manual with reports
uv run pytest tests/infra_tests/ --cov=infrastructure --cov-report=html
uv run pytest projects/{name}/tests/ --cov=projects/{name}/src --cov-report=html

Requirements:

  • projects/{name}/src/ : 90% minimum (per-project standalone gate; exemplars meet it)
  • combined-union public-project gate (scripts/pipeline/stage_01_test.py --project-only --all-projects --public-projects, DEFAULT_FAIL_UNDER) : 75% β€” deliberately lower than the per-project floor because per-project suites only cover their own src/ while the union denominator spans the public exemplar source set. Local --all-projects without --public-projects still runs every discovered project, including rotating private symlinks. Per-project floors remain authoritative.
  • infrastructure/ : 60% minimum

Tests should use real data and computation. The lexical no-mocks gate and the semantic inventory are both enforced: dependency replacements must remain at zero, while environment/path isolation is classified separately and permitted.

Testing Framework

Mock-framework prohibition and semantic-stand-in inventory

CRITICAL REQUIREMENT: Do not introduce MagicMock, mocker.patch, unittest.mock, or another mocking framework. Prefer real data, local services, subprocesses, and dependency injection. The lexical CI gate proves only that prohibited framework imports/calls are absent; --inventory separately records environment isolation and existing monkeypatch.setattr/setitem dependency replacement.

uv run python scripts/audit/verify_no_mocks.py
uv run python scripts/audit/verify_no_mocks.py --inventory --max-dependency-replacements 0

This policy ensures:

  • Tests validate actual behavior, not mocked behavior
  • Integration points are truly tested
  • Code is tested in realistic conditions
  • No false confidence from mocked tests

No-Mocks Implementation Patterns

HTTP API Testing: Use pytest-httpserver for local test servers

# BEFORE (mocked)
with patch('requests.post') as mock_post:
    mock_post.return_value = MagicMock(status_code=200, json=lambda: {"result": "ok"})

# AFTER (HTTP)
def test_api_call(ollama_test_server):
    # ollama_test_server fixture provides HTTP server
    config = OllamaClientConfig(base_url=ollama_test_server.url_for("/"))
    client = LLMClient(config)
    response = client.query("test")  # HTTP request
    assert "response" in response.lower()

CLI Testing: Execute subprocess commands instead of mocking sys.argv

# BEFORE (mocked)
with patch('sys.argv', ['cli.py', 'validate', 'file.pdf']):
    cli.main()

# AFTER (subprocess)
result = subprocess.run(
    ['python', '-m', 'infrastructure.validation.cli', 'validate', 'file.pdf'],
    capture_output=True, text=True
)
assert result.returncode == 0

PDF Generation: Create PDFs with reportlab instead of mocking PDF libraries

# BEFORE (mocked)
with patch.dict('sys.modules', {'pdfplumber': mock_pdfplumber}):
    result = extract_text(pdf_file)

# AFTER (PDF)
from reportlab.pdfgen import canvas
c = canvas.Canvas(str(pdf_file))
c.drawString(100, 750, "Test content")
c.save()

result = extract_text(pdf_file)  # PDF processing
assert "Test content" in result

File System Operations: Use temp files and directories

# BEFORE (mocked)
with patch('builtins.open') as mock_open:
    mock_open.return_value.__enter__.return_value.read.return_value = "content"

# AFTER (files)
def test_file_operation(tmp_path):
    test_file = tmp_path / "test.txt"
    test_file.write_text("content")
    result = read_file(test_file)  # File operation
    assert result == "content"

External Tool Testing: Keep default tests deterministic; mark opt-in tool/credential tests or fail with setup guidance

# BEFORE (mocked subprocess)
with patch('subprocess.run') as mock_run:
    mock_run.return_value = MagicMock(returncode=0)

# AFTER (tool execution in an opt-in marker group)
@pytest.mark.requires_latex
def test_pandoc_conversion(tmp_path):
    pandoc = shutil.which('pandoc')
    assert pandoc, "Install pandoc before running requires_latex tests"
    md_file = tmp_path / "test.md"
    md_file.write_text("# Test")
    pdf_file = tmp_path / "test.pdf"

    result = subprocess.run([pandoc, str(md_file), '-o', str(pdf_file)])
    assert result.returncode == 0
    assert pdf_file.exists()

Test Structure

Tests follow the thin orchestrator pattern principles:

  • Import methods from projects/{name}/src/ or infrastructure/ modules
  • Use data and computation
  • Validate actual behavior; avoid adding semantic dependency replacements
  • Ensure reproducible, deterministic results

Test Categories

  1. Unit Tests (test_*.py) - Individual function validation
  2. Integration Tests - Script and pipeline integration
  3. Validation Tests - PDF and markdown quality checks

Running Tests

# All tests via orchestrator (recommended)
uv run python scripts/pipeline/stage_01_test.py

# Specific test file
uv run pytest projects/{name}/tests/test_example.py -v

# Infrastructure tests with coverage
uv run pytest tests/infra_tests/ --cov=infrastructure --cov-report=html

# Project tests with coverage
uv run pytest projects/{name}/tests/ --cov=projects/{name}/src --cov-report=html

πŸ“€ Output Formats

Generated Files Structure

flowchart TB
    OUT[output]
    OUT --> P[project<br/>Project-specific outputs]
    P --> PDF[pdf<br/>PDF documents]
    P --> TEX[tex<br/>LaTeX source files]
    P --> FIG[figures<br/>Generated figures]
    P --> DATA[data<br/>Generated datasets]
    P --> HTML[project_combined.html<br/>HTML version for IDE]

    PDF --> PDF_SECT[01_abstract.pdf Β· 02_introduction.pdf Β· ...]
    PDF --> PDF_COMB["{name}_combined.pdf<br/>Full manuscript"]

    TEX --> TEX_FILES[01_abstract.tex Β· project_combined.tex Β· ...]

    FIG --> FIG_FILES[example_figure.png Β· convergence_plot.png Β· ...]

    DATA --> DATA_FILES[example_data.csv Β· convergence_data.npz Β· ...]

    classDef d fill:#0f172a,stroke:#0f172a,color:#fff
    classDef f fill:#0f766e,stroke:#0f172a,color:#fff
    class OUT,P,PDF,TEX,FIG,DATA d
    class PDF_SECT,PDF_COMB,TEX_FILES,FIG_FILES,DATA_FILES,HTML f

PDF Versions

  1. Standard PDF ({project}_combined.pdf, e.g. template_code_project_combined.pdf)

    • Professional printing format
    • Optimized for LaTeX rendering
    • Cross-references and citations
  2. IDE-Friendly PDF (project_combined_ide_friendly.pdf)

    • for text editor viewing
    • Better font rendering in IDEs
    • Simplified layout for screen reading
  3. HTML Version (project_combined.html)

    • Web browser compatible
    • IDE integration
    • Interactive features (when available)

πŸ§ͺ Advanced Modules

The template includes reusable infrastructure modules for scientific development; see docs/modules/modules-guide.md and docs/_generated/COUNTS.md for the live module list and counts. Selected module examples:

πŸ”’ Core Utilities (infrastructure/core/)

Enterprise-grade security and system monitoring.

Key Features:

  • Input Sanitization: LLM prompt validation and threat detection
  • Security Monitoring: Security event tracking and alerting
  • Rate Limiting: Configurable request rate limiting with monitoring
  • Health Checks: System health monitoring with component-level status
  • Security Headers: HTTP security header implementation

Usage:

from infrastructure.llm.core.sanitization import sanitize_llm_input
from infrastructure.core.security import get_security_validator
from infrastructure.core import SystemHealthChecker

# Validate LLM input with security checks
sanitized = sanitize_llm_input(user_prompt)

# Perform system health check
checker = SystemHealthChecker()
if checker.is_healthy():
    status = checker.get_health_status()

πŸ” Validation System (infrastructure/validation/)

Comprehensive file integrity, manuscript structures, cross-references, and output validation.

Key Features:

  • File Integrity: Hash-based verification of output files
  • Cross-Reference Validation: LaTeX reference integrity checking
  • Data Consistency: Format and structure validation
  • Academic Standards: Compliance with writing standards
  • Build Artifact Verification: Output validation

Usage:

from infrastructure.validation.integrity import verify_output_integrity, generate_integrity_report

report = verify_output_integrity(output_dir)
print(generate_integrity_report(report))

πŸ”¬ Scientific Development (infrastructure/scientific/)

Scientific computing best practices and tools.

Modular Structure:

  • stability.py - Numerical stability checking
  • benchmarking.py - Performance benchmarking
  • documentation.py - API documentation generation
  • validation.py - Best practices validation
  • templates.py - Research workflow templates

Key Features:

  • Numerical Stability: Algorithm stability testing
  • Performance Benchmarking: Execution time and memory analysis
  • Scientific Documentation: API documentation generation
  • Best Practices Validation: Code quality assessment
  • Research Workflow Templates: Reproducible experiment templates

Usage:

from infrastructure.scientific import check_numerical_stability, benchmark_function

stability = check_numerical_stability(your_function, test_inputs)
benchmark = benchmark_function(your_function, test_inputs)

πŸ€– LLM Integration (infrastructure/llm/)

Local LLM assistance for research workflows.

Key Features:

  • Ollama Integration: Local model support (privacy-first)
  • Template System: Pre-built prompts for common research tasks
  • Context Management: Multi-turn conversation handling
  • Streaming Support: Response generation
  • Model Fallback: Automatic fallback to alternative models
  • Token Counting: Track usage and costs

Research Templates:

  • Abstract summarization
  • Code documentation
  • Data interpretation
  • Section drafting assistance
  • Citation formatting
  • Technical abstract translation (Chinese, Hindi, Russian)

Usage:

from infrastructure.llm import LLMClient

client = LLMClient()
summary = client.apply_template("summarize_abstract", text=abstract)
response = client.query("What are the key findings?")

🎨 Rendering System (infrastructure/rendering/)

Multi-format output generation from single source.

Key Features:

  • PDF Rendering: Professional LaTeX-based PDFs
  • Presentation Slides: Beamer (PDF) and reveal.js (HTML) slides
  • Web Output: Interactive HTML with MathJax
  • Scientific Posters: Large-format poster generation
  • Format-Agnostic: Single source, multiple outputs
  • Quality Validation: Automated output checking

Usage:

from infrastructure.rendering import RenderManager

manager = RenderManager()
pdf = manager.render_pdf("manuscript.tex")
slides = manager.render_slides("presentation.md", format="revealjs")
html = manager.render_web("manuscript.md")
all_outputs = manager.render_all("manuscript.md")

πŸš€ Publishing Module (infrastructure/publishing/)

Automated publishing to academic platforms.

Module Structure:

  • core.py - Publication metadata extraction, DOI validation, citation generation
  • api.py - Platform API clients (Zenodo, arXiv, GitHub)
  • citations.py - Citation helpers (BibTeX CLI target plus APA/MLA library helpers)
  • metadata.py - Publication metadata management
  • platforms.py - Platform-specific integration logic

Key Features:

  • Zenodo Integration: Upload with DOI minting
  • arXiv Preparation: Submission package creation
  • GitHub Releases: Automated release management
  • Metrics Tracking: Download and citation tracking
  • Distribution Packages: Publication bundles

Usage:

from infrastructure.publishing import (
    extract_publication_metadata,
    publish_to_zenodo,
    create_github_release,
    prepare_arxiv_submission
)

# Extract metadata
metadata = extract_publication_metadata([Path("manuscript.md")])

# Publish to Zenodo
result = publish_to_zenodo(metadata, files, token)
print(result.doi)

# Create GitHub release
release = create_github_release(metadata, files, token)

# Prepare arXiv submission
package = prepare_arxiv_submission(metadata, files)

Module Integration

All advanced modules follow the thin orchestrator pattern:

  • Business logic in infrastructure/ modules with test coverage
  • Orchestration in separate utility scripts
  • Integration with existing build pipeline
  • Testing ensuring reliability
  • Documentation for each module's functionality

Additional opt-in modules:

Testing Coverage: measured per module in docs/development/coverage-gaps.md; suite locations under tests/infra_tests/.

  • βœ… Security β€” tests/infra_tests/core/
  • βœ… Health Check β€” tests/infra_tests/core/
  • βœ… Input Sanitization β€” tests/infra_tests/llm/
  • βœ… Integrity β€” tests/infra_tests/validation/
  • βœ… Publishing β€” tests/infra_tests/publishing/
  • βœ… Scientific Dev β€” tests/infra_tests/scientific/
  • βœ… Build Verifier β€” tests/infra_tests/validation/
  • βœ… LLM Integration β€” tests/infra_tests/llm/ (measured coverage β†’ docs/development/coverage-gaps.md)
  • βœ… Rendering System β€” tests/infra_tests/rendering/ (measured coverage β†’ docs/development/coverage-gaps.md)
  • βœ… Reporting β€” tests/infra_tests/reporting/ (measured coverage β†’ docs/development/coverage-gaps.md)

Accessing Outputs

# Open combined PDF
open output/{name}/pdf/{name}_combined.pdf

# Open HTML version in browser
open output/{name}/{name}_combined.html

# List all generated files
ls -la output/{name}/

# Check PDF validation
uv run python -m infrastructure.validation.cli pdf output/{name}/pdf/{name}_combined.pdf

πŸ”§ Troubleshooting

Quick Reference

Common Issues

Tests Failing

# Ensure coverage requirements met for both suites
uv run python scripts/pipeline/stage_01_test.py

# Or run individually with coverage reports
uv run pytest tests/infra_tests/ --cov=infrastructure --cov-fail-under=60
uv run pytest projects/{name}/tests/ --cov=projects/{name}/src --cov-fail-under=90

Project Fails In --all-projects But Passes Standalone

A multi-project run (./run.sh --all-projects) executes projects sequentially over a long wall time; a project can fail there yet pass when re-run on its own. Triage:

# Re-run only the failed project (the multi-project summary prints this command)
./run.sh --project {name} --pipeline --core-only --skip-infra

# Or resume the whole run from the last good checkpoint
./run.sh --all-projects --pipeline --resume
  • FileNotFoundError: .../projects/{name}/.venv/bin/python at Project Tests β€” the project's .venv/ directory survived with a dangling bin/python symlink (its base interpreter was moved/removed, e.g. a relocated miniforge/uv install). The test runner now detects this via resolve_test_python() (infrastructure/core/runtime/_python_env.py): it only uses the project interpreter when that file actually exists and otherwise falls back to the workspace interpreter, so a stale .venv/ no longer crashes the stage. To remove the stale env entirely: rm -rf projects/{name}/.venv (it is regenerated on demand; the analysis stage uses uv run which self-heals it).
  • Transient Project Tests / PDF Rendering failures under load β€” flaky failures during a 38-min multi-project sweep that do not reproduce standalone. Confirm health directly: a project's own gate (projects/{name}/output/reports/test_results.json β†’ total_failed: 0) and render artifacts (projects/{name}/output/pdf/*_combined.pdf or output/{name}/pdf/*_combined.pdf present, with no ^! lines in adjacent .log files). If clean, re-run that single project.

validate_docs_and_figures.py exit 1 at Project Analysis (rotating project)

Some rotating/private projects ship a read-only self-validator. Its run-report, session, and output-link checks often assert a completed canonical run (run_all.py / later pipeline stages). Run as a plain analysis script it should treat not-yet-generated artifacts as non-blocking warnings; pass --strict to require the full canonical run as a hard gate. Keep project-specific artifact paths in the project docs, not in this root manual.

Scripts Failing

# Run scripts individually to debug
uv run python scripts/pipeline/stage_02_analysis.py --project {name}

# Check import errors
uv run python -c "import importlib; importlib.import_module('projects.{name}.src')"

PDF Generation Issues

# Check LaTeX installation
which xelatex

# Validate LaTeX packages (pre-flight check)
uv run python -m infrastructure.rendering.latex_package_validator

# Validate markdown first
uv run python -m infrastructure.validation.cli markdown projects/{name}/manuscript/

# Check compilation logs
ls projects/{name}/output/pdf/*_compile.log output/{name}/pdf/*_compile.log

Missing LaTeX Package Errors:

If you see "File *.sty not found" during PDF rendering:

  1. Identify the missing package from the error message

  2. Install via tlmgr (BasicTeX package manager):

    sudo tlmgr update --self
    sudo tlmgr install multirow cleveref doi newunicodechar
    
  3. Verify installation:

    /usr/local/texlive/2025basic/bin/universal-darwin/kpsewhich multirow.sty
    
  4. Run pre-flight validation:

    uv run python -m infrastructure.rendering.latex_package_validator
    

Common missing packages in BasicTeX:

  • multirow, cleveref, doi, newunicodechar - Require installation
  • bm, subcaption - Already included (part of tools and caption)

Alternative: Install full MacTeX (~4 GB) instead of BasicTeX (~100 MB):

brew install --cask mactex

Missing Dependencies

# Install system dependencies
# Ubuntu/Debian:
sudo apt-get install -y pandoc texlive-xetex texlive-fonts-recommended fonts-dejavu

# macOS (BasicTeX - minimal):
brew install pandoc
brew install --cask basictex
sudo tlmgr update --self
sudo tlmgr install multirow cleveref doi newunicodechar

# macOS (MacTeX):
brew install pandoc
brew install --cask mactex

Debug Mode

# Enable verbose logging
export LOG_LEVEL=0
uv run python scripts/pipeline/stage_03_render.py --project {name}

# Run with debug output
uv run python -m infrastructure.validation.cli pdf output/{name}/pdf/{name}_combined.pdf --verbose

Log Files

Key log files for debugging:

  • projects/{name}/output/pdf/*_compile.log - working LaTeX compilation logs
  • projects/{name}/output/pdf/_combined_manuscript.md - combined markdown source when retained by the renderer
  • output/{name}/pdf/ - final copied PDF deliverables
  • Test output from pytest runs

πŸ› οΈ Maintenance

System Updates

  1. Update Dependencies

    # Update Python packages
    uv sync
    
    # Update system packages
    sudo apt-get update && sudo apt-get upgrade
    
  2. Version Control

    # Check current status
    git status
    
    # Stage changes
    git add .
    
    # Commit with descriptive message
    git commit -m "feat: add validation feature"
    
  3. Backup Strategy

    # Clean outputs before backup
    uv run python -c "from pathlib import Path; from infrastructure.core.files import clean_output_directories; clean_output_directories(Path('.'), '{name}')"
    
    # Backup source files only
    tar -czf project_backup.tar.gz projects/{name}/src/ projects/{name}/tests/ projects/{name}/scripts/ projects/{name}/manuscript/ docs/
    

Adding Features

  1. Business Logic β†’ Add to projects/{name}/src/
  2. Tests β†’ Add to projects/{name}/tests/
  3. Scripts β†’ Add to projects/{name}/scripts/ (use projects/{name}/src/ methods)
  4. Documentation β†’ Update relevant .md files
  5. Validation β†’ Ensure coverage requirements met

Performance Optimization

  • Parallel Testing: Use pytest-xdist for faster test runs
  • Caching: Enable pytest caching for repeated runs
  • Incremental Builds: Only rebuild changed components
  • Performance Monitoring: Automatic bottleneck detection in pipeline summary
  • Resource Tracking: Memory and CPU usage reporting (when enabled)

See docs/operational/config/performance-optimization.md for optimization guide.

Checkpoint and Resume

The pipeline includes automatic checkpointing for resume capability:

# Resume from last checkpoint
uv run python scripts/runner/execute_pipeline.py --project {name} --core-only --resume
./run.sh --pipeline --resume

# Start fresh (clears checkpoint on success)
uv run python scripts/runner/execute_pipeline.py --project {name} --core-only
./run.sh --pipeline

Features:

  • Automatic checkpoint after each successful stage
  • Checkpoint validation before resume
  • Graceful handling of corrupted checkpoints
  • Preserves pipeline start time and stage durations

See docs/operational/config/checkpoint-resume.md for documentation.

πŸ“š References

Internal Documentation

External Resources

🎯 Best Practices

Development Workflow

  1. Write tests first (TDD)
  2. Ensure coverage requirements met
  3. Follow thin orchestrator pattern
  4. Validate all outputs
  5. Update documentation
  6. Commit with clear messages

Project Structure

  • Working outputs: projects/{name}/output/ (generated during pipeline)
  • Final deliverables: output/{name}/ (copied by stage 5)
  • Source code: projects/{name}/src/
  • Tests: projects/{name}/tests/
  • Scripts: projects/{name}/scripts/
  • Manuscript: projects/{name}/manuscript/

Code Quality

  • Type Hints: All public APIs must have type annotations
  • Documentation: Clear docstrings for all functions
  • Error Handling: Graceful failure with informative messages
  • Consistency: Follow established patterns and conventions

System Reliability

  • Deterministic Outputs: All generation must be reproducible
  • Validation: Check all aspects of output quality
  • Error Recovery: Handle failures gracefully with clear messages
  • Performance Monitoring: Track execution time and resource usage

βœ… System Status: OPERATIONAL

All systems confirmed functional with exemplar projects:

  • βœ… Multi-project pipeline: default 10-stage DAG in pipeline.yaml (including LLM stages) + optional executive reporting for --all-projects
  • βœ… Test coverage excellence: All active projects meet coverage requirements
  • βœ… Publication-quality outputs: Professional PDFs, cross-referenced manuscripts, automated figures
  • βœ… Mathematical rigor: Advanced equations, theorem proofs, convergence analysis
  • βœ… Testing: Edge cases, performance benchmarks, type safety validation
  • βœ… Documentation: AGENTS.md/README.md across all directories
  • βœ… Data testing: Zero mocks, integration testing
  • βœ… Infrastructure robustness: Fixed critical bugs, improved error handling

Environment Management:

  • βœ… Matplotlib auto-configuration (headless operation via MPLBACKEND=Agg)
  • βœ… Optional dependency handling (python-dotenv graceful fallback)
  • βœ… Test failure tolerance (MAX_TEST_FAILURES environment variable)
  • βœ… LaTeX path management (BasicTeX/MacTeX support)
  • βœ… Docker containerization (infrastructure/docker/Dockerfile + docker-compose.yml)

Modules (v2.1):

  • βœ… Security System (tests) - Input sanitization and monitoring
  • βœ… Health Check System (tests) - System health monitoring
  • βœ… Input Sanitization (tests) - LLM prompt validation
  • βœ… LLM Integration β€” tests in tests/infra_tests/llm/ (measured coverage β†’ docs/development/coverage-gaps.md)
  • βœ… Rendering System β€” tests in tests/infra_tests/rendering/ (measured coverage β†’ docs/development/coverage-gaps.md)
  • βœ… Publishing API (integrated) - Zenodo, arXiv, GitHub automation
  • βœ… Multi-project architecture (projects/{name}/ structure)

Audit Status:

  • βœ… High code coverage across infrastructure and project gates (live % β†’ docs/_generated/COUNTS.md, docs/development/coverage-gaps.md)
  • βœ… Zero mock methods - all tests use data and HTTP calls
  • βœ… All .cursorrules standards implemented
  • βœ… compliance with thin orchestrator pattern
  • βœ… Production-ready build pipeline (core pipeline + full pipeline with optional LLM stages)
  • βœ… Reproducible outputs (deterministic with fixed seeds)
  • βœ… Graceful degradation for optional features
  • βœ… Multi-project support (projects/{name}/ structure)
  • βœ… manuscript reference validation (all citations, figures, equations, sections resolved)
  • βœ… HTTP testing with pytest-httpserver (no mocks for API calls)
StageScriptTagsFailure mode
0 Clean Output Directoriesbuilt-in _run_clean_outputscore, cleansoft fail
1 Environment Setupscripts/pipeline/stage_00_setup.pycorehard fail
2 Infrastructure Testsscripts/pipeline/stage_01_test.py --infra-only --verbose --infra-scope pipeline-smokecore, testsconfigurable tolerance
3 Project Testsscripts/pipeline/stage_01_test.py --project-only --verbosecore, testsconfigurable tolerance
4 Project Analysisscripts/pipeline/stage_02_analysis.pycorehard fail
5 Connector Searchscripts/pipeline/stage_08_connector_search.pyscienceskipped if not configured
6 Provenance Recordscripts/pipeline/stage_09_provenance_record.py --stage Connector Searchprovenanceskipped if not configured
7 PDF Renderingscripts/pipeline/stage_03_render.pycorehard fail
8 Output Validationscripts/pipeline/stage_04_validate.pycorePDF/bookends and artifact/provenance failures block; optional-format structure remains a warning + report
9 LLM Scientific Reviewscripts/pipeline/stage_06_llm_review.py --reviews-onlyllmskipped if Ollama absent
10 LLM Translationsscripts/pipeline/stage_06_llm_review.py --translations-onlyllmskipped if Ollama absent
11 Copy Outputsscripts/pipeline/stage_05_copy.pycoresoft fail
12 Ebook Generationscripts/pipeline/stage_11_ebook.pycore, ebooksoft fail
13 Metadata Packagescripts/pipeline/stage_12_metadata.pycore, metadatasoft fail
14 Executable Bundlescripts/runner/bundle_executable.pybundlesoft fail
15 Archival Publicationscripts/runner/archive_publication.pyarchivalsoft fail

Directory & sub-document map

Navigation links to in-tree documents (keeps them discoverable):

Repository README

Describes docxology/template as a whole, which may contain artifacts other than this one. Where this artifact had no useful description of its own, its summary was taken from here.

πŸš€ Research Project Template

Build Coverage Tests Documentation DOI

πŸ“„ Published: A template/ approach to Reproducible Generative Research: Architecture and Ergonomics from Configuration through Publication β€” DOI: 10.5281/zenodo.19139090

Template Repository - Click "Use this template" to create a research project with this structure

Quickstart

Just cloned the repo? Do this:

  1. git clone <this-repo> && cd template
  2. uv sync (installs the root environment, including deterministic dependencies for all public template exemplars)
  3. ./run.sh (interactive menu) or ./run.sh --pipeline --project templates/template_code_project --core-only (non-interactive, no LLM)
  4. PDFs land in output/templates/<project>/pdf/. Logs in output/templates/<project>/logs/.
  5. Run ./run.sh --help for all flags. The always-present roster is generated from PUBLIC_PROJECT_NAMES in docs/_generated/active_projects.md.

Repurposing for your research? See docs/repurposing-architectures.md β€” maps every reusable architecture (DAG pipeline, two-layer separation, evidence registry, multi-format rendering, MCP server, publishing stack) to its module and adoption path.

For deeper guidance see docs/guides/getting-started.md and docs/RUN_GUIDE.md.

Thin-orchestrator gates: uv run python scripts/audit/check_template_drift.py --strict, uv run python scripts/gates/module_line_count_check.py, uv run python -m infrastructure.core.health β€” details in docs/architecture/thin-orchestrator-summary.md.

Assistants and editors: .cursorrules summarizes architecture and tooling for Cursor; CLAUDE.md is the command cheat sheet; AGENTS.md is the full system manual (pipeline, validation, configuration). For routable agent workflows, start at docs/prompts/SKILL.md and the generated skill index docs/_generated/skills_index.md.

Contributors and CI: GitHub Actions, Dependabot, and PR/issue templates live under .github/README.md (agent entry point, doc map, CI inventory) and .github/AGENTS.md (job names, thresholds, troubleshooting).

Local hooks: After uv sync, run pre-commit install and pre-commit install --hook-type pre-push to mirror Ruff, mypy, Bandit, and smoke tests locally (see .pre-commit-config.yaml).

Strict Mermaid/PDF checks: Run npm ci at the repository root. The Python documentation and rendering gates automatically resolve the pinned node_modules/.bin/mmdc; add that directory to PATH only when invoking mmdc directly. The existing Chrome resolver supplies the browser executable.

A system for research and development projects. This template provides a test-driven structure with automated PDF generation, professional documentation, and validated build pipelines.

🧭 Positioning (honest framing)

This is primarily Daniel Ari Friedman's research operating system, made public and Apache 2.0-licensed so other researchers can fork it if helpful. It is not a one-size-fits-all template β€” it is opinionated, Python+pytest+LaTeX-flavored, and tuned to the kind of work Daniel does (Active Inference, computational biology, cognitive security). Honest framing ages better than wishful adoption metrics.

If your workflow looks similar (TDD-on-research-code, Markdown→PDF, multi-project monorepo, optional local-LLM draft assistance, deterministic + watermarked outputs, Zenodo DOI publishing), the template will probably save you time. If it doesn't look similar, a lighter alternative (Quarto, MyST, Cookiecutter-data-science) may serve you better. See MAINTAINERS.md for ownership and STATUS.md for per-subsystem freshness so you can judge what's actively maintained vs dormant.

Long-horizon viability guides β€” toolchain migration, regression testing, archival redundancy, local CI, and the design for a future executable-bundle stage β€” live in docs/maintenance/.

🎯 What This Template Provides

This is a GitHub Template Repository that gives you:

  • βœ… Multi-project support - Run multiple projects in one repository
  • βœ… Project structure with clear separation of concerns
  • βœ… Test-driven development setup with coverage requirements
  • βœ… Automated PDF generation from markdown sources
  • βœ… Thin orchestrator pattern for maintainable code
  • βœ… Methods orchestration linking pipeline contracts, methods prose, artifacts, and evidence
  • βœ… Executable methods contracts with DAG, script, artifact, and verification validation
  • βœ… Bounded parallel quick testing with isolated project processes and serial oracles
  • βœ… Public exemplar capability inventory covering structure and declared skip reasons
  • βœ… Ready-to-use utilities for any research project
  • βœ… Professional documentation structure (full inventory: docs/documentation-index.md)
  • βœ… Advanced quality analysis and document metrics
  • βœ… Reproducibility tools for scientific workflows
  • βœ… Integrity verification and validation
  • βœ… Publishing tools for academic dissemination
  • βœ… Scientific development best practices
  • βœ… Reporting with error aggregation and performance metrics
  • βœ… Local Ollama workflow documented in infrastructure/llm/README.md and docs/operational/troubleshooting/llm-review.md

πŸ—ΊοΈ Choose Your Path

Pick the entry point that matches your goal:

🧭 Documentation Hub

πŸ“š Documentation Index | πŸ“– Documentation Guide | πŸ” Quick Reference

The template ships with a large documentation corpus under docs/. The full hierarchical map (with mermaid diagram) lives in docs/AGENTS.md; the authoritative per-file index lives in docs/documentation-index.md (rely on that index, not a hard-coded file count, which drifts). Top-level layout:

  • docs/core/ β€” essential reading: how-to-use, architecture, workflow
  • docs/guides/ β€” progressive walkthroughs by skill level (1–12)
  • docs/operational/ β€” build, configuration, troubleshooting, performance
  • docs/reference/ β€” FAQ, cheatsheet, common workflows, API reference
  • docs/architecture/ β€” two-layer architecture, thin orchestrator, decision tree
  • docs/usage/ β€” examples, showcase, markdown writing guide
  • docs/modules/ β€” module-by-module guides
  • docs/development/ β€” contributing, testing, roadmap

πŸ€– Agentic operation and SKILLS

Agents should load the smallest applicable workflow before editing. The routing surface is first-class and available via two skill discovery channels:

Hermes / agentskills.io project-local skills

Every canonical exemplar under projects/templates/ now ships its own .agents/skills/<name>/SKILL.md with YAML frontmatter discoverable by Hermes and agentskills.io runtimes. Each skill captures when to use, quick reference (pytest / analysis / render commands), pitfalls, and cross-refs for that template. Load the skill by its name (e.g. template-code-project, template-active-inference) when working inside that exemplar.

SkillTemplateWhen to load
template-active-inferencetemplate_active_inferenceUse this template when several independent research tracks must compose into one manuscript whose claims stay consistent where the tracks overlap β€” here: a closed-form analytical oracle, a pymdp simulation harness, a Lean formalization boundary, and shared GNN/ontology notation.
template-advanced-literature-reviewtemplate_advanced_literature_reviewUse this template when one review question needs distinct retrieval phases, phase-specific filters, and explicit cross-phase provenance.
template-autoresearch-projecttemplate_autoresearch_projectUse this template when you need a bounded, offline AutoResearch loop: deterministic ML candidate evaluation over a fixed local dataset, with evidence-linked claims, machine-readable ledgers, artifact-integrity manifests, and deferred human-review gates.
template-autopoiesistemplate_autopoiesisUse this template when you need to generate runnable project trees deterministically β€” not a manuscript, but a whole child project (its own src/, tests/, scripts/, and manuscript/) selected by a seed from a combinatoric grammar, with recompute-based provenance verification and a falsifiable honesty manifest against green-by-construction test theater.
template-code-projecttemplate_code_projectUse this template for code-driven computational research: algorithms in src/, numerical experiments with deterministic seeds, automated publication-quality figures, and a manuscript that reports the computed results.
template-data-descriptortemplate_data_descriptorUse this template when the contribution is a published dataset or data paper: a schema contract, file inventory, data dictionary, provenance chain, license boundary, quality checks, and machine-readable descriptor must all stay consistent before publication.
template-eda-notebooktemplate_eda_notebookUse this template for exploratory data analysis on tabular data: load a dataset, surface missingness, compute descriptive statistics and per-group means, rank features by correlation, and produce a few diagnostic figures.
template-formaltemplate_formalUse this template when the research subject is the type architecture itself: illegal-state-unrepresentable design, session-typed protocols, affine/linear resource-handle discipline, or a decentralized (no-shared-global-state) multiagent simulation that needs its own local storage and local networking per agent.
template-literature-meta-analysistemplate_literature_meta_analysisUse it whenever the research object is a body of literature about a topic and you want every reported number to trace to committed, regenerable artifacts.
template-madlibtemplate_madlibUse this template when you need configuration-driven manuscript generation with auditable token provenance, conditional section structure, explicit/default field visibility, failure-boundary reporting, and a reviewer-visible authoring contract: lexicon categories, section titles, narrative moves, method steps, design principles, pipeline phases, evaluation criteria, QA probes, failure modes, authoring obligations, visualization controls, audit rules, and slots are declared in YAML; src/ deterministically expands those declarations; and the manuscript receives large-grain {{TOKEN}} bodies only after the source code has generated the supporting artifacts.
template-newspapertemplate_newspaperUse this template when you need data-driven, large-format print layout: multi-page broadsheets/tabloids with precise column geometry, typography-first constraints, and strict content/engine separation (YAML editions in content/, pure-Python ReportLab engine in src/).
template-pools-rules-toolstemplate_pools_rules_toolsUse this project when you need to: - Demonstrate how a research project integrates multiple resource directories (fonds, tools, rules) in a single pipeline - Validate that your fonds, tools, and rule infrastructure modules are correctly wired and discoverable - Onboard new teams to the three-resource architecture with a concrete, runnable example - Test cross-cutting concern integration where fonds supply data, rules govern validation, and tools execute transforms - Extend the architecture by adding new resource types; copy this project as a starting point for integration testing This template is ideal for platform teams, CI engineers, and infrastructure maintainers who need a self-validating meta-project that exercises all three resource layers without coupling to a specific domain science.
template-prose-projecttemplate_prose_projectUse this template for manuscript-focused editorial pipelines: readability gates (Flesch-Kincaid bands), structural checking, citation/BibTeX validation, and prose-quality review workflows where the document itself is the artifact under test.
template-autoscientiststemplate_autoscientistsUse this template when you need to isolate and measure agent-coordination mechanisms: coordinated teams vs single-thread baselines under matched budgets, deterministic ablation studies, and honest per-mechanism effect reporting (including nulls).
template-gold-refinementtemplate_gold_refinementUse 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.
template-methods-papertemplate_methods_paperUse this template when the paper you are writing describes a methodology rather than reports results: a procedure, protocol, or specification language, where the contribution is the controlled vocabulary and its guarantees (dimensional safety, staged validation, deterministic compilation) rather than a numeric outcome.
template-redacted-reporttemplate_redacted_reportUse this template when a report needs formal redaction before release: classification ceilings, source-control markings, redaction decisions, authority review, reviewer approvals, source-safe hash ledgers, residual-risk checks, mosaic-risk checks, and a public audit packet must be validated before any sanitized narrative is published.
template-registered-reporttemplate_registered_reportUse this template when the core method is a registered report or preregistered replication: hypotheses, outcomes, exclusion rules, analysis plan, power or sensitivity rationale, deviation ledger, and confirmatory-versus-exploratory claim boundaries must be locked before results are interpreted.
template-search-projecttemplate_search_projectUse this template for literature-review and evidence-synthesis pipelines: multi-backend search (arXiv, Crossref, local corpora, optional Paperclip), deduplication, BibTeX generation, and LLM-assisted per-paper and corpus-level synthesis.
template-siatemplate_siaUse this template when you need a self-improvement-agent evaluation harness: Meta β†’ Target β†’ Feedback generation loops, public/private task splits to detect overfitting, deterministic fixture replay for testability, and fail-closed loop validation.
template-storybooktemplate_storybookUse this template when you need full-page illustrated PDF storytelling: picture-book pages, symbolic scenes, character-generation methods, page-level orchestrators, and deterministic raster art assembled into a print-ready PDF.
template-templatetemplate_templateUse this template when your research subject is the repository itself β€” programmatic introspection of architecture, pipeline DAGs, module inventories, and security layers, rendered as a manuscript whose every metric is computed live (autopoietic: the paper regenerates itself from the code it describes).
template-textbooktemplate_textbookUse this template for book-length manuscripts: parts β†’ chapters β†’ labs β†’ question banks declared in a single config.yaml, with auto-numbering, deterministic figure/diagram generation, and structural-contract tests that keep hundreds of pages from drifting.
template-pitch-decktemplate_pitch_deckUse this template when you need a pitch, grant report, or recurring stakeholder update treated as a build artifact β€” bound to live repository facts, validated for unresolved tokens and pitch-deck clichΓ©, and regenerable byte-for-byte from source rather than hand-maintained in a proprietary slide tool.

Generated infrastructure skills

In addition to the project-local skills, the repo generates infrastructure-level SKILL.md files from live discovery:

  • Shared context-engineering skills: .agents/skills/ carries a pinned, provenance-checked Agent Skills collection discoverable by Codex/OpenAI and Hermes-compatible runtimes. Use uv run python -m infrastructure.skills runtime-status to audit Codex, Claude Code, and Hermes parity, or ... runtime-install to create reversible user-level links from the pinned shared store.
  • Workflow router: docs/prompts/SKILL.md (template-workflows) routes broad requests such as full audits, pipeline debugging, code changes, tests, validation, manuscript work, and release checks to exactly one child workflow.
  • Agentic-use hardening: docs/prompts/agentic-use/SKILL.md covers skill inventory, routing checks, .cursor/skill_manifest.json, and generated skill-index maintenance.
  • Infrastructure module skills: infrastructure/SKILL.md is the Layer-1 hub; pair the relevant infrastructure/<module>/SKILL.md with that module's AGENTS.md before editing code.
  • Script and resource-pool skills: scripts/*/SKILL.md files and public fonds/templates/, rules/templates/, and tools/templates/ skills are included when present, without scanning private lifecycle roots.
  • Human skill index: docs/_generated/skills_index.md lists all discovered skills. Regenerate after skill changes with uv run python -m infrastructure.skills write-index; refresh the editor manifest with uv run python -m infrastructure.skills write; verify both with uv run python -m infrastructure.skills check and uv run python -m infrastructure.skills check-contracts. The same inventory is returned by the opt-in stdio MCP server's list_skills tool via uv run python -m infrastructure.mcp_server.

πŸ”€ Multi-Project Support

The repo can host multiple research projects in parallel. Each project owns its own src/, tests/, manuscript/, scripts/, and output/ directory under projects/<name>/. Layer-1 infrastructure is shared.

Permanent canonical exemplars β€” always present and tracked in git:

ExemplarWhen to use
template_active_inferenceUse this template when several independent research tracks must compose into one manuscript whose claims stay consistent where the tracks overlap β€” here: a closed-form analytical oracle, a pymdp simulation harness, a Lean formalization boundary, and shared GNN/ontology notation.
template_advanced_literature_reviewUse this template when one review question needs distinct retrieval phases, phase-specific filters, and explicit cross-phase provenance.
template_autoresearch_projectUse this template when you need a bounded, offline AutoResearch loop: deterministic ML candidate evaluation over a fixed local dataset, with evidence-linked claims, machine-readable ledgers, artifact-integrity manifests, and deferred human-review gates.
template_autopoiesisUse this template when you need to generate runnable project trees deterministically β€” not a manuscript, but a whole child project (its own src/, tests/, scripts/, and manuscript/) selected by a seed from a combinatoric grammar, with recompute-based provenance verification and a falsifiable honesty manifest against green-by-construction test theater.
template_code_projectUse this template for code-driven computational research: algorithms in src/, numerical experiments with deterministic seeds, automated publication-quality figures, and a manuscript that reports the computed results.
template_data_descriptorUse this template when the contribution is a published dataset or data paper: a schema contract, file inventory, data dictionary, provenance chain, license boundary, quality checks, and machine-readable descriptor must all stay consistent before publication.
template_eda_notebookUse this template for exploratory data analysis on tabular data: load a dataset, surface missingness, compute descriptive statistics and per-group means, rank features by correlation, and produce a few diagnostic figures.
template_formalUse this template when the research subject is the type architecture itself: illegal-state-unrepresentable design, session-typed protocols, affine/linear resource-handle discipline, or a decentralized (no-shared-global-state) multiagent simulation that needs its own local storage and local networking per agent.
template_literature_meta_analysisUse it whenever the research object is a body of literature about a topic and you want every reported number to trace to committed, regenerable artifacts.
template_madlibUse this template when you need configuration-driven manuscript generation with auditable token provenance, conditional section structure, explicit/default field visibility, failure-boundary reporting, and a reviewer-visible authoring contract: lexicon categories, section titles, narrative moves, method steps, design principles, pipeline phases, evaluation criteria, QA probes, failure modes, authoring obligations, visualization controls, audit rules, and slots are declared in YAML; src/ deterministically expands those declarations; and the manuscript receives large-grain {{TOKEN}} bodies only after the source code has generated the supporting artifacts.
template_newspaperUse this template when you need data-driven, large-format print layout: multi-page broadsheets/tabloids with precise column geometry, typography-first constraints, and strict content/engine separation (YAML editions in content/, pure-Python ReportLab engine in src/).
template_pools_rules_toolsUse this project when you need to: - Demonstrate how a research project integrates multiple resource directories (fonds, tools, rules) in a single pipeline - Validate that your fonds, tools, and rule infrastructure modules are correctly wired and discoverable - Onboard new teams to the three-resource architecture with a concrete, runnable example - Test cross-cutting concern integration where fonds supply data, rules govern validation, and tools execute transforms - Extend the architecture by adding new resource types; copy this project as a starting point for integration testing This template is ideal for platform teams, CI engineers, and infrastructure maintainers who need a self-validating meta-project that exercises all three resource layers without coupling to a specific domain science.
template_prose_projectUse this template for manuscript-focused editorial pipelines: readability gates (Flesch-Kincaid bands), structural checking, citation/BibTeX validation, and prose-quality review workflows where the document itself is the artifact under test.
template_autoscientistsUse this template when you need to isolate and measure agent-coordination mechanisms: coordinated teams vs single-thread baselines under matched budgets, deterministic ablation studies, and honest per-mechanism effect reporting (including nulls).
template_gold_refinementUse 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.
template_methods_paperUse this template when the paper you are writing describes a methodology rather than reports results: a procedure, protocol, or specification language, where the contribution is the controlled vocabulary and its guarantees (dimensional safety, staged validation, deterministic compilation) rather than a numeric outcome.
template_redacted_reportUse this template when a report needs formal redaction before release: classification ceilings, source-control markings, redaction decisions, authority review, reviewer approvals, source-safe hash ledgers, residual-risk checks, mosaic-risk checks, and a public audit packet must be validated before any sanitized narrative is published.
template_registered_reportUse this template when the core method is a registered report or preregistered replication: hypotheses, outcomes, exclusion rules, analysis plan, power or sensitivity rationale, deviation ledger, and confirmatory-versus-exploratory claim boundaries must be locked before results are interpreted.
template_search_projectUse this template for literature-review and evidence-synthesis pipelines: multi-backend search (arXiv, Crossref, local corpora, optional Paperclip), deduplication, BibTeX generation, and LLM-assisted per-paper and corpus-level synthesis.
template_siaUse this template when you need a self-improvement-agent evaluation harness: Meta β†’ Target β†’ Feedback generation loops, public/private task splits to detect overfitting, deterministic fixture replay for testability, and fail-closed loop validation.
template_storybookUse this template when you need full-page illustrated PDF storytelling: picture-book pages, symbolic scenes, character-generation methods, page-level orchestrators, and deterministic raster art assembled into a print-ready PDF.
template_templateUse this template when your research subject is the repository itself β€” programmatic introspection of architecture, pipeline DAGs, module inventories, and security layers, rendered as a manuscript whose every metric is computed live (autopoietic: the paper regenerates itself from the code it describes).
template_textbookUse this template for book-length manuscripts: parts β†’ chapters β†’ labs β†’ question banks declared in a single config.yaml, with auto-numbering, deterministic figure/diagram generation, and structural-contract tests that keep hundreds of pages from drifting.
template_pitch_deckUse this template when you need a pitch, grant report, or recurring stakeholder update treated as a build artifact β€” bound to live repository facts, validated for unresolved tokens and pitch-deck clichΓ©, and regenerable byte-for-byte from source rather than hand-maintained in a proprietary slide tool.

Test and coverage figures are representative; confirm against docs/_generated/COUNTS.md after substantive changes.

Choosing an exemplar: every exemplar README opens with a ## When to use this template section, and the generated differentiation map in docs/_generated/exemplar_roster.md collects them into one "copy THIS when…" table (regenerate with uv run python scripts/docgen/exemplar_roster.py; sync is test-enforced).

The permanent exemplars share the same core layout and verification checklist. The code/prose exemplars also carry the 12-file project docs/ hub (agent_instructions.md, style_guide.md, syntax_guide.md, testing_philosophy.md, rendering_pipeline.md, faq.md, quickstart.md, output_conventions.md, troubleshooting.md, architecture.md, AGENTS.md, README.md). New projects copy whichever exemplar is closest in shape and adjust from there. See projects/AGENTS.md for the full comparison.

Publication metadata for every public exemplar is generated from project config and sidecars into docs/_generated/publication_records.md, and the GitHub-facing table in .github/README.md is auto-injected from that same source. To publish a project modularly, start with the Publication runbook: it covers the standalone public GitHub mirror, first real Zenodo DOI, new-version releases, optional mirrors, status blocks, and archival handoff.

Public Exemplar Outputs And Mirrors

Every canonical exemplar under projects/templates/ is tracked in this monorepo, including its project-local output/ tree. The copied release artifacts under output/templates/<name>/ are tracked as well, so a clone of docxology/template contains both the source and the latest rendered public artifacts. Public output files above 50 MB remain excluded by the generated-artifact guard; private or rotating project outputs remain blocked.

Each exemplar also has a standalone docxology/template_* GitHub repository linked to its Zenodo concept and latest version DOI. The current matrix is docs/_generated/publication_records.md. The standalone repository must exist before scripts/publish/publish_project_release.py can create a release there; the release script publishes the GitHub release asset and Zenodo deposit, but it does not create the repository itself. To regenerate any exemplar from the monorepo:

git clone https://github.com/docxology/template
cd template
uv sync
./run.sh --project templates/template_code_project --pipeline --core-only
uv run python scripts/pipeline/stage_04_validate.py --project templates/template_code_project
uv run python scripts/pipeline/stage_05_copy.py --project templates/template_code_project

Replace template_code_project with any public exemplar name from the table above. The standalone repositories are publication mirrors; use this monorepo when you need the shared infrastructure, full render pipeline, or cross-template validation.

The canonical exemplars also ship project-local composability overlays: domain_profile.yaml declares review gates, source policy, artifact expectations, and benchmark rubric preferences; experiment_plan.yaml declares design-validation conditions, primary metric direction, expected figures/tables, baselines, and ablations. These files are declarative inputs for validation and benchmark tooling; they do not generate experiments or run autonomous agents.

πŸ”’ Confidentiality. This is a public template repo. Only the canonical exemplars above (under projects/templates/) are git-tracked/pushed β€” .gitignore ignores projects/* and negates only projects/templates/. Any other project you add under projects/ (research, client, or confidential work) stays local-only and is never committed; scripts/audit/check_tracked_all.py blocks any accidental commit in the pre-push hook and CI.

Private lifecycle projects. In Daniel's working checkout, confidential projects live outside this public repo at $TEMPLATE_PRIVATE_PROJECTS_ROOT. The simplified sidecar uses working/ and archive/; optional ongoing/ (long-lived projects with no publication target) plus legacy active/, published/, and other/ folders are still supported when present. run.sh and python -m infrastructure.orchestration auto-sync existing folders into matching typed subfolders under projects/: working/* into projects/working/*, ongoing/* into projects/ongoing/*, archive/* into projects/archive/*, and optional active/* into projects/active/*. templates/ and optional active/ links behave like native rendered entries; working/, ongoing/, and archive/ links are visible for explicit targeted work but are not default-rendered. Inspect without changing the tree: uv run python -m infrastructure.orchestration link-projects --dry-run. Override the sibling path with TEMPLATE_PRIVATE_PROJECTS_ROOT or .private_projects_root; disable auto-sync with TEMPLATE_SKIP_LINK_SYNC=1. The symlinked project keeps working outputs at projects/<subfolder>/<name>/output/ (the private target), while final deliverables still copy to output/<subfolder>/<name>/ in this template checkout.

Other entries rotate between projects/working/ and projects/archive/ as work progresses. Never hard-code their paths in long-lived docs β€” consult docs/_generated/active_projects.md (authoritative public scope, regenerated from infrastructure.project.public_scope) and docs/_generated/COUNTS.md instead.

Common commands:

./run.sh                                     # Interactive project selection
./run.sh --project templates/template_code_project --pipeline
./run.sh --all-projects --pipeline           # All discovered projects sequentially
./secure_run.sh --steganography-only --project templates/template_code_project  # Re-watermark PDFs
mkdir -p projects/my_research/{src,tests,manuscript,scripts}  # Scaffold new project

Lifecycle: rendered = projects/templates/ plus optional projects/active/ (discovered, executed). The simplified private sidecar normally uses working/ and archive/ (plus optional ongoing/ for long-lived work with no publication target); render sidecar projects explicitly with a qualified name such as working/{name} or ongoing/{name}. See projects/PROJECTS_PARADIGM.md for lifecycle, slug rules, and discovery semantics.

πŸš€ Quick Start {#quick-start}

See the Quickstart at the top of this file for the canonical clone-to-PDF flow. For headless cloud deployment use docs/CLOUD_DEPLOY.md (uv is installed automatically when you run ./run.sh --pipeline). Beginner walkthrough: docs/guides/getting-started.md. One-page command reference: docs/reference/quick-start-cheatsheet.md. Twelve-level usage guide: docs/core/how-to-use.md.

System Status

Current state is captured in docs/_generated/COUNTS.md (updated from discovery, test runs, and CI configuration).

Key elements:

  • Active projects listed via discover_projects()
  • Coverage enforced at 60% (infrastructure) and 90% (projects)
  • Tests run with real data and computations
  • Commands standardized to uv run
  • Outputs organized per project under output/{name}/

See docs/_generated/COUNTS.md and docs/development/testing/testing-guide.md for details.

πŸŽ“ Skill-Based Learning Paths

Twelve progressive levels β€” Document Creation (1–3), Figures & Automation (4–6), Test-Driven Development (7–9), System Architecture (10–12) β€” are documented end-to-end in docs/core/how-to-use.md. Per-band walkthroughs: docs/guides/getting-started.md, docs/guides/figures-and-analysis.md, docs/guides/testing-and-reproducibility.md, docs/guides/extending-and-automation.md.

πŸ—οΈ Project Structure

Two-layer architecture:

  • Layer 1 β€” infrastructure/ (generic, reusable): build, validation, rendering, LLM, publishing, etc. Plus scripts/ (entry-point orchestrators) and tests/ (infrastructure tests, β‰₯60 % coverage).
  • Layer 2 β€” projects/<name>/ (project-specific, customizable): src/ (algorithms, β‰₯90 % coverage), tests/, scripts/ (thin orchestrators), manuscript/ (markdown sections + config.yaml).
  • Output is generated under each exemplar's project-local projects/templates/<name>/output/ tree. Final deterministic evidence (publication PDFs, figures, analysis data, hydrated manuscripts, and release/validation registries) may be tracked for public exemplars; checkpoints, logs, telemetry, pipeline snapshots, and LaTeX/slide build intermediates are disposable, ignored, and regeneratable.
  • Docs live under docs/ (full hierarchy in docs/AGENTS.md); per-directory AGENTS.md files document every leaf.

System Architecture Overview

A short summary lives here; full architecture diagrams (system overview, module-dependency graph, per-stage data flow, configuration-system flow) are maintained in AGENTS.md and docs/core/architecture.md. In short:

  • Entry points: ./run.sh (interactive or --pipeline) and uv run python scripts/runner/execute_pipeline.py --project <name> [--core-only]; numbered orchestrators under scripts/ include 00_*.py through 07_*.py (setup β†’ copy, LLM, executive report β€” see scripts/AGENTS.md).
  • Orchestration: the pipeline runs Setup β†’ Tests β†’ Analysis β†’ Render β†’ Validate β†’ Copy, with optional LLM Review and LLM Translations stages.
  • Core systems: importable infrastructure/ packages (Layer 1; live list in docs/_generated/COUNTS.md) plus per-project projects/{name}/src/ algorithms (Layer 2); see docs/_generated/COUNTS.md for the live module list.
  • Data flow: project source + manuscript markdown + config.yaml flow through the pipeline into output/<name>/{pdf,figures,data,reports}/.
  • Quality assurance: infra β‰₯60 % and project β‰₯90 % coverage gates, no-mocks policy, deterministic seeds, real PDF/markdown validation.
  • Configuration: projects/{name}/manuscript/config.yaml plus environment overrides feed PDF metadata, LaTeX preamble, figure labels, and validation rules.

Directory Overview with Documentation Links:

DirectoryPurposeDocumentation
infrastructure/Generic build/validation tools (Layer 1)infrastructure/AGENTS.md
scripts/Entry point orchestratorsscripts/AGENTS.md
tests/Infrastructure test suitetests/AGENTS.md
projects/{name}/src/Project-specific scientific code (Layer 2)Per-project AGENTS.md
projects/{name}/tests/Project test suitePer-project AGENTS.md
docs/Documentation hubdocs/documentation-index.md
projects/{name}/manuscript/Research manuscript sectionsPer-project AGENTS.md
output/Generated public evidence plus local build outputFinal evidence is tracked selectively; runtime residue is ignored

πŸ“š Explore Documentation: See docs/documentation-index.md for documentation structure

πŸ”‘ Key Architectural Principles

The repository follows a thin orchestrator pattern: business logic lives only in infrastructure/ and projects/{name}/src/; scripts coordinate, never implement. Tests prohibit mock frameworks and prefer real execution; remaining pytest.monkeypatch dependency replacements are explicitly inventoried rather than treated as proof of a mock-free suite. Coverage gates remain strict. Full narrative + benefits: docs/architecture/thin-orchestrator-summary.md, docs/core/architecture.md.

✨ Key Features

πŸ”’ Security & Monitoring

LLM input sanitization (infrastructure.llm.core.sanitization), security validators (infrastructure.core.security), runtime health checks (infrastructure.core.runtime.health_check), rate limiting, and HTTP security headers. Full surface and worked usage examples: docs/development/security.md.

πŸ› οΈ Installation & Setup

Prerequisites: pandoc and a TeX distribution (texlive-xetex on Debian/Ubuntu, MacTeX on macOS). Python deps install with uv sync (project interpreter is .venv/bin/python; the template targets Python 3.10+ (requires-python in pyproject.toml) and CI tests infrastructure on 3.10–3.13, with .python-version pinning 3.12 as the local default). Add per-project deps with uv run python scripts/maintenance/manage_workspace.py add <package> --project <name>. To generate a manuscript, follow the Quickstart at the top.

Layer 1 is also a standard Python distribution. Build it with uv build, or install the wheel attached to a GitHub release. Installation provides the research-template command (research-template --help). Optional pip extras mirror the major capability groups, for example research-project-template[rendering,publishing]; repository contributors should continue to use uv sync --group ... for development groups.

🐳 Docker Support

docker-compose up (or docker build -t research-template . && docker run -it research-template) builds a reproducible image with pandoc, TeX, Ollama LLM server support, persistent model/output volumes, and hot-reload. See Dockerfile and docker-compose.yml.

πŸ”§ Customization

Project Metadata Configuration

Two configuration paths exist: edit projects/{name}/manuscript/config.yaml (recommended) or export AUTHOR_NAME / AUTHOR_ORCID / AUTHOR_EMAIL / PROJECT_TITLE / DOI environment variables (env vars override the YAML file). The YAML schema (paper title, authors with ORCID, publication DOI, keywords, optional LLM translations block) and a worked example are documented once in CLAUDE.md and AGENTS.md; both files also list every available field. See projects/{name}/manuscript/config.yaml.example for the full template. Applied configuration drives PDF metadata, LaTeX document properties (see docs/reference/copypasta.md for preamble examples), generated file headers, and cross-reference systems.

Adding Project-Specific Scripts

Place Python scripts under projects/{name}/scripts/. They must follow the thin orchestrator pattern: import computation from projects/{name}/src/ or infrastructure/, handle only I/O / visualization / orchestration, print output paths to stdout for manifest collection, and never implement algorithms inline. Worked examples and the full pattern walkthrough live in scripts/AGENTS.md and docs/architecture/thin-orchestrator-summary.md.

Manuscript Structure

Per-project manuscript files live in projects/{name}/manuscript/: config.yaml, preamble.md, zero-padded numbered chapter files (00_abstract.md onward), optional S01_*.md supplements, and 99_references.md. Exact chapter slugs vary per project β€” the canonical exemplar is projects/templates/template_code_project/manuscript/; the numbering system and slug rules are authoritative in docs/usage/manuscript-numbering-system.md.

πŸ“Š Testing

TDD with strict coverage gates: infrastructure β‰₯ 60 %, projects β‰₯ 90 %. No unit-level mock frameworks β€” tests use real data, real files; HTTP boundaries use pytest-httpserver (in-process test server). The project pipeline runs a focused pipeline-smoke infrastructure contract plus the selected project's full coverage suite, so ordinary renders do not rerun the entire repository test matrix. Run the full infrastructure gate explicitly with uv run python scripts/pipeline/stage_01_test.py --infra-only --infra-scope full; run a project suite with uv run python scripts/pipeline/stage_01_test.py --project-only --project <name>. Per-suite commands and coverage report flags are documented in tests/AGENTS.md and docs/development/testing/testing-guide.md; live coverage / test counts live in docs/_generated/COUNTS.md.

Output

Working outputs: projects/{name}/output/. Public exemplars retain only deterministic deliverables and evidence under that tree; runtime state (.checkpoints/, .pipeline/, logs/, telemetry, snapshots) and renderer intermediates are local-only and regenerated by the pipeline. Multi-project mode adds output/executive_summary/ as a disposable copied-output surface.

πŸ” How It Works

Two entry points β€” ./run.sh (interactive or --pipeline) and uv run python scripts/runner/execute_pipeline.py --project <name> [--core-only].

Pipeline (canonical phrasing β€” keep in sync with CLAUDE.md and AGENTS.md): The default pipeline.yaml declares 16 named stages: 8 core stages, 2 optional LLM stages, 2 opt-in ebook/metadata stages, 2 opt-in bundle/archival stages, and 2 opt-in science/provenance stages (Connector Search, Provenance Record). Default full runs include the 10 core+LLM stages (Clean Output Directories plus nine numbered stages). --core-only runs 8 stages by excluding LLM-tagged and opt-in stages. Ebook, metadata, bundle, archival, science, and provenance stages are declared for contracts but invoked separately when needed (directly via their scripts/pipeline/stage_*.py entry points).

StageScriptTagsFailure mode
0 Clean Output Directoriesbuilt-in _run_clean_outputscore, cleansoft fail
1 Environment Setupscripts/pipeline/stage_00_setup.pycorehard fail
2 Infrastructure Testsscripts/pipeline/stage_01_test.py --infra-only --verbose --infra-scope pipeline-smokecore, testsconfigurable tolerance
3 Project Testsscripts/pipeline/stage_01_test.py --project-only --verbosecore, testsconfigurable tolerance
4 Project Analysisscripts/pipeline/stage_02_analysis.pycorehard fail
5 Connector Searchscripts/pipeline/stage_08_connector_search.pyscienceskipped if not configured
6 Provenance Recordscripts/pipeline/stage_09_provenance_record.py --stage Connector Searchprovenanceskipped if not configured
7 PDF Renderingscripts/pipeline/stage_03_render.pycorehard fail
8 Output Validationscripts/pipeline/stage_04_validate.pycorePDF/bookends and artifact/provenance failures block; optional-format structure remains a warning + report
9 LLM Scientific Reviewscripts/pipeline/stage_06_llm_review.py --reviews-onlyllmskipped if Ollama absent
10 LLM Translationsscripts/pipeline/stage_06_llm_review.py --translations-onlyllmskipped if Ollama absent
11 Copy Outputsscripts/pipeline/stage_05_copy.pycoresoft fail
12 Ebook Generationscripts/pipeline/stage_11_ebook.pycore, ebooksoft fail
13 Metadata Packagescripts/pipeline/stage_12_metadata.pycore, metadatasoft fail
14 Executable Bundlescripts/runner/bundle_executable.pybundlesoft fail
15 Archival Publicationscripts/runner/archive_publication.pyarchivalsoft fail

Full per-stage flowchart, failure/skip transitions, and the script-to-stage mapping for --core-only live in AGENTS.md and docs/RUN_GUIDE.md. Workflow narrative: docs/core/workflow.md. Architecture narrative: docs/core/architecture.md.

πŸ“š Documentation Index

The full per-file documentation index lives in docs/documentation-index.md (authoritative; counts drift, so it is not duplicated here). Top-level entry points:

🀝 Contributing

contribution guide | Code of conduct | Roadmap

We welcome contributions! To contribute:

  1. Ensure all tests pass with coverage requirements met - Testing Guide
  2. Follow the established project structure - Architecture
  3. Add tests for new functionality - Workflow
  4. Update documentation as needed - Documentation Guide
  5. Maintain thin orchestrator pattern - scripts use src/ methods - Pattern Guide

Recent Improvements:

  • Build system optimizations - Performance Optimization
  • Test suite enhancements
  • Simplified directory structure with markdown/ elimination

πŸ“„ License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

πŸ“š Citation

The machine-readable CITATION.cff is the single source of truth (GitHub's "Cite this repository" widget reads it). If you use this template in your research, please cite:

DOI

Cite the current release. Earlier versions retain their own Zenodo DOIs; the version-independent concept DOI always resolves to the latest.

BibTeX:

@software{friedman_template_2026,
  author    = {Daniel Ari Friedman},
  title     = {A template/ approach to Reproducible Generative Research:
               Architecture and Ergonomics from Configuration through Publication},
  year      = {2026},
  publisher = {Zenodo},
  doi       = {10.5281/zenodo.19139090},
  url       = {https://doi.org/10.5281/zenodo.19139090}
}

Plain text: Daniel Ari Friedman. (2026). A template/ approach to Reproducible Generative Research: Architecture and Ergonomics from Configuration through Publication. Zenodo. https://doi.org/10.5281/zenodo.19139090

πŸ†˜ Troubleshooting

Common issue catalog β€” failing tests, missing pandoc/xelatex, PDF quality, LLM unavailability β€” lives in docs/operational/troubleshooting/README.md and docs/reference/faq.md. Pipeline entry points and flags: docs/RUN_GUIDE.md. PDF validator: docs/modules/pdf-validation.md.

πŸ”„ Migration from Other Projects

To adapt this template: copy infrastructure/ and scripts/, mirror the projects/{name}/{src,tests,scripts,manuscript}/ layout, adopt config.yaml (see AGENTS.md), and validate by running the pipeline. Worked examples: docs/usage/examples.md, docs/best-practices/migration-guide.md.

πŸ—οΈ Architecture Benefits

Thin orchestrator pattern delivers single-source-of-truth business logic, high testability (β‰₯90 % project coverage), reusability across projects, and CI-gated quality. Full benefits + rationale: docs/core/architecture.md.


Quick Navigation by Task

TaskStart here
Assistants / Cursor.cursorrules, CLAUDE.md, AGENTS.md
Write documentsdocs/guides/getting-started.md, docs/usage/markdown-template-guide.md
Add figuresdocs/guides/figures-and-analysis.md, docs/usage/visualization-guide.md
Fix issuesdocs/operational/troubleshooting/README.md, docs/reference/faq.md
Understand architecturedocs/core/architecture.md, docs/architecture/two-layer-architecture.md
Configure systemdocs/operational/config/configuration.md, AGENTS.md
Run pipelinedocs/RUN_GUIDE.md
Contribute codedocs/development/contributing.md, docs/rules/AGENTS.md
Find all docsdocs/documentation-index.md
Check the backlogTO-DO.md
See what changedCHANGELOG.md

πŸŽ‰ Get Started Now

Ready to begin? Choose your path:

  1. New User? β†’ Start with Quick Start or docs/guides/getting-started.md
  2. Developer? β†’ Read docs/core/architecture.md and docs/core/workflow.md
  3. Need Help? β†’ Check docs/reference/faq.md or docs/operational/troubleshooting/README.md
  4. Explore All Docs? β†’ Browse docs/documentation-index.md

πŸ“š Documentation Hub: All documentation is organized in the docs/ directory with guides for every aspect of the template.

Trustgrade A

  • passBody integrity

    Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.

  • passType matchnot applicable to this artifact type

    Whether the artifact is really the kind of thing its metadata claims it is.

  • passFreshness

    How long since the source repository was last pushed to.

  • passPrompt injection

    Scans the artifact's own text for instructions aimed at your agent rather than at you.

  • passLicense

    Whether the source repository declares an SPDX license permissive enough to redistribute.

How the grade is calculated

Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:

  • Aevery check passed
  • Bone warning
  • Ctwo warnings
  • Dprompt injection or body integrity failed, or three warnings
  • Fone of those failed, and something else is wrong

These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged β€” not that the artifact is safe.

Versions

  • git-beb3f748bb312026-08-04