fluid-core/internal/contract/experiment_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

108 lines
5.5 KiB
Go

// Code generated by tools/schemagen. DO NOT EDIT.
// Source: schemas/. Regenerate with `make generate`.
package contract
type FluidExperimentAmendmentsItem struct {
Actor Actor `json:"actor" yaml:"actor"`
At Timestamp `json:"at" yaml:"at"`
Change string `json:"change" yaml:"change"`
Reason string `json:"reason" yaml:"reason"`
}
type FluidExperimentMechanism string
const (
FluidExperimentMechanismSandbox FluidExperimentMechanism = "sandbox"
FluidExperimentMechanismShadow FluidExperimentMechanism = "shadow"
FluidExperimentMechanismSynthetic FluidExperimentMechanism = "synthetic"
FluidExperimentMechanismReplay FluidExperimentMechanism = "replay"
FluidExperimentMechanismCanary FluidExperimentMechanism = "canary"
FluidExperimentMechanismOptIn FluidExperimentMechanism = "opt_in"
FluidExperimentMechanismCohort FluidExperimentMechanism = "cohort"
FluidExperimentMechanismTenant FluidExperimentMechanism = "tenant"
FluidExperimentMechanismPercentage FluidExperimentMechanism = "percentage"
)
// Valid reports whether v is a defined FluidExperimentMechanism.
func (v FluidExperimentMechanism) Valid() bool {
switch v {
case FluidExperimentMechanismSandbox, FluidExperimentMechanismShadow, FluidExperimentMechanismSynthetic, FluidExperimentMechanismReplay, FluidExperimentMechanismCanary, FluidExperimentMechanismOptIn, FluidExperimentMechanismCohort, FluidExperimentMechanismTenant, FluidExperimentMechanismPercentage:
return true
}
return false
}
// Primary metrics and guardrails are kept distinct so a scalar can never hide a
// regression (ArchitectureBlueprint.md section 48.5).
type FluidExperimentMetrics struct {
Guardrails []string `json:"guardrails,omitempty" yaml:"guardrails,omitempty"`
Learning []string `json:"learning,omitempty" yaml:"learning,omitempty"`
Primary []string `json:"primary" yaml:"primary"`
Secondary []string `json:"secondary,omitempty" yaml:"secondary,omitempty"`
}
type FluidExperimentResultState string
const (
FluidExperimentResultStatePLANNED FluidExperimentResultState = "PLANNED"
FluidExperimentResultStateRUNNING FluidExperimentResultState = "RUNNING"
FluidExperimentResultStateSTOPPED FluidExperimentResultState = "STOPPED"
FluidExperimentResultStateCOMPLETED FluidExperimentResultState = "COMPLETED"
FluidExperimentResultStateABANDONED FluidExperimentResultState = "ABANDONED"
)
// Valid reports whether v is a defined FluidExperimentResultState.
func (v FluidExperimentResultState) Valid() bool {
switch v {
case FluidExperimentResultStatePLANNED, FluidExperimentResultStateRUNNING, FluidExperimentResultStateSTOPPED, FluidExperimentResultStateCOMPLETED, FluidExperimentResultStateABANDONED:
return true
}
return false
}
type FluidExperimentResult struct {
EvidenceRefs []EvidenceRef `json:"evidence_refs,omitempty" yaml:"evidence_refs,omitempty"`
PreferredRevision *RevisionID `json:"preferred_revision,omitempty" yaml:"preferred_revision,omitempty"`
State FluidExperimentResultState `json:"state" yaml:"state"`
StoppedReason *string `json:"stopped_reason,omitempty" yaml:"stopped_reason,omitempty"`
}
type FluidExperiment struct {
// Shares by revision id or by the reserved key 'control'. Allocation is
// deterministic and enacted by the router, never by this record.
Allocation map[string]UnitInterval `json:"allocation" yaml:"allocation"`
// Success criteria may not be changed after results are visible without recording
// the amendment (ArchitectureBlueprint.md section 18).
Amendments []FluidExperimentAmendmentsItem `json:"amendments,omitempty" yaml:"amendments,omitempty"`
CandidateRevisions []RevisionID `json:"candidate_revisions" yaml:"candidate_revisions"`
Cohorts []CohortID `json:"cohorts,omitempty" yaml:"cohorts,omitempty"`
ControlRevision RevisionID `json:"control_revision" yaml:"control_revision"`
// An experiment without a hypothesis measures nothing in particular.
HypothesisRefs []HypothesisID `json:"hypothesis_refs" yaml:"hypothesis_refs"`
ID ExperimentID `json:"id" yaml:"id"`
InterfaceID InterfaceID `json:"interface_id" yaml:"interface_id"`
MaxDurationHours *float64 `json:"max_duration_hours,omitempty" yaml:"max_duration_hours,omitempty"`
Mechanism *FluidExperimentMechanism `json:"mechanism,omitempty" yaml:"mechanism,omitempty"`
// Primary metrics and guardrails are kept distinct so a scalar can never hide a
// regression (ArchitectureBlueprint.md section 48.5).
Metrics FluidExperimentMetrics `json:"metrics" yaml:"metrics"`
PlannedEndAt *Timestamp `json:"planned_end_at,omitempty" yaml:"planned_end_at,omitempty"`
Result FluidExperimentResult `json:"result" yaml:"result"`
SchemaVersion SchemaVersion `json:"schema_version" yaml:"schema_version"`
StartAt *Timestamp `json:"start_at,omitempty" yaml:"start_at,omitempty"`
StartConditions []string `json:"start_conditions,omitempty" yaml:"start_conditions,omitempty"`
// Every experiment has a stop condition (ArchitectureBlueprint.md section 55,
// invariant 7).
StopConditions []string `json:"stop_conditions" yaml:"stop_conditions"`
}
// Connects hypotheses to revisions under bounded conditions. Experiments must be
// interruptible (ArchitectureBlueprint.md section 16).
type ExperimentDocument struct {
FluidExperiment FluidExperiment `json:"fluid_experiment" yaml:"fluid_experiment"`
}