verdict

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package verdict is the engine's structured outcome contract: every migrate invocation ends in exactly one verdict — executed natively, refused with a typed reason and, where one exists, a safer native idiom, or failed during execution with the executor's stable outcome code and a disclosure of what committed before the failure. Refusals use a distinct exit code from operational errors. This type is the seam a future orchestrator adapter maps onto SchemaBot's ExecutionModeBlocked.

Index

Constants

View Source
const (
	// ExitCodeRefused is the process exit code for refusal. Exit 0 remains
	// exclusive to online-safe success and exit 1 to operational failure.
	ExitCodeRefused = 2
	// ExitCodeAcceptedBlocking marks committed execution without an online-
	// safety guarantee; it cannot be confused with online-safe exit 0.
	ExitCodeAcceptedBlocking = 3
)
View Source
const (
	// ClassCapabilityBoundary means the engine has no implemented safe route.
	ClassCapabilityBoundary = Class(refusal.ClassCapabilityBoundary)
	// ClassNoOnlineSafetyProblem means another owner should run the work.
	ClassNoOnlineSafetyProblem Class = "no-online-safety-problem"
	// ClassByDesign means pg-sprite permanently refuses the form.
	ClassByDesign = Class(refusal.ClassByDesign)
	// ClassEnvironmental means the current run environment blocked the work.
	ClassEnvironmental = Class(refusal.ClassEnvironmental)
	// ClassInvariantViolation reports incoherent engine state.
	ClassInvariantViolation = Class(refusal.ClassInvariantViolation)
)

Variables

View Source
var ErrAcceptedBlocking = errors.New("executed without online safety")

ErrAcceptedBlocking is returned after an accepted-blocking verdict is printed so the entry point can map it to ExitCodeAcceptedBlocking.

View Source
var ErrInvalidAcceptedBlocking = errors.New("invalid accepted-blocking verdict")

ErrInvalidAcceptedBlocking reports an incomplete accepted-blocking verdict.

View Source
var ErrRefused = errors.New("refused")

ErrRefused is the sentinel the CLI returns after printing a refusal verdict, so the entry point can map it to ExitCodeRefused.

Functions

func AcceptedBlockingDecision added in v0.3.3

func AcceptedBlockingDecision(r Refusal) (eligible, decided bool)

AcceptedBlockingDecision reports eligibility and whether the refusal key has an explicit decision. Completeness tests use decided to reject additions to the refusal vocabulary that have not been classified here.

func AcceptedBlockingEligible added in v0.3.3

func AcceptedBlockingEligible(r Refusal) bool

AcceptedBlockingEligible reports whether a typed refusal is in the closed accepted-blocking registry. Unknown combinations fail closed.

Types

type Cause

type Cause string

Cause narrows a refusal reason to the typed discriminator automation branches on without parsing prose: which budget fired under ReasonBudgetExceeded, or which parent shape was refused under ReasonUnsupportedPartitionedParent. The accepted-blocking registry keys on it, so a cause is part of the refusal identity, not a rendering detail.

const (
	// CauseNone is the zero cause for verdicts whose reason has no narrower
	// discriminator.
	CauseNone Cause = ""
	// CauseLockBudget: the lock was not granted within lock_timeout; nothing
	// was executed.
	CauseLockBudget Cause = "lock-budget"
	// CauseStatementBudget: the statement ran past statement_timeout and was
	// cancelled; the change needs a rewrite.
	CauseStatementBudget Cause = "statement-budget"
	// CauseParentBlockingIndexBuild identifies a blocking index build on a
	// partitioned parent.
	CauseParentBlockingIndexBuild Cause = "parent-blocking-index-build"
	// CauseParentConcurrentIndexBuild identifies a concurrent index build on
	// a partitioned parent.
	CauseParentConcurrentIndexBuild Cause = "parent-concurrent-index-build"
	// CauseParentIndexAdoption identifies index adoption on a partitioned parent.
	CauseParentIndexAdoption Cause = "parent-index-adoption"
	// CauseParentNotValidForeignKey identifies a NOT VALID foreign key on a
	// partitioned parent.
	CauseParentNotValidForeignKey Cause = "parent-not-valid-foreign-key"
	// CauseParentConcurrentIndexDrop identifies a concurrent drop of an
	// index of a partitioned parent, which PostgreSQL does not support.
	CauseParentConcurrentIndexDrop Cause = "parent-concurrent-index-drop"
	// CauseCopyAndSwapNotEnabled: the statement routes to the copy-and-swap
	// backend, which the caller has not opted into; nothing was read or
	// executed. The route is in preview, so it runs only when the policy
	// opens it.
	CauseCopyAndSwapNotEnabled Cause = "copy-and-swap-not-enabled"
)

