API Reference foundry v#0.1.3

Copy Markdown

Modules

Foundry keeps the contexts that define your domain and business logic.

Registers standard Foundry annotation module attributes as persistent.

Ash domain for Foundry audit resources.

An append-only audit log entry. Records all approval events, apply events, and compliance-relevant state transitions for :sensitive and :compliance proposals.

Policy check: only foundry_bot identity can create audit events.

Validates :compliance change events have adr_link.

Validates emergency_override events have notes.

Ash domain for the chat session store.

ETS-backed cache for expensive chat context assembly.

File-backed session store for Studio copilot sessions.

Classifies chat messages into mode (ask/change) and proposal commands.

Foundry-native retrieval and proposal orchestration for the Studio copilot.

Chat session resource backed by Mnesia disc_copies.

Behaviour for Studio copilot session persistence.

Normalizes structured provider events into a UI-friendly Studio copilot trace.

Spawns Claude Code CLI as a subprocess and streams LLM responses.

Spawns OpenAI Codex CLI as a subprocess and streams responses.

The typed output for mix foundry.compliance.check --json. Reports the implementation and test coverage status for each declared RG-* requirement.

The status of a single RG-* compliance requirement.

Aggregate counts across all requirements.

Ash domain for Foundry's internal resources (Manifest). Used only when loading and validating project manifests.

Ash domain exposing Foundry project context as MCP tools.

The typed output for mix foundry.context.all --json. A map of domain name strings to lists of ModuleContext structs.

ETS-backed cache for module context data.

Generic recursive compact serialization that filters empty values from maps and structs.

Represents a directed edge between two nodes in the project context graph.

Assembles the complete project graph by collecting all nodes and deriving edges between them based on structural and behavioral relationships.

Core Spark DSL introspection logic for mix foundry.context and mix foundry.context.all.

Formats project context for LLM consumption using compact text notation.

Manages the context lock file (.foundry/context.lock) which tracks whether the cached project context is fresh.

The typed output struct for mix foundry.context <Module> --json.

Discovers all project modules by scanning the compiled BEAM files.

Builds a NodeEntry from SparkMeta.ModuleInfo and project manifest.

The core typed output struct for per-module context queries. Mirrors the ModuleContext schema but with extended metadata.

Determines which modules have pending Ash migrations by running mix ash.codegen --check once per project invocation.

Provides convenient access to project context (nodes, edges) without running mix tasks.

Assembles and compacts the complete project context map.

Introspects Phoenix router modules to extract LiveView route metadata.

Caches the latest scenario extraction report and broadcasts updates.

Extracts Studio scenarios from executable test source.

Captures system map state at the start of an editing session. Used by the studio to render preview mode during active proposals.

Builds the spec-kit index by scanning ADRs, runbooks, findings, regulations, and other documentation files. Extracts summaries, tags, and token counts.

Checks system dependencies required for Foundry.

The typed output for mix foundry.diagram.generate --json. A graph of nodes (modules) and edges (relationships), clustered by domain. Consumed by the Phase 2 System Map D3 renderer.

A named cluster of nodes — corresponds to one domain.

A directed edge between two nodes. Represents a relationship, rule application, or Transfer step dependency.

A node in the system map graph. Corresponds to one Ash resource, Transfer, Rule, etc.

Validated file read boundary for all project file access in channels and controllers.

Local OpenAI-compatible chat provider for LM Studio.

The typed output for mix foundry.lint.all --json. Aggregates all violations from all lint rules across all modules.

A single lint violation from any lint rule.

Ash resource wrapping the output of mix foundry.lint.all.

High-level orchestrator for the lint suite.

Agent steps must declare confidence thresholds, tools, and telemetry (INV-014..017).

Sensitive resources with GraphQL mutations must have explicit authorization policies.

Validates the manifest keyword list directly (not per-module). Does not implement SparkLint.Rule — it is run as a separate pass.

INV-011 extension: Sensitive resources with Oban queues must have paper_trail.

Explicit registry of all active lint rules. Adding a new Foundry.LintRules.* module requires adding it here. Accidental registration is worse than a deliberate omission.

The project manifest resource. Validates and provides typed access to the .foundry/manifest.exs configuration file for a target project.

Module-based calculation for Foundry.Manifest. Returns true if the given library atom is present in conditional_libraries.

