|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +APAB (Agentic Phased Array Builder) is a Python package that connects an LLM to MCP-exposed engineering tools for phased-array antenna design and analysis. It plans and executes workflows end-to-end: full-wave unit-cell simulation with mutual coupling (over frequency, scan angle, polarization) propagated into array-level patterns and system-level metrics. |
| 8 | + |
| 9 | +The full-wave solver is **EdgeFEM** (not VectorEM). |
| 10 | + |
| 11 | +## Build & Development Commands |
| 12 | + |
| 13 | +```bash |
| 14 | +# Install in development mode (once pyproject.toml exists) |
| 15 | +pip install -e ".[dev]" |
| 16 | + |
| 17 | +# Run all tests |
| 18 | +pytest tests/ |
| 19 | + |
| 20 | +# Run a single test |
| 21 | +pytest tests/test_file.py::test_name -v |
| 22 | + |
| 23 | +# Type checking |
| 24 | +mypy src/apab/ |
| 25 | + |
| 26 | +# Linting |
| 27 | +ruff check src/ tests/ |
| 28 | + |
| 29 | +# CLI entry points |
| 30 | +apab init # scaffold project |
| 31 | +apab design # interactive agent session |
| 32 | +apab run # non-interactive from config |
| 33 | +apab report # generate report from run bundle |
| 34 | +apab mcp serve # run as MCP server |
| 35 | +``` |
| 36 | + |
| 37 | +## Architecture (Four Layers) |
| 38 | + |
| 39 | +1. **Agent Orchestrator** (`src/apab/agent/`) - Talks to LLM providers via a `LLMProvider` protocol. Uses tool-calling to dispatch actions to MCP tools. Default: Ollama with `qwen2.5-coder:14b`, offline-capable. |
| 40 | + |
| 41 | +2. **MCP Tool Layer** (`src/apab/mcp/`) - First-party MCP server exposing tools for simulation (EdgeFEM), array patterns (phased-array-modeling), system trades (phased-array-systems), export/plot/report, and optional external EM adapters. |
| 42 | + |
| 43 | +3. **Execution/Compute Layer** (`src/apab/compute/`) - Local execution by default. `ComputeBackend` protocol designed for future cloud backends (AWS/GCP) via entry points (`apab.compute_backends`). |
| 44 | + |
| 45 | +4. **Artifact + Provenance Layer** - Run bundles at `workspace/runs/<run_id>/` containing manifest, config, logs, and artifacts. Cache keys include config/geometry/sweep hashes and dependency versions. |
| 46 | + |
| 47 | +## Key Required Dependencies |
| 48 | + |
| 49 | +- **edgefem** (PyPI) - Full-wave unit-cell solver backend (`jman4162/EdgeFEM`) |
| 50 | +- **phased-array-modeling** (PyPI) - Array factor/patterns/impairments (`jman4162/Phased-Array-Antenna-Model`) |
| 51 | +- **phased-array-systems** (GitHub: `jman4162/phased-array-systems`) - System-level trades/scenarios |
| 52 | + |
| 53 | +## Plugin/Extension Points (Entry Points) |
| 54 | + |
| 55 | +| Group | Purpose | |
| 56 | +|---|---| |
| 57 | +| `apab.llm_providers` | LLM provider plugins (Ollama, OpenAI, Anthropic, Gemini, OpenAI-compatible) | |
| 58 | +| `apab.em_adapters` | External EM tool adapters (HFSS, CST, FEKO) | |
| 59 | +| `apab.compute_backends` | Compute backend plugins (local, future AWS/GCP) | |
| 60 | + |
| 61 | +## Key Protocols |
| 62 | + |
| 63 | +- `LLMProvider` - Provider abstraction in `src/apab/providers/`. Implementations: `OllamaProvider`, `OpenAIProvider`, `AnthropicProvider`, `GeminiProvider`, `OpenAICompatibleProvider`. |
| 64 | +- `FullWaveUnitCellSolver` - Solver protocol. EdgeFEM integrated via `EdgeFEMAdapter`. |
| 65 | +- `FullWaveFiniteArraySolver` - Reserved for future finite-array simulations. |
| 66 | +- `ExternalEMToolAdapter` - For commercial EM tools (HFSS/CST/FEKO). |
| 67 | +- `ComputeBackend` - For local and future cloud execution. |
| 68 | + |
| 69 | +## Configuration |
| 70 | + |
| 71 | +Project config lives in `apab.yaml`, validated by Pydantic. Key sections: `project`, `llm`, `mcp`, `compute`, `solver`, `unit_cell`, `sweep`, `array`, `outputs`. See SPEC.md section 7 for full example. |
| 72 | + |
| 73 | +## Data Model |
| 74 | + |
| 75 | +Core data arrays use the shape convention `S[f, scan, pol, i, j]` (complex). Derived quantities: `Z_active[f, scan, pol]`, `Gamma_active[f, scan, pol]`. Storage: HDF5 (primary), NPZ (cache), Touchstone (`.sNp` export). All schemas must be JSON/YAML-serializable. |
| 76 | + |
| 77 | +## Security Constraints |
| 78 | + |
| 79 | +- Workspace-only filesystem access by default |
| 80 | +- Local-first, offline-capable defaults (safe mode ON) |
| 81 | +- Remote LLM providers and cloud compute require explicit opt-in |
| 82 | +- `llm.redaction_mode` levels: `none` (local default), `metadata_only`, `strict` |
| 83 | +- All tool calls and remote LLM egress must be audit-logged |
0 commit comments