Documentation
¶
Overview ¶
Package prompt compiles the byte-exact provider stdin packet. It owns the only concatenation boundary between trusted template bytes and untrusted framed payloads.
Index ¶
- Constants
- func CompleteStdinSHA256(stdin []byte) string
- type CompileInput
- type CompiledPrompt
- func (prompt CompiledPrompt) CompleteStdinByteLength() int
- func (prompt CompiledPrompt) CompleteStdinSHA256() string
- func (prompt CompiledPrompt) ExactReplay() bool
- func (prompt CompiledPrompt) ReplayedSourceInvocationID() (SourceInvocationID, bool)
- func (prompt CompiledPrompt) Scope() Scope
- func (prompt CompiledPrompt) Sections() []FramedSection
- func (prompt CompiledPrompt) Stdin() []byte
- func (prompt CompiledPrompt) TrustedTemplate() TrustedTemplate
- func (prompt CompiledPrompt) Validate() error
- func (prompt CompiledPrompt) WireIdentity() string
- type Compiler
- func (compiler *Compiler) Compile(input CompileInput) (CompiledPrompt, error)
- func (compiler *Compiler) Replay(source CompiledPrompt) (CompiledPrompt, error)
- func (compiler *Compiler) ReplayStored(stdin []byte, priorExecutionID ExecutionInvocationID) (CompiledPrompt, error)
- func (compiler *Compiler) ReplayStoredWithReboundTemplate(sourceTemplate TrustedTemplate, stdin []byte, ...) (CompiledPrompt, error)
- type ExecutionInvocationID
- type FrameScope
- func (scope FrameScope) AttemptID() domain.AttemptID
- func (scope FrameScope) Coordinates() ScopeCoordinates
- func (scope FrameScope) RoleTaskID() RoleTaskID
- func (scope FrameScope) RunID() domain.RunID
- func (scope FrameScope) SessionID() domain.SessionID
- func (scope FrameScope) SourceInvocationID() SourceInvocationID
- func (scope FrameScope) String() string
- type FramedSection
- func (section FramedSection) FrameBytes() []byte
- func (section FramedSection) ID() string
- func (section FramedSection) Kind() SectionKind
- func (section FramedSection) Payload() []byte
- func (section FramedSection) PayloadByteLength() int
- func (section FramedSection) PayloadSHA256() string
- func (section FramedSection) Scope() FrameScope
- type IdentityError
- type InvocationIDIssuer
- type Objective
- type ObjectiveConflictClass
- type ObjectiveDiagnostic
- type ObjectiveLintResult
- type ParsedPrompt
- func (parsed ParsedPrompt) CompleteStdinByteLength() int
- func (parsed ParsedPrompt) CompleteStdinSHA256() string
- func (parsed ParsedPrompt) Scope() FrameScope
- func (parsed ParsedPrompt) Sections() []FramedSection
- func (parsed ParsedPrompt) Stdin() []byte
- func (parsed ParsedPrompt) WireIdentity() string
- type Payload
- type RoleTaskID
- type Scope
- func (scope Scope) AttemptID() domain.AttemptID
- func (scope Scope) Coordinates() ScopeCoordinates
- func (scope Scope) ExecutionInvocationID() ExecutionInvocationID
- func (scope Scope) FrameScope() FrameScope
- func (scope Scope) RoleTaskID() RoleTaskID
- func (scope Scope) RunID() domain.RunID
- func (scope Scope) SessionID() domain.SessionID
- func (scope Scope) SourceInvocationID() SourceInvocationID
- type ScopeCoordinates
- type SectionKind
- type SourceInvocationID
- type TrustedLayer
- type TrustedLayerProvenance
- type TrustedTemplate
- func ComposeTrustedTemplate(id, version string, layers ...TrustedLayer) (TrustedTemplate, error)
- func NewTrustedTemplate(id, version string, content []byte) (TrustedTemplate, error)
- func NewTrustedTemplateWithOpaqueLayer(id, version string, content []byte) (TrustedTemplate, error)
- func RestoreTrustedLayerManifest(template TrustedTemplate, manifestJSON string) (TrustedTemplate, error)
- func (template TrustedTemplate) ByteLength() int
- func (template TrustedTemplate) Bytes() []byte
- func (template TrustedTemplate) ID() string
- func (template TrustedTemplate) SHA256() string
- func (template TrustedTemplate) TrustedLayerManifest() []TrustedLayerProvenance
- func (template TrustedTemplate) TrustedLayerManifestJSON() (string, error)
- func (template TrustedTemplate) Version() string
Constants ¶
const ( // MaxObjectiveBytes is the fixed maximum objective length. It is a byte // limit rather than a rune limit because objective provenance is byte exact. MaxObjectiveBytes = 12000 )
const ( // TrustedLayerManifestAdapterParameter is the runtime adapter-parameter key // persisted in each publication prompt manifest. TrustedLayerManifestAdapterParameter = "trusted_layer_manifest" )
Variables ¶
This section is empty.
Functions ¶
func CompleteStdinSHA256 ¶
CompleteStdinSHA256 returns the raw lowercase hexadecimal SOT wire identity.
Types ¶
type CompileInput ¶
type CompileInput struct {
Scope ScopeCoordinates
ProjectContext *Payload
TaskRequirements *Payload
VisualAssetsManifest *Payload
ReviewTarget Payload
PriorProviderOutput *Payload
PriorFinding *Payload
PriorReport *Payload
ExternalLogs []Payload
}
CompileInput describes the only permitted frame cardinalities. The compiler determines every frame kind and order; callers cannot supply raw frames.
type CompiledPrompt ¶
type CompiledPrompt struct {
// contains filtered or unexported fields
}
CompiledPrompt is an immutable provider-stdin packet. It does not contain a provider, result, outcome, or any publication authority.
func (CompiledPrompt) CompleteStdinByteLength ¶
func (prompt CompiledPrompt) CompleteStdinByteLength() int
func (CompiledPrompt) CompleteStdinSHA256 ¶
func (prompt CompiledPrompt) CompleteStdinSHA256() string
func (CompiledPrompt) ExactReplay ¶
func (prompt CompiledPrompt) ExactReplay() bool
func (CompiledPrompt) ReplayedSourceInvocationID ¶
func (prompt CompiledPrompt) ReplayedSourceInvocationID() (SourceInvocationID, bool)
func (CompiledPrompt) Scope ¶
func (prompt CompiledPrompt) Scope() Scope
func (CompiledPrompt) Sections ¶
func (prompt CompiledPrompt) Sections() []FramedSection
func (CompiledPrompt) Stdin ¶
func (prompt CompiledPrompt) Stdin() []byte
func (CompiledPrompt) TrustedTemplate ¶
func (prompt CompiledPrompt) TrustedTemplate() TrustedTemplate
func (CompiledPrompt) Validate ¶
func (prompt CompiledPrompt) Validate() error
Validate verifies the exact stdin bytes, all frame constraints, stored section metadata, hash, scope, and replay marker.
func (CompiledPrompt) WireIdentity ¶
func (prompt CompiledPrompt) WireIdentity() string
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler owns trusted-template composition and the exact stdin wire format.
func NewCompiler ¶
func NewCompiler(template TrustedTemplate, issuer InvocationIDIssuer) (*Compiler, error)
func (*Compiler) Compile ¶
func (compiler *Compiler) Compile(input CompileInput) (CompiledPrompt, error)
Compile mints a fresh source and execution identity, frames the supplied untrusted data, and returns the exact provider stdin bytes.
func (*Compiler) Replay ¶
func (compiler *Compiler) Replay(source CompiledPrompt) (CompiledPrompt, error)
Replay performs an exact replay: it preserves stored stdin and source identity, mints only a fresh execution identity, and marks the result as a replay. A caller wanting current templates must call Compile instead.
func (*Compiler) ReplayStored ¶
func (compiler *Compiler) ReplayStored(stdin []byte, priorExecutionID ExecutionInvocationID) (CompiledPrompt, error)
ReplayStored reconstructs an exact replay from persisted stdin and the source process identity. It validates the complete frame grammar against the supplied trusted template, preserves the source scope and wire bytes, and mints only a fresh execution identity.
func (*Compiler) ReplayStoredWithReboundTemplate ¶ added in v0.1.17
func (compiler *Compiler) ReplayStoredWithReboundTemplate(sourceTemplate TrustedTemplate, stdin []byte, priorExecutionID ExecutionInvocationID) (CompiledPrompt, error)
ReplayStoredWithReboundTemplate validates a persisted packet against its source template, preserves every framed section byte and source identity, and replaces only the trusted template with the compiler's current template. This is reserved for rebinding Mulgae-owned per-launch transport authority.
type ExecutionInvocationID ¶
type ExecutionInvocationID struct {
// contains filtered or unexported fields
}
ExecutionInvocationID identifies one provider process. Unlike source identities, it deliberately has no prefix.
func ParseExecutionInvocationID ¶
func ParseExecutionInvocationID(value string) (ExecutionInvocationID, error)
func (ExecutionInvocationID) String ¶
func (id ExecutionInvocationID) String() string
type FrameScope ¶
type FrameScope struct {
// contains filtered or unexported fields
}
FrameScope is the identity serialized in every untrusted frame. Execution identity is intentionally excluded from the frame grammar.
func NewFrameScope ¶
func NewFrameScope(coordinates ScopeCoordinates, sourceInvocationID SourceInvocationID) (FrameScope, error)
func (FrameScope) AttemptID ¶
func (scope FrameScope) AttemptID() domain.AttemptID
func (FrameScope) Coordinates ¶
func (scope FrameScope) Coordinates() ScopeCoordinates
func (FrameScope) RoleTaskID ¶
func (scope FrameScope) RoleTaskID() RoleTaskID
func (FrameScope) RunID ¶
func (scope FrameScope) RunID() domain.RunID
func (FrameScope) SessionID ¶
func (scope FrameScope) SessionID() domain.SessionID
func (FrameScope) SourceInvocationID ¶
func (scope FrameScope) SourceInvocationID() SourceInvocationID
func (FrameScope) String ¶
func (scope FrameScope) String() string
type FramedSection ¶
type FramedSection struct {
// contains filtered or unexported fields
}
FramedSection records one validated frame and exposes defensive copies of its untrusted payload and exact frame bytes.
func (FramedSection) FrameBytes ¶
func (section FramedSection) FrameBytes() []byte
func (FramedSection) ID ¶
func (section FramedSection) ID() string
func (FramedSection) Kind ¶
func (section FramedSection) Kind() SectionKind
func (FramedSection) Payload ¶
func (section FramedSection) Payload() []byte
func (FramedSection) PayloadByteLength ¶
func (section FramedSection) PayloadByteLength() int
func (FramedSection) PayloadSHA256 ¶
func (section FramedSection) PayloadSHA256() string
func (FramedSection) Scope ¶
func (section FramedSection) Scope() FrameScope
type IdentityError ¶
type IdentityError struct {
// contains filtered or unexported fields
}
IdentityError reports a failure while issuing, reserving, or constructing an invocation identity. It lets callers distinguish identity failures from input, template, and frame validation failures.
func (*IdentityError) Error ¶
func (err *IdentityError) Error() string
func (*IdentityError) Operation ¶
func (err *IdentityError) Operation() string
Operation identifies the identity operation that failed.
func (*IdentityError) Unwrap ¶
func (err *IdentityError) Unwrap() error
type InvocationIDIssuer ¶
type InvocationIDIssuer interface {
NewSourceInvocationID() (SourceInvocationID, error)
NewExecutionInvocationID() (ExecutionInvocationID, error)
}
InvocationIDIssuer issues fresh canonical identities. The compiler tracks all returned raw UUIDv7 values and rejects a repeated identity, including a source/execution namespace collision.
type Objective ¶
type Objective struct {
// contains filtered or unexported fields
}
Objective is an immutable limited-trust instruction. It is linted before it can be incorporated into a compiler-owned trusted layer.
func NewObjective ¶
func (Objective) ByteLength ¶
func (Objective) Lint ¶
func (objective Objective) Lint() ObjectiveLintResult
type ObjectiveConflictClass ¶
type ObjectiveConflictClass string
ObjectiveConflictClass is a frozen deterministic preflight category. It is deliberately not configurable: a lower-trust objective cannot redefine the constraints it is checked against.
const ( ObjectiveRoleConflict ObjectiveConflictClass = "role_conflict" ObjectiveRunTypeConflict ObjectiveConflictClass = "run_type_conflict" ObjectiveSchemaConflict ObjectiveConflictClass = "schema_conflict" ObjectiveSafetyConflict ObjectiveConflictClass = "safety_conflict" ObjectiveAuthorityConflict ObjectiveConflictClass = "authority_conflict" ObjectiveInstructionOverride ObjectiveConflictClass = "instruction_override" ObjectiveOversize ObjectiveConflictClass = "oversize" ObjectiveInvalidEncoding ObjectiveConflictClass = "invalid_encoding" )
func (ObjectiveConflictClass) Valid ¶
func (class ObjectiveConflictClass) Valid() bool
type ObjectiveDiagnostic ¶
type ObjectiveDiagnostic struct {
// contains filtered or unexported fields
}
ObjectiveDiagnostic identifies one deterministic conflict and gives a stable, actionable rewrite direction.
func (ObjectiveDiagnostic) Class ¶
func (diagnostic ObjectiveDiagnostic) Class() ObjectiveConflictClass
func (ObjectiveDiagnostic) Message ¶
func (diagnostic ObjectiveDiagnostic) Message() string
type ObjectiveLintResult ¶
type ObjectiveLintResult struct {
// contains filtered or unexported fields
}
ObjectiveLintResult reports all applicable frozen classes in canonical order. Its getter returns a new slice so callers cannot mutate the result.
func LintObjective ¶
func LintObjective(content []byte) ObjectiveLintResult
LintObjective applies the frozen byte cap, UTF-8 check, and conservative ASCII phrase rules. It is intentionally deterministic rather than an LLM judgment, so a user can rewrite an objective from the exact diagnostics.
func (ObjectiveLintResult) Accepted ¶
func (result ObjectiveLintResult) Accepted() bool
func (ObjectiveLintResult) ConflictClasses ¶
func (result ObjectiveLintResult) ConflictClasses() []ObjectiveConflictClass
func (ObjectiveLintResult) Diagnostics ¶
func (result ObjectiveLintResult) Diagnostics() []ObjectiveDiagnostic
func (ObjectiveLintResult) Err ¶
func (result ObjectiveLintResult) Err() error
Err returns nil for an accepted objective and otherwise an actionable, deterministic summary suitable for preflight reporting.
type ParsedPrompt ¶
type ParsedPrompt struct {
// contains filtered or unexported fields
}
ParsedPrompt is the result of parsing a complete stdin byte stream before a provider process is started. It has no execution identity because execution identity is outside of the SOT frame grammar.
func ParseStdin ¶
func ParseStdin(template TrustedTemplate, stdin []byte) (ParsedPrompt, error)
ParseStdin accepts only a complete, canonical SOT section-12/13 packet. It rejects malformed headers, bad lengths or hashes, scope divergence, missing review targets, wrong order, truncation, and any trailing byte.
func (ParsedPrompt) CompleteStdinByteLength ¶
func (parsed ParsedPrompt) CompleteStdinByteLength() int
func (ParsedPrompt) CompleteStdinSHA256 ¶
func (parsed ParsedPrompt) CompleteStdinSHA256() string
func (ParsedPrompt) Scope ¶
func (parsed ParsedPrompt) Scope() FrameScope
func (ParsedPrompt) Sections ¶
func (parsed ParsedPrompt) Sections() []FramedSection
func (ParsedPrompt) Stdin ¶
func (parsed ParsedPrompt) Stdin() []byte
func (ParsedPrompt) WireIdentity ¶
func (parsed ParsedPrompt) WireIdentity() string
type Payload ¶
type Payload struct {
// contains filtered or unexported fields
}
Payload is an immutable untrusted byte value. It may be empty; a nil optional Payload pointer means that optional section is absent.
func NewPayload ¶
func (Payload) ByteLength ¶
type RoleTaskID ¶
type RoleTaskID struct {
// contains filtered or unexported fields
}
RoleTaskID is the canonical, opaque role-task identifier used in a frame scope. Domain role tasks deliberately do not expose an identifier because their aggregate is not an artifact identity.
func ParseRoleTaskID ¶
func ParseRoleTaskID(value string) (RoleTaskID, error)
func (RoleTaskID) String ¶
func (id RoleTaskID) String() string
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope binds the full canonical identity for one process invocation.
func NewScope ¶
func NewScope(coordinates ScopeCoordinates, sourceInvocationID SourceInvocationID, executionInvocationID ExecutionInvocationID) (Scope, error)
func (Scope) Coordinates ¶
func (scope Scope) Coordinates() ScopeCoordinates
func (Scope) ExecutionInvocationID ¶
func (scope Scope) ExecutionInvocationID() ExecutionInvocationID
func (Scope) FrameScope ¶
func (scope Scope) FrameScope() FrameScope
func (Scope) RoleTaskID ¶
func (scope Scope) RoleTaskID() RoleTaskID
func (Scope) SourceInvocationID ¶
func (scope Scope) SourceInvocationID() SourceInvocationID
type ScopeCoordinates ¶
type ScopeCoordinates struct {
// contains filtered or unexported fields
}
ScopeCoordinates are the stable identities shared by a source invocation and all of its exact replays.
func NewScopeCoordinates ¶
func NewScopeCoordinates(sessionID domain.SessionID, runID domain.RunID, roleTaskID RoleTaskID, attemptID domain.AttemptID) (ScopeCoordinates, error)
func (ScopeCoordinates) AttemptID ¶
func (coordinates ScopeCoordinates) AttemptID() domain.AttemptID
func (ScopeCoordinates) RoleTaskID ¶
func (coordinates ScopeCoordinates) RoleTaskID() RoleTaskID
func (ScopeCoordinates) RunID ¶
func (coordinates ScopeCoordinates) RunID() domain.RunID
func (ScopeCoordinates) SessionID ¶
func (coordinates ScopeCoordinates) SessionID() domain.SessionID
type SectionKind ¶
type SectionKind string
SectionKind identifies one untrusted frame type in the standalone grammar.
const ( SectionProjectContext SectionKind = "project_context" SectionTaskRequirements SectionKind = "task_requirements" SectionVisualAssetsManifest SectionKind = "visual_assets_manifest" SectionReviewTarget SectionKind = "review_target" SectionPriorProviderOutput SectionKind = "prior_provider_output" SectionPriorFinding SectionKind = "prior_finding" SectionPriorReport SectionKind = "prior_report" SectionExternalLog SectionKind = "external_log" )
func (SectionKind) Valid ¶
func (kind SectionKind) Valid() bool
type SourceInvocationID ¶
type SourceInvocationID struct {
// contains filtered or unexported fields
}
SourceInvocationID is the source identity shared by every frame in one newly composed packet.
func ParseSourceInvocationID ¶
func ParseSourceInvocationID(value string) (SourceInvocationID, error)
func (SourceInvocationID) String ¶
func (id SourceInvocationID) String() string
type TrustedLayer ¶
type TrustedLayer struct {
// contains filtered or unexported fields
}
TrustedLayer is an immutable compiler input. Callers provide individual trusted assets; only ComposeTrustedTemplate joins them into template bytes.
func NewTrustedLayer ¶
func NewTrustedLayer(id, version string, content []byte) (TrustedLayer, error)
func (TrustedLayer) ByteLength ¶
func (layer TrustedLayer) ByteLength() int
func (TrustedLayer) Bytes ¶
func (layer TrustedLayer) Bytes() []byte
func (TrustedLayer) ID ¶
func (layer TrustedLayer) ID() string
func (TrustedLayer) SHA256 ¶
func (layer TrustedLayer) SHA256() string
func (TrustedLayer) Version ¶
func (layer TrustedLayer) Version() string
type TrustedLayerProvenance ¶
type TrustedLayerProvenance struct {
// contains filtered or unexported fields
}
TrustedLayerProvenance is one immutable ordered trusted-layer receipt.
func (TrustedLayerProvenance) ByteLength ¶
func (provenance TrustedLayerProvenance) ByteLength() int
func (TrustedLayerProvenance) ID ¶
func (provenance TrustedLayerProvenance) ID() string
func (TrustedLayerProvenance) Ordinal ¶
func (provenance TrustedLayerProvenance) Ordinal() int
Ordinal is the one-based layer position in the trusted template.
func (TrustedLayerProvenance) SHA256 ¶
func (provenance TrustedLayerProvenance) SHA256() string
func (TrustedLayerProvenance) Version ¶
func (provenance TrustedLayerProvenance) Version() string
type TrustedTemplate ¶
type TrustedTemplate struct {
// contains filtered or unexported fields
}
TrustedTemplate holds exact immutable trusted bytes. Its byte getter always returns a copy, and the compiler copies it again when constructed.
func ComposeTrustedTemplate ¶
func ComposeTrustedTemplate(id, version string, layers ...TrustedLayer) (TrustedTemplate, error)
ComposeTrustedTemplate is the compiler-owned trusted-layer composer. It inserts exactly one blank line between consecutive trusted layers and never exposes a raw trusted-byte concatenation helper.
func NewTrustedTemplate ¶
func NewTrustedTemplate(id, version string, content []byte) (TrustedTemplate, error)
func NewTrustedTemplateWithOpaqueLayer ¶
func NewTrustedTemplateWithOpaqueLayer(id, version string, content []byte) (TrustedTemplate, error)
NewTrustedTemplateWithOpaqueLayer constructs a direct template with explicit single-layer provenance. NewTrustedTemplate remains provenance-free for backward compatibility.
func RestoreTrustedLayerManifest ¶ added in v0.1.17
func RestoreTrustedLayerManifest(template TrustedTemplate, manifestJSON string) (TrustedTemplate, error)
RestoreTrustedLayerManifest validates a persisted manifest against the exact trusted template bytes and restores their ordered provenance. It accepts only the canonical representation emitted by TrustedLayerManifestJSON.
func (TrustedTemplate) ByteLength ¶
func (template TrustedTemplate) ByteLength() int
func (TrustedTemplate) Bytes ¶
func (template TrustedTemplate) Bytes() []byte
func (TrustedTemplate) ID ¶
func (template TrustedTemplate) ID() string
func (TrustedTemplate) SHA256 ¶
func (template TrustedTemplate) SHA256() string
func (TrustedTemplate) TrustedLayerManifest ¶
func (template TrustedTemplate) TrustedLayerManifest() []TrustedLayerProvenance
TrustedLayerManifest returns caller-owned ordered immutable layer receipts. Direct NewTrustedTemplate values intentionally return an empty manifest.
func (TrustedTemplate) TrustedLayerManifestJSON ¶
func (template TrustedTemplate) TrustedLayerManifestJSON() (string, error)
TrustedLayerManifestJSON returns a deterministic bounded representation for runtime adapter parameters and publication manifests.
func (TrustedTemplate) Version ¶
func (template TrustedTemplate) Version() string