operatorchannelclient: the bench subjects and words the router and the channels share (B5d; ADR 0634 §1; issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package operatorchannelclient
|
||||
|
||||
// The subjects and words of the two kinded benches a channel holds, `channel` (to show and say) and `intake` (to say
|
||||
// what was chosen, and to ask a proof): the router and every channel share them (novox/hq ADR 0259 §3, ADR 0634 §1).
|
||||
// The shapes carried are the seat's types (Message, Choice, LinkAsked, Failed, Standing, Code, ProofAnswer).
|
||||
|
||||
// The benches.
|
||||
const (
|
||||
// ChannelSeat is the kinded bench a channel holds to show and say: its accepts carry the kind.
|
||||
ChannelSeat = "channel"
|
||||
// IntakeSeat is the kinded bench a channel holds to say what was chosen: its events and proofs carry the kind.
|
||||
IntakeSeat = "intake"
|
||||
)
|
||||
|
||||
// The work a channel takes, on ChannelSubject.
|
||||
const (
|
||||
Show = "show" // a message offering answers
|
||||
Edit = "edit" // a message shown before, replaced
|
||||
Send = "send" // a message offering nothing
|
||||
)
|
||||
|
||||
// ChannelSubject is where the router sends a channel of a kind its work.
|
||||
func ChannelSubject(verb, kind string) string {
|
||||
return "mesh.seat." + ChannelSeat + ".accept." + verb + "." + kind
|
||||
}
|
||||
|
||||
// What a channel says, on IntakeSubject.
|
||||
const (
|
||||
Chosen = "choice" // a button tapped
|
||||
Link = "link" // somebody asked to be linked as the operator
|
||||
FailedWhat = "failed" // a message it could not deliver
|
||||
StandingWhat = "standing" // what it says of itself
|
||||
)
|
||||
|
||||
// IntakeSubject is where a channel of a kind says what arrived.
|
||||
func IntakeSubject(what, kind string) string {
|
||||
return "mesh.seat." + IntakeSeat + ".event." + what + "." + kind
|
||||
}
|
||||
|
||||
// CodeProof is the one proof verb: a code the operator typed, carried by request and reply, never kept.
|
||||
const CodeProof = "code"
|
||||
|
||||
// ProofSubject is where a channel of a kind asks a proof.
|
||||
func ProofSubject(verb, kind string) string {
|
||||
return "mesh.seat." + IntakeSeat + ".proof." + verb + "." + kind
|
||||
}
|
||||
@@ -56,3 +56,21 @@ func jsonEqual(a, b any) bool {
|
||||
y, _ := json.Marshal(b)
|
||||
return bytes.Equal(x, y)
|
||||
}
|
||||
|
||||
// TestTheBenchSubjectsAreTheChannelsOwn: the subjects and words are mesh-sdk channel's, character for character.
|
||||
func TestTheBenchSubjectsAreTheChannelsOwn(t *testing.T) {
|
||||
for _, c := range [][2]string{
|
||||
{ChannelSubject(Show, "telegram"), channel.ChannelSubject(channel.Show, "telegram")},
|
||||
{ChannelSubject(Edit, "desk"), channel.ChannelSubject(channel.Edit, "desk")},
|
||||
{ChannelSubject(Send, "desk"), channel.ChannelSubject(channel.Send, "desk")},
|
||||
{IntakeSubject(Chosen, "telegram"), channel.IntakeSubject(channel.Chosen, "telegram")},
|
||||
{IntakeSubject(Link, "telegram"), channel.IntakeSubject(channel.Link, "telegram")},
|
||||
{IntakeSubject(FailedWhat, "desk"), channel.IntakeSubject(channel.FailedWhat, "desk")},
|
||||
{IntakeSubject(StandingWhat, "desk"), channel.IntakeSubject(channel.StandingWhat, "desk")},
|
||||
{ProofSubject(CodeProof, "telegram"), channel.ProofSubject(channel.CodeProof, "telegram")},
|
||||
} {
|
||||
if c[0] != c[1] {
|
||||
t.Errorf("subject %q, want %q", c[0], c[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user