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
This commit is contained in:
2026-11-27 00:18:50 +01:00
parent 64a27c2cab
commit 982a059e42
4 changed files with 59 additions and 70 deletions
@@ -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)
}
}
}
@@ -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
}
+21 -62
View File
@@ -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
@@ -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() != "" {