Expand description
The chat channel contract (spec 3.3 §5.3, §10 K1, §11 S-I5, S-I6, S-I10; feature
channels).
A chat thread is the doorbell and the conversation: a paired account talks to its agents,
gets decision cards, says yes once or no, and stops everything. The kernel owns the rules;
a platform adapter (Telegram first, in adk-surface) only moves messages. An adapter
implements ChannelSink for what goes out and hands what comes in to
ChannelGateway::receive as a ChannelInbound; it passes the contract suite in
conformance::channel_contract (feature conformance).
| Rule | What the gateway does |
|---|---|
| Only paired accounts reach an agent (S-I6) | An unpaired account’s message, or answer, gets a pairing code (ChannelNotice::PairingCode) and starts nothing; the person accepts the code where the kernel runs (adk-rust pair accept, POST /api/kernel/channels/pair) |
| One code per account, at most so many waiting | The gateway serializes unpaired accounts’ messages, so concurrent messages from one account get one code and the waiting limit holds; the operator dismisses a waiting account (adk-rust pair revoke, POST /api/kernel/channels/waiting/{id}/dismiss), which then gets no code for DISMISSED_FOR |
| A paired account’s message is a turn | It starts a turn as the paired person, a Human subject, in the thread’s session, keyed by the platform’s message id so a redelivery starts nothing; the turn’s reply goes back to the same thread, from whichever replica ran it |
| A message for a running turn reaches it (spec 3.3 §6 “steer”) | While the thread’s turn runs on this host, the gateway hands the message to that turn (ChannelHost::steer, InboundOutcome::Steered): its agent takes it at its next safe point and its reply answers it. A turn that ends first hands the message back, and it starts the thread’s next turn under the message’s idempotency key, once. A turn another replica runs is handed nothing: the message starts a turn behind it. A redelivery of a message handed to a turn is recognised by the replica that took it |
| A removed account reaches no agent | Removing it stops its turns that have not finished, those queued behind the thread’s session included |
| Cards carry no arguments (S-I5) | A DecisionCard holds the agent, a short summary with every argument value masked, and the risk; never the call’s arguments |
| Chat says yes once or no, never money (§7.2, §7.4) | Answers are ChannelAnswer::AllowOnce and ChannelAnswer::Deny at low and medium risk only, through ApprovalService::decide with the version the card showed (S-I2); a call that moves money (ChannelHost::moves_money, ChannelGatewayBuilder::money_tools) and high risk link to the home — high as the request rates it, or as the host does (ChannelHost::rates_high) — and a take-over, whose secret is typed in the home (§8.2), can only be denied |
| Only who may answer gets buttons | A card goes to the decision’s person when the policy lets that person answer it, and its answers only when chat may decide it |
| A second answer is shown, never retried (S-I2) | A version conflict answers ChannelNotice::AlreadyDecided, or a fresh card when the decision still waits; an answer that counts toward a quorum, or one from someone the policy does not ask, answers ChannelNotice::WaitingForOthers |
| Stop all from anywhere; resume only at home (S-I10) | “stop all” freezes the kernel and answers StopNotice; “resume” is refused with ChannelNotice::ResumeRefused |
| Nothing notifies during quiet time | A card for a decision asked during quiet time is delivered when quiet time ends, if it still waits: the quiet time of the decision’s area in force, a change made while the kernel runs included (ChannelHost::quiet_ends) |
| Every waiting decision reaches the thread | Every minute the gateway rings the decisions still waiting, so a card that could not be sent is sent again, and one held on another replica is sent too |
| A host may decide first (spec 3.5 §10 X12) | An InboundRoute set with ChannelGatewayBuilder::route sees each message, with the account’s pairing, before the gateway: a message it takes gets no pairing code and starts no turn (InboundOutcome::Routed). A served site sends strangers to its Inbox this way |
| Files ride with a message | ChannelInbound::attachments, downloaded by the adapter; never in a turn’s input. A paired account’s message with no words starts no turn (InboundOutcome::Empty) |
Every answer, pairing request, notification, stop and refusal writes a kernel.channel
audit record with surface: chat, the channel and the account, before it acts.
Backend of ChannelBindingStore | Type | Feature |
|---|---|---|
| In-memory | InMemoryChannelBindingStore | — |
| SQLite | SqliteChannelBindingStore | sqlite (default) |
| PostgreSQL | PostgresChannelBindingStore | postgres |
| Redis | RedisChannelBindingStore | redis |
Text from an agent, a tool or a chat platform reaches a sink as it is; the adapter escapes it for its platform before display (S-I9).
Structs§
- Channel
Attachment - A file an inbound chat message carried, as its adapter downloaded it, bounded in size and type (spec 3.5 §5 S18, §10 X12): untrusted input, which only a paired account’s message may bring into the site, through the media pipeline.
- Channel
Binding - A chat account paired to a person (spec 3.3 §10 K1): its messages are that person’s turns and its answers are that person’s decisions, within what chat may decide.
- Channel
Doorbell - The decision doorbell (spec 3.3 §5.3, §10 K1): an
ApprovalNotifierregistered onStoreApprovalService::with_notifierthat hands each submitted decision to theChannelGatewaygiven it, which sends the card to every paired thread of the decision’s person. - Channel
Gateway - The kernel’s side of every chat channel (spec 3.3 §5.3, §10 K1, S-I5, S-I6, S-I10): see the module documentation for the rules it applies.
- Channel
Gateway Builder - Builds a
ChannelGateway. - Channel
Inbound - What arrived from a chat thread (spec 3.3 §10 K1): untrusted input (S-I6).
- Channel
Pairing Request - An unpaired account’s request to pair (spec 3.3 §10 K1): the hash of the code it was sent, never the code.
- Decision
Card - A decision as a chat thread shows it (spec 3.3 §5.3, §7.1, S-I5): who asks, a short summary, the risk, and the answers the thread may give. Never the call’s arguments.
- InMemory
Channel - A chat channel in process memory (spec 3.3 §10 K1): a
ChannelSinkthat keeps what it is sent per thread, and makes theChannelInboundvalues a platform adapter would, for tests and the contract suite. - InMemory
Channel Binding Store - A
ChannelBindingStorein process memory, for tests and a kernel with no durable store (spec 3.3 §10 K1). Its pairings end with the process. - Postgres
Channel Binding Store - A
ChannelBindingStorein PostgreSQL, shared by every replica (spec 3.3 §10 K1, featureschannels,postgres). - Redis
Channel Binding Store - A
ChannelBindingStorein Redis, shared by every replica (spec 3.3 §10 K1, featureschannels,redis). - Sqlite
Channel Binding Store - A
ChannelBindingStorein SQLite (spec 3.3 §10 K1, featureschannels,sqlite). - Stop
Notice - Everything was stopped from a chat thread (spec 3.3 S-I10).
Enums§
- Channel
Answer - What a person can answer from a chat thread (spec 3.3 §7.2, §8.2).
- Channel
Notice - Something the gateway tells a chat thread (spec 3.3 §5.3, §8).
- Delivered
- One thing a channel sent to a thread (spec 3.3 §10 K1).
- Inbound
Body - What a person sent from a chat thread (spec 3.3 §10 K1).
- Inbound
Outcome - What the gateway did with one
ChannelInbound(spec 3.3 §10 K1).
Constants§
- DISMISSED_
FOR - How long an account the operator dismissed gets no pairing code (spec 3.3 §10 K1): a day.
Traits§
- Channel
Binding Store - Where paired chat accounts and their pairing requests are kept (spec 3.3 §10 K1), on the
backends the kernel’s other stores use, with one conformance suite
(
channel_binding_store_conformance_tests!, featureconformance). - Channel
Host - What the gateway runs on (spec 3.3 §10 K1): the
Kernel, or a test double such as the contract suite’s. - Channel
Sink - Where a channel’s messages go out (spec 3.3 §10 K1): implemented by each platform adapter.
- Inbound
Route - What a host decides about an inbound message before the gateway does (spec 3.5 §10 X12,
§7.19, A-I24): a served site sends a stranger’s message to its Inbox, where it never gets
a pairing code or starts a turn, and takes a paired person’s photos into its media
pipeline. Set it with
ChannelGatewayBuilder::route.
Functions§
- accept_
pairing - Pairs the account whose request was sent
codetouser_idwithgroups(spec 3.3 §10 K1): the control plane’sPOST /kernel/channels/pair. - revoke_
binding - Removes the chat account
id(spec 3.3 §10 K1); removing a removed one changes nothing.