T1 page by cursor: a state page continues from an opaque cursor in sequence order

mesh/state.page reads a state from an ordered watch starting after the cursor's sequence, never a
replay of the bucket per page: each kept message once across the pages of a read, a key's older
kept revisions included, at most 768 KB a page, next the opaque cursor, empty at the end. A value
written after the read reached its bucket comes marked seen-again (the cursor carries that mark;
the runner keeps nothing per read); a deleted key gets no entry. A state kept one bucket per node is
read one node's bucket after another.

Builds: design 47 H2 §779, H-A-254, H-A-382
This commit is contained in:
2026-11-22 00:10:01 +01:00
parent 0c7000fa93
commit a1c12af8b2
5 changed files with 284 additions and 132 deletions
+5 -7
View File
@@ -1206,8 +1206,9 @@ 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"`
// Cursor and MaxBytes are a `page`'s opaque cursor, the next of the page before (empty: from the start), and its size in
// keys and values (zero, or above 768 KB, is 768 KB; design 47 H2 §779).
Cursor string `json:"cursor"`
MaxBytes int `json:"max_bytes"`
// BudgetMS is the time a `page` may spend reading, in milliseconds (zero is the runtime's own, well under 30 s).
BudgetMS int `json:"budget_ms"`
@@ -1239,11 +1240,8 @@ func (b *moduleBus) State(verb string, params json.RawMessage) (json.RawMessage,
}
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, time.Duration(asked.BudgetMS)*time.Millisecond)
// One page of the state in the order the bus wrote it, after the cursor, one request for many (design 47 H2 §779).
page, err := conn.StatePage(b.module, asked.State, asked.Cursor, asked.MaxBytes, time.Duration(asked.BudgetMS)*time.Millisecond)
if err != nil {
return nil, err
}