detective

package
v0.71.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 15 Imported by: 12

Documentation

Overview

Package detective owns shared Checks, Validators and investigation Cases. These JSON types are the common local, hosted, web and terminal contract.

Index

Constants

View Source
const (
	BindingInputBindable     = "input-bindable"
	BindingMissingInput      = "missing/incompatible-input"
	BindingInvalidDefinition = "invalid/unavailable-definition"
	BindingDeferredRow       = "deferred-row-binding"
)
View Source
const MaxFanout = maxFanout

Variables

View Source
var ErrCapacity = errors.New("detective catalog capacity reached")
View Source
var ErrConflict = errors.New("definition or case changed; reload before saving")
View Source
var ErrInvalid = errors.New("invalid detective item")
View Source
var ErrNotFound = errors.New("detective item not found")
View Source
var ErrOutcomeUncertain = errors.New("mutation may have been saved but audit failed; reload before retrying")

Functions

func ActionOperationPayload added in v0.54.0

func ActionOperationPayload(req ActionRequest) (any, error)

ActionOperationPayload includes trusted bridge metadata in operation digests even though ordinary action JSON cannot bind these fields. Adapters must call this before BindOperation and freshly resolve/authorize the private reference. Nil-reference legacy actions retain their exact previous JSON payload. The returned payload contains private inputs for hashing, not receipt/audit storage.

func AggregateSteps

func AggregateSteps(children []StepResult) (string, string, string)

func AppendCaseEvent

func AppendCaseEvent(c Case, event CaseEvent, eventID string, run *CheckRun, actor string, at time.Time) (Case, AuditEvent, error)

AppendCaseEvent accepts only client notes and links to existing run evidence. The repository supplies the verified run and server-issued event ID.

func ApplyScenario

func ApplyScenario(c Case, scenario Scenario, applicationID, actor string, at time.Time) (Case, AuditEvent, error)

ApplyScenario snapshots reusable manual guidance; no step runs automatically.

func AttachRun

func AttachRun(c Case, run CheckRun, eventID, actor string, at time.Time) (Case, AuditEvent, error)

AttachRun is server-only and requires an execution bound to this Case.

func BindCaseInputs added in v0.50.1

func BindCaseInputs(schema []Input, supplied, context map[string]InputValue) (map[string]InputValue, error)

BindCaseInputs merges the authoritative Case context into a Check's declared inputs. A declared Case value cannot be replaced by a caller-supplied value; a set or range in the Case must be declared by the Check. Unrelated scalar facts remain Case context and are not passed to the Check. Returned values own their nested storage so later caller edits cannot change accepted inputs.

func CheckOperationReplay

func CheckOperationReplay(saved OperationReceipt, current OperationBinding) error

CheckOperationReplay is required before returning a stored response for an existing operation ID. Any binding mismatch is an idempotency conflict.

func CreateCase

func CreateCase(item Case, actor string, at time.Time) (Case, AuditEvent, error)

CreateCase strips server-owned history and starts a versioned active Case. Capacity and uniqueness are repository checks inside its transaction.

func EffectivePolicy

func EffectivePolicy(policy string) string

func MatchCaseCohort added in v0.50.1

func MatchCaseCohort(context, inputs map[string]InputValue) error

MatchCaseCohort verifies inputs from an ordinary query or retained execution against the Case's confirmed context. Set and range cohorts must be present exactly; unrelated scalar facts may be omitted, but cannot be contradicted.

func MatchScenarioQueryCohort added in v0.52.0

func MatchScenarioQueryCohort(step ScenarioStep, caseContext, recordedParams map[string]InputValue) error

MatchScenarioQueryCohort checks a query step's server-recorded parameter values against the Case context. Range inputs are reconstructed only from their bound scalar endpoints; a caller cannot supply a separate cohort proof.

func RecordScenarioQueryStep

func RecordScenarioQueryStep(c Case, applicationID, stepID string, proof ScenarioQueryProof, actor string, at time.Time) (Case, AuditEvent, error)

RecordScenarioQueryStep marks an ordinary saved-query guidance step reviewed using a terminal, authorized receipt. No Validator pass is inferred.

func RecordScenarioStep

func RecordScenarioStep(c Case, applicationID, stepID, status, runID string, run *CheckRun, runLinked bool, actor string, at time.Time) (Case, AuditEvent, error)

