# Infrastructure Modules Reusable build tools, validation systems, and integration components that support research projects. These modules provide the foundation for reproducible, high-quality research workflows. ## Overview The infrastructure layer provides generic, reusable functionality that can be applied across different research projects. All modules follow the **thin orchestrator pattern** - scripts coordinate business logic implemented in these infrastructure modules. ## Agent skills (`SKILL.md`) Each subpackage (and the package root) includes a **`SKILL.md`** with YAML frontmatter (`name`, `description`) so assistants can route work to the right module. **Discovery:** open [`.cursor/skill_manifest.json`](../.cursor/skill_manifest.json) (or `@.cursor/skill_manifest.json` in Cursor), search `infrastructure/**/SKILL.md`, open the hub [SKILL.md](SKILL.md), or use `@infrastructure/SKILL.md` / `@infrastructure//SKILL.md`. Regenerate the manifest after skill changes: `uv run python -m infrastructure.skills write`. | Path | Frontmatter `name` | | ------ | ------------------- | | [SKILL.md](SKILL.md) | `infrastructure-overview` | | [autoresearch/SKILL.md](autoresearch/SKILL.md) | `infrastructure-autoresearch` | | [benchmark/SKILL.md](benchmark/SKILL.md) | `infrastructure-benchmark` | | [config/SKILL.md](config/SKILL.md) | `infrastructure-config` | | [core/SKILL.md](core/SKILL.md) | `infrastructure-core` | | [docker/SKILL.md](docker/SKILL.md) | `infrastructure-docker` | | [doctor/SKILL.md](doctor/SKILL.md) | `infrastructure-doctor` | | [documentation/SKILL.md](documentation/SKILL.md) | `infrastructure-documentation` | | [llm/SKILL.md](llm/SKILL.md) | `infrastructure-llm` | | [methods/SKILL.md](methods/SKILL.md) | `infrastructure-methods` | | [orchestration/SKILL.md](orchestration/SKILL.md) | `infrastructure-orchestration` | | [project/SKILL.md](project/SKILL.md) | `infrastructure-project` | | [prose/SKILL.md](prose/SKILL.md) | `infrastructure-prose` | | [publishing/SKILL.md](publishing/SKILL.md) | `infrastructure-publishing` | | [reference/SKILL.md](reference/SKILL.md) | `infrastructure-reference` | | [reference/citation/SKILL.md](reference/citation/SKILL.md) | `infrastructure-reference-citation` | | [reference/verification/SKILL.md](reference/verification/SKILL.md) | `reference-verification` | | [rendering/SKILL.md](rendering/SKILL.md) | `infrastructure-rendering` | | [reporting/SKILL.md](reporting/SKILL.md) | `infrastructure-reporting` | | [scientific/SKILL.md](scientific/SKILL.md) | `infrastructure-scientific` | | [search/SKILL.md](search/SKILL.md) | `infrastructure-search` | | [search/literature/SKILL.md](search/literature/SKILL.md) | `infrastructure-search-literature` | | [sia/SKILL.md](sia/SKILL.md) | `infrastructure-sia` | | [skills/SKILL.md](skills/SKILL.md) | `infrastructure-skills` | | [steganography/SKILL.md](steganography/SKILL.md) | `infrastructure-steganography` | | [core/telemetry/SKILL.md](core/telemetry/SKILL.md) | `telemetry` | | [validation/SKILL.md](validation/SKILL.md) | `infrastructure-validation` | Pair each `SKILL.md` with the matching **`AGENTS.md`** for full API tables. ## Module Categories ```mermaid graph TD subgraph "๐Ÿ”ง Core Infrastructure" CORE[core
Fundamental utilities
Logging, config, progress] EXCEPTIONS[core/exceptions.py
Exception hierarchy
Context preservation] end subgraph "๐Ÿ“ Document Processing" DOC[documentation
Figure management
API documentation] RENDER[rendering
Multi-format output
PDF, HTML, slides] VALIDATION[validation
Quality assurance
Content validation] end subgraph "๐Ÿ”— External Integrations" LLM[llm
Local LLM integration
Ollama support] PUBLISHING[publishing
Academic publishing
Zenodo, arXiv, GitHub] SCIENTIFIC[scientific
Scientific utilities
Benchmarking, validation] end subgraph "๐Ÿ“Š Reporting & Quality" REPORTING[reporting
Pipeline reporting
Error aggregation] AUTORESEARCH[autoresearch
Deterministic readiness
Plans, gates, artifacts] BENCHMARK[benchmark
Template readiness
Manifest scoring] end PROJECT_SCRIPTS[Project Scripts
project/scripts/] INFRASTRUCTURE[Infrastructure Modules] PROJECT_SCRIPTS --> INFRASTRUCTURE INFRASTRUCTURE --> CORE INFRASTRUCTURE --> DOC INFRASTRUCTURE --> LLM INFRASTRUCTURE --> REPORTING INFRASTRUCTURE --> AUTORESEARCH INFRASTRUCTURE --> BENCHMARK DOC --> RENDER DOC --> VALIDATION LLM --> PUBLISHING LLM --> SCIENTIFIC class CORE,EXCEPTIONS core class DOC,RENDER,VALIDATION doc class LLM,PUBLISHING,SCIENTIFIC integration class REPORTING,AUTORESEARCH,BENCHMARK build ``` Diagrams above are selective. These packages also exist under `infrastructure/` (or nested): **`benchmark/`** (deterministic exemplar readiness scoring), **`config/`** (`.env.template`, `secure_config.yaml`), **`docker/`** (`Dockerfile`, compose), **`project/`** (discovery, structure checks), **`steganography/`** (PDF hardening), **`skills/`** (`discover_skills`, manifest for Cursor), **`core/telemetry/`** (`TelemetryCollector`, per-stage resource + diagnostic reports). `autoresearch/` adds opt-in deterministic readiness planning over the existing pipeline, project, validation, and reporting modules. `methods/` adds a read-only methods orchestration plan that links stage contracts, manuscript methodology prose, artifact manifests, evidence registries, and validation commands. ## Infrastructure Dependencies ```mermaid flowchart TD subgraph "๐Ÿ“‹ Project Scripts" ANALYSIS[scripts/pipeline/stage_02_analysis.py
Data processing & figures] FIGURES["projects/{name}/scripts/.py
Thin orchestrators"] end subgraph "๐Ÿ—๏ธ Infrastructure Layer" CORE_MOD[core
Foundation utilities] VALIDATION_MOD[validation
Quality checks] DOCUMENTATION_MOD[documentation
Figure management] RENDERING_MOD[rendering
Output generation] LLM_MOD[llm
AI assistance] PUBLISHING_MOD[publishing
Academic dissemination] REPORTING_MOD[reporting
Pipeline reporting] end subgraph "๐Ÿ“Š Data Flow" SCRIPTS -->|import| INFRASTRUCTURE SCRIPTS -->|generate| OUTPUTS[Generated outputs
figures, data, PDFs] end ANALYSIS --> CORE_MOD ANALYSIS --> DOCUMENTATION_MOD ANALYSIS --> VALIDATION_MOD FIGURES --> DOCUMENTATION_MOD FIGURES --> RENDERING_MOD CORE_MOD --> VALIDATION_MOD CORE_MOD --> DOCUMENTATION_MOD CORE_MOD --> RENDERING_MOD CORE_MOD --> LLM_MOD CORE_MOD --> PUBLISHING_MOD CORE_MOD --> REPORTING_MOD class ANALYSIS,FIGURES scripts class CORE_MOD,VALIDATION_MOD,DOCUMENTATION_MOD,RENDERING_MOD,LLM_MOD,PUBLISHING_MOD,REPORTING_MOD infra class OUTPUTS output ``` ## Module Dependency Flow ```mermaid flowchart TD A[Project Scripts] --> B[Infrastructure Modules] B --> C[Core Module] B --> D[Documentation Module] B --> E[Validation Module] B --> F[Rendering Module] B --> G[LLM Module] B --> H[Publishing Module] B --> I[Scientific Module] B --> J[Reporting Module] C --> K[exceptions.py
Base exception classes] C --> L[logging/utils.py
Unified logging system] C --> M[config/loader.py
YAML configuration] C --> N[progress.py
Progress tracking] C --> O[runtime/checkpoint.py
Pipeline state] C --> P[runtime/retry.py
Exponential backoff] C --> Q[pipeline/stage_monitor.py
Resource monitoring] C --> R[runtime/environment.py
Setup validation] C --> S[script_discovery.py
Dynamic discovery] C --> T[files/operations.py
I/O utilities] D --> U[figure_manager.py
Figure registration] D --> V[image_manager.py
Image handling] D --> W[markdown_integration.py
Auto-insertion] D --> X[glossary_gen.py
API documentation] E --> Y[output/pdf_validator.py
PDF quality checks] E --> Z[content/markdown_validator.py
Markdown validation] E --> AA[integrity/checks.py
Cross-reference validation] F --> BB[core.py
RenderManager orchestrator] F --> CC[latex_utils.py
LaTeX processing] F --> DD[web_renderer.py
Web output] G --> EE[llm/core/client.py
Ollama integration] G --> FF[llm/templates
Research templates] G --> GG[llm/core/context.py
Context management] H --> HH[api.py
Platform API clients] H --> II[package.py
Submission packaging] H --> JJ[platforms.py
Release automation] H --> KK[citations.py
BibTeX CLI target
APA/MLA helpers] I --> LL[benchmarking.py
Performance analysis] I --> MM[validation.py
Scientific standards] I --> NN[templates.py
Research workflows] J --> OO[pipeline_reporter.py
Build reports] J --> PP[error_aggregator.py
Error categorization] J --> QQ[html_templates.py
Visual reports] class A start class C,K,L,M,N,O,P,Q,R,S,T core class D,U,V,W,X doc class E,Y,Z,AA validation class F,BB,CC,DD rendering class G,EE,FF,GG llm class H,HH,II,JJ,KK publishing class I,LL,MM,NN scientific class J,OO,PP,QQ reporting ``` ## Data Flow Through Infrastructure ```mermaid flowchart LR subgraph Input["๐Ÿ“ฅ Input Sources"] YAML[config.yaml
Project metadata] SRC[src
Scientific code] MANUSCRIPT[manuscript
Research content] SCRIPTS[scripts
Orchestrators] end subgraph Processing["โš™๏ธ Infrastructure Processing"] CONFIG[config_loader
Load settings] VALIDATE[validation
Quality checks] RENDER[rendering
Generate outputs] LOGGING[logging_utils
Track progress] REPORT[reporting
Generate reports] end subgraph Output["๐Ÿ“ค Generated Outputs"] PDF["output/{project_name}/pdf
Manuscript PDFs"] FIGURES["output/{project_name}/figures
Publication plots"] REPORTS["output/{project_name}/reports
Validation reports"] HTML["output/{project_name}/web
HTML versions"] end YAML --> CONFIG SRC --> VALIDATE MANUSCRIPT --> RENDER SCRIPTS --> LOGGING CONFIG --> VALIDATE VALIDATE --> RENDER RENDER --> REPORT LOGGING --> REPORT RENDER --> PDF RENDER --> FIGURES REPORT --> REPORTS RENDER --> HTML class Input input class Processing process class Output output ``` ### Core Infrastructure - **[core/](core/)** - Fundamental utilities (logging, configuration, progress tracking) - **Exception handling** - Custom exception hierarchy and error handling ### Document Processing - **[documentation/](documentation/)** - Figure management and API documentation generation - **[rendering/](rendering/)** - Multi-format output generation (PDF, HTML, slides) - **[validation/](validation/)** - Quality assurance and content validation - **[prose/](prose/)** - Readability metrics, outline analysis, editorial quality flags for manuscripts ### External Integrations - **[llm/](llm/)** - Local Large Language Model integration - **[publishing/](publishing/)** - Academic publishing workflows - **[scientific/](scientific/)** - Scientific computing utilities - **[search/](search/)** - Multi-source literature search (arXiv, Crossref, Paperclip, local) - **[reference/](reference/)** - BibTeX read / write / convert (`parse_bibfile`, `render_database`) ### Reporting & Quality - **[reporting/](reporting/)** - Pipeline reporting and error aggregation ### Project Management - **[project/](project/)** - Multi-project discovery, validation, and lifecycle management - **[orchestration/](orchestration/)** - Pipeline CLI, interactive menu, stage logging, secure-run wrapper (backs `run.sh` / `secure_run.sh`) ### Diagnostics & Repair - **[doctor/](doctor/)** - Repository diagnostics and safe, reversible automated repair (`uv run python -m infrastructure.doctor`) ### Security & Integrity - **[steganography/](steganography/)** - Cryptographic watermarking, PDF metadata injection, and hashing ### Pipeline Telemetry - **[core/telemetry/](core/telemetry/)** - Unified per-stage resource + diagnostic tracking (`TelemetryCollector`) ## Usage in Projects Infrastructure modules are imported by project-specific scripts: ```python # In project/scripts/analysis.py from infrastructure.rendering import RenderManager from infrastructure.validation import validate_markdown from infrastructure.llm.core import LLMClient # Use infrastructure components renderer = RenderManager() client = LLMClient() ``` ### Usage Patterns ```mermaid flowchart TD subgraph "๐Ÿš€ Project Script Lifecycle" INIT[Initialize
Import infrastructure] CONFIG[Load Configuration
config_loader] PROCESS[Process Data
core utilities] VALIDATE[Validate Output
validation module] RENDER[Generate Outputs
rendering module] REPORT[Report Results
reporting module] end subgraph "๐Ÿ”ง Infrastructure Integration" CORE[core
logging, progress] DOC[documentation
figures, markdown] LLM[llm
AI assistance] PUBLISH[publishing
academic platforms] end INIT --> CORE CONFIG --> CORE PROCESS --> DOC VALIDATE --> DOC RENDER --> DOC REPORT --> CORE PROCESS --> LLM RENDER --> PUBLISH class INIT,CONFIG,PROCESS,VALIDATE,RENDER,REPORT script class CORE,DOC,LLM,PUBLISH infra ``` ## Testing Infrastructure modules maintain **โ‰ฅ60% test coverage** (live overall % โ†’ [`docs/development/coverage-gaps.md`](../docs/development/coverage-gaps.md)): ```bash # Test all infrastructure uv run pytest tests/infra_tests/ --cov=infrastructure --cov-report=term-missing # Test specific module uv run pytest tests/infra_tests/core/ -v ``` ## Architecture Principles ### Thin Orchestrator Pattern - **Business logic** resides in infrastructure modules - **Scripts** provide thin orchestration layer - **Clean separation** between reusable code and project-specific logic ### Data Policy - **No mock methods** in business logic - **computations** with actual data - **Deterministic outputs** for reproducibility ### Validation - **Quality assurance** for all outputs - **Integration testing** across modules - **Error handling** with informative messages ## Development ### Adding New Infrastructure 1. Create module in appropriate category 2. Implement business logic with tests 3. Add AGENTS.md documentation 4. Update integration tests 5. Ensure 60%+ test coverage ### Module Structure ```mermaid flowchart TB NM[infrastructure/new_module] NM --> INIT[__init__.py
Public API exports] NM --> CORE[core.py
Main functionality] NM --> UTILS[utils.py
Helper functions] NM --> CLI[cli.py
Command-line interface ยท optional] NM --> AG[AGENTS.md
Technical documentation] NM --> RD[README.md
Quick reference] NM --> SK[SKILL.md
Agent-skill descriptor] classDef d fill:#0f172a,stroke:#0f172a,color:#fff classDef code fill:#1e3a8a,stroke:#0f172a,color:#fff classDef doc fill:#0f766e,stroke:#0f172a,color:#fff class NM d class INIT,CORE,UTILS,CLI code class AG,RD,SK doc ``` ## Quality Standards - **Test Coverage**: Minimum 60% for infrastructure modules - **Documentation**: AGENTS.md for all modules - **Error Handling**: exception handling - **Performance**: Efficient resource usage - **Security**: Safe credential handling ## See Also - [AGENTS.md](AGENTS.md) - infrastructure documentation - [../tests/infra_tests/](../tests/infra_tests/) - Infrastructure test suite - [../scripts/](../scripts/) - Orchestration scripts ## Directory & sub-document map Navigation links to in-tree documents (keeps them discoverable): - [Methods Orchestration](methods/README.md) - [Steganography Module](steganography/README.md)