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

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
This commit is contained in:
2026-11-11 20:25:31 +01:00
parent 7eb6f31c53
commit 3a5f6b33fb
2 changed files with 20 additions and 3 deletions
+8 -1
View File
@@ -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, "+
+12 -2
View File
@@ -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