Documentation
¶
Overview ¶
Package validation validates untrusted provider review output before it enters the domain model. It deliberately has no provider, evidence lookup, or publication dependencies.
Index ¶
- Constants
- func CompareCurrentEvidenceClaims(left, right CurrentEvidenceClaim) int
- func RuntimeCause(err error) (domain.RuntimeDiagnosticCause, bool)
- func ValidateReviewCompleteness(completeness string, limitations []string) error
- type CurrentEvidenceClaim
- func (claim CurrentEvidenceClaim) LineEnd() int
- func (claim CurrentEvidenceClaim) LineStart() int
- func (claim CurrentEvidenceClaim) Path() ports.SafeRelativePath
- func (claim CurrentEvidenceClaim) QuoteBytes() []byte
- func (claim CurrentEvidenceClaim) Side() CurrentEvidenceSide
- func (claim CurrentEvidenceClaim) TargetSHA256() string
- type CurrentEvidenceSide
- type FindingEvidenceClaims
- func (claims FindingEvidenceClaims) Claims() []CurrentEvidenceClaim
- func (claims FindingEvidenceClaims) Finding() domain.Finding
- func (claims FindingEvidenceClaims) FindingID() string
- func (claims FindingEvidenceClaims) MatchesFinding(finding domain.Finding) bool
- func (claims FindingEvidenceClaims) VisualReferences() []VerifiedVisualReference
- type FollowupValidationScope
- type FollowupValidator
- type RepairMode
- type RepairPlan
- type ReviewValidationScope
- type ReviewValidator
- func (validator *ReviewValidator) ApplyRepair(ctx context.Context, originalRaw, repairRaw []byte, ...) (ValidatedReview, error)
- func (validator *ReviewValidator) ApplyRepairCandidate(ctx context.Context, originalRaw, repairRaw []byte, ...) (ValidatedReview, []byte, error)
- func (validator *ReviewValidator) Validate(ctx context.Context, raw []byte, scope ReviewValidationScope) (ValidatedReview, *RepairPlan, error)
- type RuntimeError
- type SchemaValidator
- type ValidatedFollowup
- func (result ValidatedFollowup) NormalizedRaw() []byte
- func (result ValidatedFollowup) ProviderInstance() string
- func (result ValidatedFollowup) ProviderRaw() []byte
- func (result ValidatedFollowup) ProviderSHA256() string
- func (result ValidatedFollowup) Resolution() domain.FollowupResolution
- func (result ValidatedFollowup) Role() domain.Role
- type ValidatedReview
- func (review ValidatedReview) Completeness() string
- func (review ValidatedReview) EvidenceClaims() []FindingEvidenceClaims
- func (review ValidatedReview) Findings() []domain.Finding
- func (review ValidatedReview) Limitations() []string
- func (review ValidatedReview) OriginalRaw() []byte
- func (review ValidatedReview) Repaired() bool
- func (review ValidatedReview) RepairedRaw() []byte
- func (review ValidatedReview) Summary() string
- type VerifiedVisualReference
- func (reference VerifiedVisualReference) Height() int
- func (reference VerifiedVisualReference) Path() ports.SafeRelativePath
- func (reference VerifiedVisualReference) SHA256() string
- func (reference VerifiedVisualReference) Valid() bool
- func (reference VerifiedVisualReference) Verification() string
- func (reference VerifiedVisualReference) Width() int
- func (reference VerifiedVisualReference) X() int
- func (reference VerifiedVisualReference) Y() int
Constants ¶
const ( // ProviderReviewWireSchemaID validates the provider-owned v1 projection // before Mulgae injects target identity and verification state. ProviderReviewWireSchemaID = "https://mulgae.local/schemas/mulgae-provider-review-wire.v1.schema.json" // ProviderReviewSchemaID validates the normalized v1 envelope after trusted // target identity and claimed verification have been injected. ProviderReviewSchemaID = "https://mulgae.local/schemas/mulgae-provider-review-output.v1.schema.json" )
const ProviderFollowupSchemaID = "https://mulgae.local/schemas/mulgae-provider-followup-output.v1.schema.json"
ProviderFollowupSchemaID is the sole schema accepted for provider followup output.
Variables ¶
This section is empty.
Functions ¶
func CompareCurrentEvidenceClaims ¶
func CompareCurrentEvidenceClaims(left, right CurrentEvidenceClaim) int
CompareCurrentEvidenceClaims orders claims by their canonical evidence region: path, numeric line range, side, normalized quote, then exact quote bytes. Target identity is a final trusted tie-breaker for callers comparing claims from different validation scopes.
func RuntimeCause ¶
func RuntimeCause(err error) (domain.RuntimeDiagnosticCause, bool)
RuntimeCause extracts the closed validation cause without inspecting error text.
func ValidateReviewCompleteness ¶
ValidateReviewCompleteness validates provider-declared review completeness and its limitations without consulting any runtime, provider, or evidence state.
Types ¶
type CurrentEvidenceClaim ¶
type CurrentEvidenceClaim struct {
// contains filtered or unexported fields
}
CurrentEvidenceClaim is an immutable, unverified current-evidence claim. Target identity is supplied only by trusted validation scope. Verification is intentionally owned by the coordinator's evidence verifier.
func (CurrentEvidenceClaim) LineEnd ¶
func (claim CurrentEvidenceClaim) LineEnd() int
LineEnd returns the one-based inclusive final line of the claim.
func (CurrentEvidenceClaim) LineStart ¶
func (claim CurrentEvidenceClaim) LineStart() int
LineStart returns the one-based inclusive first line of the claim.
func (CurrentEvidenceClaim) Path ¶
func (claim CurrentEvidenceClaim) Path() ports.SafeRelativePath
Path returns the canonical relative path claimed within the trusted target.
func (CurrentEvidenceClaim) QuoteBytes ¶
func (claim CurrentEvidenceClaim) QuoteBytes() []byte
QuoteBytes returns a defensive copy of the provider's exact quote bytes.
func (CurrentEvidenceClaim) Side ¶
func (claim CurrentEvidenceClaim) Side() CurrentEvidenceSide
Side returns the claimed closed side of the trusted target.
func (CurrentEvidenceClaim) TargetSHA256 ¶
func (claim CurrentEvidenceClaim) TargetSHA256() string
TargetSHA256 returns the canonical sha256:<lowercase-hex> trusted target ID.
type CurrentEvidenceSide ¶
type CurrentEvidenceSide string
CurrentEvidenceSide identifies one closed side of the trusted current target.
const ( CurrentEvidenceSideBase CurrentEvidenceSide = "base" CurrentEvidenceSideHead CurrentEvidenceSide = "head" CurrentEvidenceSideWorktree CurrentEvidenceSide = "worktree" CurrentEvidenceSideIndex CurrentEvidenceSide = "index" )
func (CurrentEvidenceSide) Valid ¶
func (side CurrentEvidenceSide) Valid() bool
Valid reports whether side is a supported current-target side.
type FindingEvidenceClaims ¶
type FindingEvidenceClaims struct {
// contains filtered or unexported fields
}
FindingEvidenceClaims binds an exact final system-assigned finding proof to its immutable, unverified current-evidence claims.
func (FindingEvidenceClaims) Claims ¶
func (claims FindingEvidenceClaims) Claims() []CurrentEvidenceClaim
Claims returns defensive copies in normalized evidence-region order.
func (FindingEvidenceClaims) Finding ¶
func (claims FindingEvidenceClaims) Finding() domain.Finding
Finding returns the immutable final validation finding proof.
func (FindingEvidenceClaims) FindingID ¶
func (claims FindingEvidenceClaims) FindingID() string
FindingID returns the final system-assigned finding ID.
func (FindingEvidenceClaims) MatchesFinding ¶
func (claims FindingEvidenceClaims) MatchesFinding(finding domain.Finding) bool
MatchesFinding reports whether finding is the exact complete final validation finding bound to these claims. It also rejects an internally inconsistent proof, ID, or claim set.
func (FindingEvidenceClaims) VisualReferences ¶
func (claims FindingEvidenceClaims) VisualReferences() []VerifiedVisualReference
VisualReferences returns visual references aligned with Claims. A zero value means that the corresponding current claim has no visual reference.
type FollowupValidationScope ¶
type FollowupValidationScope struct {
SessionID domain.SessionID
SourceRunID domain.RunID
ReviewID domain.ReviewID
FindingID string
SourceTargetSHA256 string
SourceExcerptSHA256 string
CurrentTargetSHA256 string
Role domain.Role
ProviderInstance string
}
FollowupValidationScope is the complete trusted lineage and execution identity injected into a provider followup result. Providers have no authority over it.
type FollowupValidator ¶
type FollowupValidator struct {
// contains filtered or unexported fields
}
FollowupValidator validates the provider-owned subset of the followup contract. Unlike ReviewValidator, it deliberately accepts no source-bearing provider document: all lineage and target identities are injected from scope.
func NewFollowupValidator ¶
func NewFollowupValidator(schemaValidator SchemaValidator, schemaID ports.AssetID) (*FollowupValidator, error)
func (*FollowupValidator) Validate ¶
func (validator *FollowupValidator) Validate(ctx context.Context, raw []byte, scope FollowupValidationScope) (ValidatedFollowup, error)
func (*FollowupValidator) ValidateWithRepairAuthority ¶
func (validator *FollowupValidator) ValidateWithRepairAuthority(ctx context.Context, raw []byte, scope FollowupValidationScope) (ValidatedFollowup, bool, error)
ValidateWithRepairAuthority reports whether one full-document reformat or schema repair is allowed. Semantic, trust-boundary, and evidence failures are deliberately terminal and never gain repair authority.
type RepairMode ¶
type RepairMode string
RepairMode describes the only two bounded provider repair forms.
const ( RepairModeReformatOnly RepairMode = "reformat_only" RepairModeFillMissingFields RepairMode = "fill_missing_fields" RepairModeExactEvidence RepairMode = "exact_evidence" )
type RepairPlan ¶
type RepairPlan struct {
// contains filtered or unexported fields
}
RepairPlan binds an eligible repair to the exact original bytes. Its getters expose copies so callers cannot alter a plan after classification.
func NewExactEvidenceRepairPlan ¶
func NewExactEvidenceRepairPlan(raw []byte, allowedPaths []string) (*RepairPlan, error)
NewExactEvidenceRepairPlan binds one repair to quote fields whose immutable target range was selected successfully but whose provider quote did not match the exact target bytes. No path, side, range, finding, or severity may be changed by this mode.
func (RepairPlan) AllowedPaths ¶
func (plan RepairPlan) AllowedPaths() []string
AllowedPaths returns the exact JSON Pointer paths that a patch may change.
func (RepairPlan) Mode ¶
func (plan RepairPlan) Mode() RepairMode
func (RepairPlan) OriginalSHA256 ¶
func (plan RepairPlan) OriginalSHA256() string
OriginalSHA256 returns the raw lowercase hexadecimal digest of the original provider stdout to which this plan is bound.
type ReviewValidationScope ¶
type ReviewValidationScope struct {
TargetSHA256 string
Role domain.Role
ProviderInstance string
// VisualAssets binds captured design-spec paths to trusted SHA-256 values.
// It is used only for artist findings and is never populated from provider output.
VisualAssets map[string]string
ArtistInputsConfigured bool
ArtistInputsReady bool
// SourceBearing is false for a root review. Source identity is not accepted
// from providers in either mode; source-bearing validation needs a later,
// trusted source-identity reducer and is intentionally out of this slice.
SourceBearing bool
}
ReviewValidationScope contains only trusted execution identity. Provider output never supplies any of these values.
type ReviewValidator ¶
type ReviewValidator struct {
// contains filtered or unexported fields
}
ReviewValidator validates provider-only JSON against the provider-wire schema, injects trusted current target identity, then validates the normalized v1 envelope.
func NewReviewValidator ¶
func NewReviewValidator(schemaValidator SchemaValidator, schemaID ports.AssetID) (*ReviewValidator, error)
NewReviewValidator creates a validator for the normalized v1 review schema. The provider wire schema is fixed separately so callers cannot weaken the ownership boundary by choosing a different pre-injection schema.
func (*ReviewValidator) ApplyRepair ¶
func (validator *ReviewValidator) ApplyRepair(ctx context.Context, originalRaw, repairRaw []byte, scope ReviewValidationScope, plan RepairPlan) (ValidatedReview, error)
ApplyRepair applies one already-classified repair response. It never retries, invokes a provider, or owns repair budget. A reformat repair revalidates a replacement review; a fill-missing-fields repair accepts only the bounded mulgae-repair-patch.v1 pointer set from its RepairPlan.
func (*ReviewValidator) ApplyRepairCandidate ¶
func (validator *ReviewValidator) ApplyRepairCandidate(ctx context.Context, originalRaw, repairRaw []byte, scope ReviewValidationScope, plan RepairPlan) (ValidatedReview, []byte, error)
ApplyRepairCandidate applies a repair and returns the exact validated provider review candidate. For a patch repair, candidate is the reconstructed JSON; repairRaw remains the distinct provider patch stream in ValidatedReview.
func (*ReviewValidator) Validate ¶
func (validator *ReviewValidator) Validate(ctx context.Context, raw []byte, scope ReviewValidationScope) (ValidatedReview, *RepairPlan, error)
Validate parses exactly one provider JSON object, rejects system-owned fields, injects trusted target identity, then runs schema validation before semantic validation. An error with a non-nil RepairPlan is eligible for at most one caller-owned repair attempt.
type RuntimeError ¶
type RuntimeError struct {
// contains filtered or unexported fields
}
RuntimeError carries the closed diagnostic cause selected by validation. Its Error projection is safe and does not include provider bytes, paths, or the wrapped validator detail.
func (*RuntimeError) Cause ¶
func (failure *RuntimeError) Cause() domain.RuntimeDiagnosticCause
func (*RuntimeError) Error ¶
func (failure *RuntimeError) Error() string
func (*RuntimeError) Unwrap ¶
func (failure *RuntimeError) Unwrap() error
type SchemaValidator ¶
SchemaValidator is owned by this consumer boundary. The JSON Schema adapter satisfies it without making validation depend on that adapter package.
type ValidatedFollowup ¶
type ValidatedFollowup struct {
// contains filtered or unexported fields
}
ValidatedFollowup is the defensive, publication-ready normalized provider result. Raw is the exact provider output; NormalizedRaw is the schema-valid document after trusted lineage and current-target values are injected.
func (ValidatedFollowup) NormalizedRaw ¶
func (result ValidatedFollowup) NormalizedRaw() []byte
func (ValidatedFollowup) ProviderInstance ¶
func (result ValidatedFollowup) ProviderInstance() string
func (ValidatedFollowup) ProviderRaw ¶
func (result ValidatedFollowup) ProviderRaw() []byte
func (ValidatedFollowup) ProviderSHA256 ¶
func (result ValidatedFollowup) ProviderSHA256() string
func (ValidatedFollowup) Resolution ¶
func (result ValidatedFollowup) Resolution() domain.FollowupResolution
func (ValidatedFollowup) Role ¶
func (result ValidatedFollowup) Role() domain.Role
type ValidatedReview ¶
type ValidatedReview struct {
// contains filtered or unexported fields
}
ValidatedReview is the immutable normalized result of one provider review. Findings contain trusted role/provider identity and unverified evidence state; evidence lookup and state transitions are deliberately elsewhere.
func (ValidatedReview) Completeness ¶
func (review ValidatedReview) Completeness() string
func (ValidatedReview) EvidenceClaims ¶
func (review ValidatedReview) EvidenceClaims() []FindingEvidenceClaims
func (ValidatedReview) Findings ¶
func (review ValidatedReview) Findings() []domain.Finding
func (ValidatedReview) Limitations ¶
func (review ValidatedReview) Limitations() []string
func (ValidatedReview) OriginalRaw ¶
func (review ValidatedReview) OriginalRaw() []byte
func (ValidatedReview) Repaired ¶
func (review ValidatedReview) Repaired() bool
func (ValidatedReview) RepairedRaw ¶
func (review ValidatedReview) RepairedRaw() []byte
func (ValidatedReview) Summary ¶
func (review ValidatedReview) Summary() string
type VerifiedVisualReference ¶
type VerifiedVisualReference struct {
// contains filtered or unexported fields
}
VerifiedVisualReference is an immutable visual-evidence identity verified against the trusted captured design-spec inventory during validation.
func (VerifiedVisualReference) Height ¶
func (reference VerifiedVisualReference) Height() int
func (VerifiedVisualReference) Path ¶
func (reference VerifiedVisualReference) Path() ports.SafeRelativePath
func (VerifiedVisualReference) SHA256 ¶
func (reference VerifiedVisualReference) SHA256() string
func (VerifiedVisualReference) Valid ¶
func (reference VerifiedVisualReference) Valid() bool
Valid reports whether the reference retains a complete verified visual identity. A zero value denotes that the corresponding current claim has no visual reference.
func (VerifiedVisualReference) Verification ¶
func (reference VerifiedVisualReference) Verification() string
func (VerifiedVisualReference) Width ¶
func (reference VerifiedVisualReference) Width() int
func (VerifiedVisualReference) X ¶
func (reference VerifiedVisualReference) X() int
func (VerifiedVisualReference) Y ¶
func (reference VerifiedVisualReference) Y() int