A-91: the operator-channel contract's asks value carries the ask's warrant
Builds: design 47 G §700, A-91; the router's record carries its warrant Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -106,10 +106,7 @@ func (c *Client) Where(id string) (state string, w *seat.Warrant, err error) {
|
||||
if err != nil || e == nil {
|
||||
return "", nil, err
|
||||
}
|
||||
var rec struct {
|
||||
State string `json:"state"`
|
||||
Warrant *seat.Warrant `json:"warrant"`
|
||||
}
|
||||
var rec seat.AsksByAskerIDValue
|
||||
if err := json.Unmarshal(e.Value, &rec); err != nil {
|
||||
return "", nil, fmt.Errorf("the router's record of %s cannot be read: %w", id, err)
|
||||
}
|
||||
|
||||
@@ -175,3 +175,16 @@ func TestAKeyPrefixIsPutBeforeEveryKeyOfTheClientsOwnStateAndNotBeforeWhere(t *t
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 G §700, A-91: Where reads the router's record as the contract's typed value, its warrant included.
|
||||
func TestWhereReadsTheRecordsWarrantTyped(t *testing.T) {
|
||||
c, _ := client()
|
||||
rec := seat.AsksByAskerIDValue{Key: "an-asker.d-1", Asker: "an-asker", State: "chosen",
|
||||
Warrant: &seat.Warrant{Ask: "d-1", Asker: "an-asker", Outcome: seat.WarrantOutcomeChosen, Option: "ok"}}
|
||||
raw, _ := json.Marshal(rec)
|
||||
c.Record = func(string) (*stdio.StateEntry, error) { return &stdio.StateEntry{Value: raw}, nil }
|
||||
state, w, err := c.Where("d-1")
|
||||
if err != nil || state != "chosen" || w == nil || w.Option != "ok" {
|
||||
t.Fatalf("Where = %q, %+v, %v; want chosen and the record's warrant", state, w, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,5 +541,6 @@ type AsksByAskerIDValue struct {
|
||||
// when it was opened, RFC 3339
|
||||
Opened string `json:"opened"`
|
||||
// how it stands: open, held-back (kept open behind the asker's newer asks, ADR 0666 §12), chosen, expired, cancelled, replaced or refused
|
||||
State string `json:"state"`
|
||||
State string `json:"state"`
|
||||
Warrant *Warrant `json:"warrant,omitempty"`
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ func TestFixtures(t *testing.T) {
|
||||
decode: func(b []byte) (any, error) { var v AsksByAskerIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "an ask the router refused at take-in, closed (design 47 G 570)", subject: "", given: "{\"answer\":\"refused: its expiry passes the bound of its highest option level\",\"asker\":\"nats\",\"asker_told\":true,\"at\":\"2026-11-11T10:00:01Z\",\"expires\":\"2026-11-12T10:00:00Z\",\"headline\":\"Recreate a bus entry\",\"key\":\"nats.r-1\",\"opened\":\"2026-11-11T10:00:00Z\",\"state\":\"refused\"}", wire: "{\"answer\":\"refused: its expiry passes the bound of its highest option level\",\"asker\":\"nats\",\"asker_told\":true,\"at\":\"2026-11-11T10:00:01Z\",\"expires\":\"2026-11-12T10:00:00Z\",\"headline\":\"Recreate a bus entry\",\"key\":\"nats.r-1\",\"opened\":\"2026-11-11T10:00:00Z\",\"state\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v AsksByAskerIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "an ask chosen, with its warrant in the router's record (design 47 G 700, A-91)", subject: "", given: "{\"asker\":\"mesh-delivery-pipeline\",\"expires\":\"2026-11-12T10:00:00Z\",\"headline\":\"Deliver a module?\",\"key\":\"mesh-delivery-pipeline.approval-1\",\"opened\":\"2026-11-11T10:00:00Z\",\"state\":\"chosen\",\"warrant\":{\"about\":\"mod.main\",\"ask\":\"approval-1\",\"ask-digest\":\"sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-11T10:05:00Z\",\"option\":\"approve\",\"outcome\":\"chosen\"}}", wire: "{\"asker\":\"mesh-delivery-pipeline\",\"expires\":\"2026-11-12T10:00:00Z\",\"headline\":\"Deliver a module?\",\"key\":\"mesh-delivery-pipeline.approval-1\",\"opened\":\"2026-11-11T10:00:00Z\",\"state\":\"chosen\",\"warrant\":{\"about\":\"mod.main\",\"ask\":\"approval-1\",\"ask-digest\":\"sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-11T10:05:00Z\",\"option\":\"approve\",\"outcome\":\"chosen\"}}",
|
||||
decode: func(b []byte) (any, error) { var v AsksByAskerIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "notify asks the message sent on every channel", subject: "", given: "{\"every-channel\":true,\"key\":\"widens.mesh-delivery\",\"severity\":\"warning\",\"subject\":\"mesh-delivery\",\"summary\":\"a change widens what a module may do\"}", wire: "{\"every-channel\":true,\"key\":\"widens.mesh-delivery\",\"severity\":\"warning\",\"subject\":\"mesh-delivery\",\"summary\":\"a change widens what a module may do\"}",
|
||||
decode: func(b []byte) (any, error) { var v NotifyInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
|
||||
@@ -60,5 +60,26 @@
|
||||
"opened": "2026-11-11T10:00:00Z",
|
||||
"state": "refused"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "an ask chosen, with its warrant in the router's record (design 47 G 700, A-91)",
|
||||
"of": "state:asks/<asker>.<id>",
|
||||
"given": {
|
||||
"asker": "mesh-delivery-pipeline",
|
||||
"expires": "2026-11-12T10:00:00Z",
|
||||
"headline": "Deliver a module?",
|
||||
"key": "mesh-delivery-pipeline.approval-1",
|
||||
"opened": "2026-11-11T10:00:00Z",
|
||||
"state": "chosen",
|
||||
"warrant": {
|
||||
"about": "mod.main",
|
||||
"ask": "approval-1",
|
||||
"ask-digest": "sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
||||
"asker": "mesh-delivery-pipeline",
|
||||
"at": "2026-11-11T10:05:00Z",
|
||||
"option": "approve",
|
||||
"outcome": "chosen"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -312,6 +312,9 @@
|
||||
"type": "string",
|
||||
"description": "when the ask was held back, RFC 3339; present while its state is held-back"
|
||||
},
|
||||
"warrant": {
|
||||
"$ref": "#/defs/Warrant"
|
||||
},
|
||||
"answer": {
|
||||
"type": "string",
|
||||
"description": "how it ended, in words"
|
||||
|
||||
@@ -442,5 +442,6 @@ export interface AsksByAskerIDValue {
|
||||
"opened": string;
|
||||
/** how it stands: open, held-back (kept open behind the asker's newer asks, ADR 0666 §12), chosen, expired, cancelled, replaced or refused */
|
||||
"state": string;
|
||||
"warrant"?: Warrant;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user