RecordScenarioStep records one reviewed step in application order. A completed step must cite a persisted, Case-linked run of the same asset. runLinked is established by the adapter's direct run-link record, since Case.RunRefs may be a bounded recent projection in hosted storage.

func UpdateCase

func UpdateCase(old, next Case, actor string, at time.Time) (Case, AuditEvent, error)

UpdateCase applies a client edit while preserving run links, scenario applications, and server-issued lifecycle history from the stored version.

func ValidInputType

func ValidInputType(t investigation.ValueType) bool

func ValidParameterName

func ValidParameterName(name string) bool

func ValidQueryRef

func ValidQueryRef(id string) bool

func ValidSlug

func ValidSlug(id string) bool

func ValidTransition

func ValidTransition(old, next, reason string) bool

func ValidateCatalog

func ValidateCatalog(c Catalog) error

func ValidateCheck

func ValidateCheck(check Check) error

func ValidateInputs

func ValidateInputs(schema []Input, values map[string]InputValue) error

func ValidatePublishedValidator

func ValidatePublishedValidator(item PublishedValidator) error

func ValidateQueryValidators

func ValidateQueryValidators(item QueryValidators) error

func ValidateScenario

func ValidateScenario(scenario Scenario) error

ValidateScenario checks query range bindings per step. Scenario inputs may be consumed by query steps or by the Check steps they configure.

func ValidateValidator

func ValidateValidator(v Validator) error

Types

type ActionRequest

type ActionRequest struct {
	// Trusted bridge fields are supplied only after fresh private-store resolution.
	// Strict HTTP decoding rejects them; ActionOperationPayload binds them explicitly.
	InputReference            *apicontract.SessionInputReference `json:"-"`
	ExpectedDefinitionDigest  string                             `json:"-"`
	ExpectedCaseContextDigest string                             `json:"-"`
	Type                      string                             `json:"type"` // save-check | save-validator | save-query-validators | create-case | update-case | append-event | run-check | run-query-validators | save-scenario | apply-scenario | record-scenario-step
	Project                   string                             `json:"project"`
	SecurityContextID         string                             `json:"securityContextId"`
	Check                     *Check                             `json:"check,omitempty"`
	Validator                 *PublishedValidator                `json:"validator,omitempty"`
	QueryValidators           *QueryValidators                   `json:"queryValidators,omitempty"`
	Case                      *Case                              `json:"case,omitempty"`
	Scenario                  *Scenario                          `json:"scenario,omitempty"`
	Event                     *CaseEvent                         `json:"event,omitempty"`
	CheckID                   string                             `json:"checkId,omitempty"`
	QueryID                   string                             `json:"queryId,omitempty"`
	CaseID                    string                             `json:"caseId,omitempty"`
	ScenarioID                string                             `json:"scenarioId,omitempty"`
	ApplicationID             string                             `json:"applicationId,omitempty"`
	StepID                    string                             `json:"stepId,omitempty"`
	StepStatus                string                             `json:"stepStatus,omitempty"`
	RunID                     string                             `json:"runId,omitempty"`
	Execution                 *apicontract.ExecutionRef          `json:"execution,omitempty"`
	Environment               string                             `json:"environment,omitempty"`
	Inputs                    map[string]InputValue              `json:"inputs,omitempty"`
}

ActionRequest is POST /datatug/detective/action. Project and securityContextId are included in the body and must match the URL/session respectively.

type ActionResponse

type ActionResponse struct {
	Check           *Check              `json:"check,omitempty"`
	Validator       *PublishedValidator `json:"validator,omitempty"`
	QueryValidators *QueryValidators    `json:"queryValidators,omitempty"`
	Case            *Case               `json:"case,omitempty"`
	Run             *CheckRun           `json:"run,omitempty"`
	Scenario        *Scenario           `json:"scenario,omitempty"`
}

type AuditEvent

