Skip to content

Latest commit

Β 

History

History
344 lines (251 loc) Β· 10.3 KB

File metadata and controls

344 lines (251 loc) Β· 10.3 KB

CLAUDE.md

This file provides guidance to Claude Code when working with the Appose meta-repository.

Project Overview

This is the Appose meta-repository - it contains the overarching project documentation, protocol specification, and links to language-specific implementations. This repository does not contain code - it is purely documentation.

What is Appose?

Appose is a library for interprocess cooperation with shared memory. It enables easy execution of code in different programming languages without copying large data structures (especially tensors for deep learning).

Key principles:

  • Simplicity - Minimal dependencies, straightforward API
  • Efficiency - Zero-copy tensor sharing via shared memory

Architecture:

  • Each language has its own implementation (separate repositories)
  • All implementations follow the same worker protocol (JSON over stdin/stdout)
  • Workers can be written in any language that implements the protocol

Repository Structure

appose/                          # Meta-repository (THIS REPO)
β”œβ”€β”€ README.md                    # Main project README with protocol spec
β”œβ”€β”€ CLAUDE.md                    # This file
β”œβ”€β”€ DOCUMENTATION.md             # Guide to the Sphinx documentation
β”œβ”€β”€ pyproject.toml               # Dependency groups for docs building
β”œβ”€β”€ .readthedocs.yaml            # ReadTheDocs configuration
β”œβ”€β”€ docs/                        # Comprehensive Sphinx documentation
β”‚   β”œβ”€β”€ conf.py                  # Sphinx configuration
β”‚   β”œβ”€β”€ Makefile                 # Build commands (uses uv)
β”‚   β”œβ”€β”€ make.bat                 # Windows build commands
β”‚   β”œβ”€β”€ requirements.txt         # Docs dependencies (legacy, use pyproject.toml)
β”‚   β”œβ”€β”€ README.md                # How to build the docs
β”‚   β”œβ”€β”€ index.rst                # Documentation landing page
β”‚   β”œβ”€β”€ getting-started.rst      # Installation and first steps
β”‚   β”œβ”€β”€ core-concepts.rst        # Architecture and key concepts
β”‚   β”œβ”€β”€ examples.rst             # Comprehensive examples
β”‚   β”œβ”€β”€ worker-protocol.rst      # Protocol specification
β”‚   β”œβ”€β”€ faq.rst                  # FAQ
β”‚   β”œβ”€β”€ alternatives.rst         # Comparison with alternatives
β”‚   β”œβ”€β”€ _static/                 # Static assets
β”‚   └── _templates/              # Custom templates
└── openmoji-svg-color/          # SVG icons (not part of docs)

Related Repositories

The actual implementations are in separate repositories:

  • appose-java: Java implementation at ../appose-java/
    • See ../appose-java/CLAUDE.md for Java-specific guidance
  • appose-python: Python implementation at ../appose-python/
    • See ../appose-python/README.md for Python-specific docs

Core Concepts

Architecture Layers

Builder β†’ Environment β†’ Service β†’ Task
  1. Builder: Creates environments with dependencies (Pixi, Mamba, UV, System)
  2. Environment: Configured environment with executables
  3. Service: Access to a worker process
  4. Task: Asynchronous operation (like a Future/Promise)
  5. Worker: Separate process that executes scripts

Worker Protocol

Communication is via JSON over stdin/stdout:

Request Types:

  • EXECUTE - Run a script
  • CANCEL - Cancel a running task

Response Types:

  • LAUNCH - Task started
  • UPDATE - Progress update
  • COMPLETION - Task finished successfully
  • CANCELATION - Task canceled
  • FAILURE - Task failed
  • CRASH - Worker crashed

See README.md or docs/worker-protocol.rst for full specification.

Documentation System

Technology Stack

  • Sphinx - Documentation generator
  • sphinx_rtd_theme - Read the Docs theme
  • sphinx_tabs - Language-specific examples in tabs (Java/Python)
  • sphinx_copybutton - Copy buttons for code blocks
  • myst_parser - Markdown support alongside RST
  • uv - Dependency management (following pyimagej pattern)

Build Commands

# Build HTML documentation
cd docs
make html

# Other formats
make latexpdf  # PDF (requires LaTeX)
make epub      # EPUB
make linkcheck # Check for broken links

# Clean build
make clean

The Makefile uses uv run --group docs sphinx-build, which automatically:

  1. Creates a virtual environment in .venv/
  2. Installs dependencies from pyproject.toml [dependency-groups] section
  3. Runs sphinx-build

Dependency Management

Dependencies are managed in pyproject.toml using PEP 735 dependency groups:

[dependency-groups]
docs = [
    "myst-parser>=2.0.0",
    "sphinx>=7.0.0",
    "sphinx-copybutton>=0.5.0",
    "sphinx-rtd-theme>=2.0.0",
    "sphinx-tabs>=3.4.0",
]