The causes a refusal can carry, grouped by the reason they narrow.

type Class added in v0.3.3

type Class string

Class identifies the routing category of a refusal. The classes an engine cause can take are declared once, in the core's pkg/refusal, and carried here under the same token, so an adapter converts a cause's refusal.Class to a verdict Class with a plain conversion and nothing can spell the two apart; no-online-safety-problem is the verdict's own, since it describes a statement that never reached the engine.

func Classes added in v0.3.3

func Classes() []Class

Classes returns the closed set of refusal classes.

func ParseClass added in v0.3.3

func ParseClass(value string) (Class, error)

ParseClass validates a refusal class token.

type IndexUsage added in v0.4.0

type IndexUsage struct {
	// IdxScans is the cumulative count of scans of the index since
	// StatsReset, or since the index was created if that is later; for a
	// partitioned index, the sum over its leaf indexes.
	IdxScans int64 `json:"idx_scan"`
	// LastIdxScan is when the server last recorded a scan; absent when it
	// recorded none, and always on PostgreSQL 14 and 15. In UTC.
	LastIdxScan *time.Time `json:"last_idx_scan,omitempty"`
	// StatsReset is when the database's statistics were last reset; absent
	// when the server reports no reset. In UTC.
	StatsReset *time.Time `json:"stats_reset,omitempty"`
	// ReadAt is the server's clock when the evidence was read. In UTC.
	ReadAt time.Time `json:"read_at"`
	// Unique reports whether the index enforces uniqueness, a guarantee the
	// drop would also discard.
	Unique bool `json:"unique"`
	// Partitions is the number of leaf indexes of a partitioned index, whose
	// scans IdxScans sums; absent for an index that is not partitioned.
	Partitions *int `json:"partitions,omitempty"`
	// TrackCounts is false when the server was counting no scans, so a zero
	// IdxScans proves nothing.
	TrackCounts bool `json:"track_counts"`
	// TrackCountsOffBySetting is true when a saved ALTER ROLE or ALTER
	// DATABASE setting turns track_counts off, so the scans of those
	// sessions are missing from IdxScans.
	TrackCountsOffBySetting bool `json:"track_counts_off_by_setting"`
}

IndexUsage is how the server pg-sprite is connected to has seen an index used, read when a DROP INDEX is refused for want of the destructive acknowledgement. It describes that one server only: every replica keeps its own counters, so an index this server never scans may still serve a replica's reads.

func (IndexUsage) Summary added in v0.4.0

func (u IndexUsage) Summary() string

Summary renders the evidence on one line for the verdict's text form.

type Outcome

type Outcome string

Outcome is what happened to the submitted change.

const (
	// OutcomeExecuted means the change ran and committed natively within
	// its budgets.
	OutcomeExecuted Outcome = "executed-natively"
	// OutcomeExecutedWithoutOnlineSafety means the operator accepted a typed
	// blocking refusal and the statement committed under explicit budgets.
	OutcomeExecutedWithoutOnlineSafety Outcome = "executed-without-online-safety"
	// OutcomeExecutedViaCopyAndSwap means the change committed through the
	// copy-and-swap route: a shadow table built under the changed shape,
	// filled and verified against the source, then swapped into the
	// source's name. The source table was never rewritten in place.
	OutcomeExecutedViaCopyAndSwap Outcome = "executed-via-copy-and-swap"
	// OutcomeRefused means the change was not executed; Reason says why.
	OutcomeRefused Outcome = "refused"
	// OutcomeFailed means execution was attempted and failed: an
	// operational error, not a refusal — the process still exits 1. Code
	// carries the executor's stable outcome code, and for a mid-sequence
	// failure FailedStep and ExecutedSQL disclose the failed step and the
	// committed prefix whose state remains, so automation can distinguish
	// "nothing happened" from "partial state left behind".
	OutcomeFailed Outcome = "failed"
)