type AuditEvent struct {
	ID                string    `json:"id"`
	At                time.Time `json:"at"`
	Actor             string    `json:"actor"`
	Project           string    `json:"project"`
	Action            string    `json:"action"`
	CaseID            string    `json:"caseId,omitempty"`
	CheckID           string    `json:"checkId,omitempty"`
	QueryID           string    `json:"queryId,omitempty"`
	QueryRevision     string    `json:"queryRevision,omitempty"`
	ResultFingerprint string    `json:"resultFingerprint,omitempty"`
	ExecutionID       string    `json:"executionId,omitempty"`
	Source            string    `json:"source,omitempty"`
	ErrorCode         string    `json:"errorCode,omitempty"`
	RunID             string    `json:"runId,omitempty"`
	Environment       string    `json:"environment,omitempty"`
	Outcome           string    `json:"outcome,omitempty"`
	RowCount          int       `json:"rowCount,omitempty"`
	DurationMs        int64     `json:"durationMs,omitempty"`
}

AuditEvent deliberately carries metadata only. No parameter values, source rows, Case context, findings or free-text notes belong in a generic audit.

func AuditForRun

func AuditForRun(run CheckRun) AuditEvent

AuditForRun recursively summarizes immutable execution metadata only.

type Binding

type Binding struct {
	Input      string `json:"input"`
	FromInput  string `json:"fromInput,omitempty"`
	Part       string `json:"part,omitempty"` // start | end for range context
	FromColumn string `json:"fromColumn,omitempty"`
}

Binding maps a child input or saved-query parameter to a parent input or a query-result row column. Range inputs use Part to select a scalar endpoint.

type BindingPreflight added in v0.70.0

type BindingPreflight struct {
	State   string `json:"state"`
	CheckID string `json:"checkId"`
	StepID  string `json:"stepId,omitempty"`
}

BindingPreflight describes binding availability, never a Check outcome or source permission. Reasons contain only fixed codes and admitted identities.

func PreflightBindings added in v0.70.0

func PreflightBindings(c Catalog, root string, inputs map[string]InputValue, queryInputs map[string][]Input) BindingPreflight

PreflightBindings uses the execution engine's catalog/input/binding rules. queryInputs is authoritative saved-query parameter metadata admitted by the host, keyed by query reference. It accepts no executor, SQL, or source handle.

type Capabilities

type Capabilities struct {
	LocalOnly bool `json:"localOnly"`
	CanRead   bool `json:"canRead"`
	CanWrite  bool `json:"canWrite"`
	CanRun    bool `json:"canRun"`
	MaxRows   int  `json:"maxRows"`
	MaxFanout int  `json:"maxFanout"`
}

type Case

type Case struct {
	ID                   string                `json:"id"`
	Title                string                `json:"title"`
	Status               string                `json:"status"` // active | closed | archived
	Version              int64                 `json:"version"`
	Context              map[string]InputValue `json:"context"`
	IncidentRefs         []string              `json:"incidentRefs"`
	ScenarioRefs         []string              `json:"scenarioRefs"`
	ScenarioApplications []ScenarioApplication `json:"scenarioApplications,omitempty"`
	RunRefs              []string              `json:"runRefs"`
	Evidence             []EvidenceRef         `json:"evidence"`
	Findings             []Finding             `json:"findings"`
	Timeline             []CaseEvent           `json:"timeline"`
	TimelineOffset       int                   `json:"timelineOffset,omitempty"`
	ClosureReason        string                `json:"closureReason,omitempty"`
	CreatedAt            time.Time             `json:"createdAt"`
	UpdatedAt            time.Time             `json:"updatedAt"`
}

type CaseEvent

type CaseEvent struct {
	ID      string    `json:"id"`
	At      time.Time `json:"at"`
	Actor   string    `json:"actor"`
	Type    string    `json:"type"`
	Message string    `json:"message,omitempty"`
	Ref     string    `json:"ref,omitempty"`
}

type CaseEventsPage

type CaseEventsPage struct {
	CaseID     string      `json:"caseId"`
	Events     []CaseEvent `json:"events"`
	NextBefore int         `json:"nextBefore,omitempty"`
	HasMore    bool        `json:"hasMore"`
}
type CaseRunLink struct {
	CaseID string    `json:"caseId"`
	RunID  string    `json:"runId"`
	At     time.Time `json:"at"`
	Actor  string    `json:"actor"`
}

CaseRunLink is the authoritative direct lookup for a Case's execution evidence. Case.RunRefs is only a recent projection and may be paged.

type Catalog

type Catalog struct {
	Checks          map[string]Check
	Validators      map[string]PublishedValidator
	QueryValidators map[string]QueryValidators
	// contains filtered or unexported fields
}

Catalog is the bounded, transitive definition graph for one evaluation. It contains no Cases or Runs, and can be loaded through direct repository reads.

