The runtime answers a bulk read of kept state: the values after a key in one request (issue 1966)

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
2026-11-09 08:51:19 +01:00
parent 27710ccabd
commit 1a9190774d
4 changed files with 86 additions and 3 deletions
+14 -1
View File
@@ -1021,9 +1021,12 @@ type stateAsked struct {
// TTLSeconds gives a created or put key its own time to live (issue 1952): create makes it only when it has no
// value, put renews it whole. Zero is none.
TTLSeconds int `json:"ttl_seconds"`
// After and MaxBytes are a `page`'s start key and its size in keys and values (zero is a megabyte).
After string `json:"after"`
MaxBytes int `json:"max_bytes"`
}
// State answers a bundle's `get`, `put`, `delete`, `keys`, `create`, `update`, `history` and `info` on its
// State answers a bundle's `get`, `put`, `delete`, `keys`, `page`, `create`, `update`, `history` and `info` on its
// module's state (ADR 0201, ADR 0259, ADR 0307); `create` and `put` take `ttl_seconds`, a key's own time to live,
// whose end every watch hears as an `expire` (issue 1952). The runtime refuses, with the reason, a state the module was not issued and a write to one it only reads.
func (b *moduleBus) State(verb string, params json.RawMessage) (json.RawMessage, error) {
@@ -1043,6 +1046,16 @@ func (b *moduleBus) State(verb string, params json.RawMessage) (json.RawMessage,
return json.RawMessage("null"), nil
}
answer = entry
case "page":
// The values after a key in key order, one request for many (a first view's page of a slow state).
if asked.MaxBytes <= 0 {
asked.MaxBytes = 1 << 20
}
page, err := conn.StatePage(b.module, asked.State, asked.After, asked.MaxBytes)
if err != nil {
return nil, err
}
answer = page
case "history":
// Every value the bucket still keeps for the key, oldest first (novox/hq ADR 0307).
kept, err := conn.StateHistory(b.module, asked.State, asked.Key)