AOC (Aggregation-Only Contracts)

Status: Implemented Source: src/Aoc/ Owner: Platform Team

Purpose

Audience: developers building or maintaining ingestion connectors (Concelier, Excititor, and similar), plus reviewers verifying that raw upstream data is never silently enriched with computed fields.

AOC enforces aggregation-only contract rules during data ingestion: connectors may persist raw upstream data with provenance, but must not write fields that are computed by downstream merge/decisioning pipelines. Enforcement is two-layered — a runtime write-guard and Roslyn analyzers. AOC is a shared library; it has no HTTP service of its own. (Some source comments still say “Append-Only Contract”; same concept.)

Components

Libraries:

Analyzers:

CLI:

Key Concepts

Forbidden fields (runtime guard, top-level → ERR_AOC_001):

Derived fields (→ ERR_AOC_006):

Document shape: the guard also enforces required/allowed top-level fields, a non-empty tenant, and upstream/content/linkset/signature provenance. Default required top-level fields are tenant, source, upstream, content, linkset (see AocGuardOptions). Codes emitted: ERR_AOC_004 (missing provenance — upstream.content_hash / upstream.signature / content.raw), ERR_AOC_005 (signature payload invalid), ERR_AOC_007 (unknown top-level field), ERR_AOC_008 (missing required field, incl. missing upstream/content/linkset), ERR_AOC_009 (invalid tenant), ERR_AOC_010 (invalid signature metadata). The enum also reserves ERR_AOC_002 (MergeAttempt) and ERR_AOC_003 (IdempotencyViolation), but AocWriteGuard.Validate does not currently emit them. See ./architecture.md §2–§3.

Configuration (AocGuardOptions): RequireTenant (default true), RequireSignatureMetadata (default true, requires upstream.signature), AllowedSignatureFormats (empty = accept any), RequiredTopLevelFields, AllowedTopLevelFields. The ASP.NET Core filter resolves options from an explicit guardOptions argument, else IOptions<AocGuardOptions>, else AocGuardOptions.Default.

HTTP mapping (AocHttpResults.Problem): RFC 7807 with problem type https://stella-ops.org/problems/aoc-violation; status by first violation code — ERR_AOC_003 → 409, ERR_AOC_004/ERR_AOC_005 → 422, ERR_AOC_006 → 403, all others → 400.