From 3a5f6b33fb62ae08f3d5561db7f82c7792e2c7f7 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 11 Nov 2026 20:25:31 +0100 Subject: [PATCH] G V-5: the views status tools take the state they write by a small interface, so the again tool's test refuses at once, not after 30 s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hand-act test of a reader's again tool waited the runtime's 30 s for a write no runtime answered; it now gives a state that refuses the write, and still proves the act is recorded before the ask is written. Builds: design 47 G ยง532 (V-5's test) Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ --- go/views/status.go | 9 ++++++++- go/views/views_test.go | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/go/views/status.go b/go/views/status.go index ecfd4c75..bc7f3af4 100644 --- a/go/views/status.go +++ b/go/views/status.go @@ -97,12 +97,19 @@ func hearAgain(ctx context.Context, kv jetstream.KeyValue, current func() []*Fol return nil } +// keptStatus is what the tools use of the state `first-views` (a stdio.KeptState is one). +type keptStatus interface { + Keys() ([]string, error) + Get(key string) (*stdio.StateEntry, error) + Put(key string, value any) (uint64, error) +} + // StatusTools are a reader's read tool of its first views (read) and its re-read tool (again), in its tools bundle, // over its StatusState: read lists what the process last said of each; again writes a hand ask the process takes, // naming the caller the runtime proved, and is recorded in the status's by-hand count and why. again is a hand act: // acts records it before the ask is written, and one that is not taken is said and nothing is asked (nil acts // record nothing, so again refuses). -func StatusTools(reader, read, again string, st stdio.KeptState, acts HandActs, now func() time.Time) []stdio.Tool { +func StatusTools(reader, read, again string, st keptStatus, acts HandActs, now func() time.Time) []stdio.Tool { return []stdio.Tool{ {Name: read, Description: fmt.Sprintf("%s's first views of the owners' states it follows (novox/hq ADR 0615): per owner and state, "+ diff --git a/go/views/views_test.go b/go/views/views_test.go index 9247b67d..b8101c3b 100644 --- a/go/views/views_test.go +++ b/go/views/views_test.go @@ -902,12 +902,12 @@ func TestViews(t *testing.T) { recorded = append(recorded, q) return take }) - again := StatusTools("reader", "reader_first_views", "reader_first_view_again", stdio.State(StatusState), acts, now)[1] + again := StatusTools("reader", "reader_first_views", "reader_first_view_again", refusingStatus{}, acts, now)[1] args := map[string]any{"owner": "o", "state": "modules", "why": "doubted"} if _, err := again.Run(args); err == nil || !strings.Contains(err.Error(), "nothing was asked again") || len(recorded) != 1 { t.Errorf("a hand act the seat did not take: %v, recorded %v", err, recorded) } - take = nil // taken: the ask is written next (here refused, for no runtime serves this test) + take = nil // taken: the ask is written next (here refused) if _, err := again.Run(args); err == nil || !strings.Contains(err.Error(), "hand ask is not written") || len(recorded) != 2 || recorded[1].Why != "doubted" || recorded[1].Verb != "reader_first_view_again" || !strings.Contains(recorded[1].What, "o's modules") { t.Errorf("a hand act taken: %v, recorded %+v", err, recorded) @@ -1105,6 +1105,16 @@ func (m *seatMsg) Subject() string { return m.subject } func (m *seatMsg) Data() []byte { return m.data } func (m *seatMsg) Ack() error { m.acked = true; return nil } +// refusingStatus is a state `first-views` whose write the runtime refuses at once (no runtime serves this test, and the +// real binding waits 30 s for one). +type refusingStatus struct{} + +func (refusingStatus) Keys() ([]string, error) { return nil, nil } +func (refusingStatus) Get(string) (*stdio.StateEntry, error) { return nil, nil } +func (refusingStatus) Put(string, any) (uint64, error) { + return 0, errors.New("no runtime serves this test") +} + // actsFunc records a hand act through a test's function. type actsFunc func(HandAct) error