mesh-issues: carry each value the issues bucket kept, read through the runtime's history, so the log begins with all the bucket still knew (hq ADR 0300 §6, ADR 0307)
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate pass: builds mesh-issues → novox; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)

This commit is contained in:
jochen
2026-10-12 10:20:51 +02:00
parent 39da2cd793
commit dcc7510cd8
9 changed files with 138 additions and 17 deletions
+21 -7
View File
@@ -464,11 +464,11 @@ func clone(is *Issue) (*Issue, error) {
return &c, json.Unmarshal(raw, &c)
}
// History is a Store that reads every value a key still keeps, oldest first. The carry reads it where the
// store offers it; the runtime offers no such read today (novox/hq ADR 0300 §6), and then the carry takes
// each issue's current value, and says so.
// History is a Store that reads every value a key still keeps, oldest first, as the runtime serves it
// (novox/hq ADR 0307, mesh-sdk State(...).History): each a put or a delete. The carry reads it where the store
// offers it, and takes each issue's current value alone where it does not, and says so.
type History interface {
History(state, key string) ([]Entry, error)
History(state, key string) ([]stdio.StateRevision, error)
}
// Carried is what the carry did (ADR 0300 §6).
@@ -479,7 +479,10 @@ type Carried struct {
Values int `json:"values"`
Already int `json:"already"`
// History says whether each value the bucket kept was carried, or the current value alone.
History bool `json:"history"`
History bool `json:"history"`
// Deletes is how many deletions among the kept values were passed over: an issue is never deleted by the
// tracker, and each value after one holds the issue whole, so the fold needs none.
Deletes int `json:"deletes,omitempty"`
Said string `json:"said"`
}
@@ -560,7 +563,8 @@ func (t *Tracker) carryOne(n uint64) (int, error) {
}
// kept is every value the bucket keeps of an issue, oldest first, ending with the one read; the current one
// alone where the store reads no history.
// alone where the store reads no history. A deletion among them is passed over and counted: the tracker never
// deletes an issue, the fold has no deletion, and the next value holds the issue whole again.
func (t *Tracker) kept(n uint64, current *Issue) ([]*Issue, error) {
h, ok := t.Store.(History)
if !ok {
@@ -572,9 +576,13 @@ func (t *Tracker) kept(n uint64, current *Issue) ([]*Issue, error) {
}
var out []*Issue
for _, e := range old {
if e.Op == "delete" {
t.carryDeletes.Add(1)
continue
}
var v Issue
if json.Unmarshal(e.Value, &v) != nil {
t.Logf("[mesh-issues] an older value of issue %d is in a form this module cannot read: not carried", n)
t.Logf("[mesh-issues] the value of issue %d at revision %d is in a form this module cannot read: not carried", n, e.Revision)
continue
}
out = append(out, &v)
@@ -609,6 +617,7 @@ func (t *Tracker) Carry() (*Carried, error) {
}
_, history := t.Store.(History)
out := &Carried{History: history}
deletes := t.carryDeletes.Load()
for _, k := range keys {
n, ok := numberOfKey(k)
if !ok {
@@ -636,12 +645,17 @@ func (t *Tracker) Carry() (*Carried, error) {
out.Already++
}
}
out.Deletes = int(t.carryDeletes.Load() - deletes)
switch {
case out.Issues == 0:
out.Said = fmt.Sprintf("Nothing to carry: the log begins every issue of the bucket (%d).", out.Already)
case history:
out.Said = fmt.Sprintf("Carried %d values of %d issues into the log, each value the bucket kept, oldest first; "+
"%d issues were there already.", out.Values, out.Issues, out.Already)
if out.Deletes > 0 {
out.Said += fmt.Sprintf(" %d deletions among the kept values were passed over: each value after one holds "+
"the issue whole.", out.Deletes)
}
default:
out.Said = fmt.Sprintf("Carried %d issues into the log, %d values: the current value of each, as the runtime "+
"reads no older value of a key; %d issues were there already.", out.Issues, out.Values, out.Already)