Every seat constant of mesh-sdk is mesh-contracts' generated name; the four whole seats' (BrokerSeat, CheckerSeat, asks.Seat, buscompose.VaultSeat) are marked deprecated for their importers. The package walk of mesh-sdk's own check refuses a string literal naming a defined seat or its subjects, and an exported name given to one, beyond testdata/seat-names.txt, which lists what stands before the move (module names that equal a seat's among them) and only shrinks. No new test function. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
60 lines
2.4 KiB
Go
60 lines
2.4 KiB
Go
package catalogue
|
|
|
|
import contractseats "git.novox.be/novox/mesh-contracts/go/seats"
|
|
|
|
// DeliverySeat is the seat mesh-delivery holds.
|
|
const DeliverySeat = contractseats.MeshDelivery
|
|
|
|
// RemovedDeliveryVerbs are the delivery seat's verbs release 6 removed (novox/hq ADR 0539 clause 17): with no plan the
|
|
// gate keeps the merge's states and derives nothing after the merge. Each stays in deliveryVerbs as an optional row
|
|
// with no input, so the holder of before and the holder of release 6 both hold the seat and a caller is answered by
|
|
// name with its replacement, given here.
|
|
var RemovedDeliveryVerbs = map[string]string{
|
|
"times": "the delivery view (nox-delivery): each machine's want and have, and since when",
|
|
"what-if": "the merge check's composition, which composes every machine a change touches",
|
|
"release": "the assigner's asks (hold, restore, backup, record), answered on the phone or in the delivery view",
|
|
"stop": "a bad fingerprint is held and its canary set back by the assigner (ADR 0429 §6, ADR 0539 clause 18)",
|
|
"retire-history": "nothing to retire: the gate keeps no delivery after its merge",
|
|
}
|
|
|
|
// SeatSays is whether a consumed `<seat>.<event>` names one of the seat's own events: the seat emits it,
|
|
// exactly or by one of its patterns (`log.*`). A consumed name whose emitter is a seat and whose event the
|
|
// seat does not emit is the event of the module of that name (novox/hq ADR 0239): mesh-delivery is a seat
|
|
// and the module holding it, and what the module says it says as itself, through the runtime that launches
|
|
// it — read as the seat's, a consumer would subscribe a subject nothing may publish.
|
|
func SeatSays(emits []string, event string) bool {
|
|
for _, e := range emits {
|
|
if e == event || topicMatches(e, event) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// topicMatches is whether an event's name matches a declared pattern, `*` one dot-separated segment and
|
|
// `>` or `**` the rest.
|
|
func topicMatches(pattern, event string) bool {
|
|
p, e := splitDots(pattern), splitDots(event)
|
|
for i, part := range p {
|
|
if part == ">" || part == "**" {
|
|
return len(e) > i
|
|
}
|
|
if i >= len(e) || (part != "*" && part != e[i]) {
|
|
return false
|
|
}
|
|
}
|
|
return len(p) == len(e)
|
|
}
|
|
|
|
func splitDots(s string) []string {
|
|
var out []string
|
|
start := 0
|
|
for i := 0; i < len(s); i++ {
|
|
if s[i] == '.' {
|
|
out = append(out, s[start:i])
|
|
start = i + 1
|
|
}
|
|
}
|
|
return append(out, s[start:])
|
|
}
|