The outcomes a migrate run can end in.

type Owner added in v0.3.3

type Owner string

Owner identifies who owns work that has no online-safety problem.

const (
	// OwnerDataChangeRunner owns DML and backfills.
	OwnerDataChangeRunner Owner = "data-change-runner"
	// OwnerDeclarativeFrontDoor owns desired catalog convergence.
	OwnerDeclarativeFrontDoor Owner = "declarative-front-door"
	// OwnerDirectOperator means the operator runs the work directly.
	OwnerDirectOperator Owner = "direct-operator"
	// OwnerProvisioning owns access-control and replication provisioning.
	OwnerProvisioning Owner = "provisioning"
)

func Owners added in v0.3.3

func Owners() []Owner

Owners returns the closed set of refusal owners.

func ParseOwner added in v0.3.3

func ParseOwner(value string) (Owner, error)

ParseOwner validates a refusal owner token.

type Reason

type Reason string

Reason is the typed cause of a refusal. Reasons are flat kebab-case tokens — they are what automation switches on; prose belongs in Detail.

const (
	// ReasonNone is the zero reason carried by an executed verdict.
	ReasonNone Reason = ""
	// ReasonUnsupportedStatement: only ALTER TABLE is supported.
	ReasonUnsupportedStatement Reason = "unsupported-statement"
	// ReasonIndexStatement: index maintenance has a native safe idiom
	// (CONCURRENTLY) and is never attempted here.
	ReasonIndexStatement Reason = "index-statement"
	// ReasonTableTooLarge: the size guard skipped the optimistic attempt.
	ReasonTableTooLarge Reason = "not-native-safe-table-too-large"
	// ReasonInsufficientPrivileges: the connected role lacks the access
	// the change needs; Detail names the exact missing GRANT (see
	// docs/engine-role.md).
	ReasonInsufficientPrivileges Reason = "insufficient-privileges"
	// ReasonUnsupportedPartitionedParent: the plan has a step pg-sprite
	// cannot run on a partitioned parent: adopting an index as a
	// constraint, a NOT VALID foreign key before PostgreSQL 18, a
	// concurrent DROP INDEX of the parent's index, or a blocking index
	// build, which is what a forced CREATE INDEX takes. An unforced CREATE
	// INDEX is not one of these, because it runs as the partitioned index
	// build.
	ReasonUnsupportedPartitionedParent Reason = "unsupported-partitioned-parent"
	// ReasonBudgetExceeded: the optimistic attempt exceeded its lock or
	// statement budget and was cancelled.
	ReasonBudgetExceeded Reason = "not-native-safe-budget-exceeded"
	// ReasonRewriteRequired: the submitted form is not safe to run as
	// submitted — it blocks the table, or it is a rename that breaks the
	// application instances still using the old name — and must run as a
	// safer sequence, but the planner has none to substitute (a
	// multi-operation statement, a pattern it cannot build, or a rename,
	// whose safe sequence spans application deploys). Running the
	// submitted form would falsify the plan's own reason, so the engine
	// refuses instead unless the override names the table.
	ReasonRewriteRequired Reason = "not-native-safe-rewrite-required"
	// ReasonBackendUnavailable: the change routes to an execution strategy
	// that has no carrying path for the operation in this build (a
	// copy-and-swap rewrite the shadow-table engine does not carry yet).
	ReasonBackendUnavailable Reason = "backend-unavailable"
	// ReasonDestructiveChange: the change discards live data or structure —
	// a dropped column, constraint, index, or NOT NULL. The imperative
	// front door runs such a statement only when the destructive
	// acknowledgement names its table; desired-state execution refuses a
	// destructive plan whole and has no acknowledgement for it, so the
	// imperative statement is the way to run a reviewed destructive change.
	ReasonDestructiveChange Reason = "destructive-change"
	// ReasonPlanFingerprintMismatch: the plan recomputed at execution time
	// does not carry the fingerprint the caller pinned, so the plan a
	// reviewer approved is not the plan that would execute; nothing runs.
	ReasonPlanFingerprintMismatch Reason = "plan-fingerprint-mismatch"
	// ReasonCreateCollision: the create plan's target name is already
	// occupied — a relation or standalone type took it after the plan was
	// derived — so the greenfield create cannot run; the caller re-derives
	// the plan against the live catalog rather than assuming the
	// occupant's shape.
	ReasonCreateCollision Reason = "create-collision"
	// ReasonDeclarativeForeignKey: the desired-state plan adds a foreign
	// key, or creates a table that declares one, and desired-state
	// execution does not run foreign-key changes yet. The plan still shows
	// the change; the imperative front door runs ADD FOREIGN KEY online.
	ReasonDeclarativeForeignKey Reason = "declarative-foreign-key"
	// ReasonCopyAndSwapRefused: the change routes to copy-and-swap and the
	// route's own gates declined it — the preflight found a table shape or
	// an environment it cannot run against, or the engine refused mid-run
	// to keep an invariant. Cause carries the route's own refusal token
	// (see docs/refusal-classes.md), Class its routing class.
	ReasonCopyAndSwapRefused Reason = "copy-and-swap-refused"
)

