From 982a059e426e705f81b6fe100ed823cdf3cb8f43 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 27 Nov 2026 00:18:50 +0100 Subject: [PATCH 1/3] The take-in sets an unknown manifest word aside at any depth and names it (H-A-808) The indexer's take-in read set aside only an unknown top-level word and refused one inside a known word, so a manifest carrying a new nested word (H2b's tool-files in a process, race in a Go artifact) would get no fingerprint and nothing of its revision would deliver. The kind is fixed whole: ParseManifestForInputs now reads with the SDK's own decoder, which sets an unknown word aside at any depth and names it (SetAside), and holds the words it knows to every other rule, so the top-level case of H-A-465 is now named too. A manifest the decoder cannot read past is still refused, and the judgement's read (ParseManifest, Manifest) stays strict. Issue 1984. Builds: design 47 H2 H-A-808 --- .../internal/index/inputs_test.go | 19 +++-- .../internal/index/stale_none2_test.go | 7 +- modules/mesh-delivery-indexer/judge/rules.go | 83 +++++-------------- .../mesh-delivery-indexer/judge/rules_test.go | 20 +++++ 4 files changed, 59 insertions(+), 70 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/inputs_test.go b/modules/mesh-delivery-indexer/internal/index/inputs_test.go index 1f2002156..c28487366 100644 --- a/modules/mesh-delivery-indexer/internal/index/inputs_test.go +++ b/modules/mesh-delivery-indexer/internal/index/inputs_test.go @@ -144,8 +144,8 @@ func TestAnArtifactOfNoToolchainHasNoLanguageAndNoLock(t *testing.T) { // 1450/A func TestAManifestTheParserRefusesLeavesNoInputsAndSaysWhy(t *testing.T) { // 1450/AC5 for name, raw := range map[string]string{ "not json": "not json", - // A word inside a known one is still refused; a top-level word is set aside (below). - "unknown field": strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "a-field-from-later": "everything",`, 1), + // A known word in a shape this SDK does not read; a word it does not know is set aside, at any depth (below). + "a field of another shape": strings.Replace(catalogueManifest(t, "avahi"), `"binary": "avahi-tools",`, `"binary": ["avahi-tools"],`, 1), } { in := inputsOf("avahi", raw, "t", nil, noBases) if in.Kept != nil || !strings.HasPrefix(in.None2, "the manifest cannot be read: ") || len(in.None2) <= len("the manifest cannot be read: ") { @@ -160,9 +160,18 @@ func TestAManifestTheParserRefusesLeavesNoInputsAndSaysWhy(t *testing.T) { // 14 without := inputsOf("avahi", catalogueManifest(t, "avahi"), "t", map[string]string{"go.sum": avahiGoSum}, noBases) with := inputsOf("avahi", strings.Replace(catalogueManifest(t, "avahi"), `"version": "1",`, `"version": "1", "class": "core",`, 1), "t", map[string]string{"go.sum": avahiGoSum}, noBases) - if with.Kept == nil || without.Kept == nil || !reflect.DeepEqual(*with.Kept, *without.Kept) || with.None2 != without.None2 || - !reflect.DeepEqual(with.Languages, without.Languages) || !reflect.DeepEqual(with.ArtifactPaths, without.ArtifactPaths) { - t.Errorf("with an unknown top-level word: %+v (kept %+v), want the inputs without it %+v (kept %+v)", with, with.Kept, without, without.Kept) + // H-A-808: so is a word inside a known one, as at the top (as `race` in a Go artifact, which H2b adds; the word here is + // one no SDK knows). + raced := strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "zzz-unknown-word": true,`, 1) + if raced == catalogueManifest(t, "avahi") { + t.Fatal("the fixture has no artifact named tools") + } + nested := inputsOf("avahi", raced, "t", map[string]string{"go.sum": avahiGoSum}, noBases) + for word, with := range map[string]moduleInputs{"top-level": with, "nested": nested} { + if with.Kept == nil || without.Kept == nil || !reflect.DeepEqual(*with.Kept, *without.Kept) || with.None2 != without.None2 || + !reflect.DeepEqual(with.Languages, without.Languages) || !reflect.DeepEqual(with.ArtifactPaths, without.ArtifactPaths) { + t.Errorf("with an unknown %s word: %+v (kept %+v), want the inputs without it %+v (kept %+v)", word, with, with.Kept, without, without.Kept) + } } } diff --git a/modules/mesh-delivery-indexer/internal/index/stale_none2_test.go b/modules/mesh-delivery-indexer/internal/index/stale_none2_test.go index a7cb02d7f..f765ce79a 100644 --- a/modules/mesh-delivery-indexer/internal/index/stale_none2_test.go +++ b/modules/mesh-delivery-indexer/internal/index/stale_none2_test.go @@ -7,12 +7,13 @@ import ( ) // unreadableAvahi is avahi's manifest with a field the running parser refuses: the shape of a manifest an older SDK could -// not read. The field is inside an artifact, since a top-level word the take-in does not know is set aside (H-A-465). +// not read. It is a known word in a shape the SDK does not read, since a word the take-in does not know is set aside, at +// any depth (H-A-465, H-A-808). func unreadableAvahi(t *testing.T) string { t.Helper() - raw := strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "a-field-from-later": "everything",`, 1) + raw := strings.Replace(catalogueManifest(t, "avahi"), `"binary": "avahi-tools",`, `"binary": ["avahi-tools"],`, 1) if raw == catalogueManifest(t, "avahi") { - t.Fatal("the fixture has no artifact named tools") + t.Fatal("the fixture has no artifact whose binary is avahi-tools") } return raw } diff --git a/modules/mesh-delivery-indexer/judge/rules.go b/modules/mesh-delivery-indexer/judge/rules.go index 29601d23f..91a81eb1a 100644 --- a/modules/mesh-delivery-indexer/judge/rules.go +++ b/modules/mesh-delivery-indexer/judge/rules.go @@ -2570,6 +2570,14 @@ func UnknownFields(raw []byte) []string { } func parseManifest(raw []byte, predefined catalogue.PredefinedList) (catalogue.Manifest, error) { + return parseManifestSettingAside(raw, predefined, false) +} + +// parseManifestSettingAside is parseManifest, but where setAside says so (the take-in's read, ParseManifestForInputs): +// a word the SDK's manifest does not know, at any depth, is then set aside and named (SetAside), as the SDK's decoder +// sets it aside (design 47 H2 H-A-808), and every other rule is applied to the words it knows. A manifest the decoder +// could not read past (ReadNoFurther) holds its name and version alone, and is refused all the same. +func parseManifestSettingAside(raw []byte, predefined catalogue.PredefinedList, setAside bool) (catalogue.Manifest, error) { var m catalogue.Manifest // Strictly. **An unknown key is refused**, which is the discipline the host's declaration // parser has and manifests lacked (novox/hq 04-ISSUES/003): a `scope:` key survived in five @@ -2581,7 +2589,7 @@ func parseManifest(raw []byte, predefined catalogue.PredefinedList) (catalogue.M decoder := json.NewDecoder(bytes.NewReader(raw)) decoder.DisallowUnknownFields() err := decoder.Decode(&m) - if err == nil && m.SetAside() != "" { + if err == nil && m.SetAside() != "" && (!setAside || m.ReadNoFurther()) { // Kept aside by UnmarshalJSON for the stored catalogue's sake; registration refuses it. err = errors.New(m.SetAside()) } @@ -4001,9 +4009,10 @@ var protectedRoots = []string{"/", "/bin", "/boot", "/dev", "/etc", "/home", "/l "/var/spool"} // ParseManifestForInputs reads a manifest for the inputs of its build and its fingerprint: the indexer's and the -// builder's read (novox/hq issue 1751). It is never a judge of config values, and never of words: a top-level word the -// SDK's manifest does not know (a word a newer SDK adds, such as `class`) is set aside, as the SDK's decoder sets it -// aside, and the inputs are taken from the words it knows (design 47 H, H-A-465), so a revision carrying a new word +// builder's read (novox/hq issue 1751). It is never a judge of config values, and never of words: a word the SDK's +// manifest does not know, at the top or inside a known one (a word a newer SDK adds, such as `class`, or `race` in a Go +// artifact), is set aside and named in the manifest it gives (SetAside), as the SDK's decoder sets it aside and names it, +// and the inputs are taken from the words it knows (design 47 H, H-A-465, H2 H-A-808), so a revision carrying a new word // still gets its fingerprint from the running indexer. The judgement's read (Manifest, ParseManifest) stays strict: the // validator built from the revision's own indexer refuses what it does not know. A value falling back to a predefined key // (ADR 0348 §7) is judged against the list the mesh published when this process holds one (PublishedPredefined); @@ -4012,72 +4021,22 @@ var protectedRoots = []string{"/", "/bin", "/boot", "/dev", "/etc", "/home", "/l // the controller from what it published. No input of a fingerprint or a build comes from the list. Everything else // ParseManifest refuses is refused here too. func ParseManifestForInputs(raw []byte) (catalogue.Manifest, error) { - return parseManifestFallingBack(withoutUnknownWords(raw)) + return parseManifestSettingAside(raw, fallbackList(raw), true) } // parseManifestFallingBack is the strict read judging each predefined key a value falls back to against the list the // mesh published, or, where this process holds none, as the value declares it (fallbacksOf). func parseManifestFallingBack(raw []byte) (catalogue.Manifest, error) { - list := catalogue.PublishedPredefined() - if list == nil { - list = fallbacksOf(raw) - } - return parseManifest(raw, list) + return parseManifest(raw, fallbackList(raw)) } -// withoutUnknownWords is raw without each top-level word the SDK's manifest does not know, the others in their order -// and their values as written; raw itself when it knows every word or is no JSON object (the strict read then says -// what is wrong with it). A word inside a known one is not set aside here: the strict read refuses it. -func withoutUnknownWords(raw []byte) []byte { - decoder := json.NewDecoder(bytes.NewReader(raw)) - if t, err := decoder.Token(); err != nil || t != json.Delim('{') { - return raw +// fallbackList is the list of predefined keys the mesh published, or, where this process holds none, each key a value of +// raw falls back to as the value declares it (fallbacksOf). +func fallbackList(raw []byte) catalogue.PredefinedList { + if list := catalogue.PublishedPredefined(); list != nil { + return list } - var out bytes.Buffer - out.WriteByte('{') - kept, setAside := 0, false - for decoder.More() { - t, err := decoder.Token() - if err != nil { - return raw - } - word, _ := t.(string) - var value json.RawMessage - if err := decoder.Decode(&value); err != nil { - return raw - } - if !knownWord(word) { - setAside = true - continue - } - if kept > 0 { - out.WriteByte(',') - } - quoted, _ := json.Marshal(word) - out.Write(quoted) - out.WriteByte(':') - out.Write(value) - kept++ - } - if !setAside { - return raw - } - out.WriteByte('}') - return out.Bytes() -} - -// knownWord is whether the SDK's manifest knows a top-level word: a manifest of that word alone, valued null, is read -// with nothing set aside. A word the SDK reads by a rule of its own that refuses null is known. -func knownWord(word string) bool { - probe, err := json.Marshal(map[string]json.RawMessage{word: json.RawMessage("null")}) - if err != nil { - return true - } - var m catalogue.Manifest - if err := json.Unmarshal(probe, &m); err != nil { - return true - } - return m.SetAside() == "" + return fallbacksOf(raw) } // fallbacksOf is the list of the predefined keys a manifest's config values fall back to, each as the value declares diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index ea89b9c01..d0e12057d 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -3093,6 +3093,26 @@ func caseAStoredManifestWithAnUnknownKeyIsSetAsideAndTheJudgeRefusesIt(t *testin if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), "a-field-from-later") { t.Errorf("%s: the module check took it: %v", where, err) } + // H-A-808: the take-in's read sets it aside and names it at any depth, as at the top, so the revision still gets + // its fingerprint from the words it knows; a rule the rest breaks (the backup's) still refuses, never the word. + if m, err := ParseManifestForInputs([]byte(raw)); err != nil && strings.Contains(err.Error(), "a-field-from-later") || + err == nil && (m.Module != "later" || !strings.Contains(m.SetAside(), `"a-field-from-later"`)) { + t.Errorf("%s: the take-in's read gave %q, set aside %q: %v", where, m.Module, m.SetAside(), err) + } + } + // A word inside a Go artifact (as H-A-808's `race`; the word here is one no SDK knows): set aside and named, and the + // artifact read as without it. + artifact := `{"name":"t","kind":"bundle","language":"go","system":"arch","from":"cmd/t","binary":"t","loads":["t"]}` + withWord := `{"module":"later","version":"2","build":{"artifacts":[` + + strings.Replace(artifact, `"binary":"t"`, `"binary":"t","zzz-unknown-word":true`, 1) + `]}}` + got, err := ParseManifestForInputs([]byte(withWord)) + without, werr := ParseManifestForInputs([]byte(`{"module":"later","version":"2","build":{"artifacts":[` + artifact + `]}}`)) + if err != nil || werr != nil || !strings.Contains(got.SetAside(), "build.artifacts[0].zzz-unknown-word") || + without.SetAside() != "" || !reflect.DeepEqual(got.Build, without.Build) { + t.Errorf("a word inside a Go artifact: %v %v, set aside %q, build %+v, want %+v", err, werr, got.SetAside(), got.Build, without.Build) + } + if _, err := ParseManifest([]byte(withWord)); err == nil || !strings.Contains(err.Error(), "zzz-unknown-word") { + t.Errorf("the judgement took a word inside a Go artifact: %v", err) } var known catalogue.Manifest if err := json.Unmarshal([]byte(`{"module": "now", "state": [{"name": "s"}]}`), &known); err != nil || known.UnknownField() != "" { From ad56d96bc47579c31f79f44fd493b2e3e5b0794b Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 27 Nov 2026 00:22:06 +0100 Subject: [PATCH 2/3] The take-in says each manifest word it set aside, once per fingerprint (H-A-809) The take-in's read names a set-aside word in the manifest's SetAside, but no reader of the indexer said it, so a fingerprint taken from part of a manifest was silent. The recompute now says, when a pass gives a module a fingerprint other than the one the bucket held, one journal line naming the module, its fingerprint and each word set aside with its path. It is a journal line, not a finding: a word set aside is the normal state while a newer manifest form reaches an older indexer. Issue 1984. Builds: design 47 H2 H-A-809 --- .../internal/index/toolchains.go | 13 +++++++ .../internal/index/toolchains_test.go | 36 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index 1243287d0..56e1fc6c4 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -369,6 +369,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc } } finals[key] = final + ix.saySetAside(k.manifest, r.fp, k.held.Fp2) continue } if !stale[key] && k.cur.Fp2 == r.fp && k.cur.None2 == r.none && sameUsed(k.cur, r.tcs, r.pkgs) { @@ -398,6 +399,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc } if wrote { w.wrote(key) + ix.saySetAside(k.manifest, r.fp, k.held.Fp2) } } if err := ix.writeOverlay(ctx, overlay, finals, w); err != nil { @@ -409,6 +411,17 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc return nil // only a take-in keeps a catalog revision (design 47 H §743, H-A-49) } +// saySetAside says, in one journal line, each word the take-in's read set aside of a module's manifest, with its path +// (SetAside), once per module and fingerprint: when a pass gives the module a fingerprint other than the one the bucket +// held (design 47 H2 H-A-809). It is not a finding: a word set aside is the normal state while a newer manifest form +// reaches an older indexer, and it ends when the indexer that reads the word runs. +func (ix *Indexer) saySetAside(m catalogue.Manifest, fp, held string) { + if fp == "" || fp == held || m.SetAside() == "" { + return + } + ix.logf("%s: its fingerprint %s is taken from the words of its manifest this indexer knows; set aside: %s", m.Module, fp, m.SetAside()) +} + // writeOverlay writes the records of a merge, each once and only if it differs from what the bucket holds; finals has // the ones that were computed, the others are written as the merge gave them. // diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index 98f4ebd3b..ef4d71460 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -903,3 +903,39 @@ func TestATakeInMovesTheImportersOfThePackagesItsRepositoryPublishes(t *testing. } } } + +// H-A-809: a take-in of a manifest with a word set aside inside a known one says, once per module and fingerprint, one +// journal line naming the module, its fingerprint and the word with its path; a pass that gives it no other fingerprint +// says nothing more. +func TestATakeInSaysEachWordItSetAsideOncePerFingerprint(t *testing.T) { + raw := strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "zzz-unknown-word": true,`, 1) + ix, mods, f := newFormIndexerUnmerged(t, mod{"avahi", raw}) + var said []string + ix.Logf = func(format string, args ...any) { said = append(said, fmt.Sprintf(format, args...)) } + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") + reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.1") + naming := func() []string { + var lines []string + for _, line := range said { + if strings.Contains(line, "zzz-unknown-word") { + lines = append(lines, line) + } + } + return lines + } + if err := ix.Apply(context.Background(), f); err != nil { + t.Fatal(err) + } + m, _ := moduleOf(t, mods, "avahi") + lines := naming() + if m.Fp2 == "" || len(lines) != 1 || !strings.HasPrefix(lines[0], "avahi: ") || !strings.Contains(lines[0], m.Fp2) || + !strings.Contains(lines[0], "build.artifacts[0].zzz-unknown-word") { + t.Errorf("fingerprint %q (none %q), lines naming the word %q, want one naming avahi, its fingerprint and the path", m.Fp2, m.None2, lines) + } + if err := ix.Recompute(context.Background()); err != nil { + t.Fatal(err) + } + if again := naming(); len(again) != len(lines) { + t.Errorf("a pass giving the same fingerprint said it again: %q", again) + } +} From 5717fd5036679f9296fe3cda520d18dc27a8e199 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 27 Nov 2026 00:31:11 +0100 Subject: [PATCH 3/3] Fold the set-aside take-in test into the replay test, and cite 1984's acceptance Review of 982a059e and ad56d96b: the indexer is over its unit test budget, so the take-in rows of H-A-809 join the existing merge-and-replay test instead of a test of their own, and the count of main stands. Its second pass is now a second take-in of the same merge, so a line said again for the same fingerprint fails the test, which a recompute writing nothing did not show. The tests cite issue 1984's acceptance labels AC-808a, AC-808b and AC-809. Issue 1984. Builds: design 47 H2 H-A-808, H-A-809 --- .../internal/index/inputs_test.go | 4 +- .../internal/index/toolchains_test.go | 95 +++++++++---------- .../mesh-delivery-indexer/judge/rules_test.go | 11 ++- 3 files changed, 54 insertions(+), 56 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/inputs_test.go b/modules/mesh-delivery-indexer/internal/index/inputs_test.go index c28487366..719a0b582 100644 --- a/modules/mesh-delivery-indexer/internal/index/inputs_test.go +++ b/modules/mesh-delivery-indexer/internal/index/inputs_test.go @@ -160,8 +160,8 @@ func TestAManifestTheParserRefusesLeavesNoInputsAndSaysWhy(t *testing.T) { // 14 without := inputsOf("avahi", catalogueManifest(t, "avahi"), "t", map[string]string{"go.sum": avahiGoSum}, noBases) with := inputsOf("avahi", strings.Replace(catalogueManifest(t, "avahi"), `"version": "1",`, `"version": "1", "class": "core",`, 1), "t", map[string]string{"go.sum": avahiGoSum}, noBases) - // H-A-808: so is a word inside a known one, as at the top (as `race` in a Go artifact, which H2b adds; the word here is - // one no SDK knows). + // 1984/AC-808a (H-A-808): so is a word inside a known one, as at the top, with the same fingerprint inputs (as `race` in + // a Go artifact, which H2b adds; the word here is one no SDK knows). raced := strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "zzz-unknown-word": true,`, 1) if raced == catalogueManifest(t, "avahi") { t.Fatal("the fixture has no artifact named tools") diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index ef4d71460..164a6bea4 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -685,22 +685,53 @@ func TestModulesThatStandOnEachOtherAreNamedAsACycle(t *testing.T) { // 1444 (th } } +// 1984/AC-809 (H-A-809): a manifest with a word set aside inside a known one says one journal line naming the module, its +// fingerprint and the word with its path, once per module and fingerprint: none at a second take-in of the same +// fingerprint, and none for a manifest with nothing set aside. func TestAMergeWritesEachModuleOnceWithItsFinalValueAndAReplayWritesNothing(t *testing.T) { // 1444 (review finding 8) - ctx := context.Background() - ix, mods, f := newFormIndexerUnmerged(t, mod{"avahi", catalogueManifest(t, "avahi")}) - reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") // agreed before the merge is heard - if err := ix.Apply(ctx, f); err != nil { - t.Fatal(err) + raced := strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "zzz-unknown-word": true,`, 1) + if raced == catalogueManifest(t, "avahi") { + t.Fatal("the fixture has no artifact named tools") } - m, _ := moduleOf(t, mods, "avahi") - if mods.writes != 1 || m.Fp2 == "" { - t.Errorf("writes = %d fp2 = %q after one merge, want one write with its fingerprint", mods.writes, m.Fp2) - } - if err := ix.Apply(ctx, f); err != nil { - t.Fatal(err) - } - if mods.writes != 1 { - t.Errorf("writes = %d after the same merge again, want still 1", mods.writes) + for _, row := range []struct { + name, manifest, aside string // aside: the path the take-in says it set aside, "" for none + }{ + {"every word known", catalogueManifest(t, "avahi"), ""}, + {"a word set aside inside a Go artifact", raced, "build.artifacts[0].zzz-unknown-word"}, + } { + ctx := context.Background() + ix, mods, f := newFormIndexerUnmerged(t, mod{"avahi", row.manifest}) + var aside []string // the journal lines saying what was set aside + ix.Logf = func(format string, args ...any) { + if line := fmt.Sprintf(format, args...); strings.Contains(line, "set aside") { + aside = append(aside, line) + } + } + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") // agreed before the merge is heard + if err := ix.Apply(ctx, f); err != nil { + t.Fatal(err) + } + m, _ := moduleOf(t, mods, "avahi") + if mods.writes != 1 || m.Fp2 == "" { + t.Errorf("%s: writes = %d fp2 = %q after one merge, want one write with its fingerprint", row.name, mods.writes, m.Fp2) + } + switch { + case row.aside == "" && len(aside) > 0: + t.Errorf("%s: said %q, want nothing set aside", row.name, aside) + case row.aside != "" && (len(aside) != 1 || !strings.HasPrefix(aside[0], "avahi: ") || !strings.Contains(aside[0], m.Fp2) || + !strings.Contains(aside[0], row.aside)): + t.Errorf("%s: said %q, want one line naming avahi, its fingerprint %s and %s", row.name, aside, m.Fp2, row.aside) + } + said := len(aside) + if err := ix.Apply(ctx, f); err != nil { + t.Fatal(err) + } + if mods.writes != 1 { + t.Errorf("%s: writes = %d after the same merge again, want still 1", row.name, mods.writes) + } + if len(aside) != said { + t.Errorf("%s: the second take-in of the same fingerprint said %q", row.name, aside[said:]) + } } } @@ -903,39 +934,3 @@ func TestATakeInMovesTheImportersOfThePackagesItsRepositoryPublishes(t *testing. } } } - -// H-A-809: a take-in of a manifest with a word set aside inside a known one says, once per module and fingerprint, one -// journal line naming the module, its fingerprint and the word with its path; a pass that gives it no other fingerprint -// says nothing more. -func TestATakeInSaysEachWordItSetAsideOncePerFingerprint(t *testing.T) { - raw := strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "zzz-unknown-word": true,`, 1) - ix, mods, f := newFormIndexerUnmerged(t, mod{"avahi", raw}) - var said []string - ix.Logf = func(format string, args ...any) { said = append(said, fmt.Sprintf(format, args...)) } - reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") - reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.1") - naming := func() []string { - var lines []string - for _, line := range said { - if strings.Contains(line, "zzz-unknown-word") { - lines = append(lines, line) - } - } - return lines - } - if err := ix.Apply(context.Background(), f); err != nil { - t.Fatal(err) - } - m, _ := moduleOf(t, mods, "avahi") - lines := naming() - if m.Fp2 == "" || len(lines) != 1 || !strings.HasPrefix(lines[0], "avahi: ") || !strings.Contains(lines[0], m.Fp2) || - !strings.Contains(lines[0], "build.artifacts[0].zzz-unknown-word") { - t.Errorf("fingerprint %q (none %q), lines naming the word %q, want one naming avahi, its fingerprint and the path", m.Fp2, m.None2, lines) - } - if err := ix.Recompute(context.Background()); err != nil { - t.Fatal(err) - } - if again := naming(); len(again) != len(lines) { - t.Errorf("a pass giving the same fingerprint said it again: %q", again) - } -} diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index d0e12057d..8b46df219 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -3090,18 +3090,20 @@ func caseAStoredManifestWithAnUnknownKeyIsSetAsideAndTheJudgeRefusesIt(t *testin if where != "the top" && !strings.Contains(m.UnknownField(), ": json: unknown field") { t.Errorf("%s: the block's decoder did not say it: %q", where, m.UnknownField()) } + // 1984/AC-808b at every depth: the judgement's read still refuses it. if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), "a-field-from-later") { t.Errorf("%s: the module check took it: %v", where, err) } - // H-A-808: the take-in's read sets it aside and names it at any depth, as at the top, so the revision still gets - // its fingerprint from the words it knows; a rule the rest breaks (the backup's) still refuses, never the word. + // 1984/AC-808a (H-A-808): the take-in's read sets it aside and names it at any depth, as at the top, so the revision + // still gets its fingerprint from the words it knows; a rule the rest breaks (the backup's) still refuses, never the + // word. if m, err := ParseManifestForInputs([]byte(raw)); err != nil && strings.Contains(err.Error(), "a-field-from-later") || err == nil && (m.Module != "later" || !strings.Contains(m.SetAside(), `"a-field-from-later"`)) { t.Errorf("%s: the take-in's read gave %q, set aside %q: %v", where, m.Module, m.SetAside(), err) } } - // A word inside a Go artifact (as H-A-808's `race`; the word here is one no SDK knows): set aside and named, and the - // artifact read as without it. + // 1984/AC-808a: a word inside a Go artifact (as H-A-808's `race`; the word here is one no SDK knows) is set aside and + // named, and the artifact read as without it. artifact := `{"name":"t","kind":"bundle","language":"go","system":"arch","from":"cmd/t","binary":"t","loads":["t"]}` withWord := `{"module":"later","version":"2","build":{"artifacts":[` + strings.Replace(artifact, `"binary":"t"`, `"binary":"t","zzz-unknown-word":true`, 1) + `]}}` @@ -3111,6 +3113,7 @@ func caseAStoredManifestWithAnUnknownKeyIsSetAsideAndTheJudgeRefusesIt(t *testin without.SetAside() != "" || !reflect.DeepEqual(got.Build, without.Build) { t.Errorf("a word inside a Go artifact: %v %v, set aside %q, build %+v, want %+v", err, werr, got.SetAside(), got.Build, without.Build) } + // 1984/AC-808b: the judgement's read still refuses it. if _, err := ParseManifest([]byte(withWord)); err == nil || !strings.Contains(err.Error(), "zzz-unknown-word") { t.Errorf("the judgement took a word inside a Go artifact: %v", err) }