diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/bus_test.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/bus_test.go index ec23fe56c..cacda2f09 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/bus_test.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/bus_test.go @@ -427,13 +427,31 @@ func (r *runtime) answer(m rpcMessage) { return nil, fmt.Errorf("the runtime answers no ask %s in this test", a.Key) } switch m.Method { - case buscalls.LedgerApply, buscalls.LedgerGet, buscalls.LedgerQuery, buscalls.LedgerRemove: + case buscalls.LedgerApply, buscalls.LedgerGet, buscalls.LedgerQuery, buscalls.LedgerRemove, buscalls.LedgerWatch: // The gate's ledger `records` (W11.1), as the tool runner keeps it: the record test's ledger in memory. r.b.mu.Lock() defer r.b.mu.Unlock() if r.b.ledger == nil { r.b.ledger = newLedgerFake(r.t) } + if m.Method == buscalls.LedgerWatch { + // The tool runner's ledger watch (design 47 H2 H-A-706): the current states first, each handed to the bundle as a + // `mesh/ledger` call named by the watch's id, then each change the ledger makes; answered once the current are sent. + var in buscalls.LedgerWatchRequest + if err := json.Unmarshal(m.Params, &in); err != nil { + return nil, err + } + err := r.b.ledger.Watch(in.Instances, func(instance string, state json.RawMessage) error { + r.mu.Lock() + n := r.next + r.next++ + r.mu.Unlock() + r.say(map[string]any{"id": fmt.Sprintf("ledger-%d", n), "method": buscalls.LedgerWatched, + "params": buscalls.InstanceChange{Watch: in.Watch, Instance: instance, State: state}}) + return nil + }) + return map[string]any{}, err + } if m.Method == buscalls.LedgerQuery { var in buscalls.QueryRequest if err := json.Unmarshal(m.Params, &in); err != nil { diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/record.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/record.go index d572411af..ffda8c243 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/record.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/record.go @@ -64,10 +64,6 @@ var RecordOperations = []string{OpOpen, OpGroup, OpTrace, OpMovers, OpPhases, Op // HeldOperations are the month's list's operations. var HeldOperations = []string{OpHold, OpDrop} -// DefaultRecordRetention is how long a record is kept when the setting record-retention gives none (design 47: 90 days -// covers every trace the operator has asked of a past delivery so far). -const DefaultRecordRetention = 90 * 24 * time.Hour - // Record is a delivery record's state, as apply derives it from its operations. type Record struct { // Instance is the record's path in the ledger; not in the state. @@ -228,16 +224,6 @@ type RecordEnded struct { Away []NodeAway `json:"away,omitempty"` } -// heldList is a month's list of records: each record opened that month, by instance. -type heldList struct { - Records map[string]heldEntry `json:"records,omitempty"` -} - -type heldEntry struct { - Instance string `json:"instance"` - Opened time.Time `json:"opened"` -} - // segmentRe is what one part of an instance's path may hold (the tool runner's rule). var segmentRe = regexp.MustCompile(`^[A-Za-z0-9_-]+$`) @@ -275,9 +261,6 @@ func RecordInstance(milestone string) (string, error) { return inst, nil } -// heldInstance is the list of the records opened in a month: `held/2026-11`. -func heldInstance(t time.Time) string { return TypeHeld + "/" + t.UTC().Format("2006-01") } - // RecordLedger is the gate's ledger: an operation applied to one instance, and one instance's state read. type RecordLedger interface { Apply(instance, operation string, body any) (uint64, error) @@ -287,6 +270,10 @@ type RecordLedger interface { Remove(instance string) error // Query is the instances a declared index names under key (`>` for the rest). Query(index, key string) ([]string, error) + // Watch hands handle the current state of each instance `instances` names (an instance, `*` for one name, `>` for the + // rest), then each change, in the order it came: the instance and its state, null once its key has gone (ADR 0597 §10, + // design 47 H2 H-A-634 (5)); it answers once the current states are handled. + Watch(instances string, handle func(instance string, state json.RawMessage) error) error } // sdkLedger is the gate's ledger through the runtime: the tool runner's ledger calls, on the gate's own ledger only @@ -352,6 +339,11 @@ func (sdkLedger) Query(index, key string) ([]string, error) { return insts, nil } +// Watch is the tool runner's watch of the gate's own ledger (mesh-sdk's stdio.WatchLedger), the current states first. +func (sdkLedger) Watch(instances string, handle func(string, json.RawMessage) error) error { + return stdio.WatchLedger(RecordsLedger, instances, func(c buscalls.InstanceChange) error { return handle(c.Instance, c.State) }) +} + func (sdkLedger) Get(instance string) (json.RawMessage, uint64, error) { out, err := ledgerCall(buscalls.LedgerGet, buscalls.InstanceRequest{Ledger: RecordsLedger, Instance: instance}) if err != nil { @@ -371,8 +363,6 @@ func (sdkLedger) Get(instance string) (json.RawMessage, uint64, error) { type Records struct { Ledger RecordLedger Now func() time.Time - // Retention is how long a record is kept; nil keeps DefaultRecordRetention. - Retention func() time.Duration // Say says the seat mesh-delivery's events of the records: pinned, freed, record-ended (recordevents.go), filling, // full and room (recordfill.go); nil says none. Say SeatSay @@ -388,11 +378,15 @@ type Records struct { // finding's subject (§809; H-A-460); an empty instance clears every one held of the record (its end). nil raises none. TooLarge func(record, instance string, bytes int, raised bool) - // held are the records kept, by instance, read once from the ledger (Current) and kept as the gate writes them: the - // gate is their one writer. - mu sync.Mutex - held map[string]*Record - loaded bool + // held are the records kept, by instance: the current states of a watch of the ledger's `record/>` at the first read, + // then as the gate writes them (the gate is their one writer); a key the watch hands gone is dropped, and remembered in + // gone so an event for it is said and changes nothing (design 47 H2 H-A-634 (2), (5)). + mu sync.Mutex + held map[string]*Record + gone map[string]bool + pending map[string]struct{} + watching bool + loaded bool } // Current is every record kept and not ended, oldest first: read from the ledger at the first call, then as the gate @@ -428,41 +422,134 @@ func (rs *Records) Kept() ([]*Record, error) { return out, nil } +// load starts the gate's watch of its ledger's `record/>` once, at the first read: the key and opening of every record the +// ledger holds come as current states, each read as today, then each change; and the month lists `held/` the +// earlier gate wrote, a watch of `held/>` hands with a state, are removed through the ledger's removal (H-A-721). A record +// that could not be read is read again at the next call. func (rs *Records) load() error { rs.mu.Lock() - loaded := rs.loaded - rs.mu.Unlock() - if loaded { + if rs.loaded { + rs.mu.Unlock() return nil } - list, err := rs.List() + started := rs.watching + rs.watching = true + rs.mu.Unlock() + if !started { + if err := rs.Ledger.Watch(TypeRecord+"/>", rs.heardRecord); err != nil { + rs.mu.Lock() + rs.watching = false + rs.mu.Unlock() + return fmt.Errorf("the delivery records cannot be watched: %w", err) + } + if err := rs.Ledger.Watch(TypeHeld+"/>", rs.removeMonthList); err != nil { + rs.log("the month lists of the records cannot be watched, so none is removed: %v", err) + } + } + rs.mu.Lock() + var pending []string + for inst := range rs.pending { + pending = append(pending, inst) + } + rs.mu.Unlock() + for _, inst := range pending { + if err := rs.heardRecord(inst, json.RawMessage("true")); err != nil { + return err + } + } + rs.mu.Lock() + defer rs.mu.Unlock() + if rs.held == nil { + rs.held = map[string]*Record{} + } + rs.loaded = true + return nil +} + +// heardRecord takes one record's state from the watch: null drops the record, as a key gone by its lifetime; a record the +// gate holds is current already, being the one writer; any other is read and kept. A record that cannot be read stays pending. +func (rs *Records) heardRecord(instance string, state json.RawMessage) error { + if string(state) == "null" || len(state) == 0 { + rs.mu.Lock() + delete(rs.held, instance) + delete(rs.pending, instance) + if rs.gone == nil { + rs.gone = map[string]bool{} + } + known := rs.gone[instance] + rs.gone[instance] = true + rs.mu.Unlock() + if !known { + rs.log("the record %s's key has gone: it is no longer read", instance) + } + return nil + } + rs.mu.Lock() + _, have := rs.held[instance] + rs.mu.Unlock() + if have { + return nil + } + r, err := rs.Read(instance) if err != nil { + rs.mu.Lock() + if rs.pending == nil { + rs.pending = map[string]struct{}{} + } + rs.pending[instance] = struct{}{} + rs.mu.Unlock() return err } rs.mu.Lock() defer rs.mu.Unlock() - if !rs.loaded { - rs.held = map[string]*Record{} - for _, r := range list { - rs.held[r.Instance] = r - } - rs.loaded = true + delete(rs.pending, instance) + if r == nil { + return nil } + if rs.held == nil { + rs.held = map[string]*Record{} + } + if _, have := rs.held[instance]; !have { + rs.held[instance] = r + } + delete(rs.gone, instance) return nil } -func (rs *Records) keep(r *Record) { - rs.mu.Lock() - defer rs.mu.Unlock() - if rs.loaded { - rs.held[r.Instance] = r +// removeMonthList removes a month list the earlier gate wrote, through the ledger's removal, which ends the instance whole +// (design 47 H2 H-A-721): its operations, its snapshot, its key and its index keys. +func (rs *Records) removeMonthList(instance string, state json.RawMessage) error { + if string(state) == "null" || len(state) == 0 { + return nil + } + if err := rs.Ledger.Remove(instance); err != nil { + rs.log("the month list %s is not removed: %v", instance, err) + return err + } + rs.log("the month list %s is removed: the gate lists its records from a watch of the ledger", instance) + return nil +} + +func (rs *Records) log(format string, a ...any) { + if rs.Logf != nil { + rs.Logf("[mesh-delivery] "+format, a...) } } -func (rs *Records) forget(instance string) { +// keep holds a record the gate writes once it keeps its records, and answers the one held under its instance: the record +// a watch handed first stays the one every reader writes through. +func (rs *Records) keep(r *Record) *Record { rs.mu.Lock() defer rs.mu.Unlock() - delete(rs.held, instance) + if !rs.loaded { + return r + } + if held, ok := rs.held[r.Instance]; ok && held != r { + return held + } + rs.held[r.Instance] = r + delete(rs.gone, r.Instance) + return r } func (rs *Records) now() time.Time { @@ -472,16 +559,6 @@ func (rs *Records) now() time.Time { return rs.Now().UTC() } -func (rs *Records) retention() time.Duration { - if rs.Retention == nil { - return DefaultRecordRetention - } - if d := rs.Retention(); d > 0 { - return d - } - return DefaultRecordRetention -} - // Read is one record, or nil when the ledger holds none at that instance (or one removed). func (rs *Records) Read(instance string) (*Record, error) { raw, seq, err := rs.Ledger.Get(instance) @@ -521,8 +598,8 @@ type RecordOpening struct { } // Open opens the record of a source revision, unless one is there already, which is left as it is (a merge call heard -// again opens no second record and says nothing new). Opened says it was opened now. Each open removes the records past -// their retention first (the retention needs no timer: records open as deliveries do). +// again opens no second record and says nothing new). Opened says it was opened now. An open writes no month list and +// removes nothing: the bus ends an ended record's keys by the ledger's ended-days (design 47 H2 H-A-634 (2), (5), (6)). func (rs *Records) Open(o RecordOpening) (r *Record, opened bool, err error) { if o.Branch == "" || o.Source < 1 || o.Call == "" { return nil, false, fmt.Errorf("a delivery record names its branch, its source revision and its merge call (%q, %d, %q)", o.Branch, o.Source, o.Call) @@ -548,9 +625,6 @@ func (rs *Records) Open(o RecordOpening) (r *Record, opened bool, err error) { return r, false, nil } now := rs.now() - if err := rs.Sweep(now); err != nil { - return nil, false, fmt.Errorf("the records past their retention cannot be removed, so no record is opened: %w", err) - } before, read, err := rs.refuseFull(milestone, inst) if err != nil { return nil, false, err @@ -564,9 +638,6 @@ func (rs *Records) Open(o RecordOpening) (r *Record, opened bool, err error) { if _, err := rs.write(&Record{Milestone: milestone}, inst, OpOpen, body, body); err != nil { return nil, false, err } - if _, err := rs.Ledger.Apply(heldInstance(now), OpHold, heldEntry{Instance: inst, Opened: now}); err != nil { - return nil, false, fmt.Errorf("the record %s is opened but not listed: %w", inst, err) - } if read { rs.sayFilling(inst, before) } @@ -576,7 +647,7 @@ func (rs *Records) Open(o RecordOpening) (r *Record, opened bool, err error) { if err := rs.SetTrace(r, o.Trace); err != nil { return r, true, fmt.Errorf("the record %s is opened and its trace is not written: %w", inst, err) } - rs.keep(r) + r = rs.keep(r) rs.sayOpened(r) return r, true, nil } @@ -602,7 +673,14 @@ func (rs *Records) ByMilestone(milestone string) (*Record, error) { } r, err := rs.Read(inst) if r != nil { - rs.keep(r) + r = rs.keep(r) + } else if err == nil { + rs.mu.Lock() + gone := rs.gone[inst] + rs.mu.Unlock() + if gone { + rs.log("the record %s's key has gone: an event for it changes nothing", inst) + } } return r, err } @@ -617,100 +695,6 @@ func (rs *Records) sayOpened(r *Record) { } } -// List is every record kept, opened within the retention and a month more, oldest first. -func (rs *Records) List() ([]*Record, error) { - now := rs.now() - var out []*Record - for _, m := range rs.months(now) { - list, err := rs.heldIn(m) - if err != nil { - return nil, err - } - for _, e := range list { - r, err := rs.Read(e.Instance) - if err != nil { - return nil, err - } - if r != nil { - out = append(out, r) - } - } - } - sort.SliceStable(out, func(i, j int) bool { return out[i].Opened.Before(out[j].Opened) }) - return out, nil -} - -// months are the months' lists a record within the retention can be in, oldest first, one more at each end. -func (rs *Records) months(now time.Time) []string { - from := now.Add(-rs.retention()).AddDate(0, -1, 0) - var out []string - for m := time.Date(from.Year(), from.Month(), 1, 0, 0, 0, 0, time.UTC); !m.After(now); m = m.AddDate(0, 1, 0) { - out = append(out, heldInstance(m)) - } - return out -} - -func (rs *Records) heldIn(month string) ([]heldEntry, error) { - raw, _, err := rs.Ledger.Get(month) - if err != nil || raw == nil { - return nil, err - } - var l heldList - if err := json.Unmarshal(raw, &l); err != nil { - return nil, fmt.Errorf("the list of records %s is not readable: %w", month, err) - } - out := make([]heldEntry, 0, len(l.Records)) - for _, e := range l.Records { - out = append(out, e) - } - sort.Slice(out, func(i, j int) bool { return out[i].Opened.Before(out[j].Opened) }) - return out, nil -} - -// Sweep removes every record opened longer ago than the retention. Nothing else is removed to make room. -func (rs *Records) Sweep(now time.Time) error { - cut := now.Add(-rs.retention()) - for _, m := range rs.months(now) { - list, err := rs.heldIn(m) - if err != nil { - return err - } - for _, e := range list { - if !e.Opened.Before(cut) { - continue - } - r, err := rs.Read(e.Instance) - if err != nil { - return err - } - if r != nil { - for _, m := range r.movers { - if err := rs.Ledger.Remove(m.Instance); err != nil { - return err - } - } - for id := range r.Acts { - inst, err := ActInstance(r.Milestone, id) - if err != nil { - return err - } - if err := rs.Ledger.Remove(inst); err != nil { - return err - } - } - if err := rs.Ledger.Remove(e.Instance); err != nil { - return err - } - rs.forget(e.Instance) - } - if _, err := rs.Ledger.Apply(m, OpDrop, map[string]any{"instance": e.Instance}); err != nil { - return err - } - } - } - return nil -} - // SetGroup writes the record's group state, unless it holds that state already. func (rs *Records) SetGroup(r *Record, g RecordGroup) error { if r.Group != nil && reflect.DeepEqual(*r.Group, g) { diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/record_test.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/record_test.go index c82e6b350..969f71897 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/record_test.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/record_test.go @@ -34,6 +34,46 @@ type ledgerFake struct { failOn string // fill is what Fill answers; nil, the ledger says no fill. fill *buscalls.Fill + // watchers are the watches the gate started, each told of every change to an instance its pattern names. + watchers []ledgerWatch +} + +// ledgerWatch is one watch of the fake ledger: the instances it names (an instance path, or a type's `/>`) and its handler. +type ledgerWatch struct { + instances string + handle func(instance string, state json.RawMessage) error +} + +func (w ledgerWatch) names(instance string) bool { + return w.instances == instance || strings.HasSuffix(w.instances, ">") && strings.HasPrefix(instance, strings.TrimSuffix(w.instances, ">")) +} + +// Watch hands the current state of each instance the pattern names, in order, and keeps the handler for change. +func (f *ledgerFake) Watch(instances string, handle func(string, json.RawMessage) error) error { + w := ledgerWatch{instances: instances, handle: handle} + f.watchers = append(f.watchers, w) + var names []string + for inst, raw := range f.states { + if w.names(inst) && string(raw) != "null" { + names = append(names, inst) + } + } + sort.Strings(names) + for _, inst := range names { + if err := handle(inst, f.states[inst]); err != nil { + return err + } + } + return nil +} + +// change hands an instance's state, null once its key has gone, to every watch that names it. +func (f *ledgerFake) change(instance string) { + for _, w := range f.watchers { + if w.names(instance) { + _ = w.handle(instance, f.states[instance]) + } + } } func (f *ledgerFake) Fill() (buscalls.Fill, error) { @@ -151,6 +191,7 @@ func (f *ledgerFake) Remove(instance string) error { f.seq[instance]++ f.states[instance] = json.RawMessage("null") f.history = append(f.history, instance+" remove") + f.change(instance) return nil } @@ -423,7 +464,7 @@ func TestTheDeliveryRecordIsALedgerInstanceKeyedByItsSourceRevision(t *testing.T if byKey, err := rs.ByKey("main", 47); err != nil || byKey == nil || byKey.Instance != r.Instance { t.Fatalf("read by its key: %+v %v", byKey, err) } - list, err := rs.List() + list, err := rs.Kept() if err != nil || len(list) != 1 || list[0].Instance != r.Instance { t.Fatalf("list %+v %v", list, err) } @@ -464,26 +505,57 @@ func TestTheDeliveryRecordIsALedgerInstanceKeyedByItsSourceRevision(t *testing.T } }) - t.Run("a record past its retention is removed at the next open", func(t *testing.T) { + // Design 47 H2 H-A-634 (2), (5), H-A-721: the gate lists its records from a watch of its ledger's `record/>`; an open + // writes no month list and removes nothing; a month list standing at the start is removed through the ledger's removal and no + // forget is applied; a key gone drops the record from every list, and an event for it changes nothing and is said. + t.Run("the records are listed from a watch: a month list standing is removed at the start, a gone key drops its record and an event for it changes nothing", func(t *testing.T) { l := newLedgerFake(t) now := at - rs := &Records{Ledger: l, Now: func() time.Time { return now }, Retention: func() time.Duration { return 90 * 24 * time.Hour }} - old, _, _ := rs.Open(opening("main", 46, heads)) + var journal []string + logf := func(format string, a ...any) { journal = append(journal, fmt.Sprintf(format, a...)) } + before := &Records{Ledger: l, Now: func() time.Time { return now }, Logf: logf} + old, _, _ := before.Open(opening("main", 46, heads)) now = at.Add(89 * 24 * time.Hour) - kept, _, _ := rs.Open(opening("main", 47, heads)) - if r, _ := rs.Read(old.Instance); r == nil { - t.Fatal("a record within its retention is removed") + kept, _, _ := before.Open(opening("main", 47, heads)) + for _, op := range l.history { + if strings.HasPrefix(op, TypeHeld+"/") { + t.Fatalf("an open wrote %s: no month list is written", op) + } } - now = at.Add(91 * 24 * time.Hour) - if _, _, err := rs.Open(opening("main", 48, heads)); err != nil { + // A month list the gate before H2 wrote, standing at the start. + if _, err := l.Apply("held/2026-11", OpHold, map[string]any{"instance": old.Instance, "opened": at}); err != nil { t.Fatal(err) } - if r, _ := rs.Read(old.Instance); r != nil { - t.Fatal("a record past its retention is kept") + l.history = nil + rs := &Records{Ledger: l, Now: func() time.Time { return now }, Logf: logf} + list, err := rs.Kept() + if err != nil || len(list) != 2 || list[0].Instance != old.Instance || list[1].Instance != kept.Instance { + t.Fatalf("the records listed from the watch are %+v (%v): the two, oldest first", list, err) } - list, _ := rs.List() - if len(list) != 2 || list[0].Instance != kept.Instance { - t.Fatalf("list %+v", list) + if string(l.states["held/2026-11"]) != "null" || !slices.Contains(l.history, "held/2026-11 remove") { + t.Fatalf("the month list holds %s after %v: removed through the ledger's removal", l.states["held/2026-11"], l.history) + } + for _, op := range l.history { + if strings.HasSuffix(op, " forget") || strings.HasSuffix(op, " "+OpDrop) || strings.HasSuffix(op, " "+OpHold) { + t.Errorf("the gate applied %s: no month list is applied", op) + } + } + // The key of the older record goes by its lifetime: the bus hands it removed. + l.states[old.Instance] = json.RawMessage("null") + l.change(old.Instance) + if list, _ := rs.Kept(); len(list) != 1 || list[0].Instance != kept.Instance { + t.Fatalf("after its key went the records are %+v: one", list) + } + if cur, _ := rs.Current(); len(cur) != 1 { + t.Fatalf("after its key went the open records are %+v: one", cur) + } + n := len(l.history) + journal = nil + if r, err := rs.ByKey("main", 46); err != nil || r != nil { + t.Fatalf("an event's record is %+v (%v): none, its key has gone", r, err) + } + if len(l.history) != n || !strings.Contains(strings.Join(journal, "\n"), "key has gone: an event for it changes nothing") { + t.Fatalf("the ledger took %v and the journal says %q: nothing written, said once", l.history[n:], journal) } }) } diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordfill.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordfill.go index 0fa96d4c8..e8bec47ed 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordfill.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordfill.go @@ -4,7 +4,7 @@ package main // full"): the gate reads its ledger's fill through the tool runner (mesh-sdk buscalls.LedgerFill), says `filling` of the // seat mesh-delivery when a record it opens takes the ledger past 80 % of its cap, refuses the next record when the // ledger has no room for one and says `full`, and holds that record's merge until the ledger is below 80 % again, when -// it says `room` and hands the merge. Nothing is dropped to make room: only the retention removes a record. The fill +// it says `room` and hands the merge. Nothing is dropped to make room: the bus ends an ended record's keys by the ledger's ended-days. The fill // is read from the bus at each judgement, and which merges wait for room is kept on their deliveries (Ready.HeldFull), // so a restarted gate judges as the one before it. @@ -109,12 +109,9 @@ func (rs *Records) sayFilling(inst string, before buscalls.Fill) { } } -// RoomAgain is whether a merge held for a full ledger since then may be handed now: the records past their retention -// removed first, the ledger below FillingPercent of its cap, said once as room. A fill it cannot read gives no room. +// RoomAgain is whether a merge held for a full ledger since then may be handed now: the ledger below FillingPercent of its +// cap, said once as room. A fill it cannot read gives no room. func (rs *Records) RoomAgain(since time.Time) (bool, error) { - if err := rs.Sweep(rs.now()); err != nil { - return false, err - } f, err := rs.Fill() if err != nil { return false, err diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordtools.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordtools.go index c8ab68e22..31f294c02 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordtools.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordtools.go @@ -51,7 +51,7 @@ func (rs *Records) RecordOf(instance, milestone string) ([]recordView, error) { if milestone == "" { return nil, errors.New("name a record's instance or a milestone") } - list, err := rs.List() + list, err := rs.Kept() if err != nil { return nil, err } @@ -84,7 +84,7 @@ type recordLine struct { // Lines are every record kept, oldest first, each with its fill against the value limit. func (rs *Records) Lines() (map[string]any, error) { - list, err := rs.List() + list, err := rs.Kept() if err != nil { return nil, err } @@ -102,7 +102,7 @@ func (rs *Records) Lines() (map[string]any, error) { } lines = append(lines, l) } - return map[string]any{"records": lines, "open": open, "kept": len(lines), "retention-days": int(rs.retention().Hours() / 24), + return map[string]any{"records": lines, "open": open, "kept": len(lines), "fill": rs.fillLine()}, nil } @@ -143,7 +143,7 @@ func (rs *Records) EndAllByHand(why, by string, acts handActs) (map[string]any, if strings.TrimSpace(why) == "" { return nil, errors.New("say why every open record is ended by hand, such as the clean state") } - list, err := rs.List() + list, err := rs.Kept() if err != nil { return nil, err }