Files
mesh-delivery/modules/mesh-delivery-indexer/internal/index/oldsections.go
T
jschoubben fbd75dfac4 indexer: what nothing reads goes
packageEntries, manifestBytes, writtenModules, WriteHeard, heldOldSections, keepOldSections,
the overlay's written and changed, moduleOfDir with moduleAt, EncodeSeriesPackage,
InputDigest, HoldSeats and the barBlock shape's functions are referenced by no file of the
repository; with HoldSeats gone the seat list's lock is a plain mutex WithSeats takes.
barShows and barOption stay: a judge test reads them.

Builds: design 47 H §764; lead answer H-A-48

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
2026-11-20 05:32:16 +01:00

40 lines
1.6 KiB
Go

package index
import (
"encoding/json"
"fmt"
)
// How many accepted modules use each old section (issue 1966 D4; novox/hq ADR 0595 §11): the indexer counts them, the
// foundation left out, as it judges, keeps the count in its state oldsections under one key, and the tool
// indexer_old_sections reads it. The judge refuses a manifest of another module that uses a section whose count is 0.
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"
// OldSectionsKey is the one key it holds.
OldSectionsKey = "counts"
)
// OldSectionsCount is the value of the oldsections state: per old section, the accepted modules outside the foundation using it.
type OldSectionsCount struct {
V int `json:"v"`
Counts map[string]int `json:"counts"`
// Reads are the `reads` entries left on the indexer's and the assigner's state, by owner and by entry, across the
// accepted manifests (judge.CountOwnerReads; ADR 0615 §1): 0 for each owner once every reader moved.
Reads map[string]int `json:"reads,omitempty"`
}
// DecodeOldSections reads the oldsections value.
func DecodeOldSections(value []byte) (OldSectionsCount, error) {
var c OldSectionsCount
if err := json.Unmarshal(value, &c); err != nil {
return c, fmt.Errorf("the count of the old sections cannot be read: %w", err)
}
if c.V != 1 {
return c, fmt.Errorf("a count of the old sections of version %d, not 1", c.V)
}
return c, nil
}