Documentation
¶
Overview ¶
Package patternsv2 implements experimental, bounded Pattern records only. It performs no persistence, device discovery, admission or execution.
Index ¶
- Constants
- Variables
- func CanonicalRecordJSON(r Record) ([]byte, error)
- func EncodeRecord(r Record) ([]byte, error)
- func EncodeSnapshot(records []Record) ([]byte, error)
- func ExecutionDigest(r Record) (string, error)
- type Candidate
- type Compiled
- type Execution
- type Inspection
- type PreviewFacts
- type Record
- type SaveCandidate
- type SnapshotInspection
- type Source
- type Support
Constants ¶
const ( RecordContract = patternidentity.RecordContract SnapshotKind = "nb1-pattern-snapshot/experimental-v2" ExecutionDomain = patternidentity.ExecutionDomain SchemaVersion = 2 MaxBytes = 1 << 20 MaxRecords = 128 MaxDepth = 32 )
Variables ¶
var ( ErrInvalid = errors.New("invalid experimental pattern") ErrUnsupported = errors.New("unsupported experimental pattern verifier") )
var ErrRevisionConflict = errors.New("experimental pattern candidate revision conflict")
ErrRevisionConflict means the author's expected_revision does not identify the newly compiled candidate. It is not a conflict with a stored record.
Functions ¶
func CanonicalRecordJSON ¶
CanonicalRecordJSON is the SHA payload only: no revision or domain prefix.
func EncodeRecord ¶
EncodeRecord returns verified canonical wire bytes. It cannot publish an unknown recipe; Inspection.CanonicalJSON supplies its read-only export.
func EncodeSnapshot ¶
func ExecutionDigest ¶
Types ¶
type Candidate ¶
type Candidate struct {
// contains filtered or unexported fields
}
Candidate is an immutable, verified authoring result. Its Record retains the author's high-level source alongside the frozen execution and revision. Accessors return independent mutable data; no store or executor is involved.
func PreviewDraft ¶
PreviewDraft strictly decodes raw authoring JSON {id,title,source}, then uses NewRecord and the existing pure preview functions. expected_revision and all other additional fields are rejected. Decode the original bytes here rather than unmarshaling them first: encoding/json can replace lone surrogates.
func (Candidate) ExecutionDigest ¶
func (Candidate) Preview ¶
func (c Candidate) Preview() PreviewFacts
type Compiled ¶
type Compiled struct {
NormalizedAction json.RawMessage `json:"normalized_action"`
RecipeID string `json:"recipe_id,omitempty"`
Execution Execution `json:"execution"`
}
type Execution ¶
type Execution struct {
Kind string `json:"-"`
Contract string `json:"-"`
Program *control.Program `json:"-"`
FrameProgram *control.FrameProgram `json:"-"`
}
Execution is a typed union. Exactly the matching Program/FrameProgram is populated; the wire shape always has one "program" field. It is data, not an execution capability, and even a verified record does not qualify hardware.
func (Execution) MarshalJSON ¶
type Inspection ¶
type Inspection struct {
// contains filtered or unexported fields
}
Inspection deliberately separates an integrity-checked, read-only document from a record accepted by a known source/recipe verifier. Private snapshots cannot be changed by mutating a returned Record or byte slice.
func InspectRecord ¶
func InspectRecord(data []byte) (Inspection, error)
func (Inspection) CanonicalJSON ¶
func (i Inspection) CanonicalJSON() []byte
func (Inspection) ExecutionDigest ¶
func (i Inspection) ExecutionDigest() string
func (Inspection) Record ¶
func (i Inspection) Record() Record
func (Inspection) Support ¶
func (i Inspection) Support() Support
func (Inspection) VerifiedRecord ¶
func (i Inspection) VerifiedRecord() (Record, error)
VerifiedRecord never treats an unknown recipe as executable/verified data.
type PreviewFacts ¶
type PreviewFacts struct {
Kind string `json:"kind"`
Contract string `json:"contract"`
NominalDurationMS int64 `json:"nominal_duration_ms"`
TimingBasis string `json:"timing_basis"`
RequiredCapabilities []string `json:"required_capabilities"`
TotalSteps *int `json:"total_steps,omitempty"`
TotalFrames *int `json:"total_frames,omitempty"`
StoredTargetWrites *int `json:"stored_target_writes,omitempty"`
PlannedTargetWrites *int `json:"planned_target_writes,omitempty"`
CycleDurationMS *int64 `json:"cycle_duration_ms,omitempty"`
NominalInitialMS *int64 `json:"nominal_initial_ms,omitempty"`
NominalTailMS *int64 `json:"nominal_tail_ms,omitempty"`
}
PreviewFacts contains nominal, pure compiler facts. The selected execution kind determines which optional fields exist, including meaningful zeroes. It does not establish device support, admission or observed wall time.
type Record ¶
type Record struct {
Contract string `json:"record_contract"`
ID string `json:"id"`
Title string `json:"title"`
Source Source `json:"source"`
Compiled Compiled `json:"compiled"`
Revision string `json:"revision"`
}
func DecodeRecord ¶
DecodeRecord accepts only a fully verified record. InspectRecord is the explicitly read-only path for a structurally valid but unsupported recipe.
func DecodeSnapshot ¶
func NewRecord ¶
NewRecord freezes one known high-level source. There is no ID registry or replacement here; persistence and its create-only transaction remain absent.
func NormalizeRecord ¶
type SaveCandidate ¶
type SaveCandidate struct {
// contains filtered or unexported fields
}
SaveCandidate adds one canonical snapshot to a confirmed Candidate. It is only an input for a later create-only store transaction, not a saved record, overwrite authorization, execution ticket or device capability check.
func PrepareSave ¶
func PrepareSave(data []byte) (SaveCandidate, error)
PrepareSave strictly decodes {id,title,source,expected_revision}. Confirmation binds the complete candidate, including the author's source notation. The returned snapshot uses the existing frozen Snapshot contract unchanged. No persistence, path lookup, device discovery or execution occurs.
func (SaveCandidate) Candidate ¶
func (s SaveCandidate) Candidate() Candidate
func (SaveCandidate) SnapshotJSON ¶
func (s SaveCandidate) SnapshotJSON() []byte
type SnapshotInspection ¶
type SnapshotInspection struct {
// contains filtered or unexported fields
}
SnapshotInspection can carry unsupported records for explicit read-only backup. Strict DecodeSnapshot/EncodeSnapshot accept verified records only. It does not imply a store exists, or that any record can run on a device.
func InspectSnapshot ¶
func InspectSnapshot(data []byte) (SnapshotInspection, error)
func (SnapshotInspection) CanonicalJSON ¶
func (s SnapshotInspection) CanonicalJSON() []byte
func (SnapshotInspection) Records ¶
func (s SnapshotInspection) Records() []Inspection
func (SnapshotInspection) VerifiedRecords ¶
func (s SnapshotInspection) VerifiedRecords() ([]Record, error)