Documentation
¶
Overview ¶
Package multiplex is part of the GoFastr harness.
See docs/harness-architecture.md for the architecture this package implements.
Package multiplex implements the multi-client routing layer that sits between transports and the engine. Per hard rule 7, this is where "engine knows about clients, not transports" lives.
Responsibilities:
- Track all attached clients per session.
- Total-order SendInput across all transports (mid-turn input rejected with TurnInProgress; rule 9).
- Track originator for each turn so PermissionRequested events carry the right ClientID.
- Enforce permission arbitration: agents cannot self-approve (rule 11); at least one human ack required by default.
- Broadcast events to all attached clients of a session.
- Route AnswerPermission deliveries to the engine.
Index ¶
- Variables
- type Mux
- func (m *Mux) Attach(session ids.SessionID, c control.Client) error
- func (m *Mux) Detach(session ids.SessionID, clientID ids.ClientID)
- func (m *Mux) Dispatch(ctx context.Context, c control.Client, cmd control.Command) error
- func (m *Mux) EngineFor(session ids.SessionID) *engine.Engine
- func (m *Mux) HasHumanAttached(session ids.SessionID) bool
- func (m *Mux) RegisterEngine(e *engine.Engine)
- func (m *Mux) Subscribe(session ids.SessionID, callID ids.CallID) <-chan engine.PermissionAnswer
- func (m *Mux) UnregisterEngine(session ids.SessionID)
- func (m *Mux) Unsubscribe(session ids.SessionID, callID ids.CallID)
- type TurnInProgressError
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownSession = errors.New("multiplex: unknown session") ErrNoPendingPermission = errors.New("multiplex: no pending permission") ErrAgentCannotSelfApprove = errors.New("multiplex: agent cannot self-approve permission (rule 11)") ErrHumanAnswerRequired = errors.New("multiplex: a human-class client must answer this prompt") ErrAnswerChannelFull = errors.New("multiplex: permission answer channel full (race)") ErrUnhandledCommand = errors.New("multiplex: command not handled at this layer") )
Errors. These are wire-format Reason codes for control.Error events.
Functions ¶
This section is empty.
Types ¶
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is the multiplexer. One per harness process; manages multiple EngineRuns simultaneously.
func (*Mux) Attach ¶
Attach registers a client with the mux for one session. The client will receive broadcast events and can issue commands via Dispatch.
func (*Mux) Detach ¶
Detach removes a client. Non-destructive at the engine level — the EngineRun continues, events still flow to other attached clients.
func (*Mux) Dispatch ¶
Dispatch is the single entry point for client → engine commands. All transports call this; the mux enforces total ordering, identity rules, and routes the command.
Returns an error event Reason on failure (caller wraps as control.Error and sends to the originating client).
func (*Mux) HasHumanAttached ¶
HasHumanAttached reports whether at least one human-class client is currently attached to the session.
func (*Mux) RegisterEngine ¶
RegisterEngine binds an EngineRun to the multiplexer. Subsequent Attach calls for the same session can connect clients to it.
func (*Mux) Subscribe ¶
Subscribe implements engine.AnswerRouter — the permission middleware calls Subscribe to wait for answers.
func (*Mux) UnregisterEngine ¶
UnregisterEngine removes a session from the mux. Attached clients receive SessionEnded as the engine shuts down separately.
type TurnInProgressError ¶
TurnInProgressError matches control.ReasonTurnInProgress on the wire.
func (*TurnInProgressError) Error ¶
func (e *TurnInProgressError) Error() string