func LoadCatalog

func LoadCatalog(ctx context.Context, rootCheckID, rootQueryID string, reader CatalogReader) (Catalog, error)

LoadCatalog resolves all transitive Check, query-local and promoted Validator dependencies before a query can execute. Every saved-query reference is checked by the adapter. The bounded direct reads avoid a whole-project blob.

type CatalogReader

type CatalogReader interface {
	GetCheck(context.Context, string) (Check, error)
	GetPublishedValidator(context.Context, string) (PublishedValidator, error)
	GetQueryValidators(context.Context, string) (QueryValidators, bool, error)
	QueryExists(context.Context, string) (bool, error)
}

CatalogReader is implemented by local files or a hosted repository. A query without local Validators returns (QueryValidators{}, false, nil).

type Check

type Check struct {
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description,omitempty"`
	Version     int64     `json:"version"`
	Inputs      []Input   `json:"inputs"`
	Steps       []Step    `json:"steps"`
	UpdatedAt   time.Time `json:"updatedAt"`
	UpdatedBy   string    `json:"updatedBy"`
}

type CheckRun

type CheckRun struct {
	ID                  string                             `json:"id"`
	Kind                string                             `json:"kind"` // check | query-validators
	CheckID             string                             `json:"checkId"`
	QueryID             string                             `json:"queryId,omitempty"`
	Definition          Check                              `json:"definition"`
	Dependencies        []Check                            `json:"dependencies"`
	PublishedValidators []PublishedValidator               `json:"publishedValidators"`
	QueryValidators     []QueryValidators                  `json:"queryValidators"`
	CaseID              string                             `json:"caseId,omitempty"`
	Environment         string                             `json:"environment"`
	InputNames          []string                           `json:"inputNames"` // values deliberately excluded from history
	InputReference      *apicontract.SessionInputReference `json:"inputReference,omitempty"`
	ExecutionStatus     string                             `json:"executionStatus"`
	Outcome             string                             `json:"outcome"`
	Severity            string                             `json:"severity,omitempty"`
	Steps               []StepResult                       `json:"steps"`
	StartedAt           time.Time                          `json:"startedAt"`
	DurationMs          int64                              `json:"durationMs"`
	CheckInvocations    int                                `json:"checkInvocations"`
	QueryExecutions     int                                `json:"queryExecutions"`
	Actor               string                             `json:"actor"`
}

func EvaluateCheck

func EvaluateCheck(ctx context.Context, req RunRequest, catalog Catalog, runner QueryRunner, metadata ExecutionMetadata) (CheckRun, error)

EvaluateCheck runs a preloaded, validated transitive Catalog. The caller authorizes project/case access and supplies the secured saved-query runner. It persists the returned run and case link in its own transaction.

func EvaluateQueryValidators

func EvaluateQueryValidators(ctx context.Context, req RunRequest, catalog Catalog, runner QueryRunner, metadata ExecutionMetadata) (CheckRun, error)

EvaluateQueryValidators runs a saved query and its local Validators without creating a synthetic global Check. Catalog must contain that local entry.

func EvaluateQueryValidatorsForResult

func EvaluateQueryValidatorsForResult(ctx context.Context, req RunRequest, catalog Catalog, result apicontract.Result, runner QueryRunner, metadata ExecutionMetadata) (CheckRun, error)

EvaluateQueryValidatorsForResult validates the rows of the exact execution selected by the user. The server must first authorize the execution, verify its project/query/environment, load its retained row snapshot under current policy, and convey any truncation or hidden/filtered population limitations. Core never trusts a client-supplied Result. Nested Checks still use runner.

type EvidenceRef

type EvidenceRef struct {
	ID   string `json:"id"`
	Kind string `json:"kind"` // check-run | query | external
	Ref  string `json:"ref"`
	Note string `json:"note,omitempty"`
}

type ExecutionMetadata

type ExecutionMetadata func(context.Context, *apicontract.ExecutionRef) (revision, fingerprint string, err error)

ExecutionMetadata resolves a server-issued immutable execution reference. A local engine embedding may omit it, but the HTTP runner records receipts.

type Finding

type Finding struct {
	ID           string   `json:"id"`
	Text         string   `json:"text"`
	Status       string   `json:"status"` // hypothesis | confirmed
	EvidenceRefs []string `json:"evidenceRefs,omitempty"`
}

