|
Some checks failed
validate / Rego (opa fmt + opa test) (push) Successful in 16s
validate / JSON Schema (ajv) (push) Successful in 20s
build-images / signing-service image (push) Successful in 24s
validate / DB (migrate up/down dry-run) (push) Failing after 26s
validate / Go (vet + test) (push) Successful in 1m16s
Adds services/verification-service exposing POST /api/v1/verify/chain for sink:dummy-sink. The handler runs the six hard-coded chain checks described in DEV-612 and reserves decision_id in a new `verification_decisions` table so a replayed sink delivery is refused without recomputing signatures. - DSSE signature verification against configurable approval + transform signer key_ids, loaded from VERIFICATION_SIGNER_KEYS (pem/hex/b64/b64u) - RFC 6962 inclusion-proof verifier (shared leaf/node hashing with services/transparency-log/pkg/backend) - Content binding: subject.digest.sha256 must match predicate.content_hash (approval) and request.payload_hash (transform) - Hard-coded coverage of allowed_transformations / allowed_sinks / expires_at predicates (OPA deferred to Phase 2 per the subtask) - Replay guard via new db/trust/migrations/0005_verification_decisions (in-memory store ships; Postgres skeleton mirrors sibling pattern) - Dockerfile mirrors signing-service pattern (distroless static + nonroot) - README documents endpoint, reason-code taxonomy, required predicate fields, and the Phase-2 non-scope Tests: happy path + 7 negatives (bad signature, missing inclusion proof, hash drift, sink not allowed, expired, replay, operation not allowed). Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|---|---|---|
| .. | ||
| trust | ||
| README.md | ||
ProofedMesh Database Layer
Alle Postgres-Schemas von ProofedMesh werden mit golang-migrate versioniert. Entscheidungsgrundlage: siehe ADR-0004.
Layout
db/
├── README.md — diese Datei
├── trust/
│ ├── migrations/
│ │ ├── 0001_per_diem_rates.up.sql
│ │ ├── 0001_per_diem_rates.down.sql
│ │ ├── 0002_agents.up.sql
│ │ ├── 0002_agents.down.sql
│ │ ├── 0003_agent_keys.up.sql
│ │ └── 0003_agent_keys.down.sql
│ └── seeds/
│ └── 0001_phase1_agents.sql
└── expense/
└── migrations/ — kommt im Phase-4-Rollout der DB-App
Seeds werden nicht von migrate versioniert — sie sind idempotentes
Bootstrap-SQL für Phase-1-Fixturen (z.B. die drei Agent-Identitäten) und
werden per psql -f oder äquivalentem Kubernetes-Job eingespielt. Jeder
Seed MUSS ON CONFLICT … DO NOTHING / IF NOT EXISTS verwenden, damit
mehrfaches Einspielen nach einem migrate down/up-Zyklus keine Duplikate
produziert.
Jede logische Datenbank bekommt ein eigenes migrations/-Verzeichnis. Die Migrationstabelle (schema_migrations) wird je Datenbank separat gepflegt. Pro Postgres-Instanz können mehrere logische Schemas liegen — die Migrationen schreiben SQL mit CREATE SCHEMA IF NOT EXISTS und SET search_path.
Konventionen
- Dateinamen:
NNNN_description.up.sql+.down.sql(vierstellige Nummer, Snake-Case). - Nummerierung streng monoton. Fehlerhafte Migrationen werden nie umnummeriert — immer durch eine neue Migration korrigiert.
- Immutable Business-Felder werden per
BEFORE UPDATE-Trigger gesichert (sieheper_diem_rates). - Postgres-Extensions werden am Anfang der Migration eingezogen (
CREATE EXTENSION IF NOT EXISTS …). - Jede
up.sqlMUSS eindown.sqlhaben; diedown.sqlDARF im Business-Fall unvollständig oder destruktiv sein, muss das dann aber im Kommentar sagen.
Lokal ausführen
Voraussetzung: eine lokale Postgres (z.B. docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:16) und die migrate-CLI (brew install golang-migrate / apt install migrate / go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest).
# Up (alle noch nicht angewandten Migrationen)
migrate -path db/trust/migrations \
-database "postgres://postgres:postgres@localhost:5432/trust?sslmode=disable" up
# Down um eine Version
migrate -path db/trust/migrations \
-database "postgres://postgres:postgres@localhost:5432/trust?sslmode=disable" down 1
# Aktuelle Version anzeigen
migrate -path db/trust/migrations \
-database "postgres://postgres:postgres@localhost:5432/trust?sslmode=disable" version
In Prod
- Rollout als dedizierter Kubernetes-Job (
job-migrate-trust) VOR dem Rolling-Update der trust-api-Pods. Siehe ADR-0004 → Ausführungsmodell. - Trust-API startet nur, wenn
schema_migrations.dirty = falseund die höchste Version die vom Code erwartete erreicht. - Rollback ist ein manueller Prozess mit CTO-Freigabe.
CI
Der Job db in .forgejo/workflows/validate.yml macht pro PR und
main-Push:
- Startet
postgres:16-alpineals Container. migrate up→ prüft, dassper_diem_rates,agentsundagent_keysangelegt sind.migrate down 2→ prüft, dassagentsundagent_keyswieder entfernt sind,per_diem_ratesaber bleibt (Trenn-Test).migrate uperneut und spieltdb/trust/seeds/0001_phase1_agents.sqlzweimal ein (Idempotenz-Test, Erwartung: genau 3 Seed-Zeilen).
Lint (sqlfluff / pg_format) ist noch nicht aktiviert — kommt in
einem separaten Heartbeat.