ProofedMesh/services/transparency-log/pkg/backend/trillian.go
CTO 69b3f3012f
All checks were successful
validate / Rego (opa fmt + opa test) (push) Successful in 14s
validate / JSON Schema (ajv) (push) Successful in 20s
validate / Go (vet + test) (push) Successful in 20s
services: add transparency-log Go service (ADR-0005 POST /api/v1/log/entries)
- services/transparency-log/pkg/backend: Backend interface with in-memory
  append-log (RFC 6962 Merkle tree) + Trillian wrapper (prod stub).
- Idempotenz-Pflicht: Wiederaufruf mit identischem content_hash liefert
  200 + gleichen log_index + aktuellen inclusion_proof.
- content_hash-Verifikation serverseitig; Mismatch → 409.
- pkg/httpapi: ADR-0005-konformer Handler (201/200/400/404/409/503).
- cmd/transparency-log: minimaler HTTP-Server, memory default,
  --backend trillian als Stub (503).
- Interop-Test in services/admin-api/internal/tlog/interop_test.go
  fährt die echte transparency-log pkg gegen die admin-api
  HTTPSubmitter — Happy-Path, Idempotenz und content_hash-Mismatch
  abgedeckt.
- go test: 10 Tests transparency-log + 2 Interop-Tests admin-api, go
  vet clean in beiden Modulen.

Folge-Subtask: Trillian-Deployment + Keys (siehe ADR-0005 Open Points).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-25 18:08:53 +00:00

35 lines
1.4 KiB
Go

package backend
import (
"context"
"errors"
)
// Trillian is the production backend wrapper that will talk to a Trillian
// log server. It is intentionally a stub for now — ADR-0005 lists Trillian
// deployment + keys as a follow-up subtask. Once that lands, this struct
// gains a Trillian LogClient and translates Submit() into
// trillian.QueueLeaves + GetInclusionProofByHash (or the current API shape
// at the time of integration).
//
// Keeping the stub here lets the httpapi + wiring layer treat the two
// backends uniformly and prevents the server from accidentally shipping
// without a prod backend hook.
type Trillian struct {
// Endpoint will later hold the Trillian LogServer address, e.g.
// "trillian-log.agent-trust.svc.cluster.local:8090".
Endpoint string
// LogID will later hold the Trillian tree id this service writes to.
LogID int64
}
// Submit returns ErrTrillianUnavailable until the Trillian deployment ships.
// Config loading, auth plumbing and the actual LogClient wiring belong in
// the follow-up Trillian subtask.
func (t Trillian) Submit(_ context.Context, _ Envelope, _ string) (Receipt, bool, error) {
return Receipt{}, false, ErrTrillianUnavailable
}
// ErrTrillianUnavailable signals that the prod backend is not wired yet.
// Translated to HTTP 503 by the httpapi layer.
var ErrTrillianUnavailable = errors.New("transparency-log: trillian backend not deployed")