Design 47 H2's corrections: the gate's ledger lifetimes and owed acts, the bus module's recreate, gitea runs-as part 2 (issue 1984) #758

Merged
mesh-tools merged 51 commits from feat/47-H2-corrections into main 2026-11-25 20:11:52 +00:00
4 changed files with 22 additions and 5 deletions
Showing only changes of commit b15c220822 - Show all commits
+3 -3
View File
@@ -189,8 +189,8 @@ func askFor(r keeper.Request, explained string) (oc.Ask, error) {
OnExpiry: "nothing is removed and the entry stays as it is",
About: keeper.ConditionKey(map[string]string{keeper.VerbDrop: "orphaned", keeper.VerbRecreate: "drifted"}[r.Verb], r.Module, r.Local),
Headline: fmt.Sprintf("%s's kept data %s: %s it?", r.Module, r.Local, what),
Explanation: fmt.Sprintf("%s asks to %s %s on the bus, %s. A snapshot of it is taken first; its data is lost from the bus.",
r.Caller, what, name, r.Why) + explained,
Explanation: fmt.Sprintf("%s asks to %s %s on the bus, %s. A snapshot of it is taken first.", r.Caller, what, name, r.Why) +
map[bool]string{true: " Its data is lost from the bus."}[r.Verb == keeper.VerbDrop] + explained,
Options: []oc.Option{
{ID: "go", Label: strings.ToUpper(what[:1]) + what[1:], Does: fmt.Sprintf("%s %s after a snapshot", what, name), Level: occ.Approve, Binds: binds},
{ID: "keep", Label: "Keep it", Does: "nothing is removed", Level: occ.Acknowledge},
@@ -349,7 +349,7 @@ func requestTools(rs requestStore) []stdio.Tool {
firstView,
tool(keeper.VerbCreate, "Create one entry of a module's kept data on the bus now, as its accepted manifest asks for it (design 25 § 12.3): handed to the bus module's keeper, which alone may create, and recorded as a hand act."),
tool(keeper.VerbApply, "Apply what a module's manifest asks of one entry where the bus holds less (a larger cap, a longer age): only a difference that grows; handed to the keeper and recorded as a hand act."),
tool(keeper.VerbRecreate, "Rebuild one entry whose settings drifted in a way that does not grow: the operator is asked first, and the keeper acts only on their warrant, after a snapshot of the entry. Its data is lost from the bus (the snapshot keeps it). Dangerous."),
tool(keeper.VerbRecreate, "Rebuild one entry whose settings drifted in a way that does not grow: the operator is asked first, and the keeper acts only on their warrant, after a snapshot of the entry. The ask names, per object, what is kept and what is made empty (the snapshot keeps the data). Dangerous."),
tool(keeper.VerbDrop, "Remove one orphan, an entry no accepted manifest asks for: the operator is asked first, and the keeper acts only on their warrant, after a snapshot of the entry. Dangerous."),
}
}
@@ -236,4 +236,11 @@ func TestTheAskOfARecreateNamesEachObjectAndWhatItRemoves(t *testing.T) {
if err != nil || !strings.Contains(ask.Explanation, "42 messages older than the age") {
t.Fatalf("the ask %+v %v", ask, err)
}
// The recreate's words come from the per-object lines, which keep the data: it never says the data is lost (H-A-686 (3)).
if strings.Contains(ask.Explanation, "lost from the bus") {
t.Errorf("the recreate's ask says its data is lost: %s", ask.Explanation)
}
if drop, _ := askFor(keeper.Request{Verb: keeper.VerbDrop, Module: "m", Local: "records", Why: "w", Caller: "c", AskExpires: now}, ""); !strings.Contains(drop.Explanation, "lost from the bus") {
t.Errorf("the drop's ask does not say its data is lost: %s", drop.Explanation)
}
}
@@ -1442,12 +1442,21 @@ func TestTheKeeperMakesWhatAVerdictAsksForAndSaysIt(t *testing.T) {
delete(bus.refuse, "update "+objects[1].Stream())
out.reset()
bus.updated = nil
// The bus holds the first object at a cap other than the one asked (a drift the first change left).
wasHeld := bus.held[objects[0].Stream()]
wasHeld.MaxBytes = objects[0].Settings.MaxBytes * 2
bus.held[objects[0].Stream()] = wasHeld
heldCap := wasHeld.MaxBytes
if got := recreate("r3"); got.Error != "" || len(bus.deleted) != 0 || len(bus.updated) != len(objects) ||
fmt.Sprint(out.events) != "[recreated m records]" || k.Held()["m"].Made["records"].Drift != "" ||
len(out.bodies) == 0 || len(out.bodies[len(out.bodies)-1].Before) != len(objects) || len(out.bodies[len(out.bodies)-1].After) != len(objects) ||
out.bodies[len(out.bodies)-1].Why != "" {
t.Fatalf("the change in place: %q, updated %v, deleted %v, said %v", got.Error, bus.updated, bus.deleted, out.events)
}
// The before names the cap the object held, never the cap asked (H-A-686 (3)).
if b, a := out.bodies[len(out.bodies)-1].Before[0], out.bodies[len(out.bodies)-1].After[0]; b.Cap != heldCap || heldCap == objects[0].Settings.MaxBytes || a.Cap != objects[0].Settings.MaxBytes {
t.Errorf("before names the cap %d, after %d: the held cap was %d, the asked %d", b.Cap, a.Cap, heldCap, objects[0].Settings.MaxBytes)
}
}},
// Review round 1 (security F2; design 25 § 12.3): a warrant acts once, spent by compare-and-set before anything is
// deleted; a second request naming the same ask is refused and deletes nothing.
+3 -2
View File
@@ -250,7 +250,7 @@ func (k *Keeper) act(r *Request) (string, error) {
if err != nil {
return "nothing done", fmt.Errorf("%s cannot be read, so nothing was changed: %w", o.Stream(), err)
}
steps = append(steps, rebuild{o: o, found: found, inPlace: found && st.WorkQueue == o.Settings.WorkQueue, before: fill})
steps = append(steps, rebuild{o: o, found: found, inPlace: found && st.WorkQueue == o.Settings.WorkQueue, before: fill, was: st})
}
// Short of room for the caps it asks, no object is changed and no snapshot taken; the warrant is spent (H-A-706, DQ-42).
if err := k.capRoom(ctx, &held, &m); err != nil {
@@ -321,7 +321,7 @@ func (k *Keeper) act(r *Request) (string, error) {
}
}
_, now, _, _ := k.Bus.Held(ctx, o)
before = append(before, EventFill{Object: o.Stream(), Part: m.Plan.PartOf(o), Count: st.before.Messages, Bytes: st.before.Bytes, Cap: o.Settings.MaxBytes})
before = append(before, EventFill{Object: o.Stream(), Part: m.Plan.PartOf(o), Count: st.before.Messages, Bytes: st.before.Bytes, Cap: st.was.MaxBytes})
after = append(after, EventFill{Object: o.Stream(), Part: m.Plan.PartOf(o), Count: now.Messages, Bytes: now.Bytes, Cap: o.Settings.MaxBytes})
how := "changed in place"
if !st.inPlace {
@@ -356,6 +356,7 @@ type rebuild struct {
o Object
found, inPlace bool
before Fill
was Settings // what the object held before: its cap is the before's, never the asked one
}
// warranted holds a recreate or a drop to the operator's warrant on the ask its tool raised: chosen by the operator,