M1: the gate prunes its state heads toward its cap at its own writes
heads is written through the SDK's pruned state, which judges the fill each put answers and past prune-mark (70 %) prunes the oldest keys to prune-target (50 %); the gate serves mesh-delivery-gate_state_prune_now and mesh-delivery-gate_state_keep, each written in the hand-act log. Builds: design 47 H2 §812; H-A-380, H-A-386, H-A-411 (3)
This commit is contained in:
@@ -12,7 +12,9 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||||
@@ -20,6 +22,8 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/stateobjects"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// HeadUntaken is the finding of a head no merge call delivered; warning, the operator its resolver (H-A-81).
|
||||
@@ -61,10 +65,27 @@ func (kvHeads) Get(key string) (*HeldHead, error) {
|
||||
}
|
||||
|
||||
func (kvHeads) Put(key string, v HeldHead) error {
|
||||
_, err := stdio.State(seat.StateHeads).Put(key, v)
|
||||
_, err := prunedHeads().Put(key, v)
|
||||
return err
|
||||
}
|
||||
|
||||
// prunedHeads is the state heads, pruned toward its cap at the gate's own writes (design 47 H2 §812; H-A-411 (3)): past
|
||||
// prune-mark of its 8 MiB the oldest keys go down to prune-target, in one journal line. A setting that is no percentage
|
||||
// is said, and the defaults hold.
|
||||
var prunedHeads = sync.OnceValue(func() *stdio.PrunedState {
|
||||
p, err := stdio.PruneSettings()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "the prune of heads keeps its defaults (%d %% to %d %%): %v\n", stdio.PruneMarkDefault, stdio.PruneTargetDefault, err)
|
||||
p = stdio.Prune{Mark: stdio.PruneMarkDefault, Target: stdio.PruneTargetDefault}
|
||||
}
|
||||
return stdio.State(seat.StateHeads).Pruned(p)
|
||||
})
|
||||
|
||||
// headsPruneTools are the gate's two prune tools over heads, each written in the hand-act log (H-A-380 (3)).
|
||||
func headsPruneTools(acts views.HandActs) []stdio.Tool {
|
||||
return stateobjects.PruneTools(Module, []stateobjects.Pruning{{Name: seat.StateHeads, State: prunedHeads()}}, acts)
|
||||
}
|
||||
|
||||
func (kvHeads) Delete(key string) error { return stdio.State(seat.StateHeads).Delete(key) }
|
||||
|
||||
func (s kvHeads) All() (map[string]HeldHead, error) {
|
||||
|
||||
@@ -263,6 +263,8 @@ func tools(h *Holder, l *listening) []stdio.Tool {
|
||||
list = append(list, recordTools(h, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
list = append(list, sourceTools(h, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
list = append(list, headTools(h, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
// The prune of heads by hand, now or kept from it (design 47 H2 §812, H-A-380 (3)).
|
||||
list = append(list, headsPruneTools(meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
// A verb that changes a delivery asks for a look at what it makes possible (react.go).
|
||||
for i := range list {
|
||||
run := list[i].Run
|
||||
|
||||
@@ -433,7 +433,9 @@
|
||||
"gate_source_again",
|
||||
"gate_source_seed",
|
||||
"gate_source_start",
|
||||
"gate_times"
|
||||
"gate_times",
|
||||
"mesh-delivery-gate_state_keep",
|
||||
"mesh-delivery-gate_state_prune_now"
|
||||
],
|
||||
"config": {
|
||||
"record-retention": {
|
||||
@@ -464,6 +466,24 @@
|
||||
"trusted": false,
|
||||
"runtime": true,
|
||||
"default": "3m"
|
||||
},
|
||||
"prune-mark": {
|
||||
"type": "number",
|
||||
"description": "The fill of the gate's state heads, in percent of its cap, past which the gate prunes it at its own write, oldest first (design 47 H2 §812): below the bus module's raise mark of 75 %.",
|
||||
"trusted": false,
|
||||
"runtime": true,
|
||||
"minimum": 1,
|
||||
"maximum": 100,
|
||||
"default": 70
|
||||
},
|
||||
"prune-target": {
|
||||
"type": "number",
|
||||
"description": "The fill, in percent of the cap, a prune of the gate's state heads takes it down to (design 47 H2 §812); below prune-mark.",
|
||||
"trusted": false,
|
||||
"runtime": true,
|
||||
"minimum": 1,
|
||||
"maximum": 100,
|
||||
"default": 50
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
|
||||
Reference in New Issue
Block a user