This follows the same pattern as ~/code/imagej/pyimagej/pyproject.toml.

Documentation Pages

  1. index.rst - Landing page with quick examples
  2. getting-started.rst - Installation, prerequisites, first program
  3. core-concepts.rst - Deep dive into architecture
  4. examples.rst - From basic to advanced use cases
  5. worker-protocol.rst - Complete protocol specification
  6. faq.rst - Frequently asked questions
  7. alternatives.rst - Comparison with Arrow, NATS, gRPC, etc.

Language Tabs Pattern

Throughout the docs, examples are shown side-by-side using sphinx_tabs:

.. tabs::

   .. tab:: Java

      .. code-block:: java

         Environment env = Appose.system();
         Service python = env.python();

   .. tab:: Python

      .. code-block:: python

         env = appose.system()
         python = env.python()

This makes it easy for users to compare implementations across languages.

Common Tasks

Adding New Documentation

  1. Create or edit .rst files in docs/
  2. Use sphinx_tabs for language-specific examples
  3. Test locally: cd docs && make html
  4. Check for warnings - build should have zero warnings
  5. Add to toctree in index.rst if new page

Updating the Protocol

The worker protocol is documented in two places:

  1. README.md - Main specification (canonical)
  2. docs/worker-protocol.rst - Detailed Sphinx version

Keep them in sync when updating.

Adding Examples

Add examples to docs/examples.rst:

  • Use tabs for Java/Python side-by-side
  • Include both simple and advanced examples
  • Group by topic (basic, progress, environments, real-world)
  • Keep examples concise but complete

Formatting Guidelines

Code blocks:

  • Always specify language: .. code-block:: java
  • Use tabs for multi-language examples
  • Keep indentation consistent (3 spaces for nested content in RST)

Avoid triple-quoted strings in Python examples within RST:

  • They cause indentation parsing errors
  • Use string concatenation instead:
    script = (
        "line 1\n"
        "line 2\n"
    )

Important Notes

This is a Documentation-Only Repo

  • No code implementation - see appose-java and appose-python for code
  • No tests to run - documentation builds are the "tests"
  • No releases - implementations are released independently
  • Shared issue tracker: https://github.com/apposed/appose/issues

ReadTheDocs Hosting

Configuration in .readthedocs.yaml:

  • Uses Python 3.11
  • Builds Sphinx docs from docs/conf.py
  • Installs dependencies from docs/requirements.txt
  • Generates PDF and EPUB in addition to HTML

Relationship to Implementations

appose/              # THIS REPO - Documentation
β”œβ”€β”€ README.md        # Protocol spec + overview
└── docs/            # Full documentation site

appose-java/         # Java implementation
β”œβ”€β”€ src/main/java/   # Java code
β”œβ”€β”€ README.md        # Java-specific README
└── CLAUDE.md        # Java-specific guidance

appose-python/       # Python implementation
β”œβ”€β”€ src/appose/      # Python code
└── README.md        # Python-specific README

Changes to the protocol require coordinating across all implementations.

Version Numbers

  • This repo doesn't have releases
  • Documentation version is set in docs/conf.py: release = '0.3.0'
  • Should match the latest stable release of implementations
  • Update when implementations release new versions

Troubleshooting

Build warnings about indentation

RST is whitespace-sensitive. Common issues:

  • Triple-quoted Python strings in code blocks
  • Inconsistent indentation in nested directives
  • Missing blank lines before/after directives

"document isn't included in any toctree"

Either:

  1. Add to a .. toctree:: directive (usually in index.rst)
  2. Add to exclude_patterns in conf.py (for files like README.md)

Theme option warnings

Check html_theme_options in conf.py against current sphinx_rtd_theme version. Deprecated options should be removed.

uv not found

Install uv:

# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Reference Links

Quick Reference

File Locations

What Where
Protocol specification README.md
Documentation source docs/*.rst
Sphinx config docs/conf.py
Build commands docs/Makefile
Dependencies pyproject.toml
ReadTheDocs config .readthedocs.yaml
Java implementation docs ../appose-java/CLAUDE.md

Common Commands

# Build docs
cd docs && make html

# Clean build
cd docs && make clean html

# Check links
cd docs && make linkcheck

# View built docs
open docs/_build/html/index.html

# Check for uncommitted changes
git status

Philosophy

Appose prioritizes simplicity over features:

  • βœ… Simple JSON protocol, not Protocol Buffers
  • βœ… Pipes (stdin/stdout), not network sockets
  • βœ… One self-contained library per language
  • βœ… Minimal dependencies
  • ❌ No plugin architecture (keeps codebase small)
  • ❌ No cross-machine communication (keeps it simple)
  • ❌ No alternative transport layers (keeps it focused)

See README.md FAQ section for rationale on these decisions.