The refusal reasons Phase 1 can emit.

func Reasons added in v0.2.0

func Reasons() []Reason

Reasons returns the closed set of non-zero Reason values. It is part of the verdict contract: the tokens are what automation switches on, so the set changes only deliberately, every token is pinned by test, and every token has a row in docs/cli-output-examples.md's refusal-reason table.

type Refusal added in v0.3.3

type Refusal struct {
	// contains filtered or unexported fields
}

Refusal is proof that a class, reason, and owner form a valid refusal: the fields are unexported and the only constructor validates them, so a refusal that reaches a renderer through WithRefusal has been classified. The classification registries in pkg/plan and pkg/migrate mint these; a refusal site never names a class on its own.

func ByDesign added in v0.3.3

func ByDesign(reason Reason) Refusal

ByDesign classifies a refusal of a form pg-sprite will never run.

func CapabilityBoundary added in v0.3.3

func CapabilityBoundary(reason Reason) Refusal

CapabilityBoundary classifies a refusal of work the engine may learn to do.

func Environmental added in v0.3.3

func Environmental(reason Reason) Refusal

Environmental classifies a refusal the run environment caused.

func InvariantViolation added in v0.3.3

func InvariantViolation(reason Reason) Refusal

InvariantViolation classifies a refusal of a state this build should not have produced.

func NewRefusal added in v0.3.3

func NewRefusal(class Class, reason Reason, owner Owner) (Refusal, error)

NewRefusal validates and constructs a refusal proof. It rejects a reason outside Reasons(), a class outside Classes(), an owner outside Owners(), and an owner that is absent when the class is no-online-safety-problem or present when it is not.

func NoOnlineSafetyProblem added in v0.3.3

func NoOnlineSafetyProblem(reason Reason, owner Owner) Refusal

NoOnlineSafetyProblem classifies a refusal of work that is safe to run elsewhere and names who runs it.

func (Refusal) Cause added in v0.3.3

func (r Refusal) Cause() Cause

Cause returns the typed cause that narrows the refusal, when one exists.

func (Refusal) Class added in v0.3.3

func (r Refusal) Class() Class

Class returns the refusal's validated class.

func (Refusal) IsZero added in v0.3.3

func (r Refusal) IsZero() bool

IsZero reports whether r was never constructed through NewRefusal.

func (Refusal) Owner added in v0.3.3

func (r Refusal) Owner() Owner

Owner returns the refusal's validated owner; empty unless the class is no-online-safety-problem.

func (Refusal) Reason added in v0.3.3

func (r Refusal) Reason() Reason

Reason returns the refusal's validated reason.

func (Refusal) Site added in v0.3.3

func (r Refusal) Site() RefusalSite

Site returns the typed refusal site that narrows the refusal, when one exists.

func (Refusal) WithCause added in v0.3.3

func (r Refusal) WithCause(cause Cause) Refusal

WithCause returns r narrowed by a typed cause.

func (Refusal) WithSite added in v0.3.3

func (r Refusal) WithSite(site RefusalSite) Refusal

WithSite returns r narrowed by a typed refusal site.

type RefusalSite added in v0.3.3

type RefusalSite string

RefusalSite is a typed refusal-site discriminator used when a reason spans statement shapes but has no underlying cause.

const (
	// RefusalSiteIndexSingleRelation is the plain one-relation DROP INDEX,
	// REINDEX INDEX, or REINDEX TABLE gate site.
	RefusalSiteIndexSingleRelation RefusalSite = "index-statement-single-relation"
	// RefusalSiteIndexOther is a multi-relation DROP INDEX, a DROP INDEX with
	// CASCADE, or a REINDEX scope that does not identify one relation.
	RefusalSiteIndexOther RefusalSite = "index-statement-other"
)

type StatisticsRefresh added in v0.4.0

type StatisticsRefresh struct {
	// Columns are the columns the statement retyped, in statement order.
	Columns []string `json:"columns"`
	// Refreshed reports that the ANALYZE committed.
	Refreshed bool `json:"refreshed"`
	// Pending is the ANALYZE still to run; empty when Refreshed.
	Pending string `json:"pending,omitempty"`
}

StatisticsRefresh is the outcome of re-analyzing a table after a committed type change, which deletes the retyped columns' planner statistics. The change stays committed whether or not the refresh ran, so a refresh still owed leaves the verdict executed and names the ANALYZE to run.

type Verdict

type Verdict struct {

	// Outcome is what happened.
	Outcome Outcome `json:"outcome"`
	// Reason is the typed refusal cause; empty when executed.
	Reason Reason `json:"reason,omitempty"`
	// Class identifies how a consumer routes a refusal.
	Class Class `json:"class,omitempty"`
	// Owner identifies who owns work with no online-safety problem.
	Owner Owner `json:"owner,omitempty"`
	// Cause narrows the refusal reason to its typed discriminator: the
	// budget that fired, or the partitioned-parent shape refused. Empty
	// when the reason has none. Preserved on an accepted-blocking verdict.
	Cause Cause `json:"cause,omitempty"`
	// Code is the executor's stable outcome code (executor.OutcomeCode)
	// carried by a failed verdict — flat kebab-case, part of the executor's
	// report contract. It stays a plain string here so this contract
	// package does not depend on the executor. Empty unless Outcome is
	// OutcomeFailed.
	Code string `json:"code,omitempty"`
	// SQLState is the SQLSTATE of the server error that failed the
	// statement, when the server rejected it; empty when the failure
	// was not a server error. Automation can branch on it, as on Code,
	// to tell a constraint the rows break (23514) from an object that
	// does not exist (42883). Empty unless Outcome is OutcomeFailed.
	SQLState string `json:"sqlstate,omitempty"`
	// ServerError is that server error's primary message, for display.
	// It leaves out the server's DETAIL line, but the primary message of
	// a data fault (SQLSTATE class 22) can still name a row's value, as
	// in `invalid input syntax for type integer: "abc"`. Empty exactly
	// when SQLState is.
	ServerError string `json:"server_error,omitempty"`
	// FailedStep is the 1-based position of the sequence step that failed,
	// matching the numbering the planner's partial-failure contracts use;
	// zero when the failure was not a mid-sequence one (a single-statement
	// attempt that fails before its COMMIT rolls back and commits nothing).
	// When Code is an outcome-unknown code, the step's own COMMIT may have
	// landed: its state is unknown, not failed.
	FailedStep int `json:"failed_step,omitempty"`
	// FailedStepSQL is the failed step's statement — the step the planner's
	// partial-failure contract says a retry resumes from. When Code is an
	// outcome-unknown code, the step may have committed, so a retry cannot
	// be assumed to resume here until the catalog is inspected.
	FailedStepSQL string `json:"failed_step_sql,omitempty"`
	// Attempts is how many bounded attempts ran before a lock-budget
	// refusal, so automation can tell an exhausted bounded retry from a
	// single cancelled attempt; zero for every other verdict.
	Attempts int `json:"attempts,omitempty"`
	// Statement is the submitted SQL.
	Statement string `json:"statement"`
	// Table is the target table (schema-qualified when the statement was),
	// when the statement has one.
	Table string `json:"table,omitempty"`
	// Detail is the human explanation: why refused, or what committed.
	Detail string `json:"detail,omitempty"`
	// WritesBlocked is true on an executed, failed, or refused copy-and-swap
	// verdict whose run blocked the table's writes (offline mode,
	// --block-writes): the write fence went on, and every write that reached
	// it was refused with SQLSTATE 55006. On a failed verdict it is set only
	// when the fence went on, and Detail says whether it still stands; on a
	// refused verdict it is set only when the stopped run's fence still
	// stands. A blocked-writes run that stopped before its fence went on
	// reports false, since the table kept taking writes. False for every
	// other verdict, including a live run's.
	WritesBlocked bool `json:"writes_blocked,omitempty"`
	// SwapLSN is set on an executed-via-copy-and-swap verdict whose run
	// committed the swap itself: the server's WAL insert position, in
	// PostgreSQL's pg_lsn text form (for example "0/1A2B3C8"), read inside
	// the swap transaction while its ACCESS EXCLUSIVE lock kept every other
	// session off the table, right before it committed. A write to the
	// table that committed below this position is in the retained source
	// and was carried into the new table; an orchestrator can use it to
	// state "writes after this position exist only in the new table".
	// Compare it with another position as pg_lsn, not as text. Empty when
	// the run did not hear its own swap commit: a run resumed after the
	// swap had committed, or one that lost its connection and learned of
	// the commit from the catalog. Empty for every other verdict.
	SwapLSN string `json:"swap_lsn,omitempty"`
	// Verification is set on an executed-via-copy-and-swap verdict whose
	// run verified the shadow before its swap: the figures of that
	// verification pass. Detail states the rows, chunks, and settled
	// chunks too; Unsettled and Carried are only here. Nil when
	// the pass compared no chunk — a run resumed after its swap had
	// committed makes no pass, and an empty table has nothing to compare —
	// and for every other verdict.
	Verification *Verification `json:"verification,omitempty"`
	// TableCreated is true on an executed verdict whose run created the
	// table, committing it in the same transaction as its row security, so
	// automation can tell a create from a run that converged a table that
	// already existed. Detail says the same for a reader. False for every
	// other verdict.
	TableCreated bool `json:"table_created,omitempty"`
	// ExtensionSchemas is set on a verdict whose run created the table
	// from a desired file that named extension schemas: the schemas the
	// create's unqualified names also resolved against, in search order
	// after the table's schema and public. ExecutedSQL ran under that
	// search path, so a reader replaying or auditing it needs them. Empty
	// for every other verdict.
	ExtensionSchemas []string `json:"extension_schemas,omitempty"`
	// Abandoned is true on a failed copy-and-swap verdict whose run the
	// engine abandoned on a data fault: the shadow is dropped, the hold on
	// the source — write fence or replication slot — is released, and the
	// checkpoint row is deleted, so nothing remains and the corrected
	// statement runs from the beginning without any acknowledgement. A
	// copy-and-swap data-fault verdict with it false is a run whose abandon
	// did not finish: the row and the hold stand as far as the discard got,
	// and the run is started over with the restart acknowledgement. A
	// data-fault verdict that carries FailedStep is a native concurrent
	// index build that failed on the rows, not a copy-and-swap run: there
	// is no run to abandon or restart, and the build's invalid index is
	// the leftover Detail names. It is the field automation branches on;
	// Detail says the same for a reader.
	// False for every other verdict, including a refusal: a run whose lock
	// session is lost after its discard finished comes back as the
	// shadow-lock-lost refusal, with nothing left behind but no field to say
	// so. On RunDesired it is set on the failed entry of
	// DesiredResult.Verdicts, not on the aggregate.
	Abandoned bool `json:"abandoned,omitempty"`
	// SaferIdiom is a native alternative to the refused statement, when one
	// exists (e.g. CREATE INDEX CONCURRENTLY, ADD CONSTRAINT ... NOT VALID).
	SaferIdiom string `json:"safer_idiom,omitempty"`
	// Guidance is the typed manual path for a rewrite-required refusal,
	// drawn from the suggest contract's Guidance vocabulary
	// (docs/suggest-report.md), the same value the plan report's statement
	// carries, for a destructive-change refusal whose statement drops a
	// column and adds it back under the same name, or for a
	// copy-and-swap-pk-unsupported refusal of a table with no primary key
	// (add-integer-primary-key). Detail states the steps
	// for a human; Guidance is the key an automated caller branches on.
	// Empty for every other verdict.
	Guidance suggest.Guidance `json:"guidance,omitempty"`
	// DependentViews names the views and materialized views that read the
	// column a refused statement retypes or drops, each schema-qualified
	// with every identifier quoted, sorted: the objects to drop or redefine
	// before the change can run. The same list the plan report's refused
	// decision carries, present whenever one blocks the change, whatever
	// the refusal's reason, and empty otherwise.
	DependentViews []string `json:"dependent_views,omitempty"`
	// DependentPolicies names the row-level security policies that read
	// the column a refused statement retypes or drops, each rendered
	// "policy" ON "schema"."table" with every identifier quoted, sorted:
	// the policies to drop before the change and recreate after it. The
	// same list the plan report's refused decision carries, present
	// whenever one blocks the change, whatever the refusal's reason, and
	// empty otherwise.
	DependentPolicies []string `json:"dependent_policies,omitempty"`
	// DependentTriggers names the triggers whose UPDATE OF list or WHEN
	// condition names the column a refused statement retypes or drops,
	// each rendered "trigger" ON "schema"."table" with every identifier
	// quoted, sorted. The same list the plan report's refused decision
	// carries, present whenever one blocks the change, whatever the
	// refusal's reason, and empty otherwise.
	DependentTriggers []string `json:"dependent_triggers,omitempty"`
	// DependentGeneratedColumns names the generated columns whose
	// expression reads the column a refused statement retypes or drops,
	// each rendered "schema"."table"."column" with every identifier quoted,
	// sorted. The same list the plan report's refused decision carries,
	// present whenever one blocks the change, whatever the refusal's
	// reason, and empty otherwise.
	DependentGeneratedColumns []string `json:"dependent_generated_columns,omitempty"`
	// PartitionKeyTables names the partitioned tables whose partition key
	// includes the column a refused statement retypes or drops, each
	// schema-qualified with every identifier quoted, sorted. The same list
	// the plan report's partition-key decision carries. Empty for every
	// other verdict.
	PartitionKeyTables []string `json:"partition_key_tables,omitempty"`
	// ExecutedSQL is the ordered SQL the engine actually ran and committed.
	// On an executed verdict it is the substituted safer native sequence
	// (empty when the submitted form ran as-is — a non-empty value is what
	// tells automation a substitution happened). On a failed verdict it is
	// the committed prefix that remains: empty means nothing is known to
	// have committed — and nothing at all did, unless Code is an
	// outcome-unknown code, in which case the failed step itself (or the
	// single statement) may have committed and the catalog decides.
	ExecutedSQL []string `json:"executed_sql,omitempty"`
	// Forced reports that --force overrode the engine's routing: the
	// submitted form ran as-is instead of a safer substitution or a
	// strategy refusal. It is the machine-readable audit record of the
	// override.
	Forced bool `json:"forced,omitempty"`
	// AllowedDestructive reports that --allow-destructive acknowledged the
	// data the statement discards: a statement the destructive-change gate
	// would refuse went on through the engine's other gates instead. It is
	// the machine-readable audit record of the acknowledgement, set on
	// every verdict the acknowledged statement ends in.
	AllowedDestructive bool `json:"allowed_destructive,omitempty"`
	// BlockingPassthrough marks execution of an operator-accepted refusal.
	BlockingPassthrough bool `json:"blocking_passthrough,omitempty"`
	// LockTimeout is the explicit lock-acquisition budget.
	LockTimeout string `json:"lock_timeout,omitempty"`
	// StatementTimeout is the explicit statement execution budget.
	StatementTimeout string `json:"statement_timeout,omitempty"`
	// StatisticsRefresh reports the ANALYZE a committed type change owes
	// the planner; nil when the statement retyped no column.
	StatisticsRefresh *StatisticsRefresh `json:"statistics_refresh,omitempty"`
	// IndexUsage is the live usage evidence of the index a destructive-change
	// refusal of an accepted DROP INDEX would have dropped; nil for every
	// other verdict.
	IndexUsage *IndexUsage `json:"index_usage,omitempty"`
	// contains filtered or unexported fields
}