type Input

type Input struct {
	Name        string                  `json:"name"`
	Type        investigation.ValueType `json:"type"`
	Cardinality string                  `json:"cardinality"` // scalar | set | range
	Required    bool                    `json:"required,omitempty"`
}

type InputValue

type InputValue struct {
	Scalar *Value
	Set    *apicontract.TypedValueSet
	Range  *ValueRange
}

InputValue uses Core's scalar/set wire form and adds a typed closed range. A range is investigation context; a saved query must explicitly bind its start/end to scalar parameters before execution.

func (InputValue) MarshalJSON

func (v InputValue) MarshalJSON() ([]byte, error)

func (*InputValue) UnmarshalJSON

func (v *InputValue) UnmarshalJSON(data []byte) error

func (InputValue) Validate

func (v InputValue) Validate() error

type OperationBinding

type OperationBinding struct {
	Project       string
	Actor         string
	Action        string
	ResourceID    string
	PayloadDigest string
}

OperationBinding ties an idempotency key to the authenticated principal, project scope, action, resource and the exact semantic request. The adapter must compute it server-side after authorization, never accept a client hash.

func BindOperation

func BindOperation(project, actor, action, resourceID string, payload any) (OperationBinding, error)

BindOperation computes a deterministic SHA-256 over Go's canonical JSON encoding (sorted map keys, stable struct fields). The payload is never put into OperationReceipt or the audit stream.

type OperationReceipt

type OperationReceipt struct {
	ID              string    `json:"id"`
	Project         string    `json:"project"`
	Actor           string    `json:"actor"`
	Action          string    `json:"action"`
	PayloadDigest   string    `json:"payloadDigest"` // server-computed canonical request binding
	ResourceID      string    `json:"resourceId,omitempty"`
	ResourceVersion int64     `json:"resourceVersion,omitempty"`
	At              time.Time `json:"at"`
}

OperationReceipt is an idempotency record committed with each mutation and audit event. It carries no parameter values, rows or free-text Case content.

func NewOperationReceipt

func NewOperationReceipt(id string, binding OperationBinding, resourceVersion int64, at time.Time) (OperationReceipt, error)

NewOperationReceipt binds one successful atomic mutation to its accepted request. The adapter persists this with resource changes and audit event.

func (OperationReceipt) Validate

func (r OperationReceipt) Validate() error

type Page

type Page[T any] struct {
	Items      []T    `json:"items"`
	NextCursor string `json:"nextCursor,omitempty"`
	HasMore    bool   `json:"hasMore"`
}

Page is a bounded direct-resource listing. Cursors are opaque to Core.

type PublishedValidator

type PublishedValidator struct {
	ID        string    `json:"id"`
	Title     string    `json:"title"`
	Version   int64     `json:"version"`
	Validator Validator `json:"validator"`
}

PublishedValidator is explicitly promoted; ordinary Validators remain attached to their query step. The promoted version is snapshotted in runs.

type QueryFailure

type QueryFailure struct{ Code string }

QueryFailure carries only an allowlisted execution error code across the runner boundary. Driver errors may contain URLs or data values and are never copied into persisted runs or responses.

func (*QueryFailure) Error

func (e *QueryFailure) Error() string

type QueryParameters

type QueryParameters = map[string]apicontract.TypedValueOrSet

QueryParameters is the result of explicit scalar/set bindings. A range must be mapped to start and end parameters before reaching the query runner.

type QueryValidators

type QueryValidators struct {
	QueryID    string      `json:"queryId"`
	Version    int64       `json:"version"`
	Validators []Validator `json:"validators"`
}

QueryValidators are local to one saved query until explicitly promoted.

type Repository

type Repository interface {
	CatalogReader
	GetCase(context.Context, string) (Case, error)
	GetRun(context.Context, string) (CheckRun, error)
	GetCaseRunLink(context.Context, string, string) (CaseRunLink, error)
	GetScenario(context.Context, string) (Scenario, error)
	ListChecks(context.Context, string, int) (Page[Check], error)
	ListCases(context.Context, string, int) (Page[Case], error)
	ListCaseEvents(context.Context, string, string, int) (Page[CaseEvent], error)
	ListRuns(context.Context, string, int) (Page[CheckRun], error)
	ListCaseRunLinks(context.Context, string, string, int) (Page[CaseRunLink], error)
	ListScenarios(context.Context, string, int) (Page[Scenario], error)
	ListPublishedValidators(context.Context, string, int) (Page[PublishedValidator], error)
	ListQueryValidators(context.Context, string, int) (Page[QueryValidators], error)
	Transact(context.Context, string, func(Transaction) error) error
}

