Skip to content

feat: Anthropic provider + /v1/messages ingress (ADR-0001 start set) - #4

Merged
command0r merged 8 commits into
mainfrom
feat/anthropic
Sep 4, 2026
Merged

command0r merged 8 commits into
mainfrom
feat/anthropic

Conversation

@command0r

Copy link
Copy Markdown
Owner

Official Anthropic SDK over IChatClient (opt-in via Anthropic:ApiKey; the model joins the permitted set mid-list, explicit-request only, never default escalation). The /v1/messages dialect works with or without the provider: x-api-key auth (Bearer fallback), string-or-block content normalization, Anthropic error taxonomy on every denial, Messages SSE event protocol with lazy header commit. One pipeline, two dialects, cross-protocol routing. 15 tests: wire mapping, SSE event well-formedness (parsed), error taxonomy, and integration (401/403/502 shapes, PII fail-closed, streamed pre-flight stays JSON, Bearer fallback, cross-protocol route). Verifier agent: APPROVE; both should-fixes (SSE-JSON coverage, Bearer test) closed.

…ctable

Every Nth entry's head hash is appended to a separate anchor file
(Audit:AnchorPath on an independent storage domain, Audit:AnchorEvery
cadence; both-or-neither, validated fail-closed). Verification requires
the log to contain every anchored count with exactly the anchored hash:
truncation past an anchor and coherent whole-log rewrites both fail.
Rotation archives log and anchors together. ADR-0007 also records the
Postgres verdict: the file stays the evidence of record; DB triggers
are HA or runtime-editable config, never bundled.

Tests prove the gap closure explicitly: the same truncated log passes
plain verification and fails anchored verification.
- anchor failure now returns ZERO trusted entries (a coherent forgery
  has no trustworthy prefix); the graph projector gates on verification
  validity instead of discarding it — forged history can no longer be
  projected or aggregated
- audit log write failure halts the appliance (FailFast) — serving
  without evidence is the thing this product exists to prevent; anchor
  write failure warns loudly and widens exposure by one cadence only,
  never killing the primary drain
- rotation archives stale anchors even when the log is missing
- anchor monotonicity enforced (tamper tell on the anchor file itself)
- tests: restart continuity, anchors-without-log, malformed anchors,
  anchor-archive-not-deleted
…y + empty-return tests

A forged prefix ending in a deliberate break can no longer dodge anchor
comparison: anchors within the verified prefix are always evaluated,
and any contradiction returns zero trusted entries. Doc comments
updated; tests pin monotonicity, the empty-return contract on hash
mismatch, and the walk-break-dodge attack.
Official Anthropic SDK over IChatClient, opt-in via Anthropic:ApiKey;
the configured model joins the permitted set mid-list (explicit request
only, never default escalation). The /v1/messages dialect works with
or without the provider: x-api-key auth, string-or-block content
normalization, Anthropic error taxonomy on every denial path, Messages
SSE event protocol with lazy header commit. One pipeline, two dialects,
cross-protocol routing (Anthropic wire in, any permitted adapter out).

Tests +10: wire mapping (content forms, system, roles, response shape,
error taxonomy table) and integration (401/403/502 shapes, PII fail-
closed, streamed pre-flight denial stays JSON, cross-protocol route).
…text partial

CI CS8785: splitting [JsonSerializable] across two partial declarations
of the same JsonSerializerContext collided the source generator's hint
names (CovenantJsonContext.Boolean.g.cs), which made the generator bail
and left both CovenantJsonContext and AuditJsonContext without their
generated members (CS0534). All registrations now live on the single
attributed declaration in OpenAiContracts.cs.
…xception on double StopAsync

WebApplicationFactory disposal can invoke StopAsync more than once;
Channel.Writer.Complete() throws on an already-completed channel, which
surfaced as flaky teardown failures in the integration tests. TryComplete
is idempotent.
Registry resolves from DI (ConfigureTestServices override wins); the
pipeline becomes a lazily-resolved singleton. Unlocks success paths an
unroutable provider never reaches. +5 tests through the real Host with a
stub provider: OpenAI buffered + SSE serving, Anthropic buffered + SSE
serving (cross-protocol), served request in evidence with attributed
spend. Raises coverage over response building, SSE emission, attribution.
…ernance logic)

The runsettings landed on main via the CI PR; this branch predated it,
so local coverage runs errored on the missing file. Identical content —
dedupes on merge.
@command0r
command0r merged commit f14ef3a into main Sep 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant