An index's key and entry are one contract of the calls package (issue 1966 S4)

IndexKey and IndexEntry {instance, sequence}: the owner's watcher and the
tool runner's reindex write the same, so a reindex leaves the index as the
watcher keeps it (the lead's ruling on issue 1966 B1; ADR 0597 §4).
This commit is contained in:
2026-11-03 15:12:38 +01:00
parent 092260870b
commit 15fc2c4ce4
2 changed files with 21 additions and 3 deletions
+12 -3
View File
@@ -10,6 +10,7 @@ package buscalls
import (
"encoding/json"
"strings"
"time"
)
@@ -286,10 +287,18 @@ type QueryRequest struct {
Limit int `json:"limit,omitempty"`
}
// IndexEntry is one entry of an index.
// IndexEntry is the value of one key of a declared index (IndexKey): the instance it points at, and the sequence of
// the operation it was written from. The owner's watcher and the tool runner's reindex both write it so.
type IndexEntry struct {
Key string `json:"key"`
Value json.RawMessage `json:"value"`
Instance string `json:"instance"`
Sequence uint64 `json:"sequence"`
}
// IndexKey is the key of an instance in a declared index: the values of the index's fields, in its order, joined by
// ".", then the instance's path with each "/" written "." (`17950.listing.a17`). The owner's watcher and the tool
// runner's reindex both write it, so a reindex leaves the index as the watcher keeps it.
func IndexKey(fields []string, instance string) string {
return strings.Join(append(append([]string{}, fields...), strings.ReplaceAll(instance, "/", ".")), ".")
}
// QueryAnswer is query's answer.
+9
View File
@@ -110,6 +110,15 @@ func TestMeshSDKHoldsOnlyWhatEveryModuleShares(t *testing.T) {
if buscalls.MetaCall != "mesh/call" {
t.Errorf("the tool call's id is handed under %q, not mesh/call", buscalls.MetaCall)
}
// 1966/AC5: an index's key is its fields' values, then the instance's path, joined by "."; its entry names the
// instance and the sequence.
if k := buscalls.IndexKey([]string{"17950", "volvo"}, "listing/a17"); k != "17950.volvo.listing.a17" {
t.Errorf("an index key is %q", k)
}
entry, _ := json.Marshal(buscalls.IndexEntry{Instance: "listing/a17", Sequence: 3})
if string(entry) != `{"instance":"listing/a17","sequence":3}` {
t.Errorf("an index entry is %s", entry)
}
// 1966/AC5: an apply naming the tool call it serves, and its answer with the state behind, round-trip.
for _, c := range []struct {
name string