Repository uses direct typed records and bounded pages; a hosted adapter never has to fetch or write one whole-project State document. Authorization of the project, saved queries and linked evidence precedes these operations.

type RunRequest

type RunRequest struct {
	InputReference            *apicontract.SessionInputReference `json:"-"`
	ExpectedDefinitionDigest  string                             `json:"-"`
	ExpectedCaseContextDigest string                             `json:"-"`
	ID                        string
	CheckID                   string
	QueryID                   string
	CaseID                    string
	Environment               string
	Actor                     string
	Inputs                    map[string]InputValue
}

RunRequest contains server-issued identity and names only. Input values are used during evaluation and never copied into CheckRun or the audit stream.

type Scenario

type Scenario struct {
	ID          string         `json:"id"`
	Title       string         `json:"title"`
	Description string         `json:"description,omitempty"`
	Version     int64          `json:"version"`
	Inputs      []Input        `json:"inputs"`
	Steps       []ScenarioStep `json:"steps"`
}

type ScenarioApplication

type ScenarioApplication struct {
	ID              string                `json:"id"`
	ScenarioID      string                `json:"scenarioId"`
	ScenarioVersion int64                 `json:"scenarioVersion"`
	Snapshot        Scenario              `json:"snapshot"`
	AppliedAt       time.Time             `json:"appliedAt"`
	AppliedBy       string                `json:"appliedBy"`
	Steps           []ScenarioStepReceipt `json:"steps"`
}

type ScenarioQueryProof

type ScenarioQueryProof struct {
	Execution       apicontract.ExecutionRef
	QueryID         string
	Environment     string
	ExecutionStatus string // completed only; errors/running cannot complete guidance
}

ScenarioQueryProof is formed only after an adapter verifies an immutable saved-query receipt, project/principal access, query identity and environment. Ordinary query execution has no positive health assertion.

type ScenarioStep

type ScenarioStep struct {
	ID       string    `json:"id"`
	Kind     string    `json:"kind"` // query | check
	Ref      string    `json:"ref"`
	Bindings []Binding `json:"bindings,omitempty"`
}

type ScenarioStepReceipt

type ScenarioStepReceipt struct {
	StepID          string                    `json:"stepId"`
	Status          string                    `json:"status"` // pending | completed | skipped: procedural progress, not a health verdict
	RunID           string                    `json:"runId,omitempty"`
	Execution       *apicontract.ExecutionRef `json:"execution,omitempty"` // ordinary saved-query receipt
	Environment     string                    `json:"environment,omitempty"`
	EvidenceOutcome string                    `json:"evidenceOutcome,omitempty"` // pass | fail | unknown
	At              time.Time                 `json:"at,omitempty"`
	Actor           string                    `json:"actor,omitempty"`
}

type State

type State struct {
	Checks          []Check              `json:"checks"`
	Validators      []PublishedValidator `json:"validators"`
	QueryValidators []QueryValidators    `json:"queryValidators"`
	Cases           []Case               `json:"cases"`
	Runs            []CheckRun           `json:"runs"`
	RunsHasMore     bool                 `json:"runsHasMore"`
	RunsNextCursor  string               `json:"runsNextCursor,omitempty"`
	Scenarios       []Scenario           `json:"scenarios"`
	Environments    []string             `json:"environments,omitempty"`
	Capabilities    Capabilities         `json:"capabilities"`
}

type Step

type Step struct {
	ID            string      `json:"id"`
	Kind          string      `json:"kind"` // query | check
	QueryID       string      `json:"queryId,omitempty"`
	CheckID       string      `json:"checkId,omitempty"`
	Bindings      []Binding   `json:"bindings,omitempty"`
	Validators    []Validator `json:"validators,omitempty"`
	OnUnavailable string      `json:"onUnavailable,omitempty"`
}

type StepResult

