internal/core/harden
import "github.com/nilstate/scafld/v2/internal/core/harden"
Package harden models provider-backed pre-approval hardening.
Constants
Source: internal/core/harden/model.go:17
const (
// VerdictPass means the draft contract is ready for approval.
VerdictPass = "pass"
// VerdictNeedsRevision means the draft needs contract edits before approval.
VerdictNeedsRevision = "needs_revision"
// DecisionKeep means the draft should proceed in its current shape.
DecisionKeep = "keep"
// DecisionShrink means the goal is valid but the draft is too large.
DecisionShrink = "shrink"
// DecisionReframe means the goal is valid but the architecture is wrong.
DecisionReframe = "reframe"
// DecisionReject means the draft should not be approved.
DecisionReject = "reject"
// ResultClean means the dimension was checked and no concern was found.
ResultClean = "clean"
// ResultAdvisory means the dimension has useful non-blocking feedback.
ResultAdvisory = "advisory"
// ResultBlocks means the dimension found work that must be resolved before approval.
ResultBlocks = "blocks"
// ResultNotApplicable means the dimension was checked and does not apply.
ResultNotApplicable = "n/a"
// StatusOpen marks an unresolved blocking observation.
StatusOpen = "open"
// StatusFixed marks a blocking observation resolved by a spec edit.
StatusFixed = "fixed"
// StatusAcceptedRisk marks a blocking observation intentionally accepted.
StatusAcceptedRisk = "accepted_risk"
// StatusSuperseded marks a blocking observation made irrelevant by later spec changes.
StatusSuperseded = "superseded"
)Variables
ErrInvalidDossier wraps malformed or semantically invalid harden output.
Source: internal/core/harden/model.go:50
var ErrInvalidDossier = errors.New("invalid harden dossier")RequiredDimensions are the hardening dimensions every round must cover.
Source: internal/core/harden/model.go:53
var RequiredDimensions = []string{
"design",
"scope",
"path",
"command",
"timing",
"rollback",
}Functions
func DossierSchemaJSON() string
Source: internal/core/harden/schema.go:11
DossierSchemaJSON returns the semantic HardenDossier JSON Schema.
func EncodeDossier(dossier Dossier) string
Source: internal/core/harden/model.go:114
EncodeDossier serializes a dossier for transport and storage.
func MissingDimensions(observations []Observation) []string
Source: internal/core/harden/model.go:271
MissingDimensions returns required dimensions not covered by the observations.
func NormalizeDossier(dossier Dossier) Dossier
Source: internal/core/harden/model.go:160
NormalizeDossier fills derived defaults without hiding invalid provider shape.
func ObservationBlocksApproval(observation Observation) bool
Source: internal/core/harden/model.go:286
ObservationBlocksApproval reports whether an observation keeps harden not-ready.
func ParseText(text string) (Dossier, error)
Source: internal/core/harden/model.go:126
ParseText parses one strict JSON HardenDossier.
func RequiredDimensionList() string
Source: internal/core/harden/model.go:64
RequiredDimensionList formats the canonical dimension order for user-facing instructions and errors.
func ShapeRequiresRevision(shape Shape) bool
Source: internal/core/harden/model.go:253
ShapeRequiresRevision reports whether the shape decision blocks approval.
func StrictDossierSchemaJSON() string
Source: internal/core/harden/schema.go:20
StrictDossierSchemaJSON returns the Codex/OpenAI structured-output variant.
func ValidDimension(dimension string) bool
Source: internal/core/harden/model.go:322
ValidDimension reports whether a harden dimension is supported.
func ValidObservationStatus(status string) bool
Source: internal/core/harden/model.go:343
ValidObservationStatus reports whether an observation status is supported.
func ValidResult(result string) bool
Source: internal/core/harden/model.go:333
ValidResult reports whether an observation result is supported.
func ValidShapeDecision(decision string) bool
Source: internal/core/harden/model.go:261
ValidShapeDecision reports whether a shape decision is supported.
func ValidVerdict(verdict string) bool
Source: internal/core/harden/model.go:301
ValidVerdict reports whether the derived harden verdict is supported.
func ValidateDossier(dossier Dossier) error
Source: internal/core/harden/model.go:185
ValidateDossier verifies provider output shape and the harden gate contract.
func ValidateShape(shape Shape) error
Source: internal/core/harden/model.go:236
ValidateShape verifies the harden design-shape decision.
func VerdictFromDossier(dossier Dossier) string
Source: internal/core/harden/model.go:220
VerdictFromDossier derives harden verdict from coverage and unresolved blocks.
Types
type Dossier
Source: internal/core/harden/model.go:94
Dossier is the normalized harden-provider payload consumed by scafld.
type Dossier struct {
Summary string `json:"summary"`
Shape Shape `json:"shape"`
Observations []Observation `json:"observations"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
SessionID string `json:"session_id,omitempty"`
OutputFormat string `json:"output_format,omitempty"`
EventSummary map[string]int `json:"event_summary,omitempty"`
Raw string `json:"-"`
}Fields
Summary string`json:"summary"`Shape Shape`json:"shape"`Observations []Observation`json:"observations"`Provider string`json:"provider,omitempty"`Model string`json:"model,omitempty"`SessionID string`json:"session_id,omitempty"`OutputFormat string`json:"output_format,omitempty"`EventSummary map[string]int`json:"event_summary,omitempty"`Raw string`json:"-"`
type Observation
Source: internal/core/harden/model.go:69
Observation records one grounded hardening claim.
type Observation struct {
Dimension string `json:"dimension"`
Result string `json:"result"`
Anchor string `json:"anchor"`
Note string `json:"note,omitempty"`
Question string `json:"question,omitempty"`
Recommended string `json:"recommended,omitempty"`
IfUnanswered string `json:"if_unanswered,omitempty"`
Default string `json:"default,omitempty"`
Status string `json:"status,omitempty"`
}Fields
Dimension string`json:"dimension"`Result string`json:"result"`Anchor string`json:"anchor"`Note string`json:"note,omitempty"`Question string`json:"question,omitempty"`Recommended string`json:"recommended,omitempty"`IfUnanswered string`json:"if_unanswered,omitempty"`Default string`json:"default,omitempty"`Status string`json:"status,omitempty"`
type Request
Source: internal/core/harden/model.go:107
Request is the provider-facing hardening prompt request.
type Request struct {
TaskID string
Prompt string
Context reviewcontext.Packet
}Fields
TaskID stringPrompt stringContext reviewcontext.Packet
type Shape
Source: internal/core/harden/model.go:82
Shape records the design gate's answer to whether the draft should exist.
type Shape struct {
Decision string `json:"decision"`
TrueShape string `json:"true_shape"`
MinimalPlan string `json:"minimal_plan"`
SharedOwner string `json:"shared_owner"`
// AdapterBoundaries names adapter surfaces only when the task crosses one.
// Empty is valid for tasks fully owned by one core/app surface.
AdapterBoundaries []string `json:"adapter_boundaries"`
RequiredSpecEdits []string `json:"required_spec_edits"`
}Fields
Decision string`json:"decision"`TrueShape string`json:"true_shape"`MinimalPlan string`json:"minimal_plan"`SharedOwner string`json:"shared_owner"`AdapterBoundaries []string`json:"adapter_boundaries"`AdapterBoundaries names adapter surfaces only when the task crosses one. Empty is valid for tasks fully owned by one core/app surface.
RequiredSpecEdits []string`json:"required_spec_edits"`
