The controller ended by its unassignment (issue 1126, ADR 0590), so no build is judged by the lease: the lease witness, its contract and the direct get the witness asked it with are removed, and its tests now prove each rollback path on the node tools' PING. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
55 lines
2.2 KiB
Go
55 lines
2.2 KiB
Go
// Package witness is the node-engine watching a core build it placed — the node tools on every machine — and
|
|
// restoring the build before it when the new one is not healthy in bound (novox/hq to-be 45 §8, ADR 0227 rule 8: the
|
|
// component being replaced is never the only witness of its successor).
|
|
//
|
|
// **The contract is this file.** What the engine reads to call a build healthy, from where, in what
|
|
// shape, within which bound — said once, here, and held by contract_test.go.
|
|
package witness
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/novox/mesh-host/internal/link"
|
|
)
|
|
|
|
// The witnesses, as a process declares which watches it (`witness`). A process that says none is placed as ever; one
|
|
// that says nothing is judged by its name's default (Default).
|
|
const (
|
|
// ByPing: healthy when this machine's runtime answers the services protocol's PING.
|
|
ByPing = "ping"
|
|
// ByNone: not judged.
|
|
ByNone = "none"
|
|
)
|
|
|
|
// Bounds (to-be 45 §8). A build is given Within of time the witness could ask in; asked every Every.
|
|
const (
|
|
// NodeToolsWithin: the runtime is announced and answering within sixty seconds of starting,
|
|
// each PING answered within PingWithin.
|
|
NodeToolsWithin = 60 * time.Second
|
|
PingWithin = 5 * time.Second
|
|
Every = 5 * time.Second
|
|
// GiveUp is how long a witness goes on when it cannot ask at all before it says the build is
|
|
// unwitnessed: the grant missing, the bus away the whole time.
|
|
GiveUp = 30 * time.Minute
|
|
)
|
|
|
|
// NodeToolsService is the runtime's name on the services protocol, and its instance is this
|
|
// machine's node name: what `$SRV.PING.<service>.<node>` asks, so only this machine's runtime can
|
|
// answer (mesh-tools node-tools internal/runtime, announce.Service{Name: module, ID: node}).
|
|
const NodeToolsService = "node-tools"
|
|
|
|
// Default is the witness a process is judged by when it names none: the core process the mesh composes on every
|
|
// machine, by the name it composes it under, and nothing else.
|
|
func Default(process string) string {
|
|
if process == NodeToolsService {
|
|
return ByPing
|
|
}
|
|
return ByNone
|
|
}
|
|
|
|
// Within is the bound for a witness.
|
|
func Within(string) time.Duration { return NodeToolsWithin }
|
|
|
|
// Component names what a witness judges, as a rollback says it.
|
|
func Component(string) string { return link.ComponentNodeTools }
|