type StepResult struct {
	StepID            string                    `json:"stepId"`
	Kind              string                    `json:"kind"`
	QueryID           string                    `json:"queryId,omitempty"`
	Source            string                    `json:"source,omitempty"`
	ObservedAt        string                    `json:"observedAt,omitempty"`
	ExecutionProfile  string                    `json:"executionProfile,omitempty"`
	Execution         *apicontract.ExecutionRef `json:"execution,omitempty"`
	QueryRevision     string                    `json:"queryRevision,omitempty"`
	ResultFingerprint string                    `json:"resultFingerprint,omitempty"`
	ErrorCode         string                    `json:"errorCode,omitempty"`
	DurationMs        int64                     `json:"durationMs,omitempty"`
	CheckID           string                    `json:"checkId,omitempty"`
	ExecutionStatus   string                    `json:"executionStatus"` // pending | running | completed | error | skipped
	Outcome           string                    `json:"outcome"`         // pass | fail | unknown
	EvidenceOutcome   string                    `json:"evidenceOutcome,omitempty"`
	OnUnavailable     string                    `json:"onUnavailable,omitempty"`
	Disposition       string                    `json:"disposition,omitempty"`
	Limitations       []apicontract.Limitation  `json:"limitations,omitempty"`
	Severity          string                    `json:"severity,omitempty"`
	RowCount          int                       `json:"rowCount,omitempty"`
	Message           string                    `json:"message,omitempty"`
	Validators        []ValidationResult        `json:"validators,omitempty"`
	Children          []StepResult              `json:"children,omitempty"`
}

type Transaction

type Transaction interface {
	GetCase(context.Context, string) (Case, error)
	GetRun(context.Context, string) (CheckRun, error)
	GetCaseRunLink(context.Context, string, string) (CaseRunLink, error)
	GetScenario(context.Context, string) (Scenario, error)
	GetOperation(context.Context, string) (OperationReceipt, error)
	PutCheck(context.Context, Check, int64) error
	PutPublishedValidator(context.Context, PublishedValidator, int64) error
	PutQueryValidators(context.Context, QueryValidators, int64) error
	PutScenario(context.Context, Scenario, int64) error
	PutCase(context.Context, Case, int64) error
	PutRun(context.Context, CheckRun) error
	PutCaseRunLink(context.Context, CaseRunLink) error
	AppendCaseEvents(context.Context, string, []CaseEvent) error
	AppendAudit(context.Context, AuditEvent) error
	PutOperation(context.Context, OperationReceipt) error
}

Transaction writes one operation receipt, its typed resources and its metadata-only audit event atomically. Put* methods compare expectedVersion; zero means the resource must be absent. The adapter must fail closed on a stale version, duplicate ID or an unavailable audit/receipt store. Before returning a stored response, GetOperation callers must call CheckOperationReplay with a fresh server-side BindOperation. PutOperation must reject receipts that fail Validate.

type ValidationResult

type ValidationResult struct {
	ValidatorID     string       `json:"validatorId"`
	ExecutionStatus string       `json:"executionStatus"`
	Outcome         string       `json:"outcome"` // pass | fail | unknown
	EvidenceOutcome string       `json:"evidenceOutcome,omitempty"`
	OnUnavailable   string       `json:"onUnavailable,omitempty"`
	Disposition     string       `json:"disposition,omitempty"`
	Severity        string       `json:"severity"`
	RowIndex        *int         `json:"rowIndex,omitempty"`
	Message         string       `json:"message,omitempty"`
	Children        []StepResult `json:"children,omitempty"`
}

type Validator

type Validator struct {
	ID            string    `json:"id"`
	ValidatorID   string    `json:"validatorId,omitempty"` // reference to promoted catalog definition
	Scope         string    `json:"scope"`                 // row | set
	Kind          string    `json:"kind"`                  // non-null | equals-fields | row-count | unique | sum-equals | check
	Severity      string    `json:"severity"`              // critical | error | warning | info
	Field         string    `json:"field,omitempty"`
	OtherField    string    `json:"otherField,omitempty"`
	Expected      *Value    `json:"expected,omitempty"`
	CheckID       string    `json:"checkId,omitempty"`
	Bindings      []Binding `json:"bindings,omitempty"`
	OnUnavailable string    `json:"onUnavailable,omitempty"` // block | fail | warn | skip
}

type Value

type Value = investigation.TypedValue

type ValueRange

type ValueRange struct {
	Type  string `json:"type"` // range
	Start Value  `json:"start"`
	End   Value  `json:"end"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL