app

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeStrictJSONObject

func DecodeStrictJSONObject(raw []byte) (map[string]any, error)

DecodeStrictJSONObject decodes raw JSON as exactly one non-null object. It rejects trailing values and duplicate object keys at every nesting level.

func FailurePrecedence

func FailurePrecedence(class domain.FailureClass) int

FailurePrecedence returns the canonical operational precedence for a failure class. Higher values win when independent failures are observed together.

Types

type CommandName

type CommandName string

CommandName is one command in the fixed Mulgae command surface.

const (
	CommandInit      CommandName = "init"
	CommandDoctor    CommandName = "doctor"
	CommandReview    CommandName = "review"
	CommandFollowup  CommandName = "followup"
	CommandDelta     CommandName = "delta"
	CommandRerun     CommandName = "rerun"
	CommandCompose   CommandName = "compose"
	CommandStatus    CommandName = "status"
	CommandReport    CommandName = "report"
	CommandFindings  CommandName = "findings"
	CommandExcerpt   CommandName = "excerpt"
	CommandProviders CommandName = "providers"
	CommandHeartbeat CommandName = "heartbeat"
	CommandRoles     CommandName = "roles"
	CommandConfig    CommandName = "config"
	CommandSchema    CommandName = "schema"
	CommandClean     CommandName = "clean"
	CommandExport    CommandName = "export"
	CommandHelp      CommandName = "help"
)

func ParseCommandName

func ParseCommandName(value string) (CommandName, error)

ParseCommandName validates a command from the fixed command surface.

func (CommandName) Valid

func (command CommandName) Valid() bool

Valid reports whether command belongs to the fixed command surface.

type CommandResult

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

CommandResult is the immutable application result consumed by a CLI adapter.

func NewCommandFailure

func NewCommandFailure(command CommandName, exitCode ExitCode, diagnostics ...Diagnostic) (CommandResult, error)

NewCommandFailure creates a typed failed command result. Every diagnostic is retained in order, allowing a command to preserve independent root causes.

func NewCommandResult

func NewCommandResult(command CommandName, ok bool, exitCode ExitCode, data []byte, diagnostics []Diagnostic) (CommandResult, error)

NewCommandResult validates a command-result combination and takes ownership of data and diagnostics. Successful results must be success/0, carry no diagnostics, and provide exactly one non-null JSON object. Failed results must use a nonzero assigned exit, carry no data, and include at least one typed diagnostic with a machine code and message.

func NewCommandSuccess

func NewCommandSuccess(command CommandName, data []byte) (CommandResult, error)

NewCommandSuccess creates an OK command result with caller-owned data that contains exactly one non-null JSON object.

func NewCommittedCommandOutcome

func NewCommittedCommandOutcome(command CommandName, exitCode ExitCode, data []byte, reasons []string) (CommandResult, error)

NewCommittedCommandOutcome creates a data-bearing child workflow outcome from verified terminal authority. Its policy and readiness exits are committed outcomes, not transport failures, and retain every stable terminal reason.

func NewCommittedCommandOutcomeWithReasons added in v0.1.2

func NewCommittedCommandOutcomeWithReasons(command CommandName, exitCode ExitCode, data []byte, reasons []CommittedReason) (CommandResult, error)

NewCommittedCommandOutcomeWithReasons preserves safe attributed messages for each independent terminal reason without changing the v1 wire shape.

func (CommandResult) Command

func (result CommandResult) Command() CommandName

Command returns the command that produced this result.

func (CommandResult) CommittedOutcome

func (result CommandResult) CommittedOutcome() bool

CommittedOutcome reports whether the result is a verified child workflow terminal outcome rather than an ordinary success or transport failure.

func (CommandResult) CommittedReasons

func (result CommandResult) CommittedReasons() []CommittedReason

CommittedReasons returns caller-owned stable terminal reasons.

func (CommandResult) Data

func (result CommandResult) Data() []byte

Data returns a caller-owned copy of successful or committed result data. Transport failures always return nil data.

func (CommandResult) Diagnostics

func (result CommandResult) Diagnostics() []Diagnostic

Diagnostics returns a caller-owned copy of the ordered typed diagnostics.

func (CommandResult) ExitCode

func (result CommandResult) ExitCode() ExitCode

ExitCode returns the assigned CLI exit projection.

func (CommandResult) OK

func (result CommandResult) OK() bool

OK reports whether the command completed with a success exit.

type CommittedReason added in v0.1.2

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

CommittedReason is one safe, stable reason attached to a data-bearing P2 outcome. Message may be empty, in which case the CLI supplies its historical generic text for the code.

func NewCommittedReason added in v0.1.2

func NewCommittedReason(code, message string) (CommittedReason, error)

func (CommittedReason) Code added in v0.1.2

func (reason CommittedReason) Code() string

func (CommittedReason) Message added in v0.1.2

func (reason CommittedReason) Message() string

type Diagnostic

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

Diagnostic is a redacted, typed description of one user-facing failure. It deliberately carries neither a causal error nor arbitrary bytes, so adapters must redact any untrusted detail before constructing it.

func NewDiagnostic

func NewDiagnostic(
	stage string,
	failureClass domain.FailureClass,
	machineCode string,
	message string,
	role string,
	provider string,
	attemptID domain.AttemptID,
	artifactPath string,
	recommendedNextCommand string,
) (Diagnostic, error)

NewDiagnostic constructs a typed, redacted user-facing diagnostic. Empty role, provider, attempt ID, artifact path, and recommended command represent fields that are not applicable to this failure.

func NewDiagnosticWithRetryable

func NewDiagnosticWithRetryable(
	stage string,
	failureClass domain.FailureClass,
	machineCode string,
	message string,
	retryable bool,
) (Diagnostic, error)

NewDiagnosticWithRetryable constructs a diagnostic whose command-envelope retryability is defined by a command-owned outcome contract rather than the generic provider-fault classification.

func NewDiagnosticWithRetryableArtifactPath

func NewDiagnosticWithRetryableArtifactPath(
	stage string,
	failureClass domain.FailureClass,
	machineCode string,
	message string,
	retryable bool,
	artifactPath string,
) (Diagnostic, error)

NewDiagnosticWithRetryableArtifactPath constructs a diagnostic with both a command-owned retryability override and an installed, redacted artifact path.

func NewDiagnosticWithRetryableDetails added in v0.1.2

func NewDiagnosticWithRetryableDetails(
	stage string,
	failureClass domain.FailureClass,
	machineCode string,
	message string,
	retryable bool,
	role string,
	provider string,
	artifactPath string,
	recommendedNextCommand string,
) (Diagnostic, error)

NewDiagnosticWithRetryableDetails constructs a command-owned retryable diagnostic while retaining closed provider attribution and a redacted remediation command.

func (Diagnostic) ArtifactPath

func (diagnostic Diagnostic) ArtifactPath() string

ArtifactPath returns the optional redacted diagnostic artifact path.

func (Diagnostic) AttemptID

func (diagnostic Diagnostic) AttemptID() domain.AttemptID

AttemptID returns the optional provider attempt identifier. Its zero value means no attempt applies to this diagnostic.

func (Diagnostic) FailureClass

func (diagnostic Diagnostic) FailureClass() domain.FailureClass

FailureClass returns the typed domain failure class.

func (Diagnostic) MachineCode

func (diagnostic Diagnostic) MachineCode() string

MachineCode returns the stable machine-readable reason code.

func (Diagnostic) Message

func (diagnostic Diagnostic) Message() string

Message returns the redacted user-facing explanation.

func (Diagnostic) Provider

func (diagnostic Diagnostic) Provider() string

Provider returns the optional provider instance identifier.

func (Diagnostic) ProviderFault added in v0.1.4

func (diagnostic Diagnostic) ProviderFault() bool

ProviderFault reports whether this failure is attributable to the provider rather than to Mulgae, the captured target, or the operator. When it is true, running the role on a different provider is a reasonable next step, and RecommendedNextCommand names one when the command could construct it.

func (Diagnostic) RecommendedNextCommand

func (diagnostic Diagnostic) RecommendedNextCommand() string

RecommendedNextCommand returns the optional redacted next command.

func (Diagnostic) Retryable

func (diagnostic Diagnostic) Retryable() bool

Retryable returns the command-owned retryability override when present and otherwise reports whether the failure was the provider's fault, which is the case where rerunning can plausibly produce a different result.

func (Diagnostic) Role

func (diagnostic Diagnostic) Role() string

Role returns the optional functional role identifier.

func (Diagnostic) Stage

func (diagnostic Diagnostic) Stage() string

Stage returns the application stage that classified the failure.

type ExitCode

type ExitCode int

ExitCode is the process exit projection of a command result.

const (
	ExitCodeSuccess      ExitCode = 0
	ExitCodePolicy       ExitCode = 1
	ExitCodeUsage        ExitCode = 2
	ExitCodeReadiness    ExitCode = 4
	ExitCodeArtifact     ExitCode = 7
	ExitCodeSecurity     ExitCode = 8
	ExitCodeCancellation ExitCode = 9
	ExitCodeInternal     ExitCode = 10
)

func (ExitCode) Valid

func (code ExitCode) Valid() bool

Valid reports whether code is an assigned Mulgae exit code.

Directories

Path Synopsis
Package childrun executes and publishes supplied child review runs.
Package childrun executes and publishes supplied child review runs.
Package clean builds deterministic, side-effect-free retention plans.
Package clean builds deterministic, side-effect-free retention plans.
Package config admits the project-local Config v3 pair and projects the fixed runtime policy consumed by review composition.
Package config admits the project-local Config v3 pair and projects the fixed runtime policy consumed by review composition.
Package delta starts immutable A-to-B child review runs.
Package delta starts immutable A-to-B child review runs.
Package doctor reports redacted, evidence-backed environment readiness.
Package doctor reports redacted, evidence-backed environment readiness.
Package evidence verifies provider current-evidence claims against caller-owned immutable target bytes.
Package evidence verifies provider current-evidence claims against caller-owned immutable target bytes.
Package export builds deterministic, redacted export packages from verified P2 projections.
Package export builds deterministic, redacted export packages from verified P2 projections.
Package followup starts one immutable, finding-scoped child workflow.
Package followup starts one immutable, finding-scoped child workflow.
Package heartbeat owns the explicitly authorized live provider diagnostic.
Package heartbeat owns the explicitly authorized live provider diagnostic.
Package help exposes exact embedded help assets through the application layer.
Package help exposes exact embedded help assets through the application layer.
Package init implements project-local configuration discovery, bootstrap, machine-local refresh, and crash-truthful installation.
Package init implements project-local configuration discovery, bootstrap, machine-local refresh, and crash-truthful installation.
Package prompt compiles the byte-exact provider stdin packet.
Package prompt compiles the byte-exact provider stdin packet.
Package providers lists the fixed, trusted provider profiles without invoking them.
Package providers lists the fixed, trusted provider profiles without invoking them.
Package publication builds deterministic, schema-validated publication records.
Package publication builds deterministic, schema-validated publication records.
Package query exposes committed publication data to status, findings, excerpt, and report consumers.
Package query exposes committed publication data to status, findings, excerpt, and report consumers.
Package recovery owns immutable failed-run inputs and accepted partial results.
Package recovery owns immutable failed-run inputs and accepted partial results.
Package report renders a human-readable projection of a committed query snapshot.
Package report renders a human-readable projection of a committed query snapshot.
Package rerun starts immutable child runs that replay a verified source attempt.
Package rerun starts immutable child runs that replay a verified source attempt.
Package review coordinates one deterministic, in-memory review run.
Package review coordinates one deterministic, in-memory review run.
Package reviewcompose admits exact committed recovery results and computes a deterministic composite review without invoking providers or reading a live target.
Package reviewcompose admits exact committed recovery results and computes a deterministic composite review without invoking providers or reading a live target.
Package reviewrun contains provider-independent review-run admission policy.
Package reviewrun contains provider-independent review-run admission policy.
Package roleassets is the single application-layer reader of the build-owned role catalog document.
Package roleassets is the single application-layer reader of the build-owned role catalog document.
Package roles exposes the fixed build-owned review role inventory.
Package roles exposes the fixed build-owned review role inventory.
Package schema exposes the embedded schema catalog through application ports.
Package schema exposes the embedded schema catalog through application ports.
Package validation validates untrusted provider review output before it enters the domain model.
Package validation validates untrusted provider review output before it enters the domain model.

Jump to

Keyboard shortcuts

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