Verdict is the structured outcome of one migrate invocation.

func (Verdict) JSON

func (v Verdict) JSON() (string, error)

JSON renders the verdict as a single JSON object.

func (Verdict) Refusal added in v0.3.3

func (v Verdict) Refusal() (Refusal, error)

Refusal reconstructs the classified refusal a refused verdict carries, so a caller that aggregates verdicts into its own result propagates the class and owner through the same one path instead of copying fields. It fails on a verdict that is not refused, or whose reason, class, and owner do not validate together — a verdict this build cannot have produced. An in-process verdict returns its full proof, re-validated the same way and checked against the exported refusal fields, so a proof that never passed the constructors, or fields rewritten after WithRefusal, cannot reach an eligibility decision. A verdict decoded from JSON reconstructs class, reason, owner, and cause, but cannot recover its refusal site; site-keyed eligibility therefore fails closed after JSON decoding, while cause-keyed eligibility is decidable from the JSON fields.

func (Verdict) String

func (v Verdict) String() string

String renders the verdict for humans.

func (Verdict) WithAcceptedBlocking added in v0.3.3

func (v Verdict) WithAcceptedBlocking(r Refusal, lockTimeout, statementTimeout time.Duration) (Verdict, error)

WithAcceptedBlocking returns an executed verdict that retains the accepted refusal identity and explicit non-zero execution budgets.

