From cc64794d4c2b5da30ed52d299bf71a261198261f Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 3 Nov 2026 15:11:59 +0100 Subject: [PATCH] Name a ledger's history and snapshot subjects in one place (issue 1966 S3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The grants part grants on them, the tool runner appends and snapshots on them and the bus module creates the history over them, so the three read one contract (the lead's ruling on issue 1966 B1; ADR 0597 §8, §9). --- go/buscompose/names_test.go | 6 ++++++ go/buscompose/nats.go | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/go/buscompose/names_test.go b/go/buscompose/names_test.go index da93c34..2f0b5cc 100644 --- a/go/buscompose/names_test.go +++ b/go/buscompose/names_test.go @@ -18,6 +18,12 @@ func TestTheBusNamesAgree(t *testing.T) { if LogStreamName("mesh-delivery-builder", "build-log") == "" || LogSubject("mesh-delivery-builder", "build-log") == "" { t.Fatal("a log has no stream or subject") } + // 1966/AC20: a ledger's history and snapshot subjects are one contract, which the grants part grants a ledger + // account its publish on. + if h, sn := LedgerHistorySubject("m", "records"), LedgerSnapshotSubject("m", "records"); h != "mesh.ledger.m.records.history" || + sn != "mesh.ledger.m.records.snapshot" { + t.Fatalf("a ledger's subjects are %q and %q", h, sn) + } // 1966/AC23: a wanted account of kind ledger for m on a names the user ledger.a.m and the own secret ledgers. ledger := WantedAccount{User: "ledger.a.m", Kind: KindLedger, Node: "a", Module: "m", URL: "nats://10.0.0.1:4222"} if got := (Principal{Kind: KindLedger, Node: "a", Module: "m"}).Username(); got != "ledger.a.m" { diff --git a/go/buscompose/nats.go b/go/buscompose/nats.go index c0f2618..f7f8ba8 100644 --- a/go/buscompose/nats.go +++ b/go/buscompose/nats.go @@ -50,6 +50,20 @@ const ( KindLedger Kind = "ledger" ) +// LedgerHistorySubject and LedgerSnapshotSubject are the subject prefixes of one ledger's history and of its instances' +// snapshots (novox/hq ADR 0597 §1, §8, §9): an instance's subject is the prefix, ".", and the instance's path with each +// "/" written "." (`decision/0290` is `….decision.0290`). One contract: the grants part grants a ledger account its +// publish on them, the tool runner appends and snapshots on them, and the bus module creates the history's stream over +// them. +func LedgerHistorySubject(module, local string) string { + return "mesh.ledger." + module + "." + local + ".history" +} + +// LedgerSnapshotSubject is the subject prefix of one ledger's instances' snapshots (LedgerHistorySubject). +func LedgerSnapshotSubject(module, local string) string { + return "mesh.ledger." + module + "." + local + ".snapshot" +} + // Seat is a role on the bus as a principal relates to it: the subjects it accepts, and those it // emits (novox/hq ADR 0118, design 29 §5). type Seat struct {