Names N3 (indexer): the indexer names its own buckets from its credential's module

Its 26 `<Module>_<state>` bucket constants (candidates, manifests, verdicts, packages, taken, the
control records, pins, pending and the rest), its consumers, findings and first views were named
from the constant Module; they are now index.Bucket(cred.Module, <state>), and its words name
the state where they named the bucket.

Builds: design 47 G A-296

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 19:18:56 +01:00
parent 0de534c692
commit cf93d30150
30 changed files with 125 additions and 167 deletions
@@ -19,8 +19,7 @@ import (
// edge entries in the state build-edges, under <module>.<branch>, and what the branch's newest build of the module
// published as heard, branch-build.<module>.<branch> in the state heard (§374, A-83).
const (
BuildEdgesState = "build-edges"
BuildEdgesBucket = Module + "_" + BuildEdgesState
BuildEdgesState = "build-edges"
// BranchBuildPrefix opens branch-build.<module>.<branch>, each part escaped as a name (A-80).
BranchBuildPrefix = "branch-build."
)
@@ -88,7 +88,7 @@ type Indexer struct {
// Findings is the indexer's finding writer (design 47 G A-29), where a manifest-accepted whose publish failed twice is kept
// until said (accepted.go, DLV-I9b); nil writes none.
Findings FindingWriter
// Packages is the packages state (PackagesBucket, packages.go; novox/hq ADR 0593 §2); nil publishes none,
// Packages is the packages state (PackagesState, packages.go; novox/hq ADR 0593 §2); nil publishes none,
// and every fingerprint takes the version line.
Packages Store
// SeatDefinitions is the state seat-definitions (seatdefs.go; design 26, DLV-I17); nil keeps none.
@@ -22,19 +22,13 @@ import (
// against the trunk's manifests the indexer holds. mesh-config reads both in place of the controller's mirror and its
// `pull-declares`; a key's write is its event, nothing polls.
// The two states' buckets.
var (
PredefinedBucket = Module + "_" + PredefinedState
ConfigCandidatesBucket = Module + "_" + ConfigCandidatesState
)
// writePredefined keeps the predefined list a merged message carries, unless the key names a later merge: a merge older
// than the one it names never replaces it (ADR 0348 §7). The same list at the same merge writes nothing (ADR 0289 §1).
func (ix *Indexer) writePredefined(ctx context.Context, f forgemsg.Forge) error {
if ix.Predefined == nil || len(f.Predefined) == 0 {
return nil
}
return ix.notYet(PredefinedBucket, write(ctx, ix.Predefined, PredefinedListKey, func(value []byte, found bool) ([]byte, bool, error) {
return ix.notYet(PredefinedState, write(ctx, ix.Predefined, PredefinedListKey, func(value []byte, found bool) ([]byte, bool, error) {
if found {
var cur struct { // the list is compared as it was kept, byte for byte
Commit string `json:"commit"`
@@ -61,9 +55,9 @@ func (ix *Indexer) writePredefined(ctx context.Context, f forgemsg.Forge) error
// notYet says a state not on the bus yet (it comes with this delivery, bound when it appears) and lets the message go:
// what it would have written is written at the next message that carries it.
func (ix *Indexer) notYet(bucket string, err error) error {
func (ix *Indexer) notYet(state string, err error) error {
if errors.Is(err, process.ErrNotYet) {
ix.logf("the state %s is not on the bus yet: nothing is written to it for this message", bucket)
ix.logf("the state %s is not on the bus yet: nothing is written to it for this message", state)
return nil
}
return err
@@ -170,7 +164,7 @@ func (ix *Indexer) writeConfigCandidate(ctx context.Context, repository string,
if err != nil {
return err
}
return ix.notYet(ConfigCandidatesBucket, write(ctx, ix.ConfigCandidates, key, func(value []byte, found bool) ([]byte, bool, error) {
return ix.notYet(ConfigCandidatesState, write(ctx, ix.ConfigCandidates, key, func(value []byte, found bool) ([]byte, bool, error) {
if found {
var cur meshcatalog.ConfigCandidatesByPullValue
if json.Unmarshal(value, &cur) == nil && cur.Head == head && reflect.DeepEqual(cur.Declares, declares) {
@@ -191,7 +185,7 @@ func (ix *Indexer) dropConfigCandidate(ctx context.Context, repository string, n
if err != nil {
return nil
}
return ix.notYet(ConfigCandidatesBucket, write(ctx, ix.ConfigCandidates, key, func(_ []byte, found bool) ([]byte, bool, error) { return nil, found, nil }))
return ix.notYet(ConfigCandidatesState, write(ctx, ix.ConfigCandidates, key, func(_ []byte, found bool) ([]byte, bool, error) { return nil, found, nil }))
}
// configCandidateOfPull is a pull message's part in config-candidates: a head whose manifests the message carries is written,
@@ -19,8 +19,6 @@ import (
const (
// EntryIndexState is the old state section of the entries' digests by fingerprint.
EntryIndexState = "entry-index"
// EntryIndexBucket is the bucket of the state.
EntryIndexBucket = Module + "_" + EntryIndexState
// EntryIndexTool is the tool that reads a fingerprint's key and its object's digest (class read).
EntryIndexTool = "indexer_entries"
)
@@ -7,10 +7,9 @@ import (
mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
)
// FindingsState is the indexer's state of its findings, and FindingsBucket its bucket (design 47 G §383, §687).
// FindingsState is the indexer's state of its findings (design 47 G §383, §687).
const (
FindingsState = "findings"
FindingsBucket = Module + "_" + FindingsState
FindingsState = "findings"
)
// FindingWriter is the indexer's finding writer, mesh-sdk's held writer of the seat mesh-conditions' generated finding (design
@@ -12,9 +12,8 @@ import (
// server delivered it, when it was published and handled, what it names and what the indexer did with it. The state keeps
// the last 64 values (its history); mesh-delivery-view's indexer_heard reads them, newest first, with their times.
const (
HeardState = "heard"
HeardBucket = Module + "_" + HeardState
HeardKey = "forge"
HeardState = "heard"
HeardKey = "forge"
// What the indexer did with a message.
HeardApplied = "applied"
HeardLeft = "left for redelivery"
@@ -24,8 +24,6 @@ import (
const (
// NamedState is the old state section of the sets of members by fingerprint.
NamedState = "named"
// NamedBucket is the bucket of the state.
NamedBucket = Module + "_" + NamedState
// NamedDropTool is the tool that removes one member from one fingerprint's set by hand (class act).
NamedDropTool = "indexer_named_drop"
// NamedWanted and NamedRunning name the two streams the sets are read from, for Named.ReadDone.
@@ -9,21 +9,17 @@ const (
// The indexer's own states, with the revisions each keeps per key (module.json `state`).
CandidatesState = "candidates"
CandidatesBucket = Module + "_" + CandidatesState
CandidatesHistory = 10
ModulesState = "modules"
ManifestsState = "manifests"
ManifestsBucket = Module + "_" + ManifestsState
ManifestsHistory = 1
// VerdictsState and VerdictsBucket are in verdicts.go.
// VerdictsState is in verdicts.go.
VerdictsHistory = 5
PredefinedState = "predefined"
ConfigCandidatesState = "config-candidates"
PackagesState = "packages"
PackagesBucket = Module + "_" + PackagesState
PackagesHistory = 5
TakenState = "taken"
TakenBucket = Module + "_" + TakenState
PredefinedListKey = "list"
ForgeBridgeModule = "mesh-delivery-forge-bridge"
GateModule = "mesh-delivery-gate"
@@ -35,3 +31,7 @@ const (
// ToolchainsBucket is the toolchains state of a build module (reads: mesh-build-go.toolchains, mesh-build-node.toolchains).
func ToolchainsBucket(module string) string { return module + "_" + toolchainsState }
// Bucket is the bus's bucket of the indexer's own state, `<module>_<state>`, module its credential's, never a constant
// (design 47 G A-296).
func Bucket(module, state string) string { return module + "_" + state }
@@ -16,8 +16,7 @@ const (
// OldSectionsTool is the tool that reads the count.
OldSectionsTool = "indexer_old_sections"
// OldSectionsState is the indexer's state of the count: the bucket mesh-delivery-indexer_oldsections.
OldSectionsState = "oldsections"
OldSectionsBucket = Module + "_" + OldSectionsState
OldSectionsState = "oldsections"
// OldSectionsKey is the one key it holds.
OldSectionsKey = "counts"
)
@@ -22,7 +22,7 @@ import (
// The published packages (novox/hq ADR 0593 §2): the indexer alone reads, from the forge's listing, the content digest
// of each package of every mesh Go module a held module reaches, and writes the module's latest published version and
// digests in its state `packages` (PackagesBucket), one key per Go module. The builder, the checker and the
// digests in its state `packages`, one key per Go module. The builder, the checker and the
// build modules read it there; nobody else computes a digest or a version.
//
// A Go module is reached when a held module's go.sum names it (KeptInputs2.Packages) or holds an import a build
@@ -33,8 +33,7 @@ const (
// PendingState is the indexer's state of held merges: the bucket mesh-delivery-indexer_pending, keyed
// takein.PendingKey, so the key order is the merge order. An old `state` entry (the indexer is foundation, ADR
// 0595 §11), history 1, reached by the indexer alone.
PendingState = "pending"
PendingBucket = Module + "_" + PendingState
PendingState = "pending"
// PendingTool reads it (ADR 0633 §5); TakeInPendingTool and DropPendingTool steer it.
PendingTool = "indexer_pending"
TakeInPendingTool = "indexer_take_in_pending"
@@ -471,7 +470,7 @@ func (ix *Indexer) Arrive(ctx context.Context, seq uint64, f forgemsg.Forge) (Ap
switch err := ix.Pending.Create(ctx, key, data); {
case errors.Is(err, process.ErrNotYet):
// The state this delivery brings is not on the bus yet (issue 1790): the merge is taken in at once, as before.
ix.logf("take-in: the state %s is not on the bus yet, so %s#%d is taken in at once, as before ADR 0633", PendingBucket, f.Repository, f.Number)
ix.logf("take-in: the state %s is not on the bus yet, so %s#%d is taken in at once, as before ADR 0633", PendingState, f.Repository, f.Number)
a, err := ix.ApplyMessage(ctx, f)
return a, "", err
case err != nil && !errors.Is(err, ErrConflict):
@@ -1083,7 +1082,7 @@ func (ix *Indexer) takeInWholeBy(ctx context.Context, entries []PendingEntry, ow
// Every manifest a take-in writes is judged in it and its verdict said before take-in.taken (issue 1966 note 154,
// ADR 0668 §4): with the verdicts state not on the bus yet, nothing is taken in; its bind evaluates pending again.
ix.logf("take-in: %d merges wait, oldest %s: the state %s is not on the bus yet, so nothing is taken in until it is, and no manifest is written without its verdict",
len(entries), entries[0].Key, VerdictsBucket)
len(entries), entries[0].Key, VerdictsState)
return Applied{}, errVerdictsNotYet
}
claimed, ok := ix.claim(ctx, entries, own, by)
@@ -25,9 +25,8 @@ import (
// keys, `made` (written once, create-only, when the state is first used) and `pins-stated` (the `at` of the newest applied event of
// that name). Pins count only once a pins-stated later than made is applied.
const (
// PinsState and PinsBucket are the state's name and its bucket; PinsCapMiB is its cap in the manifest (about 1,800 keys of about 0.2 KiB).
// PinsState is the state's name; PinsCapMiB is its cap in the manifest (about 1,800 keys of about 0.2 KiB).
PinsState = "pins"
PinsBucket = Module + "_" + PinsState
PinsHistory = 1
PinsCapMiB = 4
// PinsMadeKey and PinsStatedKey are the two keys of the state that are no revision's.
@@ -26,12 +26,8 @@ import (
const (
// RegistrationsState is the old state section of the registrations, one key per module (§2).
RegistrationsState = "registrations"
// RegistrationsBucket is the bucket of the state.
RegistrationsBucket = Module + "_" + RegistrationsState
// ProposalsState is the old state section of the changes that wait for their warrant (§667), capped at 4 MiB.
ProposalsState = "proposals"
// ProposalsBucket is the bucket of the state.
ProposalsBucket = Module + "_" + ProposalsState
// RegistrationHistoryStream is the old streams section that keeps every version of every registration (§2, §9).
RegistrationHistoryStream = "registration-history"
// RegistrationHistoryEvent is the event of the stream, one subject per module.
@@ -18,9 +18,8 @@ import (
// The builder's floor asks it through indexer_requirements, so a version is never numbered below what a consumer
// already requires.
const (
RequirementsState = "requirements"
RequirementsBucket = Module + "_" + RequirementsState
RequirementsTool = "indexer_requirements"
RequirementsState = "requirements"
RequirementsTool = "indexer_requirements"
)
// Requirement is the value of one package's key in the requirements state: By maps each consumer, "<repository>:<dir>",
@@ -27,9 +27,8 @@ import (
// callers are the holders of the build seats) and by the tool indexer_inputs. A key older than a day is deleted at each new
// ask, judged over at most the 20 oldest keys.
const (
InputsState = "inputs"
InputsBucket = Module + "_" + InputsState
InputsTool = "indexer_inputs"
InputsState = "inputs"
InputsTool = "indexer_inputs"
// InputsKeptFor is how long an input is kept at the longest.
InputsKeptFor = 24 * time.Hour
// InputsSwept is how many of the oldest keys each new ask judges.
@@ -32,8 +32,7 @@ import (
// RunsState is the indexer's state of the runs on request it holds a candidate for (A-174): the bucket
// mesh-delivery-indexer_runs, one key per run, run-<id>.
const (
RunsState = "runs"
RunsBucket = Module + "_" + RunsState
RunsState = "runs"
)
// Run is one value of the state runs: the run's members as run-started named them, and the modules whose pipeline of the
@@ -41,8 +41,7 @@ import (
const (
// SeatDefinitionsState is the indexer's state of the seat definitions (design 26), one key per seat and source.
SeatDefinitionsState = "seat-definitions"
SeatDefinitionsBucket = Module + "_" + SeatDefinitionsState
SeatDefinitionsState = "seat-definitions"
// The seat mesh-catalog's verb and events (ADR 0636 §4): the indexer, which holds the seat, serves the verb and says
// the events on the seat's own subject, for the trunks' definitions only, changed when a digest moved and removed when
// a trunk's definition went.
@@ -20,8 +20,7 @@ import (
const (
TakeInTool = "indexer_take_in"
// TakeInsState is the indexer's state of take-in asks: the bucket mesh-delivery-indexer_takeins, keyed as the modules state.
TakeInsState = "takeins"
TakeInsBucket = Module + "_" + TakeInsState
TakeInsState = "takeins"
)
// TakeInAsk is a value of the takeins state: which module a person asked to be taken in, why, who and when, and, once the
@@ -21,8 +21,7 @@ import (
const (
// UnjudgedState is the indexer's state of the digests a take-in wrote and no judge pass judged yet: the bucket
// mesh-delivery-indexer_unjudged, one key per manifest digest.
UnjudgedState = "unjudged"
UnjudgedBucket = Module + "_" + UnjudgedState
UnjudgedState = "unjudged"
)
// UnjudgedValue is one key of the unjudged state: the module whose new manifest the digest is, and the merge that wrote it.
@@ -55,7 +54,7 @@ func (ix *Indexer) keepUnjudged(ctx context.Context, digest, module string, w *m
return data, false, nil
})
if errors.Is(err, process.ErrNotYet) {
ix.logf("judge: the state %s is not on the bus yet, so the new manifest %s of %s is kept for its judging only in this take-in", UnjudgedBucket, digest, module)
ix.logf("judge: the state %s is not on the bus yet, so the new manifest %s of %s is kept for its judging only in this take-in", UnjudgedState, digest, module)
return nil
}
if err != nil {
@@ -73,7 +72,7 @@ func (ix *Indexer) withUnjudged(ctx context.Context, fresh map[string]bool) map[
keys, err := ix.Unjudged.Keys(ctx)
if err != nil {
if !errors.Is(err, process.ErrNotYet) {
ix.logf("judge: the state %s cannot be listed (%v), so only this take-in's new manifests are judged as new", UnjudgedBucket, err)
ix.logf("judge: the state %s cannot be listed (%v), so only this take-in's new manifests are judged as new", UnjudgedState, err)
}
return fresh
}
@@ -19,15 +19,13 @@ import (
)
// The indexer judges every manifest it holds, once, with its own judge (novox/hq ADR 0578 §1): it writes each verdict in
// its state verdicts (VerdictsBucket), one key per manifest digest, only when the verdict differs from the one
// its state verdicts (VerdictsState), one key per manifest digest, only when the verdict differs from the one
// held; a module's value in the modules state carries a refusal (Verdict, Problems), so a reader of modules takes it
// without a second read; a new refusal is said as the event manifest-refused; a manifest with a field the judge does not know waits instead (ownBuildIsNewest). It judges at its start, so a judge that
// changed (a new indexer) judges every manifest again, and after every merge it takes in, since a rule between manifests
// can turn on any of them. Nothing polls.
// VerdictsBucket is the indexer's state of verdicts; VerdictsState is its local name, as the tools bundle reads it.
const VerdictsBucket = Module + "_" + VerdictsState
// VerdictsState is the indexer's state of verdicts, its local name, as the tools bundle reads it.
const VerdictsState = "verdicts"
// Judged is what one pass of the judge did: the manifests judged, the verdicts written, and the modules refused.
@@ -229,7 +227,7 @@ func (ix *Indexer) judgeOverHeld(ctx context.Context, fresh map[string]bool, ove
}
wrote, revision, err := ix.writeVerdict(ctx, digests[name], v)
if errors.Is(err, process.ErrNotYet) {
return out, fmt.Errorf("the state %s is not on the bus yet: %w", VerdictsBucket, err)
return out, fmt.Errorf("the state %s is not on the bus yet: %w", VerdictsState, err)
}
if err != nil {
ix.logf("judge: the verdict on %s (digest %s) is not written: %v", name, digests[name], err)
@@ -512,7 +510,6 @@ func (ix *Indexer) writeVerdict(ctx context.Context, digest string, v meshcatalo
// does not, since when and why.
const (
OwnBuildStateName = "own-build"
OwnBuildBucket = Module + "_" + OwnBuildStateName
OwnBuildKey = "state"
)
@@ -21,8 +21,7 @@ import (
// the source revision built and its edge entries. It hears every artifact's package-published and records a version as
// released once every artifact the module's entry names is published at it.
const (
VersionsState = "versions"
VersionsBucket = Module + "_" + VersionsState
VersionsState = "versions"
// VersionsKept is how many versions of a module the state keeps (§349): at each release the module's oldest beyond them
// go, never its highest of any MAJOR.MINOR.
VersionsKept = 100
@@ -2,12 +2,8 @@ package index
import (
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph"
"git.novox.be/novox/mesh-sdk/go/views"
)
// MarksBucket is the indexer's state of what its views family said each state up to.
const MarksBucket = Module + "_" + views.MarksState
// FirstViewTools are the indexer's first-view tools (ADR 0621 §1, ADR 0622 §1, ADR 0631 §1): the tool, the state it answers, and
// the words of what that state holds. Each answers only its callers list (CallersEnv), which the manifest writes. The fourth
// first view, of which modules exist, is the seat mesh-catalog's verb revision (ADR 0663 §1, RevisionTool), granted by
@@ -38,17 +34,8 @@ type ViewedTool struct {
Tool, State, Words string
}
// ViewedStates are the states the indexer's views family says, each by its bucket: the ones its readers read.
var ViewedStates = map[string]string{
"manifests": ManifestsBucket,
VerdictsState: VerdictsBucket,
PredefinedState: PredefinedBucket,
ConfigCandidatesState: ConfigCandidatesBucket,
"candidates": CandidatesBucket,
PackagesState: PackagesBucket,
HeardState: HeardBucket,
"taken": TakenBucket,
FindingsState: FindingsBucket,
SeatDefinitionsState: SeatDefinitionsBucket,
UnjudgedState: UnjudgedBucket,
// ViewedStates are the states the indexer's views family says: the ones its readers read.
var ViewedStates = map[string]bool{
ManifestsState: true, VerdictsState: true, PredefinedState: true, ConfigCandidatesState: true, CandidatesState: true,
PackagesState: true, HeardState: true, TakenState: true, FindingsState: true, SeatDefinitionsState: true, UnjudgedState: true,
}