Documentation
¶
Overview ¶
Package foreign defines the composition seams for foreign loop backends.
Index ¶
- type BrokerDescriptor
- type Builder
- type BuilderRegistry
- func (r *BuilderRegistry) Builder(profile loop.RuntimeProfileName) (Builder, RestoredBuilder, error)
- func (r *BuilderRegistry) HasServicesBuilder(profile loop.RuntimeProfileName) bool
- func (r *BuilderRegistry) Register(profile loop.RuntimeProfileName, builder Builder, restored RestoredBuilder) error
- func (r *BuilderRegistry) RegisterServices(profile loop.RuntimeProfileName, builder ServicesBuilder, ...) error
- func (r *BuilderRegistry) ServicesBuilder(profile loop.RuntimeProfileName) (ServicesBuilder, ServicesRestoredBuilder, error)
- type DeliveryFallback
- type DeliveryHook
- type DeliveryIntent
- type DeliveryReservation
- type DeliveryResolution
- type DeliveryResolutionState
- type EventPublisher
- type RestoredBuilder
- type RestoredForeign
- type Services
- type ServicesBuilder
- type ServicesRestoredBuilder
- type UnknownProfileError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrokerDescriptor ¶
type BrokerDescriptor struct {
// contains filtered or unexported fields
}
BrokerDescriptor is the opaque, per-loop description of a collaboration broker. Harness intentionally keeps the endpoint and capability together; executable discovery, protocol selection, and transport construction belong to the composition root that consumes this value.
The capability is never returned by reference. BrokerDescriptor has no String method so a secret cannot acquire a public formatting contract.
func NewBrokerDescriptor ¶
func NewBrokerDescriptor(endpoint string, capability []byte) BrokerDescriptor
NewBrokerDescriptor takes an endpoint and capability snapshot. The input capability is copied before the descriptor is returned.
func (BrokerDescriptor) Capability ¶
func (d BrokerDescriptor) Capability() []byte
Capability returns an independent copy of the opaque broker capability.
func (BrokerDescriptor) Endpoint ¶
func (d BrokerDescriptor) Endpoint() string
Endpoint returns the broker endpoint from the immutable descriptor.
func (BrokerDescriptor) Format ¶
func (d BrokerDescriptor) Format(state fmt.State, verb rune)
Format deliberately ignores the requested verb, flags, width, and precision. The descriptor may carry a bearer capability and an endpoint path, so every formatting form receives the same fixed bounded redaction.
type Builder ¶
type Builder func( loopCtx context.Context, sessionID, loopID uuid.UUID, parent loop.Provenance, pub EventPublisher, cfg loop.BoundDefinition, idGen func() (uuid.UUID, error), fac *event.Factory, ) (loop.Backend, string, error)
Builder is the composition-root seam a session uses to construct a foreign loop. It returns the Backend and the minted ForeignSID, which the caller records.
type BuilderRegistry ¶
type BuilderRegistry struct {
// contains filtered or unexported fields
}
BuilderRegistry routes foreign-loop construction by the stable runtime profile key. The zero value is ready for use. Registration is serialized and lookup takes a snapshot of the function pair, so a configured registry can be safely composed and read concurrently.
A BuilderRegistry must not be copied after first use.
func (*BuilderRegistry) Builder ¶
func (r *BuilderRegistry) Builder(profile loop.RuntimeProfileName) (Builder, RestoredBuilder, error)
Builder returns legacy-shaped live and restored builders registered for profile. Services registrations are adapted with zero Services so legacy callers remain source-compatible without gaining authority. An unknown profile returns a bounded *UnknownProfileError and no builders.
func (*BuilderRegistry) HasServicesBuilder ¶
func (r *BuilderRegistry) HasServicesBuilder(profile loop.RuntimeProfileName) bool
HasServicesBuilder reports whether profile was registered through the additive services-aware shape. Legacy registrations are intentionally false even though ServicesBuilder can return a compatibility adapter for them; callers that manage capabilities must not mint authority for a legacy builder that cannot receive it.
func (*BuilderRegistry) Register ¶
func (r *BuilderRegistry) Register(profile loop.RuntimeProfileName, builder Builder, restored RestoredBuilder) error
Register binds a live/restored builder pair to profile. Empty profiles and duplicate registrations fail closed; an existing binding is never replaced.
func (*BuilderRegistry) RegisterServices ¶
func (r *BuilderRegistry) RegisterServices(profile loop.RuntimeProfileName, builder ServicesBuilder, restored ServicesRestoredBuilder) error
RegisterServices binds a services-aware live/restored builder pair to a profile. A profile has one registration shape; use Register for legacy builders and RegisterServices for the additive services shape.
func (*BuilderRegistry) ServicesBuilder ¶
func (r *BuilderRegistry) ServicesBuilder(profile loop.RuntimeProfileName) (ServicesBuilder, ServicesRestoredBuilder, error)
ServicesBuilder returns the services-aware live/restored builders for profile. Legacy registrations are adapted with a zero Services value so callers can use one dispatch path without changing legacy behavior.
type DeliveryFallback ¶
type DeliveryFallback = DeliveryIntent
DeliveryFallback identifies the one normal-queue fallback for a request. The hook implementation reuses the command already bound to RequestID and writes its fallback phase before returning; callers never supply a second payload.
type DeliveryHook ¶
type DeliveryHook interface {
CreateIntent(context.Context, DeliveryIntent) error
Reserve(context.Context, DeliveryReservation) error
QueueFallback(context.Context, DeliveryFallback) error
Resolve(context.Context, DeliveryResolution) error
}
DeliveryHook is the narrow durability capability supplied to one foreign loop actor. Implementations must scope every operation to the loop and request identifiers supplied in its value; they must not expose a Session, controller, journal, command sink, or other cross-loop authority. A successful QueueFallback return means its exact command payload is already durably recorded and may now be admitted through the normal actor path.
type DeliveryIntent ¶
DeliveryIntent identifies one durable delivery request. It deliberately carries only loop/request identity; the session binds the exact command payload privately before actor admission, so session controllers, journals, and message payloads do not cross the foreign-loop boundary.
type DeliveryReservation ¶
type DeliveryReservation = DeliveryIntent
DeliveryReservation identifies one reserved foreign delivery attempt.
type DeliveryResolution ¶
type DeliveryResolution struct {
LoopID uuid.UUID
RequestID uuid.UUID
TurnID uuid.UUID
State DeliveryResolutionState
}
DeliveryResolution identifies a durable delivery resolution. TurnID is optional for an ambiguous or untrackable attempt and is present when the actor has a host-owned injected fold to correlate.
type DeliveryResolutionState ¶
type DeliveryResolutionState string
DeliveryResolutionState is the provider-neutral terminal classification for one foreign delivery attempt. A successful injected fold carries its turn identity; unknown and untrackable outcomes do not.
const ( DeliveryResolutionInjected DeliveryResolutionState = "injected" DeliveryResolutionUnknown DeliveryResolutionState = "unknown" DeliveryResolutionUntrackable DeliveryResolutionState = "untrackable" )
type EventPublisher ¶
type EventPublisher interface {
PublishEvent(context.Context, event.Event) error
PublishEventChecked(context.Context, event.Event) error
}
EventPublisher is the foreign loop's narrow consumer of the session event fan-in. A session satisfies it via PublishEvent.
type RestoredBuilder ¶
type RestoredBuilder func( loopCtx context.Context, sessionID, loopID uuid.UUID, parent loop.Provenance, pub EventPublisher, cfg loop.BoundDefinition, idGen func() (uuid.UUID, error), fac *event.Factory, seed RestoredForeign, ) (loop.Backend, error)
RestoredBuilder is the composition-root seam a session uses to reconstruct a foreign loop from journal-recovered state. It mirrors Builder but carries the RestoredForeign seed and returns no sid because the seed already holds it.
type RestoredForeign ¶
type RestoredForeign struct {
ForeignSID string
// AgentSessionID is optional journaled agent state. It is empty for
// legacy events and for foreign runtimes that do not expose one.
AgentSessionID string
TurnIndex event.TurnIndex
Msgs content.AgenticMessages
}
RestoredForeign is the journal-recovered seed for a foreign loop: the recovered foreign session id, the committed turn count, and the committed conversation thread. A restored loop comes up idle, seeded with this state, and resumes (never re-creates) the recorded session on its next turn.
type Services ¶
type Services struct {
Broker BrokerDescriptor
Delivery DeliveryHook
}
Services is the immutable value supplied to a services-aware foreign builder. The zero value is the compatibility snapshot passed to legacy builders and carries no broker or delivery authority.
func NewServices ¶
func NewServices(broker BrokerDescriptor, delivery DeliveryHook) Services
NewServices takes an independent snapshot of broker descriptor bytes while retaining the narrow delivery interface value.
func (Services) Clone ¶
Clone returns an independent services snapshot. Interface values are copied as values; the hook implementation remains responsible for its own concurrency and loop scoping.
type ServicesBuilder ¶
type ServicesBuilder func( loopCtx context.Context, sessionID, loopID uuid.UUID, parent loop.Provenance, pub EventPublisher, cfg loop.BoundDefinition, idGen func() (uuid.UUID, error), fac *event.Factory, services Services, ) (loop.Backend, string, error)
ServicesBuilder is the additive foreign-loop construction seam. Services is passed last so existing builder argument order remains source-compatible.
type ServicesRestoredBuilder ¶
type ServicesRestoredBuilder func( loopCtx context.Context, sessionID, loopID uuid.UUID, parent loop.Provenance, pub EventPublisher, cfg loop.BoundDefinition, idGen func() (uuid.UUID, error), fac *event.Factory, seed RestoredForeign, services Services, ) (loop.Backend, error)
ServicesRestoredBuilder is the additive restored-loop construction seam. It mirrors RestoredBuilder and receives the immutable Services snapshot last.
type UnknownProfileError ¶
type UnknownProfileError struct{}
UnknownProfileError reports a profile that is not registered. Its message is intentionally bounded and does not include the requested profile or any construction detail.
func (*UnknownProfileError) Error ¶
func (*UnknownProfileError) Error() string