Join 9: the licence manager says binding.changed.<consumer> (A-134)

The consumer is the event's further part, the one form of G's seat events, so mesh-vault and
claude-code adopt it through their views reader.

Builds: design 47 G A-134

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 01:57:58 +01:00
parent c3e75e35e1
commit 739c0c23c6
5 changed files with 18 additions and 5 deletions
@@ -94,6 +94,10 @@ func (m *Manager) record(ctx context.Context, what, line string, detail map[stri
return nil
}
// BindingChanged is the event of a consumer's binding written or deleted, said as `binding.changed.<consumer>`: the consumer is
// its further part, the one form of G's seat events (novox/hq design 47 G A-134), so a reader adopts it.
const BindingChanged = "binding.changed"
// changed says that one consumer's key of `bindings` was written or deleted (§21, B7): its licence (empty on a
// release) and that licence's key, kind, generation, the licence before, why, by and when. Never a token.
func (m *Manager) changed(b Binding, from string) {
@@ -101,7 +105,7 @@ func (m *Manager) changed(b Binding, from string) {
if b.Licence != "" {
key = KeyFor(b.Licence)
}
_ = m.Emit("binding.changed", map[string]any{"consumer": b.Consumer, "licence": b.Licence, "key": key,
_ = m.Emit(BindingChanged+"."+b.Consumer, map[string]any{"consumer": b.Consumer, "licence": b.Licence, "key": key,
"kind": b.Kind, "generation": b.Generation, "from": from, "why": b.Why, "by": b.By,
"at": m.Now().UTC().Format(time.RFC3339Nano)})
}
@@ -572,9 +572,14 @@ func TestWhatIsNotAnAPIKeyIsRefused(t *testing.T) {
func (mm *miniMesh) changedSince(mark int) []map[string]any {
var out []map[string]any
for _, e := range mm.events[mark:] {
if body, ok := strings.CutPrefix(e, "binding.changed "); ok {
if rest, ok := strings.CutPrefix(e, BindingChanged+"."); ok {
// The consumer is the event's further part (A-134); one said under another consumer's name reads as none.
consumer, body, _ := strings.Cut(rest, " ")
var v map[string]any
_ = json.Unmarshal([]byte(body), &v)
if v["consumer"] != consumer {
v["consumer"] = "said as binding.changed." + consumer
}
out = append(out, v)
}
}
@@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"fmt"
"strings"
"testing"
"time"
@@ -93,7 +94,7 @@ func TestOneSwitchedPerAct(t *testing.T) {
switch name {
case "licence.switched":
switched = append(switched, f)
case "binding.changed":
case "binding.changed." + fmt.Sprint(f["consumer"]):
changed++
}
}
@@ -264,6 +264,9 @@ func TestResyncSaysEachOnce(t *testing.T) {
count := map[string]int{}
for _, e := range mm.events {
name, _, _ := strings.Cut(e, " ")
if strings.HasPrefix(name, BindingChanged+".") {
name = BindingChanged
}
count[name]++
}
puts, _ := got["licence-put"].([]any)
@@ -394,7 +394,7 @@ func (m *mesh) until(what string, ok func() bool) {
func (m *mesh) count(key string) int {
n := 0
for _, s := range m.said {
if s.key == key {
if s.key == key || strings.HasPrefix(s.key, key+".") {
n++
}
}
@@ -405,7 +405,7 @@ func (m *mesh) count(key string) int {
func (m *mesh) of(key string) []map[string]any {
var out []map[string]any
for _, s := range m.said {
if s.key == key {
if s.key == key || strings.HasPrefix(s.key, key+".") {
var b map[string]any
_ = json.Unmarshal(s.body, &b)
out = append(out, b)