Architecture

Architecture

AI-ChainGuard. 4 min read. Source on GitHub. Passes the style check.

Provenance chain: signed stages linked from the datasets to the deployment Opens at full size in a new tab.
The provenance chain as the console draws it.

One core library (chainguard/) holds all security logic. The CLI, FastAPI backend, ML pipeline, deployment gateway, attack scripts, and CI call that same library, so there's exactly one implementation of hashing, signing and verification. The dashboard uses only the HTTP API.

1. Overall System Architecture#

Workspace

chainguard/ core library

api/ FastAPI

Clients

HTTP

cli/main.py

ml_pipeline/
PyTorch

GitHub Actions

dashboard/
Streamlit

REST routes

crypto/hashing
SHA-256

crypto/canonical

crypto/signing + keys
Ed25519

manifest/
models + builder

provenance/merkle

provenance/policy

semantic/data_checks

verification/verifier
V0-V9

registry

trust

artifacts/manifests
signed envelopes

data/ + artifacts/models

SQLite index

keys/ 0600

deployment/gateway

Figure 1. Overall system architecture.

2. AI Supply-Chain Lifecycle with Attestation Points#

VERIFIED

FAILED / WARNING

Data collection
sklearn digits

Stage 1
datasets attested
data_steward

Stage 2
base model trained
training_pipeline

Stage 3
fine-tuned model
training_pipeline

Stage 4
deployment gateway

Signed deployment record
release root

Blocked
DEPLOYMENT_BLOCKED event

Figure 2. AI supply-chain lifecycle with attestation points.

3. Artifact Attestation Sequence#

Envelope files +SQLiteTrust store +Ed25519Semantic checksHashing + MerkleVerifierRegistryloop[each parent]Caller (pipeline / CLI/ API)register(file, type, stage, role,parents)verify(parent) - refuse ifFAILEDread parent payload, compute manifest digestpolicy check (type,stage, role, parenttypes)load role key, check it matches trusted key idSHA-256 (streamed) [+ row Merkle tree for CSV]content checks (datasets) BEFORE signingbuild payload (subject,parents' digests,provenance, checks,signer)sign canonical_json(payload)write envelope + leaves sidecar, index row, event, metricsartifact_id, manifest_digest
Figure 3. Artifact attestation sequence.

4. Verification Sequence#

SQLite (trust store,revocation)FilesVerifierGateway / API / CIverify(artifact_id)V0 load envelope (raw JSON,schema, id matches)V1 recompute SHA-256 + sizeV2 recompute row Merkleroot, diff via authenticatedsidecarV3/V4 public key, revocation, role, identityV3 Ed25519 verify overcanonical payloadV5 load parents, recomputetheir manifest digestsV6 recurse into everyparent (memoised)V7 revocation of artifact + ancestors, index row existsV8 policy, V9 semanticflags (own + inherited)store run, status, metrics, eventsVERIFIED / WARNING / FAILED+ per-check report
Figure 4. Verification sequence.

5. Attack-Detection Workflow#

no

yes

no

yes

no

yes

yes

no

no

yes

yes

no

Artifact presented

V1/V2 bytes and rows
match signed values?

FAILED: content tampered
Scenarios A, B, E1

V3/V4 valid signature
by trusted key in role?

FAILED: invalid or untrusted signature
Scenario D

V5/V6 parents exist,
digests match, ancestors pass?

FAILED: broken provenance
Scenario C

V7 revoked anywhere
in the chain?

FAILED: revoked

V8 policy satisfied?

FAILED: policy violation
C4

V9 content flagged
here or upstream?

WARNING: integrity intact,
content suspicious - E3

VERIFIED - still not proof of safety
E2, E4

Figure 5. Attack-detection workflow.

6. Deployment View#

docker compose

HTTP

pipeline
one-shot

volume: workspace

api :8000

dashboard :8501

Browser

Figure 6. Deployment view.

7. Key Design Decisions#

Decision Alternatives Reason
Envelopes on disk are the source of truth; SQLite is an index DB as truth CI and auditors can verify from files; DB tampering can't fake integrity
Sign the whole canonical payload Sign only the file hash Prevents swapping stage, parents, version, role around a valid hash
Parents referenced by manifest digest By artifact id only Hash-linking makes history rewrites detectable (C2)
Recursive verification at every use Trust a parent's stored status Stored status can be edited; recomputation costs a few ms
Semantic flags → WARNING only Fail on any flag Keeps heuristics from being mistaken for cryptographic proof
Role-bound keys + YAML policy One signing key Limits blast radius of one key compromise