Documentation
¶
Overview ¶
Package portable contains GoForge's deterministic, runtime-independent business and cryptographic primitives together with the versioned ABI used by component hosts.
Binary values in ABI payloads use canonical, standard, padded Base64. JSON decoding rejects unknown fields, duplicate object keys, invalid UTF-8, and trailing values. The package never reads clocks, randomness, files, the network, environment variables, or host logging facilities.
Index ¶
- Constants
- func NewDispatcher(limits Limits) (*Dispatcher, *ABIError)
- type ABIError
- type CapabilityDefinition
- type Dispatcher
- type EncodingDefinition
- type ErrorCode
- type ErrorDefinition
- type ExecutionState
- type Limits
- type Manifest
- type Operation
- type OperationDefinition
- type Request
- type RequestMetadata
- type Response
Constants ¶
const ( // PackageName is the canonical Component Model package name. PackageName = "pointerbyte:goforge" // PackageVersion is the version of the portable contract package. PackageVersion = "0.1.0" // ABIVersion identifies the JSON bridge contract. ABIVersion = "goforge.abi.v1" // ManifestSchema identifies the manifest JSON schema family. ManifestSchema = "goforge.manifest.v1" )
Variables ¶
This section is empty.
Functions ¶
func NewDispatcher ¶
func NewDispatcher(limits Limits) (*Dispatcher, *ABIError)
NewDispatcher constructs a dispatcher with explicit resource limits.
Types ¶
type ABIError ¶
type ABIError struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
Retryable bool `json:"retryable"`
Field string `json:"field,omitempty"`
}
ABIError is the unified portable error representation. Message is stable and never includes an underlying cryptographic or runtime error.
type CapabilityDefinition ¶
type CapabilityDefinition struct {
Name string `json:"name"`
Version string `json:"version"`
Host bool `json:"host"`
Operations []Operation `json:"operations,omitempty"`
}
CapabilityDefinition describes a portable or host-control capability.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher validates ABI envelopes, enforces execution controls and bounds, and invokes portable operations.
func DefaultDispatcher ¶
func DefaultDispatcher() *Dispatcher
DefaultDispatcher constructs an ABI v1 dispatcher with DefaultLimits.
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(request Request, state ExecutionState) Response
Dispatch validates and executes one already-decoded request.
func (*Dispatcher) DispatchJSON ¶
func (d *Dispatcher) DispatchJSON(encoded []byte, state ExecutionState) []byte
DispatchJSON decodes one strict request and always returns an ABI response. Malformed input receives an error response with an empty correlation ID.
func (*Dispatcher) Manifest ¶
func (d *Dispatcher) Manifest() Manifest
Manifest returns a fresh deterministic manifest for the dispatcher.
func (*Dispatcher) ManifestJSON ¶
func (d *Dispatcher) ManifestJSON() []byte
ManifestJSON returns the deterministic JSON encoding of Manifest.
type EncodingDefinition ¶
EncodingDefinition describes the only serialization profile supported by ABI v1.
type ErrorCode ¶
type ErrorCode string
ErrorCode is a stable machine-readable ABI error identifier.
const ( ErrorInvalidJSON ErrorCode = "invalid_json" ErrorUnknownField ErrorCode = "unknown_field" ErrorDuplicateField ErrorCode = "duplicate_field" ErrorRequestTooLarge ErrorCode = "request_too_large" ErrorResponseTooLarge ErrorCode = "response_too_large" ErrorInvalidABI ErrorCode = "invalid_abi" ErrorInvalidRequest ErrorCode = "invalid_request" ErrorUnknownOperation ErrorCode = "unknown_operation" ErrorExecutionStateRequired ErrorCode = "execution_state_required" ErrorDeadlineExceeded ErrorCode = "deadline_exceeded" ErrorCancellationRequested ErrorCode = "cancellation_requested" ErrorInvalidBase64 ErrorCode = "invalid_base64" ErrorInvalidUTF8 ErrorCode = "invalid_utf8" ErrorInputTooLarge ErrorCode = "input_too_large" ErrorInvalidKey ErrorCode = "invalid_key" ErrorInvalidNonce ErrorCode = "invalid_nonce" ErrorAuthenticationFailed ErrorCode = "authentication_failed" ErrorInternal ErrorCode = "internal" )
type ErrorDefinition ¶
type ErrorDefinition struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
Retryable bool `json:"retryable"`
}
ErrorDefinition describes a stable catalog entry in the manifest.
type ExecutionState ¶
type ExecutionState struct {
ClockChecked bool
NowUnixMilliseconds int64
CancellationChecked bool
CancellationToken string
CancellationRequested bool
}
ExecutionState is deterministic, host-observed state for one dispatch. ClockChecked and CancellationChecked prevent controls from being silently ignored. CancellationToken must equal the request token.
type Limits ¶
type Limits struct {
MaxRequestBytes int `json:"max_request_bytes"`
MaxResponseBytes int `json:"max_response_bytes"`
MaxBinaryBytes int `json:"max_binary_bytes"`
MaxStringBytes int `json:"max_string_bytes"`
MaxIDBytes int `json:"max_id_bytes"`
MaxCancellationTokenBytes int `json:"max_cancellation_token_bytes"`
MaxRequiredCapabilities int `json:"max_required_capabilities"`
MaxJSONDepth int `json:"max_json_depth"`
}
Limits defines hard resource bounds enforced by a Dispatcher.
type Manifest ¶
type Manifest struct {
Schema string `json:"schema"`
Package string `json:"package"`
Version string `json:"version"`
ABI string `json:"abi"`
Encoding EncodingDefinition `json:"encoding"`
Limits Limits `json:"limits"`
Operations []OperationDefinition `json:"operations"`
Capabilities []CapabilityDefinition `json:"capabilities"`
Errors []ErrorDefinition `json:"errors"`
}
Manifest is the deterministic ABI v1 contract manifest.
type Operation ¶
type Operation string
Operation is a stable ABI operation identifier.
const ( OperationNormalize Operation = "text.normalize" OperationValidate Operation = "text.validate" OperationSHA256 Operation = "crypto.sha256" OperationHMACSHA256 Operation = "crypto.hmac-sha256" OperationAESGCMEncrypt Operation = "crypto.aes-gcm.encrypt" OperationAESGCMDecrypt Operation = "crypto.aes-gcm.decrypt" OperationBase64Encode Operation = "encoding.base64.encode" OperationBase64Decode Operation = "encoding.base64.decode" )
type OperationDefinition ¶
type OperationDefinition struct {
Name Operation `json:"name"`
Capability string `json:"capability"`
}
OperationDefinition connects an operation to its required capability.
type Request ¶
type Request struct {
ABI string `json:"abi"`
ID string `json:"id"`
Operation Operation `json:"operation"`
Metadata *RequestMetadata `json:"metadata,omitempty"`
Payload json.RawMessage `json:"payload"`
}
Request is the strict ABI v1 request envelope.
type RequestMetadata ¶
type RequestMetadata struct {
DeadlineUnixMilliseconds *int64 `json:"deadline_unix_ms,omitempty"`
CancellationToken string `json:"cancellation_token,omitempty"`
RequiredCapabilities []string `json:"required_capabilities,omitempty"`
}
RequestMetadata carries portable control metadata. The host supplies the corresponding checked state through ExecutionState.