From 2979bc3b84ae469093a36e3507dfa1e221a0d2f1 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 01:25:22 +0100 Subject: [PATCH] assigner: an ask's words cut each digest and fingerprint to 12 digits, so the router no longer refuses every backup ask as a secret; the backup ask binds its composition by that prefix --- .../cmd/mesh-delivery-assigner/pass.go | 2 +- .../internal/assign/askjson.go | 16 ++++++++++++++++ .../internal/assign/asks.go | 9 +++++++-- .../internal/assign/asks_test.go | 10 ++++++++-- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go index de23fc9b..511d18a8 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -1085,7 +1085,7 @@ func (p *passer) backups(ctx context.Context, reverting map[string]bool) { continue } current, currentAsk, there := assign.DecodeAsk(akey, p.w.read(buckets.Asks())[akey]) - if there != nil || assign.BackupAskDigest(current) != want.Composed { + if there != nil || assign.BackupAskDigest(current) != assign.ShortDigest(want.Composed) { after := -1 if there == nil { after = current.Asking diff --git a/modules/mesh-delivery-assigner/internal/assign/askjson.go b/modules/mesh-delivery-assigner/internal/assign/askjson.go index c7d9f48f..880b09fb 100644 --- a/modules/mesh-delivery-assigner/internal/assign/askjson.go +++ b/modules/mesh-delivery-assigner/internal/assign/askjson.go @@ -5,6 +5,7 @@ import ( "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" + "regexp" "time" occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" @@ -13,6 +14,10 @@ import ( // assignerAsk is the asking-th ask a, as the asks state holds it: the router's ask as JSON (asks.Ask.Ask). func assignerAsk(asking int, a oc.Ask) asks.Ask { + a.Headline, a.Explanation, a.Details, a.OnExpiry = said(a.Headline), said(a.Explanation), said(a.Details), said(a.OnExpiry) + for i := range a.Options { + a.Options[i].Label, a.Options[i].Does = said(a.Options[i].Label), said(a.Options[i].Does) + } raw, err := json.Marshal(a) if err != nil { // an oc.Ask holds only strings, bools and a slice of them: it cannot fail panic(fmt.Sprintf("assign: the ask %q does not marshal: %v", a.ID, err)) @@ -20,6 +25,17 @@ func assignerAsk(asking int, a oc.Ask) asks.Ask { return asks.Ask{Asking: asking, Ask: raw} } +// longHex is a digest or fingerprint whole: 64 hexadecimal digits. +var longHex = regexp.MustCompile(`[0-9a-f]{64}`) + +// said is words as an ask carries them out of the mesh: each digest or fingerprint cut to its first 12 digits, which the +// router lets pass, where it refuses a long hexadecimal string as a secret's shape (mesh-sdk outward; novox 2026-11-16 01:24: +// every backup ask was refused for its "(composition sha256:…)" and the fingerprints in the node's words, and the operator +// was never asked). +func said(words string) string { + return longHex.ReplaceAllStringFunc(words, func(h string) string { return h[:12] }) +} + // AskOf is the router's ask an asks-state value carries. func AskOf(a asks.Ask) (oc.Ask, error) { var ask oc.Ask diff --git a/modules/mesh-delivery-assigner/internal/assign/asks.go b/modules/mesh-delivery-assigner/internal/assign/asks.go index f5359702..f88290fe 100644 --- a/modules/mesh-delivery-assigner/internal/assign/asks.go +++ b/modules/mesh-delivery-assigner/internal/assign/asks.go @@ -288,9 +288,10 @@ func NextBackupAsking(after int) int { return max(after+1, 2) } -var backupDigest = regexp.MustCompile(`\(composition (sha256:[0-9a-f]{64})\)`) +var backupDigest = regexp.MustCompile(`\(composition (sha256:[0-9a-f]{12})\)`) -// BackupAskDigest is the digest of the composition a backup ask was made about, from its explanation; empty for an ask that names +// BackupAskDigest is the digest of the composition a backup ask was made about, from its explanation, cut to its first 12 digits as +// the ask says it (ShortDigest); empty for an ask that names // none. An answer is taken for the composition of the ask it answers, and a new revision at the same fingerprint is asked again // under a new number (ADR 0539 §16). func BackupAskDigest(a asks.Ask) string { @@ -304,6 +305,10 @@ func BackupAskDigest(a asks.Ask) string { return "" } +// ShortDigest is a composition's digest as a backup ask names it, its first 12 digits (said): the ask stays bound to its +// composition, and a new composition is asked again. +func ShortDigest(digest string) string { return said(digest) } + // BackupAnswerWords are the words of a want carrying the answer to the asking-th ask: each asking's answer is another want // value, so a backup that fails again after "back up again" and is answered "again" again changes the key and the node retries. func BackupAnswerWords(option string, asking int) string { diff --git a/modules/mesh-delivery-assigner/internal/assign/asks_test.go b/modules/mesh-delivery-assigner/internal/assign/asks_test.go index 29772b9b..d6ff0f23 100644 --- a/modules/mesh-delivery-assigner/internal/assign/asks_test.go +++ b/modules/mesh-delivery-assigner/internal/assign/asks_test.go @@ -5,6 +5,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-teller/tellerevents" "mesh-delivery-assigner/internal/assignment" "mesh-delivery-assigner/internal/puts" + "regexp" "slices" "strings" "testing" @@ -366,8 +367,13 @@ func TestTheRecordAndBackupAsksAreValid(t *testing.T) { if NextBackupAsking(-1) != 0 || NextBackupAsking(0) != 2 || NextBackupAsking(2) != 3 { t.Errorf("the numbers of the askings: %d %d %d", NextBackupAsking(-1), NextBackupAsking(0), NextBackupAsking(2)) } - if BackupAskDigest(b) != dgst { - t.Errorf("the ask names composition %q, want %q", BackupAskDigest(b), dgst) + if BackupAskDigest(b) != ShortDigest(dgst) || ShortDigest(dgst) == dgst { + t.Errorf("the ask names composition %q, want %q", BackupAskDigest(b), ShortDigest(dgst)) + } + // novox 2026-11-16: the router refuses a long hexadecimal string, so no word of an ask carries a digest or fingerprint whole. + held := BackupAsk(bkey, "novox", "mail", fNew, dgst, "the kept data between "+fNew+" and "+fNew+" is not known", 0, now) + if a := mustAsk(t, held); regexp.MustCompile(`[0-9a-f]{20,}`).MatchString(a.Headline + a.Explanation + a.Details) { + t.Errorf("the ask carries a long hexadecimal string: %q", a.Explanation) } if BackupAnswerWords("again", 0) == BackupAnswerWords("again", 1) { t.Errorf("two answers of the same option are one want value")