fluid-core/internal/contract/routing_policy_gen.go
tegwick 76912adef8
Some checks failed
ci / build (push) Failing after 1m6s
Generate contract types, pin fixtures to spec, add build and ADRs
Completes FLUID-WP-0002. The record types in internal/contract are
generated from schemas/ by a dependency-free generator; fixtures
transcribed from the spec's worked examples validate against those
schemas and round-trip through the generated types with
DisallowUnknownFields, so a spec change that misses the schemas fails
CI rather than drifting silently.

Adds identifier prefix helpers, Makefile, GitHub Actions, and five ADRs
recording the Go choice, out-of-process attachment, the wire contract as
boundary, the evidence store, and revision identity.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014KmVxhJ35tCo7rE7UnLwWu

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 1116572@bnt-lap001
Assistant-Session: 8ba9bb93-a72a-4883-b189-2499cce5c400
2026-09-04 02:03:12 +02:00

82 lines
3.5 KiB
Go

// Code generated by tools/schemagen. DO NOT EDIT.
// Source: schemas/. Regenerate with `make generate`.
package contract
// What keeps a long-lived consumer on one side of an experiment.
type RoutingPolicyRulesItemStickyBy string
const (
RoutingPolicyRulesItemStickyByConsumerID RoutingPolicyRulesItemStickyBy = "consumer_id"
RoutingPolicyRulesItemStickyByTenant RoutingPolicyRulesItemStickyBy = "tenant"
RoutingPolicyRulesItemStickyByCorrelationID RoutingPolicyRulesItemStickyBy = "correlation_id"
RoutingPolicyRulesItemStickyByNone RoutingPolicyRulesItemStickyBy = "none"
)
// Valid reports whether v is a defined RoutingPolicyRulesItemStickyBy.
func (v RoutingPolicyRulesItemStickyBy) Valid() bool {
switch v {
case RoutingPolicyRulesItemStickyByConsumerID, RoutingPolicyRulesItemStickyByTenant, RoutingPolicyRulesItemStickyByCorrelationID, RoutingPolicyRulesItemStickyByNone:
return true
}
return false
}
type RoutingPolicyRulesItem struct {
// Revision id to traffic share. Shares must sum to 1. Assignment of a given
// consumer must be stable across requests.
Allocation map[string]UnitInterval `json:"allocation" yaml:"allocation"`
Cohort *CohortID `json:"cohort,omitempty" yaml:"cohort,omitempty"`
Experiment *ExperimentID `json:"experiment,omitempty" yaml:"experiment,omitempty"`
// What keeps a long-lived consumer on one side of an experiment.
StickyBy *RoutingPolicyRulesItemStickyBy `json:"sticky_by,omitempty" yaml:"sticky_by,omitempty"`
Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty"`
}
type RoutingPolicySignatureAlgorithm string
const (
RoutingPolicySignatureAlgorithmEd25519 RoutingPolicySignatureAlgorithm = "ed25519"
)
// Valid reports whether v is a defined RoutingPolicySignatureAlgorithm.
func (v RoutingPolicySignatureAlgorithm) Valid() bool {
switch v {
case RoutingPolicySignatureAlgorithmEd25519:
return true
}
return false
}
type RoutingPolicySignature struct {
Algorithm RoutingPolicySignatureAlgorithm `json:"algorithm" yaml:"algorithm"`
KeyID string `json:"key_id" yaml:"key_id"`
Value string `json:"value" yaml:"value"`
}
type RoutingPolicy struct {
// Where a request lands when no earlier resolution step matched.
DefaultRevision RevisionID `json:"default_revision" yaml:"default_revision"`
// Monotonic. The router ignores a policy older than the one it holds.
Generation int64 `json:"generation" yaml:"generation"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Interface InterfaceID `json:"interface" yaml:"interface"`
IssuedAt *Timestamp `json:"issued_at,omitempty" yaml:"issued_at,omitempty"`
IssuedBy *Actor `json:"issued_by,omitempty" yaml:"issued_by,omitempty"`
// Evaluated in order; the first matching rule wins. Matching must be a pure
// function of the request and its cohort assignment.
Rules []RoutingPolicyRulesItem `json:"rules" yaml:"rules"`
SchemaVersion SchemaVersion `json:"schema_version" yaml:"schema_version"`
Signature *RoutingPolicySignature `json:"signature,omitempty" yaml:"signature,omitempty"`
}
// Deterministic routing written by the experiment controller and consumed by the
// revision router. The controller never touches traffic itself; this separation
// keeps experimental intent out of the runtime decision mechanism
// (ArchitectureBlueprint.md section 17).
type RoutingPolicyDocument struct {
RoutingPolicy RoutingPolicy `json:"routing_policy" yaml:"routing_policy"`
}