G V-8 (TS), A-17, test: the TypeScript writer is generic over the contract's bodies and names its events; findings-asked is mesh-conditions' event

The TypeScript writer holds no FindingBody of its own and works on the wire form (checkFinding, views reader findings laid out by
viewFindingBody); both writers name findings-asked as the seat mesh-conditions' event. The view-waits test waits on the raise,
not on a count of yields.

Builds: design 47 G §686, §640, §687, A-3, A-13, A-17
Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-11 21:45:07 +01:00
parent 43960cc925
commit 58bbc26219
6 changed files with 165 additions and 130 deletions
+7 -6
View File
@@ -10,9 +10,13 @@ import (
stdio "git.novox.be/novox/mesh-sdk/go"
)
// FindingsAskedEvent is the event `findings-asked`, always the seat mesh-conditions' event, named with that seat (design 47 G
// A-17); a stdio module's writer subscribes to it by this name, and no module supplies it.
const FindingsAskedEvent = "mesh-conditions.findings-asked"
// NewStdioWriter makes the finding writer of a stdio module (design 47 G A-16, §461, §485, §503): it fills `Publish` from
// the module's own event publish (stdio.Emit, answered once the bus acknowledged it) and `Listen` from its subscription
// (stdio.SubscribeNew, only the asks published after it is made), so no module writes that adapter. A `Publish` or `Listen`
// (stdio.SubscribeNew of FindingsAskedEvent, only the asks published after it is made), so no module writes that adapter. A `Publish` or `Listen`
// the config already holds is kept. The runtime publishes and subscribes by the event's name on the subject the module's
// membership names for it, so each of the writer's four subjects (FindingSubjects) is told by its event.
func NewStdioWriter[F, C, S, A any](cfg WriterConfig[F, C, S, A]) (*Writer[F, C, S, A], error) {
@@ -32,11 +36,8 @@ func newStdioWriter[F, C, S, A any](cfg WriterConfig[F, C, S, A],
}
}
if cfg.Listen == nil {
cfg.Listen = func(_ context.Context, subject string, handle func([]byte)) (func(), error) {
event, err := eventOfSubject(subject)
if err != nil {
return nil, err
}
cfg.Listen = func(_ context.Context, _ string, handle func([]byte)) (func(), error) {
event := FindingsAskedEvent
var stopped atomic.Bool
// the runtime keeps a subscription until the process ends: a stopped listener hands on nothing
if err := subscribe(event, func(env stdio.Envelope) error {
+1 -1
View File
@@ -85,7 +85,7 @@ func TestStdioWriterPublishesAndListensThroughTheModulesOwnPlumbing(t *testing.T
}
var heard []string
stop, err := w.cfg.Listen(context.Background(), w.subj.Asked, func(b []byte) { heard = append(heard, string(b)) })
if err != nil || len(subscribed) != 1 || subscribed[0] != "findings-asked" {
if err != nil || len(subscribed) != 1 || subscribed[0] != "mesh-conditions.findings-asked" {
t.Fatalf("the listen: %v %v", subscribed, err)
}
_ = deliver(stdio.Envelope{Body: json.RawMessage(`{"ask":"x"}`)})
+6 -3
View File
@@ -310,8 +310,9 @@ func TestViews(t *testing.T) {
defer func() { waitBound = kept }()
var raised, cleared, said []Status
var mu sync.Mutex
raisedCh := make(chan struct{}, 4) // told after the part's raise, so the test reads it only once it is made
f := &Follower{Owner: "o", Tool: "o.revision", State: BranchState("catalog", "trunk"), Now: now,
RaiseWaits: func(s Status) { mu.Lock(); raised = append(raised, s); mu.Unlock() },
RaiseWaits: func(s Status) { mu.Lock(); raised = append(raised, s); mu.Unlock(); raisedCh <- struct{}{} },
ClearWaits: func(s Status) { mu.Lock(); cleared = append(cleared, s); mu.Unlock() },
Said: func(s Status) { mu.Lock(); said = append(said, s); mu.Unlock() }}
f.Holds("trunk.11")
@@ -321,8 +322,10 @@ func TestViews(t *testing.T) {
t.Fatalf("status = %+v", s)
}
ended <- true
for i := 0; i < 1000 && !f.Status().WaitsRaised; i++ {
runtime.Gosched()
select {
case <-raisedCh:
case <-time.After(10 * time.Second):
t.Fatal("the bound ended and view-waits was not raised")
}
mu.Lock()
if len(raised) != 1 || raised[0].WaitsFor != "trunk.12" {