Its conditions' keys, its asks' subjects, its reader and emitter, its ends bucket and its tools' first views take the module its credential names (the tools: the module the runtime serves them as) instead of constants of its name; a guard test finds none in its code. Builds: design 47 G A-296, §428 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
49 lines
2.2 KiB
Go
49 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/views"
|
|
)
|
|
|
|
// The holders and buckets the teller names, taken from its own manifest (module.json: its name, what it invokes and
|
|
// consumes) and the states it keeps itself; a unit row checks them against it (TestTheNamesAreTheManifests). No contract
|
|
// names a holder (novox/hq ADR 0625 §4, ADR 0634 §1).
|
|
const (
|
|
// answersState is the teller's own state answers, said as its views family views.answers, and marksState the state of
|
|
// what that family said it up to.
|
|
answersState = "answers"
|
|
marksState = "teller-marks"
|
|
// The revisions the teller's answers keep per key.
|
|
answersHistory = 5
|
|
)
|
|
|
|
// ownBuckets are the teller's own state buckets, `<module>_<state>`, the module its credential's (design 47 G A-296): answers,
|
|
// asked (what it asked of the router and which condition it raised, ADR 0437 §4), widens-said (the last commit it said a widening
|
|
// of per module and branch), its first views (views.StatusState) and findings (ADR 0615 §6), and the marks of what its views
|
|
// family said its answers up to (A-178).
|
|
type ownBuckets struct{ answers, asked, widensSaid, firstViews, findings, marks string }
|
|
|
|
// bucketsOf names the teller's own buckets from module, its credential's.
|
|
func bucketsOf(module string) ownBuckets {
|
|
b := func(state string) string { return module + "_" + state }
|
|
return ownBuckets{answers: b(answersState), asked: b("asked"), widensSaid: b(widensSaidState), firstViews: b(views.StatusState),
|
|
findings: b("findings"), marks: b(marksState)}
|
|
}
|
|
|
|
// answerKey is the key, in the teller's answers, of its answer to the ask at askKey: the same string.
|
|
func answerKey(askKey string) string { return askKey }
|
|
|
|
// answeredEvent is the event the teller says after each answer it writes (manifest emits): the key of the ask and the answer.
|
|
const answeredEvent = "answered"
|
|
|
|
// Answered is the body of the event answered.
|
|
type Answered struct {
|
|
Key string `json:"key"`
|
|
Ask string `json:"ask"`
|
|
Answer json.RawMessage `json:"answer"`
|
|
}
|
|
|
|
// answeredID is the bus message id of the event for one ask's answer: said twice, it is kept once.
|
|
func answeredID(key, askID string) string { return "answered." + key + "." + askID }
|