Reads and parses .foundry/manifest.exs from a project root. Returns the manifest as a keyword list. Caches per {file_path, mtime} in ETS.

Loads and validates the project manifest from .foundry/manifest.exs. Returns a validated Foundry.Manifest record or raises on error.

Validates CLDR backend exists when :ash_money is in conditional_libraries.

Validates approvers.sensitive_lead and approvers.compliance_officer are present.

Validates coverage_weights values sum to 1.0 ± 0.001.

Validates sensitive_resource_exemptions reference modules in sensitive_resources.

Helpers for reading resolved dependency versions from mix.lock.

Shared page metadata inference for LiveView modules.

Manages a dev server subprocess for live preview of reference projects.

Ash resource wrapping the full project context graph from mix foundry.project.context.

Ash resource wrapping the output of mix foundry.context <Module>.

Ash resource wrapping the output of mix foundry.project.status.

Coordinates project selection, cloning, dependency installation, and runtime switching.

Ash domain for Foundry proposal resources.

Records a single approval event for a proposal. Slots are immutable once filled — an approver cannot change their approval. Revocation requires rejecting the proposal and creating a new one. See: ADR-014 §Dual Approval Mechanics.

A git blob hash for a single file at the time a proposal was created. Used for stale detection per ADR-009. If the file's current blob hash at HEAD differs from this value, the proposal is STALE.

Deterministic impact analysis computed by Foundry.Copilot.ImpactAnalyzer. Not LLM-generated — derived from static analysis of the diff and the project's context graph. See: ADR-012 §Impact Tab.

Structured output from the pre-approval lint run. Populated when a proposal transitions from DRAFT to PENDING_REVIEW. A proposal with :error severity violations cannot advance past PENDING_REVIEW.

A single lint violation from the pre-approval lint run.

Policy check: Only authorized approvers can apply a proposal.

Policy check: Approver must be a named approver in the manifest with the correct role.

Policy check: DRAFT proposals are only visible to the requester. PENDING_REVIEW and later are visible to all project users.

A proposed change to a target project's codebase. The central resource for Foundry's governance model.

Foundry-specific facade over the generic spark_meta analysis pipeline.

Structured representation of an Ash resource action.

Scans LiveView module source to infer Ash action calls.

Extracts page-related metadata from LiveView modules.

Structured representation of an Ash resource attribute.

Structured representation of an AshAuthentication strategy.

Structured representation of a monetary attribute.

Structured representation of an Ash resource relationship.

Structured representation of a side effect.

Structured representation of a Reactor step.

Ash resource representing a spec-kit document (ADR, runbook, finding, regulation, or usage rule).

Extracts durable session findings from assistant responses and persists them as canonical spec-kit artifacts under docs/findings/.

Runtime health picture composed from all Phase 1 data.

Extracts resolved stack dependency versions from mix.lock.

Launch helpers for the local Foundry Studio runtime.

Lightweight test-side annotations for Studio scenario extraction.

Ash.Tracer implementation for Foundry scenario tracing.

Phoenix LiveView on_mount hook that registers the LiveView channel PID with its associated test process PID during test execution.

ETS-backed registry mapping LiveView channel PIDs to test process PIDs.

The typed output for mix foundry.versions.check --json. Current dependency versions read from mix.exs.

Mix Tasks

Reads all regulation files in docs/regulations/, extracts RG-* requirements, then verifies each one has at least one implementation: pointer to a module or test, and that a corresponding ExUnit test exists tagged :compliance.

Introspects a single compiled Ash/Reactor/Rule module and emits its full context as a JSON object matching Foundry.Context.ModuleContext.

Introspects every Foundry-relevant compiled module in the current project and emits a JSON object mapping domain names to arrays of ModuleContext objects.

Builds the system map graph by calling Foundry.Context.Introspector.build_all/1, projecting the result into Foundry.Diagram.SystemMap (nodes, edges, clusters), and writing the output to docs/diagrams/system_map.json.

Initialize a new Foundry project by scaffolding required directories and files.

Runs the full Foundry lint suite against all compiled modules and the project manifest. Emits a JSON report and exits non-zero if any :error severity violations are found.

Generates project context for Foundry modules.

Outputs the current project health status as JSON.

Starts the Foundry Studio web runtime for the current target project.

Reads mix.exs in the current project directory and emits the version of every known Foundry-ecosystem dependency as a JSON object.