func (Verdict) WithRefusal added in v0.3.3

func (v Verdict) WithRefusal(r Refusal) Verdict

WithRefusal returns v as a refused verdict carrying r's reason, class, owner, cause, and full in-process proof. It is the one path from a classified refusal onto the verdict contract, so a site that forgets to classify has no Reason to set.

type Verification added in v0.5.5

type Verification struct {
	// Rows is the number of source rows the pass hashed.
	Rows int64 `json:"rows"`
	// Chunks is the number of chunks the pass compared.
	Chunks int `json:"chunks"`
	// Settled is the number of chunks a live pass found differing in its
	// sweep and then settled key by key against the stream; zero for a run
	// that blocked writes.
	Settled int `json:"settled"`
	// Unsettled is the number of chunks a live pass could settle neither
	// way, every one of them holding keys the pass left for the swap; zero
	// whenever Carried is.
	Unsettled int `json:"unsettled"`
	// Carried is the number of keys the live pass left for the swap to
	// compare under its lock, the keys of the unsettled chunks that never
	// held still; the swap compared each and found it equal, or it would
	// have refused. The count only: the keys themselves are row data.
	Carried int `json:"carried"`
}

Verification is what a copy-and-swap run's verification pass compared before the swap: the source against its shadow, chunk by chunk, up to the copy's complete watermark. Every field is present, zero included, so a reader tells a pass that settled nothing from one that did not say.

Jump to

Keyboard shortcuts

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