free-agent
Safe HaskellNone
LanguageGHC2024

Free.Agent.Connector

Description

Persistent REPL agent as a bus participant.

runConnector spawns a process (via openProc), attaches to the free-agent bus, and loops: await addressed posts → commit body to repl stdin → block on the next stdout frame → scribe reply.

Framing is port-side: the repl's prompt grammar (procMarks) decides turn boundaries, and the emit end blocks until a complete frame arrives. No polling; the timeouts here are deadlines around blocking reads, not backoff loops.

Turn correlation is content-decided, not geometry-decided. Each addressed post is treated as an ask whose bus stamp is the correlation id. The response post carries that id in its thread and is addressed back to the asker. Zero-frame and two-frame violations are reported as in-band diagnostic posts with the same ask id, so downstream consumers can detect them by the stamped output grammar rather than by timing.

Synopsis

Documentation

data ConnectorConfig Source #

Constructors

ConnectorConfig 

Fields

Turn handler (exported for oracles)

data TurnResult Source #

The result of one critical-section turn, before scribing.

Constructors

TurnOk Text

Exactly one response frame.

TurnZeroFrame

No frame arrived before the deadline.

TurnMultiFrame [Text]

More than one frame arrived for the same ask.

Instances

Instances details
Eq TurnResult Source # 
Instance details

Defined in Free.Agent.Connector

Show TurnResult Source # 
Instance details

Defined in Free.Agent.Connector

runTurn :: ConnectorConfig -> ProcEnds Text Text Text -> Stamped Text -> IO [Post Text] Source #

Run one critical-section turn for an addressed post.

The ask is identified by the incoming post's bus stamp. The response carries that id in its thread and is addressed back to the asker. This makes correlation content-decided: a dropped, doubled, or misordered frame is observable from the bus log, not inferred from pipe adjacency.