From 9b818420907e91886b4882095252e10873a570b0 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:00:22 +0100 Subject: [PATCH 01/34] C1: the build-step part says imports-reported, so a build module can report a module's import set The build seats gain the event imports-reported. (part build-step, form 4), body {node, module, fingerprint, commit, imports}, all required, imports possibly empty, kept as toolchain-reported (90 days, 16 MiB). Fixtures on node-build-go and node-build-node; the image build module says none. Builds: design 47 H2 H-A-517, H-A-518, H-A-532 DQ-2, DQ-13 --- .../go/seats/nodebuildgo/contract.go | 48 ++++++++++++++++-- .../go/seats/nodebuildgo/contract_test.go | 4 ++ .../go/seats/nodebuildimage/contract.go | 48 ++++++++++++++++-- .../go/seats/nodebuildnode/contract.go | 48 ++++++++++++++++-- .../go/seats/nodebuildnode/contract_test.go | 4 ++ .../parts/build-step.json | 49 ++++++++++++++++++- .../seats/node-build-go/fixtures/events.json | 27 ++++++++++ .../node-build-node/fixtures/events.json | 26 ++++++++++ .../ts/seats/nodebuildgo/index.d.ts | 9 ++++ .../ts/seats/nodebuildgo/index.js | 9 ++++ .../seats/nodebuildgo/parts/build-step.d.ts | 20 ++++++++ .../ts/seats/nodebuildgo/parts/build-step.js | 1 + .../ts/seats/nodebuildimage/index.d.ts | 9 ++++ .../ts/seats/nodebuildimage/index.js | 9 ++++ .../nodebuildimage/parts/build-step.d.ts | 20 ++++++++ .../seats/nodebuildimage/parts/build-step.js | 1 + .../ts/seats/nodebuildnode/index.d.ts | 9 ++++ .../ts/seats/nodebuildnode/index.js | 9 ++++ .../seats/nodebuildnode/parts/build-step.d.ts | 20 ++++++++ .../seats/nodebuildnode/parts/build-step.js | 1 + 20 files changed, 358 insertions(+), 13 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/nodebuildgo/contract.go b/modules/mesh-delivery-contracts/go/seats/nodebuildgo/contract.go index 038451d87..c006c6287 100644 --- a/modules/mesh-delivery-contracts/go/seats/nodebuildgo/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/nodebuildgo/contract.go @@ -17,13 +17,13 @@ const Seat = "node-build-go" const Form = 1 // FormBuildStep is the form of what the part build-step adds. -const FormBuildStep = 3 +const FormBuildStep = 4 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "1 build-step:3" - generatedFieldsDigest = "AnswerAnswer=a3b42bd5e791 AskArtifact=35eb85c27e97 AskTaken=8c917075eed4 AskTakenEvent=e4fc9b81e066 BuiltArtifact=b5fcef7a8b58 BuiltArtifactResolvedItem=3bcbbcfd1a1f Capacity=b40cca7ccdfa CheckAccept=ef89c6962ae4 CheckRunAccept=ef89c6962ae4 CheckStepAccept=ef89c6962ae4 CurrentAnswer=e39824e012cb CurrentAsk=ac167e5ee11f DeliveryAccept=ef89c6962ae4 DeliveryStepAccept=ef89c6962ae4 DetectedStep=a6fcd7d0eca4 DetectedSteps=05198185c776 DetectedStepsByModuleArtifactValue=cb35b5775cc6 Drop=fb4637978e86 DropAnswer=7538f2f5e68e FailingTest=f3fb3f1a3ca8 Fetch=6e12677bbc2c FetchAnswer=46fc3d5bd7ee FetchBesideItem=774b4bf88ba4 FetchBuildsItem=aee5adc97246 FetchPackage=20d1668a0eee FetchRefusal=de1518848b4c InstallAsk=9f965aa5b30b KeptArtifactAnswer=706729f8ccb9 KeptResult=8657683cdcd7 LevelAnswer=143c69c28a6a LevelAnswerDigest=d54b7fd7b1da LevelAnswerDigestNeedsItem=946b37d1d4a1 LevelAnswerDigestPackagesItem=a7d30558470d LevelAnswerKeptItem=85d3c2f78632 LevelAnswerUnmetItem=946b37d1d4a1 ModuleTree=00bb59e9f262 NotRun=d322fb1eb153 OutputAnswer=97ba4bd92bf9 Pause=d6521e0cdd1e PauseAnswer=7538f2f5e68e PausesByCapacityNodeValue=5392cf505c80 PausesByDroppedIDValue=0e15ac9cacbd PausesByPausedNodeValue=d111aad0f0cf PlacedBeside=53479337ff18 Program=b48ae74f34e0 RecheckAccept=ef89c6962ae4 ResumeAnswer=7538f2f5e68e RunHead=774b4bf88ba4 RunInput=3dc41505a4b7 RunJob=88af2a7f432b RunProgram=6fd636999d54 Step=75190430d510 StepAsk=f0d09ea1670e StepAskBuild=de784b6c05da StepAskCheck=b77941df6dea StepAskCompose=4c6a08e10231 StepEnded=9bc24593a47d StepEndedEvent=207787118dac StepProgress=d25781cc895a StepProgressEvent=179344ce0ca2 StepResult=67f88be36d0e StepRun=a7a81f25515f StepsAnswer=2c02cac2df23 StepsByAskerNodeIDValue=50ccfd4cebd8 StepsByNodeIDValue=50ccfd4cebd8 TakenVersion=1b8d0547f61e TestCounts=9c1332427159 Toolchain=8ecb7debf9ad ToolchainReported=d26392767c50 ToolchainReportedEvent=fa0a431c9c7b ToolchainUsed=6cc7ccabc9f8 ToolchainsByNodeLanguageValue=f97d1dd27613" + generatedForms = "1 build-step:4" + generatedFieldsDigest = "AnswerAnswer=a3b42bd5e791 AskArtifact=35eb85c27e97 AskTaken=8c917075eed4 AskTakenEvent=e4fc9b81e066 BuiltArtifact=b5fcef7a8b58 BuiltArtifactResolvedItem=3bcbbcfd1a1f Capacity=b40cca7ccdfa CheckAccept=ef89c6962ae4 CheckRunAccept=ef89c6962ae4 CheckStepAccept=ef89c6962ae4 CurrentAnswer=e39824e012cb CurrentAsk=ac167e5ee11f DeliveryAccept=ef89c6962ae4 DeliveryStepAccept=ef89c6962ae4 DetectedStep=a6fcd7d0eca4 DetectedSteps=05198185c776 DetectedStepsByModuleArtifactValue=cb35b5775cc6 Drop=fb4637978e86 DropAnswer=7538f2f5e68e FailingTest=f3fb3f1a3ca8 Fetch=6e12677bbc2c FetchAnswer=46fc3d5bd7ee FetchBesideItem=774b4bf88ba4 FetchBuildsItem=aee5adc97246 FetchPackage=20d1668a0eee FetchRefusal=de1518848b4c ImportsReported=c5960405236e ImportsReportedEvent=1615a3e4797e InstallAsk=9f965aa5b30b KeptArtifactAnswer=706729f8ccb9 KeptResult=8657683cdcd7 LevelAnswer=143c69c28a6a LevelAnswerDigest=d54b7fd7b1da LevelAnswerDigestNeedsItem=946b37d1d4a1 LevelAnswerDigestPackagesItem=a7d30558470d LevelAnswerKeptItem=85d3c2f78632 LevelAnswerUnmetItem=946b37d1d4a1 ModuleTree=00bb59e9f262 NotRun=d322fb1eb153 OutputAnswer=97ba4bd92bf9 Pause=d6521e0cdd1e PauseAnswer=7538f2f5e68e PausesByCapacityNodeValue=5392cf505c80 PausesByDroppedIDValue=0e15ac9cacbd PausesByPausedNodeValue=d111aad0f0cf PlacedBeside=53479337ff18 Program=b48ae74f34e0 RecheckAccept=ef89c6962ae4 ResumeAnswer=7538f2f5e68e RunHead=774b4bf88ba4 RunInput=3dc41505a4b7 RunJob=88af2a7f432b RunProgram=6fd636999d54 Step=75190430d510 StepAsk=f0d09ea1670e StepAskBuild=de784b6c05da StepAskCheck=b77941df6dea StepAskCompose=4c6a08e10231 StepEnded=9bc24593a47d StepEndedEvent=207787118dac StepProgress=d25781cc895a StepProgressEvent=179344ce0ca2 StepResult=67f88be36d0e StepRun=a7a81f25515f StepsAnswer=2c02cac2df23 StepsByAskerNodeIDValue=50ccfd4cebd8 StepsByNodeIDValue=50ccfd4cebd8 TakenVersion=1b8d0547f61e TestCounts=9c1332427159 Toolchain=8ecb7debf9ad ToolchainReported=d26392767c50 ToolchainReportedEvent=fa0a431c9c7b ToolchainUsed=6cc7ccabc9f8 ToolchainsByNodeLanguageValue=f97d1dd27613" ) const ( @@ -49,6 +49,7 @@ const ( const ( EventStepEnded = "step-ended" EventToolchainReported = "toolchain-reported" + EventImportsReported = "imports-reported" EventStepProgress = "step-progress" EventAskTaken = "ask-taken" ) @@ -84,7 +85,7 @@ func VerbDescription(verb string) string { // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventStepEnded, EventToolchainReported, EventStepProgress, EventAskTaken} + return []string{EventStepEnded, EventToolchainReported, EventImportsReported, EventStepProgress, EventAskTaken} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -113,6 +114,17 @@ func SubjectToolchainReported(node string) string { // SubjectToolchainReportedAll hears every toolchain-reported. const SubjectToolchainReportedAll = "mesh.seat.node-build-go.event.toolchain-reported.*" +// StreamImportsReported is the stream imports-reported is kept in. +const StreamImportsReported = "SEAT_node-build-go_imports-reported" + +// SubjectImportsReported is where imports-reported is published, on mesh.seat.node-build-go.event.imports-reported.. +func SubjectImportsReported(node string) string { + return "mesh.seat.node-build-go.event.imports-reported." + node +} + +// SubjectImportsReportedAll hears every imports-reported. +const SubjectImportsReportedAll = "mesh.seat.node-build-go.event.imports-reported.*" + // SubjectStepProgress is where step-progress is published, on mesh.seat.node-build-go.event.step-progress.. func SubjectStepProgress(node string) string { return "mesh.seat.node-build-go.event.step-progress." + node @@ -586,6 +598,22 @@ type FetchRefusal struct { Reason string `json:"reason"` } +// ImportsReported is the mesh packages a module's programs import, said by the build module at a build's end (design 47 H2 H-A-517, H-A-532 DQ-2): the import closure without tests, each package by its import path, the union over the module's programs (H-A-518); the indexer keeps it only for the fingerprint main's modules state holds (H-A-532 DMC-2). +type ImportsReported struct { + // the commit the build was made from + Commit string `json:"commit"` + // the fingerprint the build was asked for + Fingerprint string `json:"fingerprint"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + // each mesh package the module's programs import, by its import path; empty when they import none + Imports []string `json:"imports"` + // the module built + Module string `json:"module"` + // the node the build ran on + Node string `json:"node"` +} + // InstallAsk is the job of an ask of the kind install (design 47 H2 §800, H-A-367 (4), H-A-403): the npm tree a module's package lock names, installed with an integrity-checked install and no install scripts, and published to the artifact store (the seat oci-artifact-registry) as the module's archive :node-modules under the ask's version, which the builder's reservation covers. type InstallAsk struct { // who asked it @@ -1246,6 +1274,9 @@ type StepEndedEvent = StepEnded // ToolchainReportedEvent is the body of the event toolchain-reported. type ToolchainReportedEvent = ToolchainReported +// ImportsReportedEvent is the body of the event imports-reported. +type ImportsReportedEvent = ImportsReported + // StepProgressEvent is the body of the event step-progress. type StepProgressEvent = StepProgress @@ -1363,6 +1394,15 @@ func DecodeToolchainReportedEvent(raw []byte) (ToolchainReportedEvent, int, erro return v, formRead(raw), nil } +// DecodeImportsReportedEvent reads a ImportsReportedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeImportsReportedEvent(raw []byte) (ImportsReportedEvent, int, error) { + var v ImportsReportedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + // DecodeStepProgressEvent reads a StepProgressEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). func DecodeStepProgressEvent(raw []byte) (StepProgressEvent, int, error) { var v StepProgressEvent diff --git a/modules/mesh-delivery-contracts/go/seats/nodebuildgo/contract_test.go b/modules/mesh-delivery-contracts/go/seats/nodebuildgo/contract_test.go index 5447adb4e..32a121e39 100644 --- a/modules/mesh-delivery-contracts/go/seats/nodebuildgo/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/nodebuildgo/contract_test.go @@ -23,6 +23,10 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.step-ended\\.[^.*> ]+$")}, {name: "a node's toolchain reported", subject: "mesh.seat.node-build-go.event.toolchain-reported.anchor", given: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"anchor\",\"recipe\":\"1\",\"version\":\"1.26.0\"}", wire: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"anchor\",\"recipe\":\"1\",\"version\":\"1.26.0\"}", decode: func(b []byte) (any, error) { var v ToolchainReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.toolchain-reported\\.[^.*> ]+$")}, + {name: "a module's import set said at its build's end (design 47 H2 H-A-517)", subject: "mesh.seat.node-build-go.event.imports-reported.anchor", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"imports\":[\"git.novox.be/novox/mesh-sdk/go/bus\",\"git.novox.be/novox/mesh-sdk/go/catalogue\"],\"module\":\"nats\",\"node\":\"anchor\"}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"imports\":[\"git.novox.be/novox/mesh-sdk/go/bus\",\"git.novox.be/novox/mesh-sdk/go/catalogue\"],\"module\":\"nats\",\"node\":\"anchor\"}", + decode: func(b []byte) (any, error) { var v ImportsReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.imports-reported\\.[^.*> ]+$")}, + {name: "a module whose programs import no mesh package says an empty set (H-A-532 DQ-2)", subject: "mesh.seat.node-build-go.event.imports-reported.anchor", given: "{\"commit\":\"89abcdef0123456789abcdef0123456789abcdef\",\"fingerprint\":\"fp-4567\",\"imports\":[],\"module\":\"feh\",\"node\":\"anchor\"}", wire: "{\"commit\":\"89abcdef0123456789abcdef0123456789abcdef\",\"fingerprint\":\"fp-4567\",\"imports\":[],\"module\":\"feh\",\"node\":\"anchor\"}", + decode: func(b []byte) (any, error) { var v ImportsReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.imports-reported\\.[^.*> ]+$")}, {name: "a running ask says its progress", subject: "mesh.seat.node-build-go.event.step-progress.anchor", given: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}", wire: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}", decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.step-progress\\.[^.*> ]+$")}, {name: "a builder's build ended, naming its asker and no commit or fingerprint (G 548)", subject: "mesh.seat.node-build-go.event.step-ended.anchor", given: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"anchor\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}", wire: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"anchor\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}", diff --git a/modules/mesh-delivery-contracts/go/seats/nodebuildimage/contract.go b/modules/mesh-delivery-contracts/go/seats/nodebuildimage/contract.go index 77dc64f16..a70d6243c 100644 --- a/modules/mesh-delivery-contracts/go/seats/nodebuildimage/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/nodebuildimage/contract.go @@ -17,13 +17,13 @@ const Seat = "node-build-image" const Form = 1 // FormBuildStep is the form of what the part build-step adds. -const FormBuildStep = 3 +const FormBuildStep = 4 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "1 build-step:3" - generatedFieldsDigest = "AnswerAnswer=a3b42bd5e791 AskArtifact=35eb85c27e97 AskTaken=8c917075eed4 AskTakenEvent=e4fc9b81e066 BuiltArtifact=b5fcef7a8b58 BuiltArtifactResolvedItem=3bcbbcfd1a1f Capacity=b40cca7ccdfa CheckAccept=ef89c6962ae4 CheckStepAccept=ef89c6962ae4 CurrentAnswer=e39824e012cb CurrentAsk=ac167e5ee11f DeliveryAccept=ef89c6962ae4 DeliveryStepAccept=ef89c6962ae4 DetectedStep=a6fcd7d0eca4 DetectedSteps=05198185c776 DetectedStepsByModuleArtifactValue=cb35b5775cc6 Drop=fb4637978e86 DropAnswer=7538f2f5e68e FailingTest=f3fb3f1a3ca8 Fetch=6e12677bbc2c FetchAnswer=46fc3d5bd7ee FetchBesideItem=774b4bf88ba4 FetchBuildsItem=aee5adc97246 FetchPackage=20d1668a0eee FetchRefusal=de1518848b4c InstallAsk=9f965aa5b30b KeptArtifactAnswer=706729f8ccb9 KeptResult=8657683cdcd7 LevelAnswer=143c69c28a6a LevelAnswerDigest=d54b7fd7b1da LevelAnswerDigestNeedsItem=946b37d1d4a1 LevelAnswerDigestPackagesItem=a7d30558470d LevelAnswerKeptItem=85d3c2f78632 LevelAnswerUnmetItem=946b37d1d4a1 ModuleTree=00bb59e9f262 NotRun=d322fb1eb153 OutputAnswer=97ba4bd92bf9 Pause=d6521e0cdd1e PauseAnswer=7538f2f5e68e PausesByCapacityNodeValue=5392cf505c80 PausesByDroppedIDValue=0e15ac9cacbd PausesByPausedNodeValue=d111aad0f0cf PlacedBeside=53479337ff18 Program=b48ae74f34e0 RecheckAccept=ef89c6962ae4 ResumeAnswer=7538f2f5e68e RunHead=774b4bf88ba4 RunInput=3dc41505a4b7 RunJob=88af2a7f432b RunProgram=6fd636999d54 Step=75190430d510 StepAsk=f0d09ea1670e StepAskBuild=de784b6c05da StepAskCheck=b77941df6dea StepAskCompose=4c6a08e10231 StepEnded=9bc24593a47d StepEndedEvent=207787118dac StepProgress=d25781cc895a StepProgressEvent=179344ce0ca2 StepResult=67f88be36d0e StepRun=a7a81f25515f StepsAnswer=2c02cac2df23 StepsByAskerNodeIDValue=50ccfd4cebd8 StepsByNodeIDValue=50ccfd4cebd8 TakenVersion=1b8d0547f61e TestCounts=9c1332427159 Toolchain=8ecb7debf9ad ToolchainReported=d26392767c50 ToolchainReportedEvent=fa0a431c9c7b ToolchainUsed=6cc7ccabc9f8 ToolchainsByNodeLanguageValue=f97d1dd27613" + generatedForms = "1 build-step:4" + generatedFieldsDigest = "AnswerAnswer=a3b42bd5e791 AskArtifact=35eb85c27e97 AskTaken=8c917075eed4 AskTakenEvent=e4fc9b81e066 BuiltArtifact=b5fcef7a8b58 BuiltArtifactResolvedItem=3bcbbcfd1a1f Capacity=b40cca7ccdfa CheckAccept=ef89c6962ae4 CheckStepAccept=ef89c6962ae4 CurrentAnswer=e39824e012cb CurrentAsk=ac167e5ee11f DeliveryAccept=ef89c6962ae4 DeliveryStepAccept=ef89c6962ae4 DetectedStep=a6fcd7d0eca4 DetectedSteps=05198185c776 DetectedStepsByModuleArtifactValue=cb35b5775cc6 Drop=fb4637978e86 DropAnswer=7538f2f5e68e FailingTest=f3fb3f1a3ca8 Fetch=6e12677bbc2c FetchAnswer=46fc3d5bd7ee FetchBesideItem=774b4bf88ba4 FetchBuildsItem=aee5adc97246 FetchPackage=20d1668a0eee FetchRefusal=de1518848b4c ImportsReported=c5960405236e ImportsReportedEvent=1615a3e4797e InstallAsk=9f965aa5b30b KeptArtifactAnswer=706729f8ccb9 KeptResult=8657683cdcd7 LevelAnswer=143c69c28a6a LevelAnswerDigest=d54b7fd7b1da LevelAnswerDigestNeedsItem=946b37d1d4a1 LevelAnswerDigestPackagesItem=a7d30558470d LevelAnswerKeptItem=85d3c2f78632 LevelAnswerUnmetItem=946b37d1d4a1 ModuleTree=00bb59e9f262 NotRun=d322fb1eb153 OutputAnswer=97ba4bd92bf9 Pause=d6521e0cdd1e PauseAnswer=7538f2f5e68e PausesByCapacityNodeValue=5392cf505c80 PausesByDroppedIDValue=0e15ac9cacbd PausesByPausedNodeValue=d111aad0f0cf PlacedBeside=53479337ff18 Program=b48ae74f34e0 RecheckAccept=ef89c6962ae4 ResumeAnswer=7538f2f5e68e RunHead=774b4bf88ba4 RunInput=3dc41505a4b7 RunJob=88af2a7f432b RunProgram=6fd636999d54 Step=75190430d510 StepAsk=f0d09ea1670e StepAskBuild=de784b6c05da StepAskCheck=b77941df6dea StepAskCompose=4c6a08e10231 StepEnded=9bc24593a47d StepEndedEvent=207787118dac StepProgress=d25781cc895a StepProgressEvent=179344ce0ca2 StepResult=67f88be36d0e StepRun=a7a81f25515f StepsAnswer=2c02cac2df23 StepsByAskerNodeIDValue=50ccfd4cebd8 StepsByNodeIDValue=50ccfd4cebd8 TakenVersion=1b8d0547f61e TestCounts=9c1332427159 Toolchain=8ecb7debf9ad ToolchainReported=d26392767c50 ToolchainReportedEvent=fa0a431c9c7b ToolchainUsed=6cc7ccabc9f8 ToolchainsByNodeLanguageValue=f97d1dd27613" ) const ( @@ -48,6 +48,7 @@ const ( const ( EventStepEnded = "step-ended" EventToolchainReported = "toolchain-reported" + EventImportsReported = "imports-reported" EventStepProgress = "step-progress" EventAskTaken = "ask-taken" ) @@ -83,7 +84,7 @@ func VerbDescription(verb string) string { // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventStepEnded, EventToolchainReported, EventStepProgress, EventAskTaken} + return []string{EventStepEnded, EventToolchainReported, EventImportsReported, EventStepProgress, EventAskTaken} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -114,6 +115,17 @@ func SubjectToolchainReported(node string) string { // SubjectToolchainReportedAll hears every toolchain-reported. const SubjectToolchainReportedAll = "mesh.seat.node-build-image.event.toolchain-reported.*" +// StreamImportsReported is the stream imports-reported is kept in. +const StreamImportsReported = "SEAT_node-build-image_imports-reported" + +// SubjectImportsReported is where imports-reported is published, on mesh.seat.node-build-image.event.imports-reported.. +func SubjectImportsReported(node string) string { + return "mesh.seat.node-build-image.event.imports-reported." + node +} + +// SubjectImportsReportedAll hears every imports-reported. +const SubjectImportsReportedAll = "mesh.seat.node-build-image.event.imports-reported.*" + // SubjectStepProgress is where step-progress is published, on mesh.seat.node-build-image.event.step-progress.. func SubjectStepProgress(node string) string { return "mesh.seat.node-build-image.event.step-progress." + node @@ -584,6 +596,22 @@ type FetchRefusal struct { Reason string `json:"reason"` } +// ImportsReported is the mesh packages a module's programs import, said by the build module at a build's end (design 47 H2 H-A-517, H-A-532 DQ-2): the import closure without tests, each package by its import path, the union over the module's programs (H-A-518); the indexer keeps it only for the fingerprint main's modules state holds (H-A-532 DMC-2). +type ImportsReported struct { + // the commit the build was made from + Commit string `json:"commit"` + // the fingerprint the build was asked for + Fingerprint string `json:"fingerprint"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + // each mesh package the module's programs import, by its import path; empty when they import none + Imports []string `json:"imports"` + // the module built + Module string `json:"module"` + // the node the build ran on + Node string `json:"node"` +} + // InstallAsk is the job of an ask of the kind install (design 47 H2 §800, H-A-367 (4), H-A-403): the npm tree a module's package lock names, installed with an integrity-checked install and no install scripts, and published to the artifact store (the seat oci-artifact-registry) as the module's archive :node-modules under the ask's version, which the builder's reservation covers. type InstallAsk struct { // who asked it @@ -1241,6 +1269,9 @@ type StepEndedEvent = StepEnded // ToolchainReportedEvent is the body of the event toolchain-reported. type ToolchainReportedEvent = ToolchainReported +// ImportsReportedEvent is the body of the event imports-reported. +type ImportsReportedEvent = ImportsReported + // StepProgressEvent is the body of the event step-progress. type StepProgressEvent = StepProgress @@ -1358,6 +1389,15 @@ func DecodeToolchainReportedEvent(raw []byte) (ToolchainReportedEvent, int, erro return v, formRead(raw), nil } +// DecodeImportsReportedEvent reads a ImportsReportedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeImportsReportedEvent(raw []byte) (ImportsReportedEvent, int, error) { + var v ImportsReportedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + // DecodeStepProgressEvent reads a StepProgressEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). func DecodeStepProgressEvent(raw []byte) (StepProgressEvent, int, error) { var v StepProgressEvent diff --git a/modules/mesh-delivery-contracts/go/seats/nodebuildnode/contract.go b/modules/mesh-delivery-contracts/go/seats/nodebuildnode/contract.go index ce3d01670..bec01ef93 100644 --- a/modules/mesh-delivery-contracts/go/seats/nodebuildnode/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/nodebuildnode/contract.go @@ -17,13 +17,13 @@ const Seat = "node-build-node" const Form = 1 // FormBuildStep is the form of what the part build-step adds. -const FormBuildStep = 3 +const FormBuildStep = 4 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "1 build-step:3" - generatedFieldsDigest = "AnswerAnswer=a3b42bd5e791 AskArtifact=35eb85c27e97 AskTaken=8c917075eed4 AskTakenEvent=e4fc9b81e066 BuiltArtifact=b5fcef7a8b58 BuiltArtifactResolvedItem=3bcbbcfd1a1f Capacity=b40cca7ccdfa CheckAccept=ef89c6962ae4 CheckStepAccept=ef89c6962ae4 CurrentAnswer=e39824e012cb CurrentAsk=ac167e5ee11f DeliveryAccept=ef89c6962ae4 DeliveryStepAccept=ef89c6962ae4 DetectedStep=a6fcd7d0eca4 DetectedSteps=05198185c776 DetectedStepsByModuleArtifactValue=cb35b5775cc6 Drop=fb4637978e86 DropAnswer=7538f2f5e68e FailingTest=f3fb3f1a3ca8 Fetch=6e12677bbc2c FetchAnswer=46fc3d5bd7ee FetchBesideItem=774b4bf88ba4 FetchBuildsItem=aee5adc97246 FetchPackage=20d1668a0eee FetchRefusal=de1518848b4c InstallAccept=ef89c6962ae4 InstallAsk=9f965aa5b30b KeptArtifactAnswer=706729f8ccb9 KeptResult=8657683cdcd7 LevelAnswer=143c69c28a6a LevelAnswerDigest=d54b7fd7b1da LevelAnswerDigestNeedsItem=946b37d1d4a1 LevelAnswerDigestPackagesItem=a7d30558470d LevelAnswerKeptItem=85d3c2f78632 LevelAnswerUnmetItem=946b37d1d4a1 ModuleTree=00bb59e9f262 NotRun=d322fb1eb153 OutputAnswer=97ba4bd92bf9 Pause=d6521e0cdd1e PauseAnswer=7538f2f5e68e PausesByCapacityNodeValue=5392cf505c80 PausesByDroppedIDValue=0e15ac9cacbd PausesByPausedNodeValue=d111aad0f0cf PlacedBeside=53479337ff18 Program=b48ae74f34e0 RecheckAccept=ef89c6962ae4 ResumeAnswer=7538f2f5e68e RunHead=774b4bf88ba4 RunInput=3dc41505a4b7 RunJob=88af2a7f432b RunProgram=6fd636999d54 Step=75190430d510 StepAsk=f0d09ea1670e StepAskBuild=de784b6c05da StepAskCheck=b77941df6dea StepAskCompose=4c6a08e10231 StepEnded=9bc24593a47d StepEndedEvent=207787118dac StepProgress=d25781cc895a StepProgressEvent=179344ce0ca2 StepResult=67f88be36d0e StepRun=a7a81f25515f StepsAnswer=2c02cac2df23 StepsByAskerNodeIDValue=50ccfd4cebd8 StepsByNodeIDValue=50ccfd4cebd8 TakenVersion=1b8d0547f61e TestCounts=9c1332427159 Toolchain=8ecb7debf9ad ToolchainReported=d26392767c50 ToolchainReportedEvent=fa0a431c9c7b ToolchainUsed=6cc7ccabc9f8 ToolchainsByNodeLanguageValue=f97d1dd27613" + generatedForms = "1 build-step:4" + generatedFieldsDigest = "AnswerAnswer=a3b42bd5e791 AskArtifact=35eb85c27e97 AskTaken=8c917075eed4 AskTakenEvent=e4fc9b81e066 BuiltArtifact=b5fcef7a8b58 BuiltArtifactResolvedItem=3bcbbcfd1a1f Capacity=b40cca7ccdfa CheckAccept=ef89c6962ae4 CheckStepAccept=ef89c6962ae4 CurrentAnswer=e39824e012cb CurrentAsk=ac167e5ee11f DeliveryAccept=ef89c6962ae4 DeliveryStepAccept=ef89c6962ae4 DetectedStep=a6fcd7d0eca4 DetectedSteps=05198185c776 DetectedStepsByModuleArtifactValue=cb35b5775cc6 Drop=fb4637978e86 DropAnswer=7538f2f5e68e FailingTest=f3fb3f1a3ca8 Fetch=6e12677bbc2c FetchAnswer=46fc3d5bd7ee FetchBesideItem=774b4bf88ba4 FetchBuildsItem=aee5adc97246 FetchPackage=20d1668a0eee FetchRefusal=de1518848b4c ImportsReported=c5960405236e ImportsReportedEvent=1615a3e4797e InstallAccept=ef89c6962ae4 InstallAsk=9f965aa5b30b KeptArtifactAnswer=706729f8ccb9 KeptResult=8657683cdcd7 LevelAnswer=143c69c28a6a LevelAnswerDigest=d54b7fd7b1da LevelAnswerDigestNeedsItem=946b37d1d4a1 LevelAnswerDigestPackagesItem=a7d30558470d LevelAnswerKeptItem=85d3c2f78632 LevelAnswerUnmetItem=946b37d1d4a1 ModuleTree=00bb59e9f262 NotRun=d322fb1eb153 OutputAnswer=97ba4bd92bf9 Pause=d6521e0cdd1e PauseAnswer=7538f2f5e68e PausesByCapacityNodeValue=5392cf505c80 PausesByDroppedIDValue=0e15ac9cacbd PausesByPausedNodeValue=d111aad0f0cf PlacedBeside=53479337ff18 Program=b48ae74f34e0 RecheckAccept=ef89c6962ae4 ResumeAnswer=7538f2f5e68e RunHead=774b4bf88ba4 RunInput=3dc41505a4b7 RunJob=88af2a7f432b RunProgram=6fd636999d54 Step=75190430d510 StepAsk=f0d09ea1670e StepAskBuild=de784b6c05da StepAskCheck=b77941df6dea StepAskCompose=4c6a08e10231 StepEnded=9bc24593a47d StepEndedEvent=207787118dac StepProgress=d25781cc895a StepProgressEvent=179344ce0ca2 StepResult=67f88be36d0e StepRun=a7a81f25515f StepsAnswer=2c02cac2df23 StepsByAskerNodeIDValue=50ccfd4cebd8 StepsByNodeIDValue=50ccfd4cebd8 TakenVersion=1b8d0547f61e TestCounts=9c1332427159 Toolchain=8ecb7debf9ad ToolchainReported=d26392767c50 ToolchainReportedEvent=fa0a431c9c7b ToolchainUsed=6cc7ccabc9f8 ToolchainsByNodeLanguageValue=f97d1dd27613" ) const ( @@ -49,6 +49,7 @@ const ( const ( EventStepEnded = "step-ended" EventToolchainReported = "toolchain-reported" + EventImportsReported = "imports-reported" EventStepProgress = "step-progress" EventAskTaken = "ask-taken" ) @@ -84,7 +85,7 @@ func VerbDescription(verb string) string { // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventStepEnded, EventToolchainReported, EventStepProgress, EventAskTaken} + return []string{EventStepEnded, EventToolchainReported, EventImportsReported, EventStepProgress, EventAskTaken} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -115,6 +116,17 @@ func SubjectToolchainReported(node string) string { // SubjectToolchainReportedAll hears every toolchain-reported. const SubjectToolchainReportedAll = "mesh.seat.node-build-node.event.toolchain-reported.*" +// StreamImportsReported is the stream imports-reported is kept in. +const StreamImportsReported = "SEAT_node-build-node_imports-reported" + +// SubjectImportsReported is where imports-reported is published, on mesh.seat.node-build-node.event.imports-reported.. +func SubjectImportsReported(node string) string { + return "mesh.seat.node-build-node.event.imports-reported." + node +} + +// SubjectImportsReportedAll hears every imports-reported. +const SubjectImportsReportedAll = "mesh.seat.node-build-node.event.imports-reported.*" + // SubjectStepProgress is where step-progress is published, on mesh.seat.node-build-node.event.step-progress.. func SubjectStepProgress(node string) string { return "mesh.seat.node-build-node.event.step-progress." + node @@ -588,6 +600,22 @@ type FetchRefusal struct { Reason string `json:"reason"` } +// ImportsReported is the mesh packages a module's programs import, said by the build module at a build's end (design 47 H2 H-A-517, H-A-532 DQ-2): the import closure without tests, each package by its import path, the union over the module's programs (H-A-518); the indexer keeps it only for the fingerprint main's modules state holds (H-A-532 DMC-2). +type ImportsReported struct { + // the commit the build was made from + Commit string `json:"commit"` + // the fingerprint the build was asked for + Fingerprint string `json:"fingerprint"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + // each mesh package the module's programs import, by its import path; empty when they import none + Imports []string `json:"imports"` + // the module built + Module string `json:"module"` + // the node the build ran on + Node string `json:"node"` +} + // InstallAsk is the job of an ask of the kind install (design 47 H2 §800, H-A-367 (4), H-A-403): the npm tree a module's package lock names, installed with an integrity-checked install and no install scripts, and published to the artifact store (the seat oci-artifact-registry) as the module's archive :node-modules under the ask's version, which the builder's reservation covers. type InstallAsk struct { // who asked it @@ -1248,6 +1276,9 @@ type StepEndedEvent = StepEnded // ToolchainReportedEvent is the body of the event toolchain-reported. type ToolchainReportedEvent = ToolchainReported +// ImportsReportedEvent is the body of the event imports-reported. +type ImportsReportedEvent = ImportsReported + // StepProgressEvent is the body of the event step-progress. type StepProgressEvent = StepProgress @@ -1365,6 +1396,15 @@ func DecodeToolchainReportedEvent(raw []byte) (ToolchainReportedEvent, int, erro return v, formRead(raw), nil } +// DecodeImportsReportedEvent reads a ImportsReportedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeImportsReportedEvent(raw []byte) (ImportsReportedEvent, int, error) { + var v ImportsReportedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + // DecodeStepProgressEvent reads a StepProgressEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). func DecodeStepProgressEvent(raw []byte) (StepProgressEvent, int, error) { var v StepProgressEvent diff --git a/modules/mesh-delivery-contracts/go/seats/nodebuildnode/contract_test.go b/modules/mesh-delivery-contracts/go/seats/nodebuildnode/contract_test.go index a55579a37..8e8a9f1f1 100644 --- a/modules/mesh-delivery-contracts/go/seats/nodebuildnode/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/nodebuildnode/contract_test.go @@ -23,6 +23,10 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.step-ended\\.[^.*> ]+$")}, {name: "a node's toolchain reported", subject: "mesh.seat.node-build-node.event.toolchain-reported.anchor", given: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"anchor\",\"recipe\":\"1\",\"version\":\"1.26.0\"}", wire: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"anchor\",\"recipe\":\"1\",\"version\":\"1.26.0\"}", decode: func(b []byte) (any, error) { var v ToolchainReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.toolchain-reported\\.[^.*> ]+$")}, + {name: "a module's import set said at its build's end (design 47 H2 H-A-517)", subject: "mesh.seat.node-build-node.event.imports-reported.anchor", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"imports\":[\"@novox/mesh-sdk\"],\"module\":\"nats\",\"node\":\"anchor\"}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"imports\":[\"@novox/mesh-sdk\"],\"module\":\"nats\",\"node\":\"anchor\"}", + decode: func(b []byte) (any, error) { var v ImportsReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.imports-reported\\.[^.*> ]+$")}, + {name: "a module whose programs import no mesh package says an empty set (H-A-532 DQ-2)", subject: "mesh.seat.node-build-node.event.imports-reported.anchor", given: "{\"commit\":\"89abcdef0123456789abcdef0123456789abcdef\",\"fingerprint\":\"fp-4567\",\"imports\":[],\"module\":\"feh\",\"node\":\"anchor\"}", wire: "{\"commit\":\"89abcdef0123456789abcdef0123456789abcdef\",\"fingerprint\":\"fp-4567\",\"imports\":[],\"module\":\"feh\",\"node\":\"anchor\"}", + decode: func(b []byte) (any, error) { var v ImportsReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.imports-reported\\.[^.*> ]+$")}, {name: "a running ask says its progress", subject: "mesh.seat.node-build-node.event.step-progress.anchor", given: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}", wire: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}", decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.step-progress\\.[^.*> ]+$")}, {name: "a builder's build ended, naming its asker and no commit or fingerprint (G 548)", subject: "mesh.seat.node-build-node.event.step-ended.anchor", given: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"anchor\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}", wire: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"anchor\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}", diff --git a/modules/mesh-delivery-contracts/parts/build-step.json b/modules/mesh-delivery-contracts/parts/build-step.json index 97d1c763b..6eebb2339 100644 --- a/modules/mesh-delivery-contracts/parts/build-step.json +++ b/modules/mesh-delivery-contracts/parts/build-step.json @@ -2059,6 +2059,42 @@ "fingerprint", "lock" ] + }, + "ImportsReported": { + "type": "object", + "description": "the mesh packages a module's programs import, said by the build module at a build's end (design 47 H2 H-A-517, H-A-532 DQ-2): the import closure without tests, each package by its import path, the union over the module's programs (H-A-518); the indexer keeps it only for the fingerprint main's modules state holds (H-A-532 DMC-2)", + "properties": { + "node": { + "type": "string", + "description": "the node the build ran on" + }, + "module": { + "type": "string", + "description": "the module built" + }, + "fingerprint": { + "type": "string", + "description": "the fingerprint the build was asked for" + }, + "commit": { + "type": "string", + "description": "the commit the build was made from" + }, + "imports": { + "type": "array", + "items": { + "type": "string" + }, + "description": "each mesh package the module's programs import, by its import path; empty when they import none" + } + }, + "required": [ + "node", + "module", + "fingerprint", + "commit", + "imports" + ] } }, "events": [ @@ -2084,6 +2120,17 @@ "max-mib": 16 } }, + { + "name": "imports-reported", + "subject": "imports-reported.", + "body": { + "$ref": "#/defs/ImportsReported" + }, + "keep": { + "max-age-days": 90, + "max-mib": 16 + } + }, { "name": "step-progress", "subject": "step-progress.", @@ -2099,5 +2146,5 @@ } } ], - "form": 3 + "form": 4 } diff --git a/modules/mesh-delivery-contracts/seats/node-build-go/fixtures/events.json b/modules/mesh-delivery-contracts/seats/node-build-go/fixtures/events.json index a874e9bd9..2813c5ffd 100644 --- a/modules/mesh-delivery-contracts/seats/node-build-go/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/node-build-go/fixtures/events.json @@ -72,6 +72,33 @@ "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } }, + { + "name": "a module's import set said at its build's end (design 47 H2 H-A-517)", + "of": "event:imports-reported", + "subject": "mesh.seat.node-build-go.event.imports-reported.anchor", + "given": { + "node": "anchor", + "module": "nats", + "fingerprint": "fp-0123", + "commit": "0123456789abcdef0123456789abcdef01234567", + "imports": [ + "git.novox.be/novox/mesh-sdk/go/bus", + "git.novox.be/novox/mesh-sdk/go/catalogue" + ] + } + }, + { + "name": "a module whose programs import no mesh package says an empty set (H-A-532 DQ-2)", + "of": "event:imports-reported", + "subject": "mesh.seat.node-build-go.event.imports-reported.anchor", + "given": { + "node": "anchor", + "module": "feh", + "fingerprint": "fp-4567", + "commit": "89abcdef0123456789abcdef0123456789abcdef", + "imports": [] + } + }, { "name": "a running ask says its progress", "of": "event:step-progress", diff --git a/modules/mesh-delivery-contracts/seats/node-build-node/fixtures/events.json b/modules/mesh-delivery-contracts/seats/node-build-node/fixtures/events.json index 8525beb23..5ac0b1087 100644 --- a/modules/mesh-delivery-contracts/seats/node-build-node/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/node-build-node/fixtures/events.json @@ -72,6 +72,32 @@ "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } }, + { + "name": "a module's import set said at its build's end (design 47 H2 H-A-517)", + "of": "event:imports-reported", + "subject": "mesh.seat.node-build-node.event.imports-reported.anchor", + "given": { + "node": "anchor", + "module": "nats", + "fingerprint": "fp-0123", + "commit": "0123456789abcdef0123456789abcdef01234567", + "imports": [ + "@novox/mesh-sdk" + ] + } + }, + { + "name": "a module whose programs import no mesh package says an empty set (H-A-532 DQ-2)", + "of": "event:imports-reported", + "subject": "mesh.seat.node-build-node.event.imports-reported.anchor", + "given": { + "node": "anchor", + "module": "feh", + "fingerprint": "fp-4567", + "commit": "89abcdef0123456789abcdef0123456789abcdef", + "imports": [] + } + }, { "name": "a running ask says its progress", "of": "event:step-progress", diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/index.d.ts index 039d741d0..c731d5c24 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/index.d.ts @@ -29,6 +29,7 @@ export declare const accepts: { export declare const events: { readonly stepEnded: "step-ended"; readonly toolchainReported: "toolchain-reported"; + readonly importsReported: "imports-reported"; readonly stepProgress: "step-progress"; readonly askTaken: "ask-taken"; }; @@ -47,6 +48,12 @@ export declare function toolchainReportedSubject(node: string): string; export declare const toolchainReportedSubjectAll: "mesh.seat.node-build-go.event.toolchain-reported.*"; +export declare const importsReportedStream: "SEAT_node-build-go_imports-reported"; + +export declare function importsReportedSubject(node: string): string; + +export declare const importsReportedSubjectAll: "mesh.seat.node-build-go.event.imports-reported.*"; + export declare function stepProgressSubject(node: string): string; export declare const stepProgressSubjectAll: "mesh.seat.node-build-go.event.step-progress.*"; @@ -142,6 +149,8 @@ export type FetchBesideItem = buildStep.FetchBesideItem; export type FetchBuildsItem = buildStep.FetchBuildsItem; export type FetchPackage = buildStep.FetchPackage; export type FetchRefusal = buildStep.FetchRefusal; +export type ImportsReported = buildStep.ImportsReported; +export type ImportsReportedEvent = buildStep.ImportsReportedEvent; export type InstallAsk = buildStep.InstallAsk; export type KeptArtifactAnswer = buildStep.KeptArtifactAnswer; export type KeptArtifactInput = buildStep.KeptArtifactInput; diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/index.js b/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/index.js index 8b89fb011..038451119 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/index.js @@ -27,6 +27,7 @@ export const accepts = { export const events = { stepEnded: "step-ended", toolchainReported: "toolchain-reported", + importsReported: "imports-reported", stepProgress: "step-progress", askTaken: "ask-taken", }; @@ -49,6 +50,14 @@ export function toolchainReportedSubject(node) { export const toolchainReportedSubjectAll = "mesh.seat.node-build-go.event.toolchain-reported.*"; +export const importsReportedStream = "SEAT_node-build-go_imports-reported"; + +export function importsReportedSubject(node) { + return "mesh.seat.node-build-go.event.imports-reported." + node; +} + +export const importsReportedSubjectAll = "mesh.seat.node-build-go.event.imports-reported.*"; + export function stepProgressSubject(node) { return "mesh.seat.node-build-go.event.step-progress." + node; } diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/parts/build-step.d.ts b/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/parts/build-step.d.ts index d6a8207e0..35d3e8e67 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/parts/build-step.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/parts/build-step.d.ts @@ -16,6 +16,7 @@ export declare const verbs: { export declare const events: { readonly stepEnded: "step-ended"; readonly toolchainReported: "toolchain-reported"; + readonly importsReported: "imports-reported"; readonly stepProgress: "step-progress"; readonly askTaken: "ask-taken"; }; @@ -215,6 +216,22 @@ export interface FetchRefusal { "reason": string; } +/** the mesh packages a module's programs import, said by the build module at a build's end (design 47 H2 H-A-517, H-A-532 DQ-2): the import closure without tests, each package by its import path, the union over the module's programs (H-A-518); the indexer keeps it only for the fingerprint main's modules state holds (H-A-532 DMC-2) */ +export interface ImportsReported { + /** the commit the build was made from */ + "commit": string; + /** the fingerprint the build was asked for */ + "fingerprint": string; + /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ + "form"?: number; + /** each mesh package the module's programs import, by its import path; empty when they import none */ + "imports": string[]; + /** the module built */ + "module": string; + /** the node the build ran on */ + "node": string; +} + /** the job of an ask of the kind install (design 47 H2 §800, H-A-367 (4), H-A-403): the npm tree a module's package lock names, installed with an integrity-checked install and no install scripts, and published to the artifact store (the seat oci-artifact-registry) as the module's archive :node-modules under the ask's version, which the builder's reservation covers */ export interface InstallAsk { /** who asked it */ @@ -797,6 +814,9 @@ export type StepEndedEvent = StepEnded; /** is the body of the event toolchain-reported. */ export type ToolchainReportedEvent = ToolchainReported; +/** is the body of the event imports-reported. */ +export type ImportsReportedEvent = ImportsReported; + /** is the body of the event step-progress. */ export type StepProgressEvent = StepProgress; diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/parts/build-step.js b/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/parts/build-step.js index b9d7f08fd..57aa1458d 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/parts/build-step.js +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildgo/parts/build-step.js @@ -16,6 +16,7 @@ export const verbs = { export const events = { stepEnded: "step-ended", toolchainReported: "toolchain-reported", + importsReported: "imports-reported", stepProgress: "step-progress", askTaken: "ask-taken", }; diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/index.d.ts index 4ef94e064..255c55ec3 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/index.d.ts @@ -28,6 +28,7 @@ export declare const accepts: { export declare const events: { readonly stepEnded: "step-ended"; readonly toolchainReported: "toolchain-reported"; + readonly importsReported: "imports-reported"; readonly stepProgress: "step-progress"; readonly askTaken: "ask-taken"; }; @@ -46,6 +47,12 @@ export declare function toolchainReportedSubject(node: string): string; export declare const toolchainReportedSubjectAll: "mesh.seat.node-build-image.event.toolchain-reported.*"; +export declare const importsReportedStream: "SEAT_node-build-image_imports-reported"; + +export declare function importsReportedSubject(node: string): string; + +export declare const importsReportedSubjectAll: "mesh.seat.node-build-image.event.imports-reported.*"; + export declare function stepProgressSubject(node: string): string; export declare const stepProgressSubjectAll: "mesh.seat.node-build-image.event.step-progress.*"; @@ -139,6 +146,8 @@ export type FetchBesideItem = buildStep.FetchBesideItem; export type FetchBuildsItem = buildStep.FetchBuildsItem; export type FetchPackage = buildStep.FetchPackage; export type FetchRefusal = buildStep.FetchRefusal; +export type ImportsReported = buildStep.ImportsReported; +export type ImportsReportedEvent = buildStep.ImportsReportedEvent; export type InstallAsk = buildStep.InstallAsk; export type KeptArtifactAnswer = buildStep.KeptArtifactAnswer; export type KeptArtifactInput = buildStep.KeptArtifactInput; diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/index.js b/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/index.js index 5c4dfbc7b..1e15c6f47 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/index.js @@ -26,6 +26,7 @@ export const accepts = { export const events = { stepEnded: "step-ended", toolchainReported: "toolchain-reported", + importsReported: "imports-reported", stepProgress: "step-progress", askTaken: "ask-taken", }; @@ -48,6 +49,14 @@ export function toolchainReportedSubject(node) { export const toolchainReportedSubjectAll = "mesh.seat.node-build-image.event.toolchain-reported.*"; +export const importsReportedStream = "SEAT_node-build-image_imports-reported"; + +export function importsReportedSubject(node) { + return "mesh.seat.node-build-image.event.imports-reported." + node; +} + +export const importsReportedSubjectAll = "mesh.seat.node-build-image.event.imports-reported.*"; + export function stepProgressSubject(node) { return "mesh.seat.node-build-image.event.step-progress." + node; } diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/parts/build-step.d.ts b/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/parts/build-step.d.ts index d6a8207e0..35d3e8e67 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/parts/build-step.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/parts/build-step.d.ts @@ -16,6 +16,7 @@ export declare const verbs: { export declare const events: { readonly stepEnded: "step-ended"; readonly toolchainReported: "toolchain-reported"; + readonly importsReported: "imports-reported"; readonly stepProgress: "step-progress"; readonly askTaken: "ask-taken"; }; @@ -215,6 +216,22 @@ export interface FetchRefusal { "reason": string; } +/** the mesh packages a module's programs import, said by the build module at a build's end (design 47 H2 H-A-517, H-A-532 DQ-2): the import closure without tests, each package by its import path, the union over the module's programs (H-A-518); the indexer keeps it only for the fingerprint main's modules state holds (H-A-532 DMC-2) */ +export interface ImportsReported { + /** the commit the build was made from */ + "commit": string; + /** the fingerprint the build was asked for */ + "fingerprint": string; + /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ + "form"?: number; + /** each mesh package the module's programs import, by its import path; empty when they import none */ + "imports": string[]; + /** the module built */ + "module": string; + /** the node the build ran on */ + "node": string; +} + /** the job of an ask of the kind install (design 47 H2 §800, H-A-367 (4), H-A-403): the npm tree a module's package lock names, installed with an integrity-checked install and no install scripts, and published to the artifact store (the seat oci-artifact-registry) as the module's archive :node-modules under the ask's version, which the builder's reservation covers */ export interface InstallAsk { /** who asked it */ @@ -797,6 +814,9 @@ export type StepEndedEvent = StepEnded; /** is the body of the event toolchain-reported. */ export type ToolchainReportedEvent = ToolchainReported; +/** is the body of the event imports-reported. */ +export type ImportsReportedEvent = ImportsReported; + /** is the body of the event step-progress. */ export type StepProgressEvent = StepProgress; diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/parts/build-step.js b/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/parts/build-step.js index b9d7f08fd..57aa1458d 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/parts/build-step.js +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildimage/parts/build-step.js @@ -16,6 +16,7 @@ export const verbs = { export const events = { stepEnded: "step-ended", toolchainReported: "toolchain-reported", + importsReported: "imports-reported", stepProgress: "step-progress", askTaken: "ask-taken", }; diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/index.d.ts index fe5f6f723..376e9e229 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/index.d.ts @@ -29,6 +29,7 @@ export declare const accepts: { export declare const events: { readonly stepEnded: "step-ended"; readonly toolchainReported: "toolchain-reported"; + readonly importsReported: "imports-reported"; readonly stepProgress: "step-progress"; readonly askTaken: "ask-taken"; }; @@ -47,6 +48,12 @@ export declare function toolchainReportedSubject(node: string): string; export declare const toolchainReportedSubjectAll: "mesh.seat.node-build-node.event.toolchain-reported.*"; +export declare const importsReportedStream: "SEAT_node-build-node_imports-reported"; + +export declare function importsReportedSubject(node: string): string; + +export declare const importsReportedSubjectAll: "mesh.seat.node-build-node.event.imports-reported.*"; + export declare function stepProgressSubject(node: string): string; export declare const stepProgressSubjectAll: "mesh.seat.node-build-node.event.step-progress.*"; @@ -142,6 +149,8 @@ export type FetchBesideItem = buildStep.FetchBesideItem; export type FetchBuildsItem = buildStep.FetchBuildsItem; export type FetchPackage = buildStep.FetchPackage; export type FetchRefusal = buildStep.FetchRefusal; +export type ImportsReported = buildStep.ImportsReported; +export type ImportsReportedEvent = buildStep.ImportsReportedEvent; export type InstallAsk = buildStep.InstallAsk; export type KeptArtifactAnswer = buildStep.KeptArtifactAnswer; export type KeptArtifactInput = buildStep.KeptArtifactInput; diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/index.js b/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/index.js index d8e6a1fe3..c7abd06c6 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/index.js @@ -27,6 +27,7 @@ export const accepts = { export const events = { stepEnded: "step-ended", toolchainReported: "toolchain-reported", + importsReported: "imports-reported", stepProgress: "step-progress", askTaken: "ask-taken", }; @@ -49,6 +50,14 @@ export function toolchainReportedSubject(node) { export const toolchainReportedSubjectAll = "mesh.seat.node-build-node.event.toolchain-reported.*"; +export const importsReportedStream = "SEAT_node-build-node_imports-reported"; + +export function importsReportedSubject(node) { + return "mesh.seat.node-build-node.event.imports-reported." + node; +} + +export const importsReportedSubjectAll = "mesh.seat.node-build-node.event.imports-reported.*"; + export function stepProgressSubject(node) { return "mesh.seat.node-build-node.event.step-progress." + node; } diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/parts/build-step.d.ts b/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/parts/build-step.d.ts index d6a8207e0..35d3e8e67 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/parts/build-step.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/parts/build-step.d.ts @@ -16,6 +16,7 @@ export declare const verbs: { export declare const events: { readonly stepEnded: "step-ended"; readonly toolchainReported: "toolchain-reported"; + readonly importsReported: "imports-reported"; readonly stepProgress: "step-progress"; readonly askTaken: "ask-taken"; }; @@ -215,6 +216,22 @@ export interface FetchRefusal { "reason": string; } +/** the mesh packages a module's programs import, said by the build module at a build's end (design 47 H2 H-A-517, H-A-532 DQ-2): the import closure without tests, each package by its import path, the union over the module's programs (H-A-518); the indexer keeps it only for the fingerprint main's modules state holds (H-A-532 DMC-2) */ +export interface ImportsReported { + /** the commit the build was made from */ + "commit": string; + /** the fingerprint the build was asked for */ + "fingerprint": string; + /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ + "form"?: number; + /** each mesh package the module's programs import, by its import path; empty when they import none */ + "imports": string[]; + /** the module built */ + "module": string; + /** the node the build ran on */ + "node": string; +} + /** the job of an ask of the kind install (design 47 H2 §800, H-A-367 (4), H-A-403): the npm tree a module's package lock names, installed with an integrity-checked install and no install scripts, and published to the artifact store (the seat oci-artifact-registry) as the module's archive :node-modules under the ask's version, which the builder's reservation covers */ export interface InstallAsk { /** who asked it */ @@ -797,6 +814,9 @@ export type StepEndedEvent = StepEnded; /** is the body of the event toolchain-reported. */ export type ToolchainReportedEvent = ToolchainReported; +/** is the body of the event imports-reported. */ +export type ImportsReportedEvent = ImportsReported; + /** is the body of the event step-progress. */ export type StepProgressEvent = StepProgress; diff --git a/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/parts/build-step.js b/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/parts/build-step.js index b9d7f08fd..57aa1458d 100644 --- a/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/parts/build-step.js +++ b/modules/mesh-delivery-contracts/ts/seats/nodebuildnode/parts/build-step.js @@ -16,6 +16,7 @@ export const verbs = { export const events = { stepEnded: "step-ended", toolchainReported: "toolchain-reported", + importsReported: "imports-reported", stepProgress: "step-progress", askTaken: "ask-taken", }; -- 2.54.0 From 286f2b668d631b11555a1c2a5e92a2c3571a846d Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:02:25 +0100 Subject: [PATCH 02/34] S1: the step runner says a done build's import set as imports-reported AskSteps gains SayImports, called once at the end of a build that read its imports (any branch; the indexer judges the fingerprint), with the module, the fingerprint asked, the commit and the imports; SayImportsOn publishes it on mesh.seat..event.imports-reported. (buildstep.ImportsReportedSubject), id per module and fingerprint. A failed say is journalled and leaves the answer standing; BuildAnswer.Imports stays as the say's input. Builds: design 47 H2 H-A-517, H-A-518, H-A-532 DQ-2, DQ-7, DMC-2 --- .../mesh-delivery-sdk/buildstep/ask_test.go | 7 ++++ .../buildstep/pipelinestep.go | 13 ++++++++ modules/mesh-delivery-sdk/steprun/askrun.go | 26 +++++++++++++++ .../mesh-delivery-sdk/steprun/askrun_test.go | 33 +++++++++++++++++-- modules/mesh-delivery-sdk/steprun/steprun.go | 14 ++++++++ 5 files changed, 90 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-sdk/buildstep/ask_test.go b/modules/mesh-delivery-sdk/buildstep/ask_test.go index f65616775..9b1c9b003 100644 --- a/modules/mesh-delivery-sdk/buildstep/ask_test.go +++ b/modules/mesh-delivery-sdk/buildstep/ask_test.go @@ -368,6 +368,13 @@ func TestAskSubjectsStreamsAndKeys(t *testing.T) { if l, n, err := ParseStepEndedSubject(subj); err != nil || l != AskNode || n != "ace" { t.Errorf("parse %q: %s %s %v", subj, l, n, err) } + // Design 47 H2 H-A-532 DQ-2: a build's import set is said on its own node's subject of the seat. + if s, err := ImportsReportedSubject(AskNode, "ace"); err != nil || s != "mesh.seat.node-build-node.event.imports-reported.ace" { + t.Errorf("imports-reported subject %q %v", s, err) + } + if _, err := ImportsReportedSubject(AskGo, "a.b"); err == nil { + t.Error("an imports-reported subject of a dotted node") + } end, err := EndOf(stepAsk(), "ace", OutcomePassed) if err != nil { t.Fatal(err) diff --git a/modules/mesh-delivery-sdk/buildstep/pipelinestep.go b/modules/mesh-delivery-sdk/buildstep/pipelinestep.go index 275340aab..e1ab5cb7b 100644 --- a/modules/mesh-delivery-sdk/buildstep/pipelinestep.go +++ b/modules/mesh-delivery-sdk/buildstep/pipelinestep.go @@ -337,6 +337,19 @@ func StepEndedSubject(language, node string) (string, error) { return "mesh.seat." + seat + ".event.step-ended." + node, nil } +// ImportsReportedSubject is where the holder of a language's build seat on node says a build's import set, the event +// imports-reported of the part build-step (design 47 H2 H-A-517, H-A-532 DQ-2). +func ImportsReportedSubject(language, node string) (string, error) { + seat, err := BuildSeat(language) + if err != nil { + return "", err + } + if err := checkNode(node); err != nil { + return "", err + } + return "mesh.seat." + seat + ".event.imports-reported." + node, nil +} + // ParseStepEndedSubject is the inverse of StepEndedSubject. func ParseStepEndedSubject(subject string) (language, node string, err error) { rest, ok := strings.CutPrefix(subject, "mesh.seat.node-build-") diff --git a/modules/mesh-delivery-sdk/steprun/askrun.go b/modules/mesh-delivery-sdk/steprun/askrun.go index c0ab6fc7e..28e0977a8 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun.go +++ b/modules/mesh-delivery-sdk/steprun/askrun.go @@ -11,6 +11,7 @@ import ( "sort" "strings" + nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" trunk "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" ) @@ -60,6 +61,11 @@ type AskSteps struct { // event step-ended on that node's subject (sdkstep.StepEndedSubject), under the ask's id. Nil runs no step ask. Node string SayStep func(end sdkstep.StepEnded) error + // SayImports says a build's import set as the seat's event imports-reported on Node's subject (SayImportsOn): a + // build that read its imports says them at its end, whatever its branch, and the indexer keeps the set only for the + // fingerprint main's modules state holds (design 47 H2 H-A-517, H-A-532 DQ-2, DMC-2). A say that fails leaves the + // build's answer standing and is said in the journal. Nil says none. + SayImports func(nodebuildgo.ImportsReported) error // Outputs are the holder's outputs objects (OutputsStore), where a test step keeps its run's output as `.` (design 47 H2 §791, H-A-412), which the seat's verb output reads (OutputTool). Nil keeps none, said in the journal. Outputs OutputObjects @@ -324,10 +330,30 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version strin return nil, err } answer.Imports = read.Imports + s.sayImports(job, read.Imports) } return answer, nil } +// sayImports says the import set a done build read (design 47 H2 H-A-517, H-A-532 DQ-2): the module, the fingerprint +// it was asked for, its commit and the imports, an empty list when its programs import no mesh package. A failed say is +// said in the journal and never fails the build (principle 3: loud, not lost). +func (s AskSteps) sayImports(job sdkstep.BuildJob, imports []string) { + if s.SayImports == nil { + return + } + body := nodebuildgo.ImportsReported{Node: s.Node, Module: job.Module, Fingerprint: job.Fp, Imports: imports} + if job.Fetch != nil { + body.Commit = job.Fetch.Commit + } + if body.Imports == nil { + body.Imports = []string{} + } + if err := s.SayImports(body); err != nil && s.Logf != nil { + s.Logf("the import set of %s at %s was not said: %v", job.Module, job.Fp, err) + } +} + func (s AskSteps) check(ctx context.Context, job sdkstep.CheckJob) (any, error) { return s.checkTexts(ctx, job, nil) } diff --git a/modules/mesh-delivery-sdk/steprun/askrun_test.go b/modules/mesh-delivery-sdk/steprun/askrun_test.go index 8e35229b7..f31d68d7b 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun_test.go +++ b/modules/mesh-delivery-sdk/steprun/askrun_test.go @@ -84,8 +84,19 @@ func TestRunAskBuilds(t *testing.T) { r.calls = append(r.calls, "imports "+string(b)) return map[string]any{"imports": []string{"git.novox.be/novox/mesh-sdk/go/announce", "git.novox.be/novox/mesh-sdk/go/health"}}, nil } + // Design 47 H2 H-A-517, H-A-532 DQ-2: a done build that read its imports says them once, as imports-reported on the + // seat's subject of its node; a failed build says none, and a say that fails leaves the answer standing, journalled. + var said []string + var sayErr error + var journal []string + steps.Node, steps.Logf = "anchor", func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) } + steps.SayImports = SayImportsOn(sdkstep.AskGo, "anchor", func(subject string, body any, id string) error { + b, _ := json.Marshal(body) + said = append(said, subject+" "+id+" "+string(b)) + return sayErr + }) // Issue 1585: the ask's package versions reach the fetch, and the ask's own fetch arguments stay as they were. - a := ask(sdkstep.BuildJob{Module: "m", Path: "modules/m", Publish: true, + a := ask(sdkstep.BuildJob{Module: "m", Path: "modules/m", Publish: true, Fp: "fp-1", Fetch: &sdkstep.Fetch{Repository: "novox/x", Commit: runCommit}, Artifacts: []sdkstep.AskArtifact{{Artifact: "base", From: "registry/b@sha256:00"}, {Artifact: "bundle"}, {Artifact: "lib", Seat: "go-package-registry", Version: "v0.1.15"}}}) a.Packages = sdkstep.PackageVersions{"git.novox.be/novox/mesh-sdk/go": runCommit} @@ -101,8 +112,8 @@ func TestRunAskBuilds(t *testing.T) { got := strings.Join(r.calls, "\n") want := `copy {"artifact":"base","from":"registry/b@sha256:00","module":"m"} fetch {"commit":"` + runCommit + `","packages":{"git.novox.be/novox/mesh-sdk/go":"` + runCommit + `"},"repository":"novox/x"} -build {"artifact":"bundle","module":"modules/m","publish":true,"version":"0.1.16","workspace":"/w/1"} -build {"artifact":"lib","module":"modules/m","publish":true,"seat":"go-package-registry","version":"v0.1.15","workspace":"/w/1"} +build {"artifact":"bundle","fp":"fp-1","module":"modules/m","publish":true,"version":"0.1.16","workspace":"/w/1"} +build {"artifact":"lib","fp":"fp-1","module":"modules/m","publish":true,"seat":"go-package-registry","version":"v0.1.15","workspace":"/w/1"} imports {"module":"modules/m","workspace":"/w/1"}` if got != want { t.Fatalf("calls:\n%s\nwant:\n%s", got, want) @@ -117,6 +128,19 @@ imports {"module":"modules/m","workspace":"/w/1"}` if !slices.Equal(answer.Imports, []string{"git.novox.be/novox/mesh-sdk/go/announce", "git.novox.be/novox/mesh-sdk/go/health"}) { t.Errorf("the answer's imports are %v", answer.Imports) } + wantSaid := `mesh.seat.node-build-go.event.imports-reported.anchor imports-reported.m.fp-1 {"commit":"` + runCommit + + `","fingerprint":"fp-1","imports":["git.novox.be/novox/mesh-sdk/go/announce","git.novox.be/novox/mesh-sdk/go/health"],"module":"m","node":"anchor"}` + if len(said) != 1 || said[0] != wantSaid { + t.Errorf("said %q, want once %q", said, wantSaid) + } + said, sayErr = nil, errors.New("no responders") + if out, err := RunAsk(context.Background(), steps, a); err != nil || len(out.(sdkstep.BuildAnswer).Artifacts) != 3 { + t.Errorf("a failed say failed the build: %v, %v", out, err) + } + if len(said) != 1 || len(journal) != 1 || !strings.Contains(journal[0], "the import set of m at fp-1 was not said: no responders") { + t.Errorf("a failed say: said %q, journal %q; want it said in the journal", said, journal) + } + said, sayErr = nil, nil // Design 47 H2 H-A-482 addendum (a): a failed build keeps its error text, as the build module bounded it, as the ask's // output object, which the verb output answers. @@ -130,6 +154,9 @@ imports {"module":"modules/m","workspace":"/w/1"}` if _, err := RunAsk(context.Background(), steps, failed); err == nil { t.Fatal("a failed build answered no error") } + if len(said) != 0 { + t.Errorf("a failed build said its imports: %q", said) + } got2, err := readOutput(outputs, "ace", failed.ID, nil) if err != nil || !strings.Contains(got2.Output, `bundle: esbuild for code: status 1 | ✘ [ERROR] Could not resolve "./missing"`) || got2.Size != len(got2.Output) { t.Errorf("the failed build's output = %+v, %v; want its error text kept", got2, err) diff --git a/modules/mesh-delivery-sdk/steprun/steprun.go b/modules/mesh-delivery-sdk/steprun/steprun.go index 19c615b4d..3fab08db7 100644 --- a/modules/mesh-delivery-sdk/steprun/steprun.go +++ b/modules/mesh-delivery-sdk/steprun/steprun.go @@ -9,6 +9,7 @@ import ( "strings" "time" + nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" stdio "git.novox.be/novox/mesh-sdk/go" ) @@ -357,6 +358,19 @@ func SayStepOn(language, node string, publish func(subject string, body any, id } } +// SayImportsOn is AskSteps.SayImports on a language's build seat of node: the event imports-reported published with +// publish (stdio.SeatPublish) on sdkstep.ImportsReportedSubject, under an id per module and fingerprint, so a build said +// again is kept once (design 47 H2 H-A-517, H-A-532 DQ-2). +func SayImportsOn(language, node string, publish func(subject string, body any, id string) error) func(nodebuildgo.ImportsReported) error { + return func(r nodebuildgo.ImportsReported) error { + subject, err := sdkstep.ImportsReportedSubject(language, node) + if err != nil { + return err + } + return publish(subject, r, "imports-reported."+r.Module+"."+r.Fingerprint) + } +} + // SayOn is a holder's Puller.Say: an event of the language's build seat published on that seat's subject of node with // publish (stdio.SeatPublish), `mesh.seat.node-build-.event..`. func SayOn(language, node string, publish func(subject string, body any, id string) error) func(event string, body any, id string) error { -- 2.54.0 From e2c3cea04232de8a2fb4bca08aacf925e4860925 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:07:18 +0100 Subject: [PATCH 03/34] I1: the indexer hears imports-reported and keeps each module's import set The indexer consumes node-build-go and node-build-node imports-reported; a report of the fingerprint main's modules state holds for the module keeps the set on the module (Imports, ImportForm, as the build log path did) and in the new state imports (one key per module, {module, fingerprint, commit, imports: [{package, digest}]}, the digests the import form is computed with), deleted with the module's modules key. A report of another fingerprint is left; one naming no module or fingerprint is said and acknowledged. Builds: design 47 H2 H-A-517, H-A-518, H-A-519, H-A-527, H-A-529, H-A-532 DQ-3, DQ-4, DQ-13, DMC-2 --- .../cmd/mesh-delivery-indexer/main.go | 8 ++ .../cmd/mesh-delivery-indexer/versions.go | 22 ++++ modules/mesh-delivery-indexer/go.mod | 1 + .../internal/index/candidates.go | 2 + .../internal/index/imports.go | 60 +++++++--- .../internal/index/imports_test.go | 46 +++++--- .../internal/index/importset.go | 105 ++++++++++++++++++ .../internal/index/modules.go | 3 + .../internal/index/modules_test.go | 7 +- .../mesh-delivery-indexer/manifest_test.go | 5 +- modules/mesh-delivery-indexer/module.json | 3 + 11 files changed, 226 insertions(+), 36 deletions(-) create mode 100644 modules/mesh-delivery-indexer/internal/index/importset.go diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index 801db723f..eef0293aa 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -26,6 +26,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildnode" "git.novox.be/novox/mesh-sdk/go/buscalls" "github.com/nats-io/nats.go" "github.com/nats-io/nats.go/jetstream" @@ -378,6 +379,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro BuildEdges: awaitedStore{b: process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.BuildEdgesState), "no build of another watched branch keeps its edges", logger.Printf)}, Pins: pinsStore, PinsPending: pendingOf(js, cred), Held: awaitedStore{b: process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.HeldState), "no held take-in is kept, so indexer_pending reads none", logger.Printf)}, + Imports: awaitedStore{b: process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.ImportsState), "no import set is kept, so every module keeps the version line", logger.Printf)}, Inputs: inputsStore, InputObjects: inObjects, SayVersionReleased: sayVersionReleased(conn, cred), SayVersionsFilled: sayVersionsFilled(conn, cred), @@ -631,6 +633,12 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if err := hub.Handle(nodebuildgo.SubjectStepEndedAll, func(m jetstream.Msg) { heardStepEnded(ctx, ix, m, logger.Printf) }); err != nil { return err } + // A build's import set, said by its build module at its end (design 47 H2 H-A-517, H-A-532 DQ-2). + for _, subject := range []string{nodebuildgo.SubjectImportsReportedAll, nodebuildnode.SubjectImportsReportedAll} { + if err := hub.Handle(subject, func(m jetstream.Msg) { heardImportsReported(ctx, ix, m, logger.Printf) }); err != nil { + return err + } + } if err := hub.Handle(decidedSubject(cred.Module), func(m jetstream.Msg) { heardDecided(ctx, registry, m, logger.Printf) }); err != nil { return err } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go index fa9a746b2..af3069a1f 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "errors" "fmt" "strings" "sync/atomic" @@ -179,6 +180,27 @@ func heardStepEnded(ctx context.Context, ix *index.Indexer, m jetstream.Msg, log _ = m.Ack() } +// heardImportsReported keeps a build's import set (design 47 H2 H-A-517, H-A-527): one that does not decode, or names no +// module or fingerprint, is said and acknowledged; one that cannot be kept is left, so the bus gives it again. +func heardImportsReported(ctx context.Context, ix *index.Indexer, m jetstream.Msg, logf func(string, ...any)) { + var e nodebuildgo.ImportsReported + if err := json.Unmarshal(m.Data(), &e); err != nil { + logf("%s holds what is no imports-reported, left: %v", m.Subject(), err) + _ = m.Ack() + return + } + err := ix.HearImportsReported(ctx, e) + switch { + case errors.Is(err, index.ErrImportsUnreadable): + logf("%s: %v, left", m.Subject(), err) + case err != nil: + logf("imports: the import set of %s at %s could not be kept, so the bus gives it again: %v", e.Module, e.Fingerprint, err) + leftForBus(m, fmt.Sprintf("the imports-reported of %s at %s", e.Module, e.Fingerprint), err, logf) + return + } + _ = m.Ack() +} + // sayVersionsFilled says versions-filled (design 47 G §372) once, on the seat's stream that keeps it with no age limit. func sayVersionsFilled(conn *nats.Conn, cred process.Account) func(context.Context, meshcatalog.VersionsFilledEvent, string) error { return func(_ context.Context, e meshcatalog.VersionsFilledEvent, id string) error { diff --git a/modules/mesh-delivery-indexer/go.mod b/modules/mesh-delivery-indexer/go.mod index 956577d21..dcf518af7 100644 --- a/modules/mesh-delivery-indexer/go.mod +++ b/modules/mesh-delivery-indexer/go.mod @@ -17,6 +17,7 @@ require ( git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo v0.0.0-00010101000000-000000000000 + git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildnode v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/npmpackageregistry v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 github.com/nats-io/nats-server/v2 v2.11.17 diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index 42e39d950..dec560fb4 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -187,6 +187,8 @@ type Indexer struct { SayTakeIn func(ctx context.Context, event, id string, body any) error // Held is the state held: each watched branch's source-moved held unacknowledged (held.go, design 47 H §744); nil keeps none. Held Store + // Imports is the state imports: each module's reported import set (importset.go, design 47 H2 H-A-527); nil keeps none. + Imports Store // Runs is the state runs: the runs on request the indexer holds a candidate for (runcandidates.go, A-174); nil keeps none. Runs Store runMu sync.Mutex // one run event at a time (runcandidates.go) diff --git a/modules/mesh-delivery-indexer/internal/index/imports.go b/modules/mesh-delivery-indexer/internal/index/imports.go index bf8bb1cfb..06a034458 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports.go +++ b/modules/mesh-delivery-indexer/internal/index/imports.go @@ -76,7 +76,24 @@ func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) (bool, error if e.Event != builds.BuildEndedEvent || e.Outcome != builds.BuildDone || len(e.Imports) == 0 || ix.Modules == nil || e.FP == "" { return false, nil } - key, err := meshcatalogclient.ModulesKey(e.Module) + return ix.keepImports(ctx, reported{module: e.Module, fp: e.FP, commit: e.Commit, imports: e.Imports}) +} + +// reported is one build's import set as its build module reported it (design 47 H2 H-A-517): the module, the +// fingerprint built, its commit and the imported mesh packages by import path. +type reported struct { + module, fp, commit string + imports []string +} + +// keepImports keeps the import set e on its module when e's fingerprint is the one main's modules state holds for it +// (H-A-532 DMC-2), with ImportForm, and writes it with each package's digest into the state imports (H-A-527, DQ-3, +// DQ-4: the digests the import form is computed with). It reports whether it wrote the module. +func (ix *Indexer) keepImports(ctx context.Context, e reported) (bool, error) { + if ix.Modules == nil || e.fp == "" { + return false, nil + } + key, err := meshcatalogclient.ModulesKey(e.module) if err != nil { return false, nil } @@ -87,10 +104,10 @@ func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) (bool, error return false, err } cur, err := meshcatalogclient.DecodeModule(raw) - if err != nil || cur.Fp2 != e.FP || cur.Inputs2 == nil || cur.Manifest == "" { + if err != nil || cur.Fp2 != e.fp || cur.Inputs2 == nil || cur.Manifest == "" { return false, nil // a build of a fingerprint the module no longer holds says nothing of its inputs now } - if slices.Equal(cur.Inputs2.Imports, e.Imports) && cur.Inputs2.ImportForm != "" { + if slices.Equal(cur.Inputs2.Imports, e.imports) && cur.Inputs2.ImportForm != "" && ix.importSetHeld(ctx, key, e) { return false, nil } _, m, err := ix.manifestRaw(ctx, cur.Manifest) @@ -101,20 +118,21 @@ func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) (bool, error for artifact, language := range languagesOf(m) { used, ok := cur.Toolchains[language] if !ok { - ix.logf("%s: its fingerprint names no %s toolchain, so the imports of its build are not kept", e.Module, language) + ix.logf("%s: its fingerprint names no %s toolchain, so the imports of its build are not kept", e.module, language) return false, nil } toolchains[artifact] = meshcatalogclient.Toolchain2{Language: language, Version: used.Version, Recipe: used.Recipe} } kept := *cur.Inputs2 - kept.Imports, kept.ImportForm = slices.Clone(e.Imports), "" + kept.Imports, kept.ImportForm = slices.Clone(e.imports), "" + digests := map[string]string{} if built, err := ix.publishedAsBuilt(ctx, cur, e); err != nil { - ix.logf("%s: the packages its build imported cannot be read as built (%v): its imports are kept, and its next recompute writes the import form", e.Module, err) - } else if r := fingerprint.Resolve(cur.Repository, e.Imports, built); len(r.Missing) > 0 { - ix.logf("%s: no published package holds %v: its imports are kept, and the recompute that resolves them writes the import form", e.Module, r.Missing) + ix.logf("%s: the packages its build imported cannot be read as built (%v): its imports are kept, and its next recompute writes the import form", e.module, err) + } else if r := fingerprint.Resolve(cur.Repository, e.imports, built); len(r.Missing) > 0 { + ix.logf("%s: no published package holds %v: its imports are kept, and the recompute that resolves them writes the import form", e.module, r.Missing) } else { - in := inputsFrom(e.Module, kept, toolchains) - in.Imports, in.Requires = r.Digests, r.Requires + in := inputsFrom(e.module, kept, toolchains) + in.Imports, in.Requires, digests = r.Digests, r.Requires, r.Digests if fp, _ := fingerprint.Of(in); fp != "" { kept.ImportForm = fp } @@ -126,7 +144,7 @@ func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) (bool, error return nil, false, nil } now, err := meshcatalogclient.DecodeModule(value) - if err != nil || now.Fp2 != e.FP || now.Manifest != cur.Manifest || now.Inputs2 == nil { + if err != nil || now.Fp2 != e.fp || now.Manifest != cur.Manifest || now.Inputs2 == nil { return nil, false, nil } in := *now.Inputs2 @@ -136,16 +154,22 @@ func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) (bool, error wrote = err == nil && !unchanged(data, false, value, found) return data, false, err }) - return wrote && err == nil, err + if err != nil { + return false, err + } + if err := ix.writeImportSet(ctx, key, e, digests); err != nil { + return wrote, err + } + return wrote, nil } // publishedAsBuilt are the published Go modules holding the imports of build e of module cur, each as the build took // it: a module of the built module's own repository at the commit built, one of another repository at the version the // module's fingerprint pins (cur.Packages), else its latest published version. A module whose published commit is the // one built is taken from the packages state; any other is read from the forge's listing at that commit. -func (ix *Indexer) publishedAsBuilt(ctx context.Context, cur meshcatalog.ModulesByModuleValue, e builds.BuildLogEntry) (map[string]meshcatalog.PackagesByModuleValue, error) { +func (ix *Indexer) publishedAsBuilt(ctx context.Context, cur meshcatalog.ModulesByModuleValue, e reported) (map[string]meshcatalog.PackagesByModuleValue, error) { published := ix.publishedAll(ctx) - if r := fingerprint.Resolve(cur.Repository, e.Imports, published); len(r.Missing) > 0 { + if r := fingerprint.Resolve(cur.Repository, e.imports, published); len(r.Missing) > 0 { if err := ix.FillPackages(ctx); err != nil { return nil, err } @@ -161,14 +185,14 @@ func (ix *Indexer) publishedAsBuilt(ctx context.Context, cur meshcatalog.Modules type at struct{ repository, commit string } reread := map[at][]string{} var asVersion map[string]meshcatalog.PackagesByModuleValue - for _, imp := range e.Imports { + for _, imp := range e.imports { r := fingerprint.Resolve(cur.Repository, []string{imp}, published) for mod := range r.Requires { p := published[mod] commit := p.Commit switch pin := cur.Packages[mod]; { - case trunk.SameRepository(p.Repository, cur.Repository) && e.Commit != "": - commit = e.Commit + case trunk.SameRepository(p.Repository, cur.Repository) && e.commit != "": + commit = e.commit case strings.HasPrefix(pin, "v"): if c, ok := byVersion[mod+"@"+pin]; ok { if asVersion == nil { @@ -176,7 +200,7 @@ func (ix *Indexer) publishedAsBuilt(ctx context.Context, cur meshcatalog.Modules } c.Commit, asVersion[mod] = pin, c } else { - ix.logf("%s: the version %s of %s it was pinned to is no series' newest any more, so its imports are read at the latest published commit", e.Module, pin, mod) + ix.logf("%s: the version %s of %s it was pinned to is no series' newest any more, so its imports are read at the latest published commit", e.module, pin, mod) } case pin != "": commit = pin diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index 762b8bbd9..bc4df00a8 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -5,11 +5,10 @@ import ( "errors" "strings" "testing" - "time" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" "git.novox.be/novox/mesh-sdk/go/process" "mesh-delivery-indexer/internal/fingerprint" @@ -61,7 +60,7 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") listings := forge{c1: sdkFiles("a1", "b1"), c2: sdkFiles("a1", "b2"), c3: sdkFiles("a2", "b2")} - ix.Packages, ix.Files = newMem(), listings.files + ix.Packages, ix.Files, ix.Imports = newMem(), listings.files, newMem() // avahi's go.sum names mesh-sdk (the version line), as every Go module's does; mesh-sdk's module is held at c1. setPackages(t, mods, "avahi", []string{meshSDK}) sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) @@ -87,7 +86,7 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T // The build of that fingerprint ends, reporting its imports: kept, and the fingerprint does not move. end := buildEnd(t, "avahi", before.Fp2, meshSDK, meshSDK+"/announce") - if err := ix.ApplyBuildEnd(ctx, end); err != nil { + if err := ix.HearImportsReported(ctx, end); err != nil { t.Fatal(err) } if err := ix.Recompute(ctx); err != nil { @@ -98,6 +97,11 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T t.Fatalf("after the build's imports: fp2 %q (was %q), imports %v, import form %q; want the same fingerprint and the imports kept", after.Fp2, before.Fp2, after.Inputs2.Imports, after.Inputs2.ImportForm) } + // Design 47 H2 H-A-527, H-A-532 DQ-3, DQ-4: the set is kept in the state imports with each package's digest at that build. + if set, found, err := ix.ImportSetOf(ctx, "avahi"); err != nil || !found || set.Fingerprint != before.Fp2 || set.Commit != cat1 || len(set.Imports) != 2 || + set.Imports[0].Package != meshSDK || set.Imports[0].Digest != digestIn(pub, meshSDK) || set.Imports[1].Digest != digestIn(pub, meshSDK+"/announce") || set.Imports[1].Digest == "" { + t.Fatalf("imports.avahi = %+v, %v, %v; want the set at %s with each package's published digest %v", set, found, err, before.Fp2, pub.Packages) + } // mesh-sdk merges a change of buildstep only: avahi does not import it. held, _ = ix.heldModules(ctx) @@ -159,13 +163,21 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T func buildOfAnOlderFingerprintKeepsNoImports(t *testing.T) { ctx := context.Background() ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) + ix.Imports = newMem() reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") - if err := ix.ApplyBuildEnd(ctx, buildEnd(t, "avahi", "src2:"+strings.Repeat("e", 64), meshSDK)); err != nil { + if err := ix.HearImportsReported(ctx, buildEnd(t, "avahi", "src2:"+strings.Repeat("e", 64), meshSDK)); err != nil { t.Fatal(err) } if m, _ := moduleOf(t, mods, "avahi"); m.Inputs2 == nil || len(m.Inputs2.Imports) != 0 { t.Fatalf("imports %v kept from a build of another fingerprint", m.Inputs2) } + if _, found, _ := ix.ImportSetOf(ctx, "avahi"); found { + t.Fatal("imports.avahi kept from a build of another fingerprint (H-A-519)") + } + // A report naming no module or fingerprint is unreadable: said and acknowledged, never kept (principle 3). + if err := ix.HearImportsReported(ctx, buildEnd(t, "avahi", "", meshSDK)); !errors.Is(err, ErrImportsUnreadable) { + t.Fatalf("a report with no fingerprint: %v, want ErrImportsUnreadable", err) + } } // Review finding 2 (ADR 0593 §2 "never left stale", §3): avahi, with no reported import set, replaces a mesh Go module @@ -222,15 +234,19 @@ func aSiblingDirectoryAloneMovesItsImporter(t *testing.T) { } } -func buildEnd(t *testing.T, module, fp string, imports ...string) []byte { - t.Helper() - raw, err := builds.EncodeBuildLogEntry(builds.BuildLogEntry{Event: builds.BuildEndedEvent, Module: module, FP: fp, - Repository: catalogueRepo, Directory: "modules/" + module, Commit: cat1, Ref: "main", Node: "n1", At: time.Now(), - Outcome: builds.BuildDone, Imports: imports}) - if err != nil { - t.Fatal(err) +// digestIn is the published digest of package pkg in p. +func digestIn(p meshcatalog.PackagesByModuleValue, pkg string) string { + for _, d := range p.Packages { + if d.Package == pkg { + return d.Digest + } } - return raw + return "" +} + +func buildEnd(t *testing.T, module, fp string, imports ...string) nodebuildgo.ImportsReported { + t.Helper() + return nodebuildgo.ImportsReported{Node: "n1", Module: module, Fingerprint: fp, Commit: cat1, Imports: imports} } // setPackages writes a module's version-line packages, as a merge reading its go.sum keeps them. @@ -291,7 +307,7 @@ func anAcceptedSeriesPinsItsNewest(t *testing.T) { t.Fatalf("with no series published, versions %v, want mesh-sdk kept with no pin, never the commit (H-A-161)", before.Packages) } step("the build reports its imports", func() error { - return ix.ApplyBuildEnd(ctx, buildEnd(t, "avahi", before.Fp2, meshSDK, meshSDK+"/announce")) + return ix.HearImportsReported(ctx, buildEnd(t, "avahi", before.Fp2, meshSDK, meshSDK+"/announce")) }) pinned := step("0.1.15 published from c3", hear("0.1.15", c3)) if pinned.Fp2 == before.Fp2 || pinned.Packages[meshSDK] != "v0.1.15" { @@ -337,7 +353,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * t.Fatal(err) } first, _ := moduleOf(t, mods, "avahi") - if err := ix.ApplyBuildEnd(ctx, buildEnd(t, "avahi", first.Fp2, meshSDK, meshSDK+"/announce")); err != nil { + if err := ix.HearImportsReported(ctx, buildEnd(t, "avahi", first.Fp2, meshSDK, meshSDK+"/announce")); err != nil { t.Fatal(err) } held, _ = ix.heldModules(ctx) diff --git a/modules/mesh-delivery-indexer/internal/index/importset.go b/modules/mesh-delivery-indexer/internal/index/importset.go new file mode 100644 index 000000000..7073ceecd --- /dev/null +++ b/modules/mesh-delivery-indexer/internal/index/importset.go @@ -0,0 +1,105 @@ +package index + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "slices" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" +) + +// ImportsState is the indexer's state imports (design 47 H2 H-A-527, H-A-532 DQ-3): one key per module, the module's +// modules key, holding the import set main's last build of the module reported (H-A-517, H-A-519) with each package's +// digest at that build (DQ-4). It is written only when an imports-reported is kept, and its key is deleted with the +// module's modules key; the tool indexer_imports reads it. +const ImportsState = "imports" + +// ImportSet is a value of the state imports: the module, the fingerprint and commit of the build that reported the set, +// and each imported mesh package with its digest; a package no published module held when it was kept has none. +type ImportSet struct { + Module string `json:"module"` + Fingerprint string `json:"fingerprint"` + Commit string `json:"commit"` + Imports []ImportedPackage `json:"imports"` +} + +// ImportedPackage is one package of an import set, by import path, with its digest. +type ImportedPackage struct { + Package string `json:"package"` + Digest string `json:"digest,omitempty"` +} + +// ErrImportsUnreadable says an imports-reported does not fit its shape: the message is said and acknowledged, never +// given again. +var ErrImportsUnreadable = errors.New("not an imports-reported the indexer can keep") + +// HearImportsReported keeps the import set a build module reported at a build's end (design 47 H2 H-A-517), when its +// fingerprint is the one main's modules state holds for the module (H-A-532 DMC-2); one of a fingerprint the module no +// longer holds is left (H-A-519). A body naming no module or fingerprint is ErrImportsUnreadable. +func (ix *Indexer) HearImportsReported(ctx context.Context, e nodebuildgo.ImportsReported) error { + if e.Module == "" || e.Fingerprint == "" { + return fmt.Errorf("%w: it names no module or no fingerprint", ErrImportsUnreadable) + } + _, err := ix.keepImports(ctx, reported{module: e.Module, fp: e.Fingerprint, commit: e.Commit, imports: slices.Clone(e.Imports)}) + return err +} + +// ImportSetOf is the import set the state imports keeps for the module key; found is false when it keeps none. +func (ix *Indexer) ImportSetOf(ctx context.Context, key string) (set ImportSet, found bool, err error) { + if ix.Imports == nil { + return ImportSet{}, false, nil + } + v, _, found, err := ix.Imports.Get(ctx, key) + if err != nil || !found { + return ImportSet{}, false, err + } + if err := json.Unmarshal(v, &set); err != nil { + return ImportSet{}, false, fmt.Errorf("%s.%s is not an import set: %w", ImportsState, key, err) + } + return set, true, nil +} + +// importSetHeld says whether the state imports already holds e for key, the same fingerprint and packages; a store that +// keeps none holds it, so nothing is written for it. +func (ix *Indexer) importSetHeld(ctx context.Context, key string, e reported) bool { + if ix.Imports == nil { + return true + } + set, found, err := ix.ImportSetOf(ctx, key) + if err != nil || !found || set.Fingerprint != e.fp { + return false + } + return slices.EqualFunc(set.Imports, e.imports, func(p ImportedPackage, imp string) bool { return p.Package == imp }) +} + +// writeImportSet writes e with its packages' digests into the state imports at key. +func (ix *Indexer) writeImportSet(ctx context.Context, key string, e reported, digests map[string]string) error { + if ix.Imports == nil { + return nil + } + set := ImportSet{Module: e.module, Fingerprint: e.fp, Commit: e.commit, Imports: []ImportedPackage{}} + for _, imp := range e.imports { + set.Imports = append(set.Imports, ImportedPackage{Package: imp, Digest: digests[imp]}) + } + data, err := json.Marshal(set) + if err != nil { + return err + } + if err := write(ctx, ix.Imports, key, func([]byte, bool) ([]byte, bool, error) { return data, false, nil }); err != nil { + return fmt.Errorf("%s.%s: %w", ImportsState, key, err) + } + return nil +} + +// dropImportSet deletes the module key's import set, as its modules key is deleted (H-A-532 DQ-3). +func (ix *Indexer) dropImportSet(ctx context.Context, key string) error { + if ix.Imports == nil { + return nil + } + if err := write(ctx, ix.Imports, key, func(_ []byte, found bool) ([]byte, bool, error) { return nil, found, nil }); err != nil { + return fmt.Errorf("%s.%s: %w", ImportsState, key, err) + } + return nil +} diff --git a/modules/mesh-delivery-indexer/internal/index/modules.go b/modules/mesh-delivery-indexer/internal/index/modules.go index 60321160f..7547cf191 100644 --- a/modules/mesh-delivery-indexer/internal/index/modules.go +++ b/modules/mesh-delivery-indexer/internal/index/modules.go @@ -276,6 +276,9 @@ func (ix *Indexer) dropRemoved(ctx context.Context, repository string, held map[ return fmt.Errorf("modules.%s: %w", key, err) } ix.logf("modules.%s deleted: %s holds no module of that name at its trunk (issue 1900)", key, repository) + if err := ix.dropImportSet(ctx, key); err != nil { + return err + } } for _, key := range handed { if err := ix.handOver(ctx, key); err != nil { diff --git a/modules/mesh-delivery-indexer/internal/index/modules_test.go b/modules/mesh-delivery-indexer/internal/index/modules_test.go index d765110e7..4851c23cd 100644 --- a/modules/mesh-delivery-indexer/internal/index/modules_test.go +++ b/modules/mesh-delivery-indexer/internal/index/modules_test.go @@ -511,7 +511,8 @@ func TestAModuleMovesBetweenRepositoriesOnlyWhenItsTrunkDropsIt(t *testing.T) { } { t.Run(tc.name, func(t *testing.T) { mods := &deletesSeen{memStore: newMem()} - ix := &Indexer{Module: testSelf, Store: newMem(), Modules: mods, Builds: NewBuilds()} + ix := &Indexer{Module: testSelf, Store: newMem(), Modules: mods, Builds: NewBuilds(), Imports: newMem()} + ix.Imports.(*memStore).put("a", []byte(`{"module":"a","fingerprint":"f","commit":"c","imports":[]}`)) var logs []string ix.Logf = func(format string, args ...any) { logs = append(logs, format) } if tc.heads { @@ -547,6 +548,10 @@ func TestAModuleMovesBetweenRepositoriesOnlyWhenItsTrunkDropsIt(t *testing.T) { if deleted := slices.Contains(mods.deleted, "a"); deleted != tc.deletedKeyA { t.Errorf("modules.a deleted %v, want %v", deleted, tc.deletedKeyA) } + // Design 47 H2 H-A-532 DQ-3: the module's import set goes with its modules key. + if _, kept, _ := ix.ImportSetOf(context.Background(), "a"); kept == tc.deletedKeyA { + t.Errorf("imports.a kept %v, want %v", kept, !tc.deletedKeyA) + } if _, ok := mods.vals["b"]; ok == tc.bGoneAtEnd { t.Errorf("modules.b held %v, want %v", ok, !tc.bGoneAtEnd) } diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index 92d68c246..ff72ef942 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -149,7 +149,8 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build {Name: index.RequirementsState, History: 5, MaxMiB: 8}, {Name: index.SeatDefinitionsState, History: 5, MaxMiB: 32}, {Name: index.EntryIndexState, History: 1, MaxMiB: 8}, {Name: index.NamedState, History: 1, MaxMiB: 4}, // design 47 G §695 {Name: index.RegistrationsState, History: 1, MaxMiB: 8}, {Name: index.ProposalsState, History: 1, MaxMiB: 4}, - {Name: index.VersionsState, History: 1, MaxMiB: 64}, {Name: index.BuildEdgesState, History: 1, MaxMiB: 8}, {Name: index.InputsState, History: 1, MaxMiB: 8}, {Name: index.PinsState, History: 1, MaxMiB: index.PinsCapMiB}, {Name: index.HeldState, History: 1, MaxMiB: 8}, + {Name: index.VersionsState, History: 1, MaxMiB: 64}, {Name: index.BuildEdgesState, History: 1, MaxMiB: 8}, {Name: index.InputsState, History: 1, MaxMiB: 8}, {Name: index.PinsState, History: 1, MaxMiB: index.PinsCapMiB}, {Name: index.HeldState, History: 1, MaxMiB: 8}, {Name: index.ImportsState, History: 1, MaxMiB: 8}, // H-A-532 DQ-3 + {Name: index.DryRunsState, History: 1, TTL: 3600, MaxMiB: 16}}; !reflect.DeepEqual(m.State, want) { // DLV-I7, DLV-I17; design 47 H2 §804, §820 t.Errorf("state = %+v, want %+v", m.State, want) } @@ -186,7 +187,7 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build // internal/broker/state.go:62-93). // The registry seats' published fill each (§413: no consume of version.numbered) package's series (DLV-I5, design 51 *The versions*). if want := []string{"go-package-registry.published", "mesh-build-go.toolchain.reported", "mesh-build-node.toolchain.reported", "mesh-builds.package-published", "mesh-builds.step-ended", "mesh-builds.toolchain-agreed", "mesh-builds.version-reserved", "mesh-catalog.catalog-revision", "mesh-catalog.registration-changed", "mesh-catalog.room", "mesh-conditions.findings-asked", - "mesh-delivery.source-moved", "mesh-pipeline-runner.pipeline-ended", "mesh-pipeline-runner.pipeline-started", "mesh-pipeline-runner.run-started", "mesh-wants.pipeline-wanted", "mesh-wants.wait-ended", "mesh-wants.wanted", "node-build-go.step-ended", "node-engine.running", "npm-package-registry.published", "operator-channel.decided", "seat:mesh-module-assigner.views.assignments", "seat:mesh-module-assigner.views.seat-holders"}; !reflect.DeepEqual(sorted(m.Consumes), want) { + "mesh-delivery.source-moved", "mesh-pipeline-runner.pipeline-ended", "mesh-pipeline-runner.pipeline-started", "mesh-pipeline-runner.run-started", "mesh-wants.pipeline-wanted", "mesh-wants.wait-ended", "mesh-wants.wanted", "node-build-go.imports-reported", "node-build-go.step-ended", "node-build-node.imports-reported", "node-engine.running", "npm-package-registry.published", "operator-channel.decided", "seat:mesh-module-assigner.views.assignments", "seat:mesh-module-assigner.views.seat-holders"}; !reflect.DeepEqual(sorted(m.Consumes), want) { t.Errorf("consumes = %v, want %v", m.Consumes, want) } if b, ok := m.OwnSecrets["broker"]; !ok || len(m.OwnSecrets) != 1 || b != "${dir:state}/broker" { diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index d7f1bbac5..f8104a980 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -88,6 +88,8 @@ "mesh-builds.step-ended", "mesh-builds.toolchain-agreed", "node-build-go.step-ended", + "node-build-go.imports-reported", + "node-build-node.imports-reported", "mesh-wants.wait-ended", "mesh-catalog.catalog-revision", "mesh-catalog.registration-changed", @@ -170,6 +172,7 @@ { "name": "inputs", "history": 1, "max-mib": 8 }, { "name": "pins", "history": 1, "max-mib": 4 }, { "name": "held", "history": 1, "max-mib": 8 }, + { "name": "imports", "history": 1, "max-mib": 8 }, { "name": "dry-runs", "history": 1, "ttl-seconds": 3600, "max-mib": 16 } ], "streams": [ -- 2.54.0 From b89a65fde6ea97d85545f7efe404114be677826f Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:08:22 +0100 Subject: [PATCH 04/34] I2: indexer_imports reads one module's import set The tool answers the set the state imports keeps for a module, each package with its digest and the reporting build's fingerprint and commit, or that none is kept, so the module moves by its go.mod's requirements. Builds: design 47 H2 H-A-527, H-A-528, H-A-532 DQ-3 --- .../cmd/mesh-delivery-indexer-tools/main.go | 3 +- .../internal/index/imports_test.go | 8 +++++ .../internal/index/importset.go | 33 +++++++++++++++++++ .../mesh-delivery-indexer/manifest_test.go | 4 +-- modules/mesh-delivery-indexer/module.json | 1 + 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go index 6f7f219d9..d0abc2afe 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go @@ -232,7 +232,8 @@ func main() { return err }, 10*time.Second)...) tools = append(tools, configReadersTool(watched, trunk.State("modules")), busStateTool(trunk.State), requirementsTool(keptSource), - packageUsersTool(trunk.State), seatDefinitionTool(keptSource), outOfStepTool(os.Getenv(stdio.ServedAs), keptSource)) + packageUsersTool(trunk.State), seatDefinitionTool(keptSource), outOfStepTool(os.Getenv(stdio.ServedAs), keptSource), + index.ImportsReadTool(keptRead{stdio.State(index.ImportsState)})) if err := stdio.Serve("", tools); err != nil { fmt.Fprintf(os.Stderr, "[mesh-delivery-indexer-tools] %v\n", err) os.Exit(1) diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index bc4df00a8..f876d59a9 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -102,6 +102,14 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T set.Imports[0].Package != meshSDK || set.Imports[0].Digest != digestIn(pub, meshSDK) || set.Imports[1].Digest != digestIn(pub, meshSDK+"/announce") || set.Imports[1].Digest == "" { t.Fatalf("imports.avahi = %+v, %v, %v; want the set at %s with each package's published digest %v", set, found, err, before.Fp2, pub.Packages) } + // H-A-527: indexer_imports reads it for one module, and says so of a module with none. + tool := ImportsReadTool(ix.Imports) + if got, err := tool.Run(map[string]any{"module": "avahi"}); err != nil || got.(map[string]any)["kept"] != true || got.(map[string]any)["set"].(ImportSet).Fingerprint != before.Fp2 { + t.Fatalf("indexer_imports avahi = %+v, %v; want the kept set", got, err) + } + if got, err := tool.Run(map[string]any{"module": "feh"}); err != nil || got.(map[string]any)["kept"] != false || !strings.Contains(got.(map[string]any)["said"].(string), "go.mod's requirements") { + t.Fatalf("indexer_imports feh = %+v, %v; want none kept, said", got, err) + } // mesh-sdk merges a change of buildstep only: avahi does not import it. held, _ = ix.heldModules(ctx) diff --git a/modules/mesh-delivery-indexer/internal/index/importset.go b/modules/mesh-delivery-indexer/internal/index/importset.go index 7073ceecd..50c261db8 100644 --- a/modules/mesh-delivery-indexer/internal/index/importset.go +++ b/modules/mesh-delivery-indexer/internal/index/importset.go @@ -7,7 +7,9 @@ import ( "fmt" "slices" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" + stdio "git.novox.be/novox/mesh-sdk/go" ) // ImportsState is the indexer's state imports (design 47 H2 H-A-527, H-A-532 DQ-3): one key per module, the module's @@ -16,6 +18,9 @@ import ( // module's modules key; the tool indexer_imports reads it. const ImportsState = "imports" +// ImportsTool reads one module's import set (H-A-527, H-A-532 DQ-3). +const ImportsTool = "indexer_imports" + // ImportSet is a value of the state imports: the module, the fingerprint and commit of the build that reported the set, // and each imported mesh package with its digest; a package no published module held when it was kept has none. type ImportSet struct { @@ -103,3 +108,31 @@ func (ix *Indexer) dropImportSet(ctx context.Context, key string) error { } return nil } + +// ImportsReadTool is indexer_imports (H-A-527): one module's import set from the state imports, each package with its +// digest and the fingerprint and commit of the build that reported it, or that none is kept, so it moves by its go.mod's +// requirements (H-A-528). +func ImportsReadTool(st Store) stdio.Tool { + return stdio.Tool{Name: ImportsTool, + Description: "One module's import set: the mesh packages its programs import, as the build of main's fingerprint reported " + + "them, each with its digest at that build, and that build's fingerprint and commit (design 47 H2 H-A-527); a module " + + "with none kept moves by its go.mod's requirements until its first report (H-A-528).", + Input: map[string]any{"type": "object", "required": []string{"module"}, "properties": map[string]any{ + "module": map[string]any{"type": "string", "description": "the module, such as avahi"}}}, + Run: func(args map[string]any) (any, error) { + module, _ := args["module"].(string) + key, err := meshcatalogclient.ModulesKey(module) + if module == "" || err != nil { + return nil, fmt.Errorf("%s names a module: %q is none", ImportsTool, module) + } + set, found, err := (&Indexer{Imports: st}).ImportSetOf(context.Background(), key) + if err != nil { + return nil, fmt.Errorf("the state %s cannot be read: %w", ImportsState, err) + } + if !found { + return map[string]any{"module": module, "kept": false, + "said": "no import set is kept for " + module + ": it moves by its go.mod's requirements until its first report"}, nil + } + return map[string]any{"module": module, "kept": true, "set": set}, nil + }} +} diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index ff72ef942..6ee02a8ff 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -215,7 +215,7 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build t.Errorf("%s answers the state %s, which the views family does not say", v.Tool, v.State) } } - want = append(want, "indexer_first_views", "indexer_first_view_again", index.ConfigReadersTool, index.BusStateTool, index.RequirementsTool, index.PackageUsersTool, // DLV-F3r, DLV-I10, DLV-I11, DLV-I7, DLV-I8, DLV-I9c + want = append(want, "indexer_first_views", "indexer_first_view_again", index.ConfigReadersTool, index.BusStateTool, index.RequirementsTool, index.ImportsTool, index.PackageUsersTool, // H-A-527; DLV-F3r, DLV-I10, DLV-I11, DLV-I7, DLV-I8, DLV-I9c index.SeatDefinitionTool, index.SeatDefinitionsAgainTool, index.OutOfStepTool, // DLV-I19 index.FingerprintsAgainTool, // issue 1966 // milestone 47/G W4.12 (design 47, the indexer's tools): the catalog graph revisions read and steered. @@ -223,7 +223,7 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build index.EntryIndexTool, index.EntryPinsTool, index.NamedDropTool, // design 47 G §675, H-A-204 index.ProposalsTool, index.ProposalDropTool, index.SeedAgainTool, index.InputsTool, index.PinsTool, index.PinDropTool, index.PendingTool, index.TakeInPendingTool, index.TakeInAgainTool, index.TakeInSkipTool, index.RunsTool, index.RunDropTool, // design 47 G §667, §8, §579, §64 (A-194) index.DryRunsTool, index.RegistrationsTool) // design 47 H2 §804, §806 - if !reflect.DeepEqual(m.Tools, want) || len(want) != 46 || !slices.Contains(m.Tools, "modules") { + if !reflect.DeepEqual(m.Tools, want) || len(want) != 47 || !slices.Contains(m.Tools, "modules") { t.Errorf("tools = %v, want %v", m.Tools, want) } // Design 47 G §2, §9: every version of every registration is kept with no age limit, 64 MiB, on the old streams section. diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index f8104a980..5599a0277 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -48,6 +48,7 @@ "indexer_config_readers", "indexer_bus_state", "indexer_requirements", + "indexer_imports", "indexer_package_users", "indexer_seat_definition", "indexer_seat_definitions_again", -- 2.54.0 From f1e4ab1cf616d14de0d5aea79e2501d69d9d82d4 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:08:54 +0100 Subject: [PATCH 05/34] I3: the indexer reads no imports from the builder's build log ApplyBuildEnd and its start replay go: a module's import set reaches the indexer only as imports-reported. The build-log read stays for the module paths and the out-of-step findings. Builds: design 47 H2 H-A-517, H-A-532 DQ-7 --- .../cmd/mesh-delivery-indexer/main.go | 20 ++---- .../internal/index/imports.go | 65 ------------------- 2 files changed, 5 insertions(+), 80 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index eef0293aa..2a9b11597 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -426,19 +426,16 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro done = step("reading the build log") // The log's entries at the start are read before any fingerprint is computed (below). var started atomic.Bool - var startEnds []stdio.LogEntry // the log's entries read at the start, whose imports are kept once the packages are published + var startEnds []stdio.LogEntry // the log's entries read at the start, whose out-of-step findings are judged below if err := calls.ReadLog(builds.BuilderModule, builds.BuilderLog).Watch("", stdio.LogFromAll, func(le stdio.LogEntry) error { if err := known.Put(le.Value); err != nil { logger.Printf("%s entry %d is not read: %v", builds.BuildLogRead, le.Sequence, err) return nil } if started.Load() { - // A trunk build's generated files out of step with their seat definitions (DLV-I20). + // A trunk build's generated files out of step with their seat definitions (DLV-I20). Its imports are not read + // here: the build module says them as imports-reported (design 47 H2 H-A-517, H-A-532 DQ-7). ix.ApplyOutOfStepBuild(ctx, le.Value) - // A done build's imports are kept on its module (ADR 0593 §2); at the start they are kept once the packages are. - if err := ix.ApplyBuildEnd(ctx, le.Value); err != nil { - logger.Printf("%s entry %d: its imports are not kept: %v", builds.BuildLogRead, le.Sequence, err) - } } else { startEnds = append(startEnds, le) } @@ -502,8 +499,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro buildFollow.Store(buildModules) // Only now, with the toolchains read, are the fingerprints computed once (before it every Go module would be written as // having no toolchain reported, and back). - // The packages the held modules reach and the state does not hold yet are published at their trunk's taken merge, and - // the imports the log's done builds reported are then kept, before the fingerprints are computed (ADR 0593 §2, §4). + // The packages the held modules reach and the state does not hold yet are published at their trunk's taken merge, + // before the fingerprints are computed (ADR 0593 §2, §4). done() packages.Ready(func(jetstream.KeyValue) { done := step("publishing the packages at start") @@ -513,20 +510,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro done() }) done = step(fmt.Sprintf("the out-of-step findings of %d build ends", len(startEnds))) - values := make([][]byte, len(startEnds)) for i, le := range startEnds { ix.ApplyOutOfStepBuild(ctx, le.Value) - values[i] = le.Value if (i+1)%50000 == 0 { logger.Printf("start: out-of-step findings: %d of %d entries", i+1, len(startEnds)) } } done() - if err := ix.ApplyBuildEndsAtStart(ctx, values, func(i int, err error) { - logger.Printf("%s entry %d: its imports are not kept: %v", builds.BuildLogRead, startEnds[i].Sequence, err) - }); err != nil { - logger.Printf("keeping the view after the build ends at start: %v", err) - } startEnds = nil done = step("computing the fingerprints") if err := ix.RecomputeAtStart(ctx); err != nil { diff --git a/modules/mesh-delivery-indexer/internal/index/imports.go b/modules/mesh-delivery-indexer/internal/index/imports.go index 06a034458..68888d8a6 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports.go +++ b/modules/mesh-delivery-indexer/internal/index/imports.go @@ -6,9 +6,7 @@ import ( "maps" "slices" "strings" - "time" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" @@ -16,69 +14,6 @@ import ( "mesh-delivery-indexer/internal/fingerprint" ) -// ApplyBuildEnd keeps the imports a done build reports at its end (builds.BuildLogEntry.Imports; novox/hq ADR 0593 -// §2) on the module it built, when the build's fingerprint is the one the module holds: the import set of the module's -// last trunk build. With them it keeps ImportForm, the import-form fingerprint of exactly what the build was built from: -// the module's kept inputs and the toolchains its fingerprint was computed with, and each imported package's digest at -// the version the build took it at (another repository's at the version the module's fingerprint pins, its own -// repository's at the commit built). A recompute that gives that value again keeps the fingerprint (§4); one that -// differs writes the import form. The fingerprint itself is not changed here. -// -// An entry that is no done build's end, reports no imports, or is of a fingerprint the module no longer holds is left. -// Imports that cannot be resolved (a package the forge cannot list) are kept with no ImportForm: the next recompute that -// resolves them writes the import form, one rebuild too many, never a stale module. -func (ix *Indexer) ApplyBuildEnd(ctx context.Context, value []byte) error { - _, err := ix.applyBuildEnd(ctx, value) - return err // the imports reach the next take-in's revision (design 47 H §743, H-A-49) -} - -// ApplyBuildEndsAtStart applies every entry of the build log read at start as ApplyBuildEnd does, and keeps the view -// once, after them, when any entry wrote a module: KeepView writes the whole catalog view, so once per entry is a start -// that never ends (measured: 50 min CPU per start). An entry that fails is passed to failed with its position. -func (ix *Indexer) ApplyBuildEndsAtStart(ctx context.Context, values [][]byte, failed func(i int, err error)) error { - began := time.Now() - ix.logf("replaying %d build ends of the build log at start", len(values)) - wrote := 0 - slow := 0 // entries that took over a second - for i, v := range values { - if (i+1)%50000 == 0 { - ix.logf("replaying the build ends at start: %d of %d, %d wrote a module, %d took over a second, %s so far", i+1, len(values), wrote, slow, time.Since(began).Round(time.Millisecond)) - } - t := time.Now() - w, err := ix.applyBuildEnd(ctx, v) - if d := time.Since(t); d > time.Second { - slow++ - ix.logf("replaying the build ends at start: entry %d took %s", i+1, d.Round(time.Millisecond)) - } - if err != nil { - if failed != nil { - failed(i, err) - } - continue - } - if w { - wrote++ - } - } - ix.logf("replayed %d build ends at start: %d wrote a module, in %s", len(values), wrote, time.Since(began).Round(time.Millisecond)) - return nil -} - -// applyBuildEnd reports whether it wrote the module (its final write changed the held value). -func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) (bool, error) { - if !builds.IsBuildEntry(value) { - return false, nil - } - e, err := builds.DecodeBuildLogEntry(value) - if err != nil { - return false, err - } - if e.Event != builds.BuildEndedEvent || e.Outcome != builds.BuildDone || len(e.Imports) == 0 || ix.Modules == nil || e.FP == "" { - return false, nil - } - return ix.keepImports(ctx, reported{module: e.Module, fp: e.FP, commit: e.Commit, imports: e.Imports}) -} - // reported is one build's import set as its build module reported it (design 47 H2 H-A-517): the module, the // fingerprint built, its commit and the imported mesh packages by import path. type reported struct { -- 2.54.0 From c0b3e4ad08632f0fef144a58de763f782c2aa87f Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:10:25 +0100 Subject: [PATCH 06/34] S2: the step runner judges an import set by its build seat's language form A Node build's imports are npm names in the mesh's scope (@novox/mesh-sdk, one package, no sub-path), a Go build's Go module paths under the forge's prefix; AskSteps.ImportScope and ImportPrefix carry the build module's settings, trunk.DefaultNpmScope and ForgeModulePrefix when they name none (trunk.CheckNpmImports, CheckGoImports). Builds: design 47 H2 H-A-534, H-A-532 DQ-6 --- modules/mesh-delivery-sdk/steprun/askrun.go | 19 ++++++-- .../mesh-delivery-sdk/steprun/askrun_test.go | 12 +++++ modules/mesh-delivery-sdk/trunk/packages.go | 44 ++++++++++++++++++- modules/mesh-delivery-sdk/trunk/trunk_test.go | 20 +++++++++ 4 files changed, 90 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-sdk/steprun/askrun.go b/modules/mesh-delivery-sdk/steprun/askrun.go index 28e0977a8..ab4d93e39 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun.go +++ b/modules/mesh-delivery-sdk/steprun/askrun.go @@ -66,6 +66,10 @@ type AskSteps struct { // fingerprint main's modules state holds (design 47 H2 H-A-517, H-A-532 DQ-2, DMC-2). A say that fails leaves the // build's answer standing and is said in the journal. Nil says none. SayImports func(nodebuildgo.ImportsReported) error + // ImportPrefix and ImportScope are the forms an import set is judged by, read from the build module's settings + // (design 47 H2 H-A-534): a Go build's imports are Go module paths under ImportPrefix, the forge's module prefix + // (trunk.ForgeModulePrefix when empty); a Node build's are npm names in ImportScope (trunk.DefaultNpmScope when empty). + ImportPrefix, ImportScope string // Outputs are the holder's outputs objects (OutputsStore), where a test step keeps its run's output as `.` (design 47 H2 §791, H-A-412), which the seat's verb output reads (OutputTool). Nil keeps none, said in the journal. Outputs OutputObjects @@ -90,7 +94,7 @@ func RunAsk(ctx context.Context, steps AskSteps, ask sdkstep.StepAsk) (any, erro if ask.Build != nil { job := *ask.Build job.Fetch = withPackages(job.Fetch, ask.Packages) - out, err := steps.build(ctx, job, ask.Version) + out, err := steps.build(ctx, job, ask.Version, ask.Language) var dec *Declining if err != nil && !sdkstep.IsPassing(err) && !errors.As(err, &dec) && ctx.Err() == nil { // A failed build keeps its error text, as the build module bounded it, as the ask's output object, header and @@ -208,7 +212,7 @@ func (s AskSteps) onToolchain(ctx context.Context, want *sdkstep.ToolchainUsed) // build runs a build job; version is the version the ask carries (design 47 G §573), which each artifact's build is given // as its argument version, the build's MESH_VERSION (§370), unless the artifact names its own. -func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version string) (any, error) { +func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version, language string) (any, error) { answer := sdkstep.BuildAnswer{} tc, err := s.onToolchain(ctx, job.Toolchain) if err != nil { @@ -326,7 +330,7 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version strin if err := json.Unmarshal(r, &read); err != nil { return nil, fmt.Errorf("the imports of %s answered what is not a list: %s", job.Module, r) } - if err := trunk.CheckImports(read.Imports); err != nil { + if err := s.checkImports(language, read.Imports); err != nil { return nil, err } answer.Imports = read.Imports @@ -335,6 +339,15 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version strin return answer, nil } +// checkImports judges a build's import set by the form of the language its build seat serves (design 47 H2 H-A-534): npm +// names in the mesh's scope for a Node build, Go module paths under the forge's prefix for every other. +func (s AskSteps) checkImports(language string, imports []string) error { + if language == sdkstep.AskNode { + return trunk.CheckNpmImports(imports, s.ImportScope) + } + return trunk.CheckGoImports(imports, s.ImportPrefix) +} + // sayImports says the import set a done build read (design 47 H2 H-A-517, H-A-532 DQ-2): the module, the fingerprint // it was asked for, its commit and the imports, an empty list when its programs import no mesh package. A failed say is // said in the journal and never fails the build (principle 3: loud, not lost). diff --git a/modules/mesh-delivery-sdk/steprun/askrun_test.go b/modules/mesh-delivery-sdk/steprun/askrun_test.go index f31d68d7b..634058b67 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun_test.go +++ b/modules/mesh-delivery-sdk/steprun/askrun_test.go @@ -141,6 +141,18 @@ imports {"module":"modules/m","workspace":"/w/1"}` t.Errorf("a failed say: said %q, journal %q; want it said in the journal", said, journal) } said, sayErr = nil, nil + // Design 47 H2 H-A-534: an import set is judged by its build seat's form: npm names on the Node seat, Go paths on the Go seat. + steps.Imports = func(context.Context, map[string]any) (any, error) { + return map[string]any{"imports": []string{"@novox/mesh-sdk"}}, nil + } + if _, err := RunAsk(context.Background(), steps, a); err == nil || !strings.Contains(err.Error(), "@novox/mesh-sdk") { + t.Errorf("an npm set on the Go seat: %v, want it refused", err) + } + a.Language = sdkstep.AskNode + if out, err := RunAsk(context.Background(), steps, a); err != nil || !slices.Equal(out.(sdkstep.BuildAnswer).Imports, []string{"@novox/mesh-sdk"}) { + t.Errorf("an npm set on the Node seat: %v, %v; want it taken", out, err) + } + said = nil // Design 47 H2 H-A-482 addendum (a): a failed build keeps its error text, as the build module bounded it, as the ask's // output object, which the verb output answers. diff --git a/modules/mesh-delivery-sdk/trunk/packages.go b/modules/mesh-delivery-sdk/trunk/packages.go index 4d5f653b1..53df9f615 100644 --- a/modules/mesh-delivery-sdk/trunk/packages.go +++ b/modules/mesh-delivery-sdk/trunk/packages.go @@ -28,12 +28,52 @@ func PackageRepository(pkg string) (repository, dir string, ok bool) { return "novox/" + name, dir, true } +// DefaultNpmScope is the npm scope of the mesh's npm packages when a build module's setting names none (design 47 H2 +// H-A-534): a TypeScript import set names each mesh npm package by its name in it, such as @novox/mesh-sdk. +const DefaultNpmScope = "@novox" + // CheckImports refuses an import set (the imports of a module's kept inputs, of a build's answer and of a build log entry) // that holds a path that is no mesh package's, or is not sorted and each once. func CheckImports(imports []string) error { + return CheckGoImports(imports, ForgeModulePrefix) +} + +// CheckGoImports refuses a Go import set holding a path that is no Go module path under prefix, the forge's module prefix +// a build module's setting names (design 47 H2 H-A-534), or that is not sorted and each once. +func CheckGoImports(imports []string, prefix string) error { + if prefix == "" { + prefix = ForgeModulePrefix + } + return checkSorted(imports, func(pkg string) error { + rest, found := strings.CutPrefix(pkg, prefix) + if name, _, _ := strings.Cut(rest, "/"); !found || name == "" || strings.ContainsAny(pkg, " \t\n@") { + return fmt.Errorf("trunk: the import %q is no mesh package's path (it starts with %s)", pkg, prefix) + } + return nil + }) +} + +// CheckNpmImports refuses a TypeScript import set holding an entry that is no npm package name in scope (such as +// @novox/mesh-sdk, never a sub-path of it: one package, one digest, H-A-532 DQ-6), or that is not sorted and each once +// (design 47 H2 H-A-534). +func CheckNpmImports(imports []string, scope string) error { + if scope == "" { + scope = DefaultNpmScope + } + return checkSorted(imports, func(pkg string) error { + name, found := strings.CutPrefix(pkg, scope+"/") + if !found || name == "" || strings.ContainsAny(name, "/@ \t\n") { + return fmt.Errorf("trunk: the import %q is no mesh npm package's name (%s/)", pkg, scope) + } + return nil + }) +} + +// checkSorted refuses imports holding an entry one refuses, or not sorted and each once. +func checkSorted(imports []string, one func(string) error) error { for i, pkg := range imports { - if _, _, ok := PackageRepository(pkg); !ok || strings.ContainsAny(pkg, " \t\n@") { - return fmt.Errorf("trunk: the import %q is no mesh package's path (it starts with %s)", pkg, ForgeModulePrefix) + if err := one(pkg); err != nil { + return err } if i > 0 && imports[i-1] >= pkg { return fmt.Errorf("trunk: the imports are not sorted and each once (%s after %s)", pkg, imports[i-1]) diff --git a/modules/mesh-delivery-sdk/trunk/trunk_test.go b/modules/mesh-delivery-sdk/trunk/trunk_test.go index b098f048a..b565fe5f8 100644 --- a/modules/mesh-delivery-sdk/trunk/trunk_test.go +++ b/modules/mesh-delivery-sdk/trunk/trunk_test.go @@ -44,6 +44,26 @@ func TestAnImportSetHoldsMeshPackagesSortedAndEachOnce(t *testing.T) { t.Errorf("%s: %v is taken", name, bad) } } + // Design 47 H2 H-A-534: a Go set is judged under the prefix the build module's setting names, a TypeScript set by npm + // names in the mesh's scope, each package once (no sub-path, H-A-532 DQ-6). + if err := CheckGoImports([]string{"git.example.org/o/r/go"}, "git.example.org/o/"); err != nil { + t.Errorf("a Go set under another prefix is refused: %v", err) + } + if CheckGoImports([]string{a}, "git.example.org/o/") == nil { + t.Error("a Go set outside the prefix set is taken") + } + if err := CheckNpmImports([]string{"@novox/mesh-contracts-node-build-go", "@novox/mesh-sdk"}, ""); err != nil { + t.Errorf("an npm set in the default scope is refused: %v", err) + } + if err := CheckNpmImports([]string{"@acme/sdk"}, "@acme"); err != nil { + t.Errorf("an npm set in another scope is refused: %v", err) + } + for name, bad := range map[string][]string{"a Go path": {a}, "a sub-path": {"@novox/mesh-sdk/stdio"}, "another scope": {"@other/x"}, + "no scope": {"mesh-sdk"}, "unsorted": {"@novox/mesh-sdk", "@novox/a"}, "a version": {"@novox/mesh-sdk@1"}} { + if CheckNpmImports(bad, "") == nil { + t.Errorf("npm %s: %v is taken", name, bad) + } + } } // A repository keys the indexer's taken and the view's reach by its forge name, in lower case, from either spelling (ADR 0556). -- 2.54.0 From 2f4fe5fa8bfc8c335ee1bd458b265fa136a427c3 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:13:13 +0100 Subject: [PATCH 07/34] I8: every take-in computes with main's import set, a watched branch's too The recompute takes each module's set from the state imports (a branch's copy of another set gives way to it), with main's import form while main's value holds that set, so the form costs no rebuild; a branch's take-in reads the state through an overlay and drops none of it. Builds: design 47 H2 H-A-519, H-A-529, H-A-532 DMC-6 --- .../internal/index/candidates.go | 7 ++- .../internal/index/dryrun.go | 6 +++ .../internal/index/imports_test.go | 29 ++++++++++ .../internal/index/importset.go | 54 +++++++++++++++++++ .../internal/index/toolchains.go | 1 + 5 files changed, 95 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index dec560fb4..bb9ebb0f4 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -165,8 +165,11 @@ type Indexer struct { fillAgain atomic.Bool // a kick arrived while it ran underSeats bool // a dry run inside judge.WithSeats: its judge passes do not hold the seat list (verdicts.go) isDry bool // a dry run (dryrun.go): its packages are a working copy over the live state, and it drops no kept package key (packages.go) - judgeMu sync.Mutex // one judge pass at a time (verdicts.go) - keepMu sync.Mutex // one catalog graph revision kept at a time (keepEntries) + // trunkModules is, in a dry run, the live modules state under its view: main's values, whose import form a branch takes + // with main's import set (importset.go, H-A-532 DMC-6); nil reads Modules. + trunkModules Store + judgeMu sync.Mutex // one judge pass at a time (verdicts.go) + keepMu sync.Mutex // one catalog graph revision kept at a time (keepEntries) // Pins is the state pins (pins.go); nil keeps none. PinsPending says how many messages the indexer's durable consumer of the // events stream has not been given: a revision is removed only while none is pending (§579). Pins Store diff --git a/modules/mesh-delivery-indexer/internal/index/dryrun.go b/modules/mesh-delivery-indexer/internal/index/dryrun.go index 51b3cb61d..784501f81 100644 --- a/modules/mesh-delivery-indexer/internal/index/dryrun.go +++ b/modules/mesh-delivery-indexer/internal/index/dryrun.go @@ -71,6 +71,12 @@ func (ix *Indexer) dry(branch, call string) *dryRun { x.Taken, d.taken = over(ix.Taken) x.Predefined, d.predefined = over(ix.Predefined) x.OldSections, d.oldSections = over(ix.OldSections) + // Every branch's take-in reads main's import sets (design 47 H2 H-A-519, H-A-532 DMC-6), and writes none of them. + x.Imports, _ = over(ix.Imports) + x.trunkModules = ix.Modules + if ix.trunkModules != nil { + x.trunkModules = ix.trunkModules + } ix.mu.Lock() x.source = sourceNow{rev: ix.source.rev, heads: maps.Clone(ix.source.heads)} x.toolchains = map[string]map[string]nodebuildgo.Toolchain{} diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index f876d59a9..a2710c314 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -102,6 +102,35 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T set.Imports[0].Package != meshSDK || set.Imports[0].Digest != digestIn(pub, meshSDK) || set.Imports[1].Digest != digestIn(pub, meshSDK+"/announce") || set.Imports[1].Digest == "" { t.Fatalf("imports.avahi = %+v, %v, %v; want the set at %s with each package's published digest %v", set, found, err, before.Fp2, pub.Packages) } + // H-A-519, H-A-532 DMC-6: a take-in computes with main's import set, a watched branch's too: a branch's copy holding + // another set (buildstep alone, which would write its own import form) computes to main's fingerprint, and a branch's + // take-in drops no set of main's. + branch := ix.dry("feature", "c") + stale := after + staleIn := *after.Inputs2 + staleIn.Imports, staleIn.ImportForm = []string{meshSDK + "/buildstep"}, "" + stale.Inputs2 = &staleIn + if err := write(ctx, branch.ix.Modules, "avahi", func([]byte, bool) ([]byte, bool, error) { + b, err := meshcatalogclient.EncodeModule(stale) + return b, false, err + }); err != nil { + t.Fatal(err) + } + if err := branch.ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + if v, _, _, _ := branch.ix.Modules.Get(ctx, "avahi"); v == nil { + t.Fatal("the branch holds no avahi") + } else if m, _ := meshcatalogclient.DecodeModule(v); m.Fp2 != before.Fp2 { + t.Fatalf("the branch's avahi computes to %q, want main's %q with main's set and its import form", m.Fp2, before.Fp2) + } + if err := branch.ix.dropImportSet(ctx, "avahi"); err != nil { + t.Fatal(err) + } + if _, found, _ := ix.ImportSetOf(ctx, "avahi"); !found { + t.Fatal("a branch's take-in dropped main's import set") + } + branch.end(ctx) // H-A-527: indexer_imports reads it for one module, and says so of a module with none. tool := ImportsReadTool(ix.Imports) if got, err := tool.Run(map[string]any{"module": "avahi"}); err != nil || got.(map[string]any)["kept"] != true || got.(map[string]any)["set"].(ImportSet).Fingerprint != before.Fp2 { diff --git a/modules/mesh-delivery-indexer/internal/index/importset.go b/modules/mesh-delivery-indexer/internal/index/importset.go index 50c261db8..13eb30137 100644 --- a/modules/mesh-delivery-indexer/internal/index/importset.go +++ b/modules/mesh-delivery-indexer/internal/index/importset.go @@ -8,6 +8,7 @@ import ( "slices" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" stdio "git.novox.be/novox/mesh-sdk/go" ) @@ -136,3 +137,56 @@ func ImportsReadTool(st Store) stdio.Tool { return map[string]any{"module": module, "kept": true, "set": set}, nil }} } + +// withReportedImports is cur with the import set the state imports keeps for key, the set main's last build reported, +// which every take-in computes with, a watched branch's too (design 47 H2 H-A-519, H-A-532 DMC-6); a value holding +// another set takes it with main's import form while main's value holds that set (so the form costs no rebuild of its +// own, H-A-529), else with none, so its next computation writes the import form. cur is left as it is when the state +// keeps no set for key, or it holds no inputs. +func (ix *Indexer) withReportedImports(ctx context.Context, key string, cur meshcatalog.ModulesByModuleValue) meshcatalog.ModulesByModuleValue { + if cur.Inputs2 == nil { + return cur + } + set, found, err := ix.ImportSetOf(ctx, key) + if err != nil { + ix.logf("%s.%s cannot be read, so %s keeps the import set its value holds: %v", ImportsState, key, key, err) + return cur + } + if !found { + return cur + } + imports := make([]string, 0, len(set.Imports)) + for _, p := range set.Imports { + imports = append(imports, p.Package) + } + if slices.Equal(cur.Inputs2.Imports, imports) { + return cur + } + in := *cur.Inputs2 + in.Imports, in.ImportForm = imports, ix.trunkImportForm(ctx, key, imports) + if len(imports) == 0 { + in.Imports = nil + } + cur.Inputs2 = &in + return cur +} + +// trunkImportForm is the import form main's modules value of key holds with imports, "" when it holds another set. +func (ix *Indexer) trunkImportForm(ctx context.Context, key string, imports []string) string { + st := ix.trunkModules + if st == nil { + st = ix.Modules + } + if st == nil { + return "" + } + v, _, found, err := st.Get(ctx, key) + if err != nil || !found { + return "" + } + m, err := meshcatalogclient.DecodeModule(v) + if err != nil || m.Inputs2 == nil || !slices.Equal(m.Inputs2.Imports, imports) { + return "" + } + return m.Inputs2.ImportForm +} diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index a9fa0270a..66df18707 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -221,6 +221,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc cur, stale[key] = again, true held[key] = cur } + cur = ix.withReportedImports(ctx, key, cur) all[key] = &known{key: key, cur: cur, manifest: m, languages: languagesOf(m), bases: basesOf(m), contexts: hasContext(m), held: before} } tools := ix.agreed() -- 2.54.0 From b52a70b1b24f0b9956fa05d86f17b26719db8591 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:14:24 +0100 Subject: [PATCH 08/34] I9: the catalog graph's kind 1 comes from the reported import set An entry whose fingerprint was computed with an import set gets one kind-1 edge per import, from the package artifact of the longest name holding it to its artifacts of that ecosystem; a requirement no import names gives none. An entry with no set keeps kind 1 from packages. Builds: design 47 H2 H-A-522, H-A-532 DQ-14 --- .../internal/index/catalog_edges.go | 61 +++++++++++++++---- .../internal/index/catalog_edges_test.go | 14 +++++ 2 files changed, 64 insertions(+), 11 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_edges.go b/modules/mesh-delivery-indexer/internal/index/catalog_edges.go index 70d441e35..a33ae40a3 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_edges.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_edges.go @@ -245,22 +245,32 @@ func edgesOf(a meshcatalog.CatalogEntry, all map[string]meshcatalog.CatalogEntry } modules := slices.Sorted(maps.Keys(all)) delivers := primaryOf(a) - // Kind 1: a package its build imports, from the artifact that publishes it, to each artifact built from that ecosystem (§47). - for _, name := range slices.Sorted(maps.Keys(a.Packages)) { - for _, m := range modules { - b := all[m] - if m == a.Module { - continue - } - for _, art := range b.Artifacts { - if art.Package == nil || art.Package.Name != name { + // Kind 1: a package its build imports, from the artifact that publishes it, to each artifact built from that ecosystem (§47): + // from its reported import set, each import from the package artifact of the longest name holding it (design 47 H2 + // H-A-522, H-A-532 DQ-14); from its manifest's packages only until a set is reported. + if imports := importSetOf(a); len(imports) > 0 { + for _, imp := range imports { + var holder *meshcatalog.Artifact + for _, m := range modules { + if m == a.Module { continue } - for _, to := range importersOf(a, art.Package.Ecosystem) { - add(meshcatalog.Edge{Kind: 1, From: art.Ref, To: to, Stale: true, Word: "packages", Why: name}) + for i, art := range all[m].Artifacts { + if p := art.Package; p != nil && (imp == p.Name || strings.HasPrefix(imp, p.Name+"/")) && + (holder == nil || len(p.Name) > len(holder.Package.Name)) { + holder = &all[m].Artifacts[i] + } } } + if holder == nil { + continue + } + for _, to := range importersOf(a, holder.Package.Ecosystem) { + add(meshcatalog.Edge{Kind: 1, From: holder.Ref, To: to, Stale: true, Word: "imports", Why: imp}) + } } + } else { + edgesOfPackages(a, all, modules, add) } // Kind 2: an artifact its manifest's `needs` references in another module, published before the artifact that names it // delivers (A-212, §432). @@ -453,3 +463,32 @@ func (ix *Indexer) withActs(ctx context.Context, entries map[string]meshcatalog. } return WithActs(entries, defs) } + +// importSetOf is the import set the entry's fingerprint was computed with (its inputs' imports), none before a report. +func importSetOf(a meshcatalog.CatalogEntry) []string { + if a.Inputs == nil || a.Inputs.From == nil { + return nil + } + return a.Inputs.From.Imports +} + +// edgesOfPackages are kind 1 from the entry's packages, its go.mod's requirements, for an entry with no reported import set +// (H-A-522). +func edgesOfPackages(a meshcatalog.CatalogEntry, all map[string]meshcatalog.CatalogEntry, modules []string, add func(meshcatalog.Edge)) { + for _, name := range slices.Sorted(maps.Keys(a.Packages)) { + for _, m := range modules { + b := all[m] + if m == a.Module { + continue + } + for _, art := range b.Artifacts { + if art.Package == nil || art.Package.Name != name { + continue + } + for _, to := range importersOf(a, art.Package.Ecosystem) { + add(meshcatalog.Edge{Kind: 1, From: art.Ref, To: to, Stale: true, Word: "packages", Why: name}) + } + } + } + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go index 056a2df0e..92585d5f2 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go @@ -49,6 +49,20 @@ func TestAnEntryCarriesItsEdgesOfKindsOneToFourAndSix(t *testing.T) { if len(before.Edges) != 0 || len(entries["app"].Edges) != 0 { t.Errorf("the entries given were changed") } + // Design 47 H2 H-A-522, H-A-532 DQ-14: with a reported import set, kind 1 comes from it, each import from the package of + // the longest Go module path holding it (lib/go/sub, nested in lib/go), and none from a requirement no import names. + entries["sub"] = meshcatalog.CatalogEntry{Module: "sub", Artifacts: []meshcatalog.Artifact{{Ref: "sub:go", Language: "go", Kind: "package", + Package: &meshcatalog.ArtifactPackage{Ecosystem: EcosystemGo, Name: "git.example/lib/go/sub"}}}} + entries["other"] = meshcatalog.CatalogEntry{Module: "other", Artifacts: []meshcatalog.Artifact{{Ref: "other:go", Language: "go", Kind: "package", + Package: &meshcatalog.ArtifactPackage{Ecosystem: EcosystemGo, Name: "git.example/other/go"}}}} + imp := entries["app"] + imp.Packages = map[string]string{"git.example/lib/go": "1.2.3", "git.example/other/go": "0.1.0"} + imp.Inputs = &meshcatalog.EntryInputs{From: &meshcatalog.FingerprintInputs{Imports: []string{"git.example/lib/go/sub/x"}}} + entries["app"] = imp + if got := WithEdges(entries)["app"].Edges; got[0] != (meshcatalog.Edge{Kind: 1, From: "sub:go", To: "app:program", Stale: true, Word: "imports", Why: "git.example/lib/go/sub/x"}) || + slices.ContainsFunc(got[1:], func(e meshcatalog.Edge) bool { return e.Kind == 1 }) { + t.Errorf("edges with an import set: %+v, want one kind 1 from sub:go and none from the requirements", got) + } } // Design 47 G A-208: a revision kept holds each entry with its edges, so the builder and the assigner read them from the entry. -- 2.54.0 From 03c3690d54b2c6444fc572b768306cffc6ab2631 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:23:56 +0100 Subject: [PATCH 09/34] I4: the import form takes no pin, and a reported set is a key or a held set The import form's fingerprint takes each imported package by its content and no released version: a release of the same content leaves it, and a held fingerprint made with a pin from before stands while its import form is unchanged; only the version line takes the pins. The import form is chosen when the module's set is reported: a key in the state imports, an empty set too, or, until its next report, a set its modules value already holds. An import form with no imports is a valid modules value: it says a reported empty set. Builds: design 47 H2 H-A-530, H-A-521, H-A-529, H-A-536, H-A-537, H-A-538 --- .../clients/meshcatalogclient/catalog_test.go | 10 +- .../go/clients/meshcatalogclient/module.go | 5 +- .../internal/index/form.go | 24 +-- .../internal/index/imports_test.go | 149 ++++++++++++++++-- .../internal/index/importset.go | 16 +- .../internal/index/toolchains.go | 11 +- .../internal/index/versions.go | 16 +- 7 files changed, 185 insertions(+), 46 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go index 8bebbd58d..3a86574d5 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go @@ -69,6 +69,12 @@ func TestManifestAndModuleValuesKeepTheirRules(t *testing.T) { if m, err := DecodeModule(raw); err != nil || m.Fp2 != good.Fp2 || m.Path != RootPath { t.Errorf("DecodeModule = %+v, %v", m, err) } + // Design 47 H2 H-A-536, H-A-538: an import form with no imports is a reported empty import set. + empty := good + empty.Inputs2 = &seat.ModulesByModuleValueInputs2{Tree: "t", ImportForm: SourcePrefix2 + hex64("a")} + if _, err := EncodeModule(empty); err != nil { + t.Errorf("a reported empty import set: %v", err) + } refused := good refused.Verdict, refused.Problems = VerdictRefused, []string{"p"} if _, err := EncodeModule(refused); err != nil { @@ -90,8 +96,8 @@ func TestManifestAndModuleValuesKeepTheirRules(t *testing.T) { "a toolchain with no recipe": func(m *seat.ModulesByModuleValue) { m.Toolchains = map[string]seat.ToolchainUsed{"go": {Language: "go", Version: "1.26"}} }, - "an import form with no imports": func(m *seat.ModulesByModuleValue) { - m.Inputs2 = &seat.ModulesByModuleValueInputs2{Tree: "t", ImportForm: SourcePrefix2 + hex64("a")} + "an import form of another form": func(m *seat.ModulesByModuleValue) { + m.Inputs2 = &seat.ModulesByModuleValueInputs2{Tree: "t", Imports: []string{"p"}, ImportForm: "src1:" + hex64("a")} }, } { m := good diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/module.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/module.go index 87c4d7c8d..1179fa7ff 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/module.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/module.go @@ -68,8 +68,9 @@ func CheckModule(m seat.ModulesByModuleValue) error { } } if in := m.Inputs2; in != nil { - if f := in.ImportForm; f != "" && (len(in.Imports) == 0 || !strings.HasPrefix(f, SourcePrefix2) || !keys.IsHex64(f[len(SourcePrefix2):])) { - return fmt.Errorf("meshcatalogclient: the kept import form %q is set only with imports, and is %s and 64 hex digits", f, SourcePrefix2) + // An import form with no imports says a reported empty import set (design 47 H2 H-A-536, H-A-538). + if f := in.ImportForm; f != "" && (!strings.HasPrefix(f, SourcePrefix2) || !keys.IsHex64(f[len(SourcePrefix2):])) { + return fmt.Errorf("meshcatalogclient: the kept import form %q is not %s and 64 hex digits", f, SourcePrefix2) } for p, object := range in.Paths { if !cleanInside(p) { diff --git a/modules/mesh-delivery-indexer/internal/index/form.go b/modules/mesh-delivery-indexer/internal/index/form.go index 8e9c0687f..1b1874c8a 100644 --- a/modules/mesh-delivery-indexer/internal/index/form.go +++ b/modules/mesh-delivery-indexer/internal/index/form.go @@ -16,25 +16,25 @@ import ( type form struct { fp, none string versions sdkstep.PackageVersions - // stands: fp is the held fingerprint of the build that reported the imports, made with the pins built (its held - // packages) from the import form raw; pinnedOf keeps it while the pins are those (H-A-172). - stands bool - raw string - built map[string]string + // imports: fp is of the import form, which takes each imported package by its content and no pin (design 47 H2 + // H-A-530), so pinnedOf leaves it as it is; the held fingerprint of the build that reported the imports stands as held, + // whatever pins it was made with (ADR 0593 §4, H-A-529). + imports bool } // formOf is the module's fingerprint from its kept inputs (bases already its bases' fingerprints) and toolchains, in the // form they call for (novox/hq ADR 0593 §2, §4): // -// - **The import form**, for a module whose last trunk build reported its imports (kept.Imports) when every import is -// published (the packages state): the content digest of each imported package and the requirements' digest of each +// - **The import form**, for a module whose import set is reported (reported: a key in the state imports, whatever the +// set's length, or a set its value held before that state was, design 47 H2 H-A-536, H-A-537; the set is kept.Imports) +// when every import is published (the packages state): the content digest of each imported package and the requirements' digest of each // mesh Go module holding one. Its versions are each holding module's published commit (another repository's only); an // import set naming none of another repository while the go.mod requires one keeps the version line's (refined). // - **A change of form never rebuilds by itself** (§4): kept.ImportForm is the import-form fingerprint of the inputs // the build that reported the imports was built from. While the import form computes to it, nothing the build was // built from changed: the module keeps the fingerprint it holds (prev), in whatever form, and its versions. // Otherwise the import form is written, and ImportForm moves with it. -// - **The version line** otherwise (no import set, or an import none publishes): the version of each mesh Go module of +// - **The version line** otherwise (no reported import set, or an import none publishes): the version of each mesh Go module of // another repository its go.mod requires, at any version (design 47 H-A-157), read as the indexer always read it // (fingerprint.HeldVersionsOf), and the content of each mesh Go module of its own repository its go.mod replaces by a // directory (fingerprint.VersionLine), so a change of that directory alone moves it (review finding 2). Its versions are the other repositories' alone. @@ -46,9 +46,9 @@ type form struct { // digests of that version's commit. // // It sets kept.ImportForm when it writes the import form. -func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, toolchains map[string]meshcatalogclient.Toolchain2, prev meshcatalog.ModulesByModuleValue, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) form { +func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, reported bool, toolchains map[string]meshcatalogclient.Toolchain2, prev meshcatalog.ModulesByModuleValue, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) form { in := inputsFrom(module, *kept, toolchains) - if len(kept.Imports) > 0 { + if reported { r := fingerprint.Resolve(repository, kept.Imports, published) if len(r.Missing) == 0 { in.Imports, in.Requires = r.Digests, r.Requires @@ -59,10 +59,10 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp case kept.ImportForm == fp && prev.Fp2 != "": // The build that reported the imports stands, and so do its versions. return form{fp: prev.Fp2, versions: refined(sdkstep.PackageVersions(prev.Packages), r.Versions, module, repository, kept, held, pins), - stands: true, raw: fp, built: prev.Packages} + imports: true} } kept.ImportForm = fp - return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins)} + return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins), imports: true} } if logf != nil { logf("%s: no published package holds %s, so its fingerprint takes the version line", module, strings.Join(r.Missing, ", ")) diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index a2710c314..d4ab0b575 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -56,6 +56,8 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T t.Run("a change of a sibling directory alone moves its importer", aSiblingDirectoryAloneMovesItsImporter) t.Run("an unread packages state writes no fingerprint, and they are computed again by hand (issue 1966)", anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain) t.Run("an accepted series' newest published version pins it, by that version's contents", anAcceptedSeriesPinsItsNewest) + t.Run("only the version line's fingerprint takes a release's pin", onlyTheVersionLineTakesAPin) + t.Run("a reported set is a key of the state imports, an empty one too, or a set held before it", aReportedSetIsAKeyOrAHeldSet) ctx := context.Background() ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") @@ -176,8 +178,9 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != moved.Fp2 || m.Packages[meshSDK] != "" { t.Fatalf("after mesh-sdk's module release alone: fp2 %q (was %q), versions %v; want it unpinned where it was", m.Fp2, moved.Fp2, m.Packages) } - // The registry publishes its Go package at 0.1.20, another version than the module's release: the import form's - // fingerprint takes that pin and moves, once (H-A-172, H-A-183). + // The registry publishes its Go package at 0.1.20, another version than the module's release, from c3, whose content + // avahi's fingerprint already takes: its build is pinned to v0.1.20, and the import form takes no pin, so the + // fingerprint stands (I4/AC1; design 47 H2 H-A-530, H-A-183). if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c3, GoModule: meshSDK, Published: true}); err != nil { t.Fatal(err) } @@ -186,13 +189,137 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T t.Fatal(err) } } - if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 == moved.Fp2 || m.Fp2 == "" || m.Packages[meshSDK] != "v0.1.20" || m.Inputs2.ImportForm != moved.Inputs2.ImportForm { - t.Fatalf("after mesh-sdk's release: fp2 %q (was %q), versions %v, import form %q; want a new fingerprint pinned to v0.1.20, the import form kept", + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != moved.Fp2 || m.Packages[meshSDK] != "v0.1.20" || m.Inputs2.ImportForm != moved.Inputs2.ImportForm { + t.Fatalf("after mesh-sdk's release: fp2 %q (was %q), versions %v, import form %q; want the fingerprint where it was, pinned to v0.1.20 (H-A-530)", m.Fp2, moved.Fp2, m.Packages, m.Inputs2.ImportForm) - } else if err := ix.Recompute(ctx); err != nil { + } +} + +// Design 47 H2 H-A-530: only the version line's fingerprint takes a release's pin, so a release moves a module with no +// reported import set (I4/AC2, H-A-167 for the version line); a held fingerprint made with a pin from before stands +// while the import form computes to the one its build reported (I4/AC3, ADR 0593 §4, H-A-529). +func onlyTheVersionLineTakesAPin(t *testing.T) { + ctx := context.Background() + start := func() (*Indexer, *memStore) { + t.Helper() + ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") + ix.Packages, ix.Files, ix.Imports = newMem(), forge{c1: sdkFiles("a1", "b1")}.files, newMem() + setPackages(t, mods, "avahi", []string{meshSDK}) + sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) + if err != nil { + t.Fatal(err) + } + mods.put("mesh-sdk", sdkModule) + held, _ := ix.heldModules(ctx) + if err := ix.publish(ctx, "novox/mesh-sdk", c1, held, false, TrunkBranch); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + return ix, mods + } + release := func(ix *Indexer) { + t.Helper() + if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c1, GoModule: meshSDK, Published: true}); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + } + + // I4/AC2: avahi reports no imports, so it is on the version line; mesh-sdk's release moves it. + ix, mods := start() + line, _ := moduleOf(t, mods, "avahi") + release(ix) + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 == line.Fp2 || m.Fp2 == "" || m.Packages[meshSDK] != "v0.1.20" { + t.Fatalf("the version line after the release: fp2 %q (was %q), versions %v; want moved, pinned to v0.1.20", m.Fp2, line.Fp2, m.Packages) + } + + // I4/AC3: avahi's build reports its imports, and its held fingerprint was made with a pin from before (H-A-172): + // the release of the same content leaves it as held. + ix, mods = start() + before, _ := moduleOf(t, mods, "avahi") + if err := ix.HearImportsReported(ctx, buildEnd(t, "avahi", before.Fp2, meshSDK, meshSDK+"/announce")); err != nil { t.Fatal(err) - } else if again, _ := moduleOf(t, mods, "avahi"); again.Fp2 != m.Fp2 { - t.Fatalf("a pass with nothing moved moved the pinned fingerprint %q to %q", m.Fp2, again.Fp2) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + old, _ := moduleOf(t, mods, "avahi") + if old.Inputs2 == nil || old.Inputs2.ImportForm == "" { + t.Fatalf("no import form kept from the report: %+v", old.Inputs2) + } + old.Fp2, old.Packages = fingerprint.WithPins(old.Inputs2.ImportForm, map[string]string{meshSDK: "v0.1.19"}), map[string]string{meshSDK: "v0.1.19"} + raw, err := meshcatalogclient.EncodeModule(old) + if err != nil { + t.Fatal(err) + } + mods.put("avahi", raw) + release(ix) + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != old.Fp2 || m.Packages[meshSDK] != "v0.1.20" { + t.Fatalf("a held fingerprint with a pin from before after the release: fp2 %q (was %q), versions %v; want it as held, pinned to v0.1.20", + m.Fp2, old.Fp2, m.Packages) + } +} + +// Design 47 H2 H-A-536, H-A-537: a module's import set is reported when the state imports keeps a key for it, whatever +// the set's length, or, until its next report, when its modules value holds a set from before that state: either is +// on the import form, so mesh-sdk's release of a commit whose content avahi does not import moves neither, while the +// version line would. +func aReportedSetIsAKeyOrAHeldSet(t *testing.T) { + ctx := context.Background() + for _, c := range []struct { + name string + imports []string + dropKey bool + }{ + {"a reported empty set (H-A-536)", nil, false}, + {"a set held before the state imports, no key (H-A-537)", []string{meshSDK + "/buildstep"}, true}, + } { + ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") + ix.Packages, ix.Files, ix.Imports = newMem(), forge{c1: sdkFiles("a1", "b1"), c3: sdkFiles("a2", "b1")}.files, newMem() + setPackages(t, mods, "avahi", []string{meshSDK}) + sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) + if err != nil { + t.Fatal(err) + } + mods.put("mesh-sdk", sdkModule) + held, _ := ix.heldModules(ctx) + if err := ix.publish(ctx, "novox/mesh-sdk", c1, held, false, TrunkBranch); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + before, _ := moduleOf(t, mods, "avahi") + if err := ix.HearImportsReported(ctx, buildEnd(t, "avahi", before.Fp2, c.imports...)); err != nil { + t.Fatal(err) + } + if c.dropKey { + if err := ix.dropImportSet(ctx, "avahi"); err != nil { + t.Fatal(err) + } + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != before.Fp2 || m.Inputs2.ImportForm == "" { + t.Fatalf("%s: after the report fp2 %q (was %q), import form %q; want the fingerprint as it was, on the import form", c.name, m.Fp2, before.Fp2, m.Inputs2.ImportForm) + } + // mesh-sdk 0.1.20 is published from c3, which changes announce alone: avahi imports none of it. + if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c3, GoModule: meshSDK, Published: true}); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != before.Fp2 || m.Packages[meshSDK] != "v0.1.20" { + t.Errorf("%s: after the release fp2 %q (was %q), versions %v; want it where it was, pinned to v0.1.20", c.name, m.Fp2, before.Fp2, m.Packages) + } } } @@ -475,7 +602,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * {"a build's imports naming none of another repository, which none publishes", held, []string{own}, ""}, } { kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}, Imports: c.imports} - f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, c.imports != nil, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, nil) if got := f.versions[contracts]; got != c.want { t.Errorf("%s: version of %s = %q, want %q", c.name, contracts, got, c.want) } @@ -487,12 +614,12 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * // so the module has a fingerprint, and the same tree gives the same one whatever commit names it. sibling := "git.novox.be/novox/mesh-catalog/modules/sibling" kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t\nderived modules/sibling o1", Packages: []string{sibling}} - f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, false, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) if f.fp == "" { t.Fatalf("an unpublished package of the same repository: none %q, want a fingerprint by its directory's tree", f.none) } kept.Tree = "t\nderived modules/sibling o2" - if g := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil); g.fp == "" || g.fp == f.fp { + if g := formOf("avahi", "novox/mesh-catalog", &kept, false, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil); g.fp == "" || g.fp == f.fp { t.Errorf("the sibling's directory changed: fingerprint %q, was %q; want a new one", g.fp, f.fp) } }) @@ -502,7 +629,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * imports []string }{{"an import no package holds", []string{meshSDK + "/announce"}}, {"no import reported", nil}} { kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Imports: c.imports, ImportForm: "src2:" + strings.Repeat("a", 64)} - f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, c.imports != nil, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) if kept.ImportForm != "" { t.Errorf("%s: kept import form %q after the version line %q", c.name, kept.ImportForm, f.fp) } diff --git a/modules/mesh-delivery-indexer/internal/index/importset.go b/modules/mesh-delivery-indexer/internal/index/importset.go index 13eb30137..09a6601f4 100644 --- a/modules/mesh-delivery-indexer/internal/index/importset.go +++ b/modules/mesh-delivery-indexer/internal/index/importset.go @@ -143,24 +143,28 @@ func ImportsReadTool(st Store) stdio.Tool { // another set takes it with main's import form while main's value holds that set (so the form costs no rebuild of its // own, H-A-529), else with none, so its next computation writes the import form. cur is left as it is when the state // keeps no set for key, or it holds no inputs. -func (ix *Indexer) withReportedImports(ctx context.Context, key string, cur meshcatalog.ModulesByModuleValue) meshcatalog.ModulesByModuleValue { +// +// reported says whether the module's import set is reported (H-A-536, H-A-537): the state imports keeps a key for it, +// whatever the set's length, or, until its next report replaces it, its value already holds a set (one kept before the +// state imports was), read as it is. +func (ix *Indexer) withReportedImports(ctx context.Context, key string, cur meshcatalog.ModulesByModuleValue) (_ meshcatalog.ModulesByModuleValue, reported bool) { if cur.Inputs2 == nil { - return cur + return cur, false } set, found, err := ix.ImportSetOf(ctx, key) if err != nil { ix.logf("%s.%s cannot be read, so %s keeps the import set its value holds: %v", ImportsState, key, key, err) - return cur + return cur, len(cur.Inputs2.Imports) > 0 } if !found { - return cur + return cur, len(cur.Inputs2.Imports) > 0 } imports := make([]string, 0, len(set.Imports)) for _, p := range set.Imports { imports = append(imports, p.Package) } if slices.Equal(cur.Inputs2.Imports, imports) { - return cur + return cur, true } in := *cur.Inputs2 in.Imports, in.ImportForm = imports, ix.trunkImportForm(ctx, key, imports) @@ -168,7 +172,7 @@ func (ix *Indexer) withReportedImports(ctx context.Context, key string, cur mesh in.Imports = nil } cur.Inputs2 = &in - return cur + return cur, true } // trunkImportForm is the import form main's modules value of key holds with imports, "" when it holds another set. diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index 66df18707..bc1688871 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -130,6 +130,9 @@ type known struct { // held is the fingerprint the bucket holds for the module and the toolchains it was computed with (for a merge, the // value before it): what stillComputed keeps while the builders agree on no toolchain. held meshcatalog.ModulesByModuleValue + // reported: the module's import set is reported (withReportedImports; design 47 H2 H-A-536, H-A-537), so its + // fingerprint takes the import form, an empty set's too. + reported bool } // Recompute writes again every module whose new-form fingerprint, or reason for none, is no longer what it holds: from @@ -221,8 +224,8 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc cur, stale[key] = again, true held[key] = cur } - cur = ix.withReportedImports(ctx, key, cur) - all[key] = &known{key: key, cur: cur, manifest: m, languages: languagesOf(m), bases: basesOf(m), contexts: hasContext(m), held: before} + cur, reported := ix.withReportedImports(ctx, key, cur) + all[key] = &known{key: key, cur: cur, manifest: m, languages: languagesOf(m), bases: basesOf(m), contexts: hasContext(m), held: before, reported: reported} } tools := ix.agreed() published, err := ix.publishedForPass(ctx, held) @@ -309,7 +312,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc r = result{fp: fp, tcs: k.held.Toolchains, pkgs: pkgs} } default: - f := formOf(module, k.cur.Repository, &kept, toolchains, k.held, held, pub, pins, ix.logf) + f := formOf(module, k.cur.Repository, &kept, k.reported, toolchains, k.held, held, pub, pins, ix.logf) r.fp, r.none = f.fp, f.none if r.fp != "" { // a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167) @@ -532,7 +535,7 @@ func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, } toolchains[artifact] = meshcatalogclient.Toolchain2{Language: language, Version: used.Version, Recipe: used.Recipe} } - f := formOf(module, k.held.Repository, &kept, toolchains, k.held, held, published, pins, nil) + f := formOf(module, k.held.Repository, &kept, k.reported, toolchains, k.held, held, published, pins, nil) if f.none != "" || f.fp == "" { return "", nil, false } diff --git a/modules/mesh-delivery-indexer/internal/index/versions.go b/modules/mesh-delivery-indexer/internal/index/versions.go index 5dd969287..9bba033c5 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions.go +++ b/modules/mesh-delivery-indexer/internal/index/versions.go @@ -458,17 +458,15 @@ func releasedPins(versions sdkstep.PackageVersions, series map[string]SeriesPack return out } -// pinnedOf is a form's fingerprint and its pins (releasedPins): the pins are part of what a build is made of, so every -// form's fingerprint takes them (design 47 H-A-167, H-A-172; ADR 0573 §4) and a re-pin moves it, the module a mover -// built again against the release; a fingerprint with no pin is the form's as it is. The held fingerprint of a build that -// stands is kept while its pins are the ones it was built with, else its import form takes the new pins. +// pinnedOf is a form's fingerprint and its pins (releasedPins), which the catalog entry's packages name for its build. +// Only the version line's fingerprint takes the pins (design 47 H-A-167, as H2 H-A-530 keeps it for the version line), so +// a re-pin moves it, the module a mover built again against the release. The import form's takes none (H-A-530): it +// takes each imported package by its content, so a release whose content is unchanged leaves it, and the held +// fingerprint of the build that reported the imports stands as held (ADR 0593 §4, H-A-529). func pinnedOf(f form, series map[string]SeriesPackage, m catalogue.Manifest, repository string, required []string) (string, sdkstep.PackageVersions) { pins := releasedPins(f.versions, series, m, repository, required) - if f.stands { - if maps.Equal(f.built, map[string]string(pins)) { - return f.fp, pins - } - return fingerprint.WithPins(f.raw, pins), pins + if f.imports { + return f.fp, pins } return fingerprint.WithPins(f.fp, pins), pins } -- 2.54.0 From 12000b46d1af0653fb755e197e81af33a54fe52b Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:24:46 +0100 Subject: [PATCH 10/34] I9: an entry's import form says its import set is reported Kind 1 comes from the import set when the entry's import form is set, an absent imports then the empty set, so a reported empty set gives no kind-1 edge; an entry with no import form is on the version line and keeps kind 1 from packages. Builds: design 47 H2 H-A-522, H-A-536, H-A-538 --- .../internal/index/catalog_edges.go | 14 ++++++++------ .../internal/index/catalog_edges_test.go | 9 ++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_edges.go b/modules/mesh-delivery-indexer/internal/index/catalog_edges.go index a33ae40a3..15712a0b0 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_edges.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_edges.go @@ -248,7 +248,7 @@ func edgesOf(a meshcatalog.CatalogEntry, all map[string]meshcatalog.CatalogEntry // Kind 1: a package its build imports, from the artifact that publishes it, to each artifact built from that ecosystem (§47): // from its reported import set, each import from the package artifact of the longest name holding it (design 47 H2 // H-A-522, H-A-532 DQ-14); from its manifest's packages only until a set is reported. - if imports := importSetOf(a); len(imports) > 0 { + if imports, reported := importSetOf(a); reported { for _, imp := range imports { var holder *meshcatalog.Artifact for _, m := range modules { @@ -464,12 +464,14 @@ func (ix *Indexer) withActs(ctx context.Context, entries map[string]meshcatalog. return WithActs(entries, defs) } -// importSetOf is the import set the entry's fingerprint was computed with (its inputs' imports), none before a report. -func importSetOf(a meshcatalog.CatalogEntry) []string { - if a.Inputs == nil || a.Inputs.From == nil { - return nil +// importSetOf is the import set the entry's fingerprint was computed with (its inputs' imports) and whether it is reported: +// the entry's import form is set (design 47 H2 H-A-538), and an absent imports is then the empty set (H-A-536); an entry +// on the version line has none. +func importSetOf(a meshcatalog.CatalogEntry) ([]string, bool) { + if a.Inputs == nil || a.Inputs.From == nil || a.Inputs.From.ImportForm == "" { + return nil, false } - return a.Inputs.From.Imports + return a.Inputs.From.Imports, true } // edgesOfPackages are kind 1 from the entry's packages, its go.mod's requirements, for an entry with no reported import set diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go index 92585d5f2..352d48874 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "os" "slices" + "strings" "testing" "time" @@ -57,12 +58,18 @@ func TestAnEntryCarriesItsEdgesOfKindsOneToFourAndSix(t *testing.T) { Package: &meshcatalog.ArtifactPackage{Ecosystem: EcosystemGo, Name: "git.example/other/go"}}}} imp := entries["app"] imp.Packages = map[string]string{"git.example/lib/go": "1.2.3", "git.example/other/go": "0.1.0"} - imp.Inputs = &meshcatalog.EntryInputs{From: &meshcatalog.FingerprintInputs{Imports: []string{"git.example/lib/go/sub/x"}}} + imp.Inputs = &meshcatalog.EntryInputs{From: &meshcatalog.FingerprintInputs{Imports: []string{"git.example/lib/go/sub/x"}, ImportForm: "src2:" + strings.Repeat("a", 64)}} entries["app"] = imp if got := WithEdges(entries)["app"].Edges; got[0] != (meshcatalog.Edge{Kind: 1, From: "sub:go", To: "app:program", Stale: true, Word: "imports", Why: "git.example/lib/go/sub/x"}) || slices.ContainsFunc(got[1:], func(e meshcatalog.Edge) bool { return e.Kind == 1 }) { t.Errorf("edges with an import set: %+v, want one kind 1 from sub:go and none from the requirements", got) } + // H-A-536, H-A-538: the entry's import form says its set is reported, an absent imports the empty set: no kind 1 at all. + imp.Inputs.From.Imports = nil + entries["app"] = imp + if got := WithEdges(entries)["app"].Edges; slices.ContainsFunc(got, func(e meshcatalog.Edge) bool { return e.Kind == 1 }) { + t.Errorf("edges with a reported empty import set: %+v, want no kind 1", got) + } } // Design 47 G A-208: a revision kept holds each entry with its edges, so the builder and the assigner read them from the entry. -- 2.54.0 From 3fffe7e2dd97728228ead2a43a05ee6d0ca4b7ec Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:26:47 +0100 Subject: [PATCH 11/34] S2: the step runner checks only that an import set is sorted and each once Nothing in a path or name tells a mesh package apart: mesh Go modules come from the Go package registry, not the forge. The per-language form check and its settings go (CheckGoImports, CheckNpmImports, DefaultNpmScope, AskSteps.ImportPrefix and ImportScope); CheckImports judges every seat's set sorted and each once, and the indexer keeps of it the packages a module of the module graph publishes. Builds: design 47 H2 H-A-539 (withdraws H-A-534's form check and H-A-535's settings) --- modules/mesh-delivery-sdk/steprun/askrun.go | 19 ++------ .../mesh-delivery-sdk/steprun/askrun_test.go | 17 ++++--- modules/mesh-delivery-sdk/trunk/packages.go | 47 ++----------------- modules/mesh-delivery-sdk/trunk/trunk_test.go | 32 ++++--------- 4 files changed, 24 insertions(+), 91 deletions(-) diff --git a/modules/mesh-delivery-sdk/steprun/askrun.go b/modules/mesh-delivery-sdk/steprun/askrun.go index ab4d93e39..90d3a6aa4 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun.go +++ b/modules/mesh-delivery-sdk/steprun/askrun.go @@ -66,10 +66,6 @@ type AskSteps struct { // fingerprint main's modules state holds (design 47 H2 H-A-517, H-A-532 DQ-2, DMC-2). A say that fails leaves the // build's answer standing and is said in the journal. Nil says none. SayImports func(nodebuildgo.ImportsReported) error - // ImportPrefix and ImportScope are the forms an import set is judged by, read from the build module's settings - // (design 47 H2 H-A-534): a Go build's imports are Go module paths under ImportPrefix, the forge's module prefix - // (trunk.ForgeModulePrefix when empty); a Node build's are npm names in ImportScope (trunk.DefaultNpmScope when empty). - ImportPrefix, ImportScope string // Outputs are the holder's outputs objects (OutputsStore), where a test step keeps its run's output as `.` (design 47 H2 §791, H-A-412), which the seat's verb output reads (OutputTool). Nil keeps none, said in the journal. Outputs OutputObjects @@ -94,7 +90,7 @@ func RunAsk(ctx context.Context, steps AskSteps, ask sdkstep.StepAsk) (any, erro if ask.Build != nil { job := *ask.Build job.Fetch = withPackages(job.Fetch, ask.Packages) - out, err := steps.build(ctx, job, ask.Version, ask.Language) + out, err := steps.build(ctx, job, ask.Version) var dec *Declining if err != nil && !sdkstep.IsPassing(err) && !errors.As(err, &dec) && ctx.Err() == nil { // A failed build keeps its error text, as the build module bounded it, as the ask's output object, header and @@ -212,7 +208,7 @@ func (s AskSteps) onToolchain(ctx context.Context, want *sdkstep.ToolchainUsed) // build runs a build job; version is the version the ask carries (design 47 G §573), which each artifact's build is given // as its argument version, the build's MESH_VERSION (§370), unless the artifact names its own. -func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version, language string) (any, error) { +func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version string) (any, error) { answer := sdkstep.BuildAnswer{} tc, err := s.onToolchain(ctx, job.Toolchain) if err != nil { @@ -330,7 +326,7 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version, lang if err := json.Unmarshal(r, &read); err != nil { return nil, fmt.Errorf("the imports of %s answered what is not a list: %s", job.Module, r) } - if err := s.checkImports(language, read.Imports); err != nil { + if err := trunk.CheckImports(read.Imports); err != nil { // sorted and each once only (design 47 H2 H-A-539) return nil, err } answer.Imports = read.Imports @@ -339,15 +335,6 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version, lang return answer, nil } -// checkImports judges a build's import set by the form of the language its build seat serves (design 47 H2 H-A-534): npm -// names in the mesh's scope for a Node build, Go module paths under the forge's prefix for every other. -func (s AskSteps) checkImports(language string, imports []string) error { - if language == sdkstep.AskNode { - return trunk.CheckNpmImports(imports, s.ImportScope) - } - return trunk.CheckGoImports(imports, s.ImportPrefix) -} - // sayImports says the import set a done build read (design 47 H2 H-A-517, H-A-532 DQ-2): the module, the fingerprint // it was asked for, its commit and the imports, an empty list when its programs import no mesh package. A failed say is // said in the journal and never fails the build (principle 3: loud, not lost). diff --git a/modules/mesh-delivery-sdk/steprun/askrun_test.go b/modules/mesh-delivery-sdk/steprun/askrun_test.go index 634058b67..51c997b83 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun_test.go +++ b/modules/mesh-delivery-sdk/steprun/askrun_test.go @@ -141,16 +141,19 @@ imports {"module":"modules/m","workspace":"/w/1"}` t.Errorf("a failed say: said %q, journal %q; want it said in the journal", said, journal) } said, sayErr = nil, nil - // Design 47 H2 H-A-534: an import set is judged by its build seat's form: npm names on the Node seat, Go paths on the Go seat. + // Design 47 H2 H-A-539: an import set is judged only sorted and each once, whatever its entries name, on every seat: + // a Go build's set naming an npm name and a module of another host is taken; an unsorted one is refused. steps.Imports = func(context.Context, map[string]any) (any, error) { - return map[string]any{"imports": []string{"@novox/mesh-sdk"}}, nil + return map[string]any{"imports": []string{"@novox/mesh-sdk", "github.com/x/y"}}, nil } - if _, err := RunAsk(context.Background(), steps, a); err == nil || !strings.Contains(err.Error(), "@novox/mesh-sdk") { - t.Errorf("an npm set on the Go seat: %v, want it refused", err) + if out, err := RunAsk(context.Background(), steps, a); err != nil || !slices.Equal(out.(sdkstep.BuildAnswer).Imports, []string{"@novox/mesh-sdk", "github.com/x/y"}) { + t.Errorf("a set of any names on the Go seat: %v, %v; want it taken", out, err) } - a.Language = sdkstep.AskNode - if out, err := RunAsk(context.Background(), steps, a); err != nil || !slices.Equal(out.(sdkstep.BuildAnswer).Imports, []string{"@novox/mesh-sdk"}) { - t.Errorf("an npm set on the Node seat: %v, %v; want it taken", out, err) + steps.Imports = func(context.Context, map[string]any) (any, error) { + return map[string]any{"imports": []string{"github.com/x/y", "@novox/mesh-sdk"}}, nil + } + if _, err := RunAsk(context.Background(), steps, a); err == nil || !strings.Contains(err.Error(), "sorted") { + t.Errorf("an unsorted set: %v, want it refused", err) } said = nil diff --git a/modules/mesh-delivery-sdk/trunk/packages.go b/modules/mesh-delivery-sdk/trunk/packages.go index 53df9f615..fd36260d7 100644 --- a/modules/mesh-delivery-sdk/trunk/packages.go +++ b/modules/mesh-delivery-sdk/trunk/packages.go @@ -28,53 +28,12 @@ func PackageRepository(pkg string) (repository, dir string, ok bool) { return "novox/" + name, dir, true } -// DefaultNpmScope is the npm scope of the mesh's npm packages when a build module's setting names none (design 47 H2 -// H-A-534): a TypeScript import set names each mesh npm package by its name in it, such as @novox/mesh-sdk. -const DefaultNpmScope = "@novox" - // CheckImports refuses an import set (the imports of a module's kept inputs, of a build's answer and of a build log entry) -// that holds a path that is no mesh package's, or is not sorted and each once. +// that is not sorted and each once. Nothing in a path or a name tells a mesh package apart (design 47 H2 H-A-539, which +// withdraws H-A-534's forms): a build module reports every module path or package name its build resolved but the +// language's standard library, and the indexer keeps of it the packages a module of the module graph publishes. func CheckImports(imports []string) error { - return CheckGoImports(imports, ForgeModulePrefix) -} - -// CheckGoImports refuses a Go import set holding a path that is no Go module path under prefix, the forge's module prefix -// a build module's setting names (design 47 H2 H-A-534), or that is not sorted and each once. -func CheckGoImports(imports []string, prefix string) error { - if prefix == "" { - prefix = ForgeModulePrefix - } - return checkSorted(imports, func(pkg string) error { - rest, found := strings.CutPrefix(pkg, prefix) - if name, _, _ := strings.Cut(rest, "/"); !found || name == "" || strings.ContainsAny(pkg, " \t\n@") { - return fmt.Errorf("trunk: the import %q is no mesh package's path (it starts with %s)", pkg, prefix) - } - return nil - }) -} - -// CheckNpmImports refuses a TypeScript import set holding an entry that is no npm package name in scope (such as -// @novox/mesh-sdk, never a sub-path of it: one package, one digest, H-A-532 DQ-6), or that is not sorted and each once -// (design 47 H2 H-A-534). -func CheckNpmImports(imports []string, scope string) error { - if scope == "" { - scope = DefaultNpmScope - } - return checkSorted(imports, func(pkg string) error { - name, found := strings.CutPrefix(pkg, scope+"/") - if !found || name == "" || strings.ContainsAny(name, "/@ \t\n") { - return fmt.Errorf("trunk: the import %q is no mesh npm package's name (%s/)", pkg, scope) - } - return nil - }) -} - -// checkSorted refuses imports holding an entry one refuses, or not sorted and each once. -func checkSorted(imports []string, one func(string) error) error { for i, pkg := range imports { - if err := one(pkg); err != nil { - return err - } if i > 0 && imports[i-1] >= pkg { return fmt.Errorf("trunk: the imports are not sorted and each once (%s after %s)", pkg, imports[i-1]) } diff --git a/modules/mesh-delivery-sdk/trunk/trunk_test.go b/modules/mesh-delivery-sdk/trunk/trunk_test.go index b565fe5f8..39b9ffc34 100644 --- a/modules/mesh-delivery-sdk/trunk/trunk_test.go +++ b/modules/mesh-delivery-sdk/trunk/trunk_test.go @@ -35,33 +35,17 @@ func TestSameRepository(t *testing.T) { // 1281/AC1 } func TestAnImportSetHoldsMeshPackagesSortedAndEachOnce(t *testing.T) { + // Design 47 H2 H-A-539: an import set is judged only sorted and each once, whatever forge, prefix or scope its entries name. a, b := ForgeModulePrefix+"mesh-sdk/go", ForgeModulePrefix+"mesh-delivery/modules/mesh-delivery-sdk" - if err := CheckImports([]string{b, a}); err != nil { - t.Errorf("a sorted set is refused: %v", err) - } - for name, bad := range map[string][]string{"unsorted": {a, b}, "twice": {a, a}, "not a mesh package": {"github.com/x/y"}, "a version": {a + "@v1"}} { - if CheckImports(bad) == nil { - t.Errorf("%s: %v is taken", name, bad) + for name, good := range map[string][]string{"Go module paths": {b, a}, "another host": {"example.org/x/y", "github.com/x/y"}, + "npm names": {"@novox/mesh-sdk", "@other/x", "left-pad"}, "none": nil} { + if err := CheckImports(good); err != nil { + t.Errorf("%s: %v is refused: %v", name, good, err) } } - // Design 47 H2 H-A-534: a Go set is judged under the prefix the build module's setting names, a TypeScript set by npm - // names in the mesh's scope, each package once (no sub-path, H-A-532 DQ-6). - if err := CheckGoImports([]string{"git.example.org/o/r/go"}, "git.example.org/o/"); err != nil { - t.Errorf("a Go set under another prefix is refused: %v", err) - } - if CheckGoImports([]string{a}, "git.example.org/o/") == nil { - t.Error("a Go set outside the prefix set is taken") - } - if err := CheckNpmImports([]string{"@novox/mesh-contracts-node-build-go", "@novox/mesh-sdk"}, ""); err != nil { - t.Errorf("an npm set in the default scope is refused: %v", err) - } - if err := CheckNpmImports([]string{"@acme/sdk"}, "@acme"); err != nil { - t.Errorf("an npm set in another scope is refused: %v", err) - } - for name, bad := range map[string][]string{"a Go path": {a}, "a sub-path": {"@novox/mesh-sdk/stdio"}, "another scope": {"@other/x"}, - "no scope": {"mesh-sdk"}, "unsorted": {"@novox/mesh-sdk", "@novox/a"}, "a version": {"@novox/mesh-sdk@1"}} { - if CheckNpmImports(bad, "") == nil { - t.Errorf("npm %s: %v is taken", name, bad) + for name, bad := range map[string][]string{"unsorted": {a, b}, "twice": {a, a}, "npm unsorted": {"@novox/mesh-sdk", "@novox/a"}} { + if CheckImports(bad) == nil { + t.Errorf("%s: %v is taken", name, bad) } } } -- 2.54.0 From 656bc8b5c2f4acd36e984041b38cbae130ca6747 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:30:00 +0100 Subject: [PATCH 12/34] I4: a fingerprint takes of a reported set only what the module graph publishes At every recompute, and where a report's import form is computed, the import set counts only the imports a package artifact of the module graph's entries holds (a Go module path or an npm name, itself or a path under it); any other import is outside the mesh and never sends the module to the version line. The state imports keeps the reported set whole. A graph state that cannot be listed keeps no name back, since its nodes name no package. Builds: design 47 H2 H-A-539, H-A-540 --- .../internal/index/form.go | 7 +- .../internal/index/imports.go | 7 +- .../internal/index/imports_test.go | 71 +++++++++++-------- .../internal/index/importset.go | 52 ++++++++++++++ .../internal/index/toolchains.go | 14 ++-- 5 files changed, 113 insertions(+), 38 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/form.go b/modules/mesh-delivery-indexer/internal/index/form.go index 1b1874c8a..ceceb5773 100644 --- a/modules/mesh-delivery-indexer/internal/index/form.go +++ b/modules/mesh-delivery-indexer/internal/index/form.go @@ -27,7 +27,8 @@ type form struct { // // - **The import form**, for a module whose import set is reported (reported: a key in the state imports, whatever the // set's length, or a set its value held before that state was, design 47 H2 H-A-536, H-A-537; the set is kept.Imports) -// when every import is published (the packages state): the content digest of each imported package and the requirements' digest of each +// when every import in the mesh (one a package of the module graph's entries holds, mesh; any other is outside it, +// H-A-539, H-A-540) is published (the packages state): the content digest of each imported package and the requirements' digest of each // mesh Go module holding one. Its versions are each holding module's published commit (another repository's only); an // import set naming none of another repository while the go.mod requires one keeps the version line's (refined). // - **A change of form never rebuilds by itself** (§4): kept.ImportForm is the import-form fingerprint of the inputs @@ -46,10 +47,10 @@ type form struct { // digests of that version's commit. // // It sets kept.ImportForm when it writes the import form. -func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, reported bool, toolchains map[string]meshcatalogclient.Toolchain2, prev meshcatalog.ModulesByModuleValue, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) form { +func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, reported bool, mesh map[string]bool, toolchains map[string]meshcatalogclient.Toolchain2, prev meshcatalog.ModulesByModuleValue, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) form { in := inputsFrom(module, *kept, toolchains) if reported { - r := fingerprint.Resolve(repository, kept.Imports, published) + r := fingerprint.Resolve(repository, inTheMesh(kept.Imports, mesh), published) if len(r.Missing) == 0 { in.Imports, in.Requires = r.Digests, r.Requires fp, none := fingerprint.Of(in) diff --git a/modules/mesh-delivery-indexer/internal/index/imports.go b/modules/mesh-delivery-indexer/internal/index/imports.go index 68888d8a6..22110afbe 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports.go +++ b/modules/mesh-delivery-indexer/internal/index/imports.go @@ -61,9 +61,12 @@ func (ix *Indexer) keepImports(ctx context.Context, e reported) (bool, error) { kept := *cur.Inputs2 kept.Imports, kept.ImportForm = slices.Clone(e.imports), "" digests := map[string]string{} - if built, err := ix.publishedAsBuilt(ctx, cur, e); err != nil { + mesh, meshErr := ix.meshPackages(ctx, nil) // the import form takes only what the module graph publishes (H-A-539, H-A-540) + if meshErr != nil { + ix.logf("%s: the packages the module graph publishes cannot be read (%v): its imports are kept, and its next recompute writes the import form", e.module, meshErr) + } else if built, err := ix.publishedAsBuilt(ctx, cur, e); err != nil { ix.logf("%s: the packages its build imported cannot be read as built (%v): its imports are kept, and its next recompute writes the import form", e.module, err) - } else if r := fingerprint.Resolve(cur.Repository, e.imports, built); len(r.Missing) > 0 { + } else if r := fingerprint.Resolve(cur.Repository, inTheMesh(e.imports, mesh), built); len(r.Missing) > 0 { ix.logf("%s: no published package holds %v: its imports are kept, and the recompute that resolves them writes the import form", e.module, r.Missing) } else { in := inputsFrom(e.module, kept, toolchains) diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index d4ab0b575..02ea1a4fe 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -65,11 +65,7 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T ix.Packages, ix.Files, ix.Imports = newMem(), listings.files, newMem() // avahi's go.sum names mesh-sdk (the version line), as every Go module's does; mesh-sdk's module is held at c1. setPackages(t, mods, "avahi", []string{meshSDK}) - sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) - if err != nil { - t.Fatal(err) - } - mods.put("mesh-sdk", sdkModule) + meshSDKPublished(t, ix, mods) held, _ := ix.heldModules(ctx) if err := ix.publish(ctx, "novox/mesh-sdk", c1, held, false, TrunkBranch); err != nil { t.Fatal(err) @@ -206,11 +202,7 @@ func onlyTheVersionLineTakesAPin(t *testing.T) { reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") ix.Packages, ix.Files, ix.Imports = newMem(), forge{c1: sdkFiles("a1", "b1")}.files, newMem() setPackages(t, mods, "avahi", []string{meshSDK}) - sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) - if err != nil { - t.Fatal(err) - } - mods.put("mesh-sdk", sdkModule) + meshSDKPublished(t, ix, mods) held, _ := ix.heldModules(ctx) if err := ix.publish(ctx, "novox/mesh-sdk", c1, held, false, TrunkBranch); err != nil { t.Fatal(err) @@ -278,16 +270,15 @@ func aReportedSetIsAKeyOrAHeldSet(t *testing.T) { }{ {"a reported empty set (H-A-536)", nil, false}, {"a set held before the state imports, no key (H-A-537)", []string{meshSDK + "/buildstep"}, true}, + // H-A-539, H-A-540: an import no entry of the module graph publishes is outside the mesh: kept whole in the state + // imports, never sending the module to the version line. + {"a set with an import outside the mesh (H-A-540)", []string{"github.com/x/y", meshSDK + "/buildstep"}, false}, } { ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") ix.Packages, ix.Files, ix.Imports = newMem(), forge{c1: sdkFiles("a1", "b1"), c3: sdkFiles("a2", "b1")}.files, newMem() setPackages(t, mods, "avahi", []string{meshSDK}) - sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) - if err != nil { - t.Fatal(err) - } - mods.put("mesh-sdk", sdkModule) + meshSDKPublished(t, ix, mods) held, _ := ix.heldModules(ctx) if err := ix.publish(ctx, "novox/mesh-sdk", c1, held, false, TrunkBranch); err != nil { t.Fatal(err) @@ -303,6 +294,8 @@ func aReportedSetIsAKeyOrAHeldSet(t *testing.T) { if err := ix.dropImportSet(ctx, "avahi"); err != nil { t.Fatal(err) } + } else if set, found, _ := ix.ImportSetOf(ctx, "avahi"); !found || len(set.Imports) != len(c.imports) { + t.Fatalf("%s: imports.avahi = %+v, %v; want the reported set whole", c.name, set, found) } if err := ix.Recompute(ctx); err != nil { t.Fatal(err) @@ -323,6 +316,34 @@ func aReportedSetIsAKeyOrAHeldSet(t *testing.T) { } } +// meshSDKPublished holds mesh-sdk at c1 as an entry of the module graph whose Go package artifact publishes meshSDK (its +// go.mod's module line), so an import of it is in the mesh (design 47 H2 H-A-539, H-A-540). +func meshSDKPublished(t *testing.T, ix *Indexer, mods *memStore) { + t.Helper() + manifest := `{"module":"mesh-sdk","version":"0.1","build":{"artifacts":[{"name":"go","kind":"package","language":"go","paths":["go"]}]}}` + digest := meshcatalogclient.ManifestDigest([]byte(manifest)) + kept, err := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "mesh-sdk", Manifest: manifest}) + if err != nil { + t.Fatal(err) + } + key, _ := meshcatalogclient.ManifestsKey(digest) + if ix.Manifests == nil { + ix.Manifests = newMem() + } + ix.Manifests.(*memStore).put(key, kept) + sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package", Manifest: digest}) + if err != nil { + t.Fatal(err) + } + mods.put("mesh-sdk", sdkModule) + ix.ReadFile = func(_ context.Context, repository, _, file string) ([]byte, error) { + if repository == "novox/mesh-sdk" && file == "go/go.mod" { + return []byte("module " + meshSDK + "\n"), nil + } + return nil, nil + } +} + // A build of a fingerprint the module no longer holds says nothing of its inputs now: its imports are not kept. func buildOfAnOlderFingerprintKeepsNoImports(t *testing.T) { ctx := context.Background() @@ -437,11 +458,7 @@ func anAcceptedSeriesPinsItsNewest(t *testing.T) { reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") ix.Packages, ix.Files = newMem(), forge{c1: sdkFiles("a1", "b1"), c2: sdkFiles("a1", "b2"), c3: sdkFiles("a2", "b2")}.files setPackages(t, mods, "avahi", []string{meshSDK}) - sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) - if err != nil { - t.Fatal(err) - } - mods.put("mesh-sdk", sdkModule) + meshSDKPublished(t, ix, mods) step := func(what string, act func() error) meshcatalog.ModulesByModuleValue { t.Helper() if err := act(); err != nil { @@ -504,11 +521,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") ix.Packages, ix.Files = newMem(), forge{c1: sdkFiles("a1", "b1"), c3: sdkFiles("a2", "b2")}.files setPackages(t, mods, "avahi", []string{meshSDK}) - raw, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) - if err != nil { - t.Fatal(err) - } - mods.put("mesh-sdk", raw) + meshSDKPublished(t, ix, mods) held, _ := ix.heldModules(ctx) if err := ix.publish(ctx, "novox/mesh-sdk", c1, held, false, TrunkBranch); err != nil { t.Fatal(err) @@ -602,7 +615,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * {"a build's imports naming none of another repository, which none publishes", held, []string{own}, ""}, } { kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}, Imports: c.imports} - f := formOf("avahi", "novox/mesh-catalog", &kept, c.imports != nil, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, c.imports != nil, map[string]bool{contracts: true, own: true, meshSDK: true}, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, nil) if got := f.versions[contracts]; got != c.want { t.Errorf("%s: version of %s = %q, want %q", c.name, contracts, got, c.want) } @@ -614,12 +627,12 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * // so the module has a fingerprint, and the same tree gives the same one whatever commit names it. sibling := "git.novox.be/novox/mesh-catalog/modules/sibling" kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t\nderived modules/sibling o1", Packages: []string{sibling}} - f := formOf("avahi", "novox/mesh-catalog", &kept, false, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, false, map[string]bool{contracts: true, own: true, meshSDK: true}, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) if f.fp == "" { t.Fatalf("an unpublished package of the same repository: none %q, want a fingerprint by its directory's tree", f.none) } kept.Tree = "t\nderived modules/sibling o2" - if g := formOf("avahi", "novox/mesh-catalog", &kept, false, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil); g.fp == "" || g.fp == f.fp { + if g := formOf("avahi", "novox/mesh-catalog", &kept, false, map[string]bool{contracts: true, own: true, meshSDK: true}, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil); g.fp == "" || g.fp == f.fp { t.Errorf("the sibling's directory changed: fingerprint %q, was %q; want a new one", g.fp, f.fp) } }) @@ -629,7 +642,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * imports []string }{{"an import no package holds", []string{meshSDK + "/announce"}}, {"no import reported", nil}} { kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Imports: c.imports, ImportForm: "src2:" + strings.Repeat("a", 64)} - f := formOf("avahi", "novox/mesh-catalog", &kept, c.imports != nil, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, c.imports != nil, map[string]bool{meshSDK: true}, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) if kept.ImportForm != "" { t.Errorf("%s: kept import form %q after the version line %q", c.name, kept.ImportForm, f.fp) } diff --git a/modules/mesh-delivery-indexer/internal/index/importset.go b/modules/mesh-delivery-indexer/internal/index/importset.go index 09a6601f4..2867c5e51 100644 --- a/modules/mesh-delivery-indexer/internal/index/importset.go +++ b/modules/mesh-delivery-indexer/internal/index/importset.go @@ -6,10 +6,12 @@ import ( "errors" "fmt" "slices" + "strings" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" stdio "git.novox.be/novox/mesh-sdk/go" ) @@ -194,3 +196,53 @@ func (ix *Indexer) trunkImportForm(ctx context.Context, key string, imports []st } return m.Inputs2.ImportForm } + +// meshPackages are the names of the packages the entries of the module graph being computed publish (its held modules, +// as viewEntries gives each its artifacts; the graph's nodes name no package, so a graph state that cannot be listed +// keeps nothing from it, ADR 0603 §2), a Go module path or an npm name each: what a reported import set is held against +// at every recompute (design 47 H2 H-A-539, H-A-540). held nil reads the indexer's modules. +func (ix *Indexer) meshPackages(ctx context.Context, held map[string]meshcatalog.ModulesByModuleValue) (map[string]bool, error) { + if held == nil { + var err error + if held, err = ix.heldModules(ctx); err != nil { + return nil, err + } + } + names := map[string]bool{} + for name, cur := range held { + if cur.Manifest == "" { + continue + } + raw, m, err := ix.manifestRaw(ctx, cur.Manifest) + if err != nil { + continue // a manifest that cannot be read publishes nothing this pass; the recompute says it of the module + } + for _, a := range ix.withArtifacts(ctx, CatalogEntryOf(name, cur, m, raw, graph.Node{}), m).Artifacts { + if p := a.Package; p != nil && p.Name != "" && (p.Ecosystem == EcosystemGo || p.Ecosystem == EcosystemNpm) { + names[p.Name] = true + } + } + } + return names, nil +} + +// inTheMesh are the imports a package of names holds, the package itself or a path under it (I9's reading); any other +// import is outside the mesh, and never sends the module to the version line (design 47 H2 H-A-539, H-A-540). The state +// imports keeps the set whole; only what the fingerprint takes is held against names. +func inTheMesh(imports []string, names map[string]bool) []string { + var out []string + for _, imp := range imports { + for p := imp; p != ""; { + if names[p] { + out = append(out, imp) + break + } + i := strings.LastIndex(p, "/") + if i < 0 { + break + } + p = p[:i] + } + } + return out +} diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index bc1688871..a6935710a 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -235,6 +235,12 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc ix.logf("no fingerprint is written by this pass: %v", err) return fmt.Errorf("no fingerprint is written: %w", err) } + // The packages the module graph's entries publish: a reported import set counts only those (design 47 H2 H-A-539, H-A-540). + mesh, err := ix.meshPackages(ctx, held) + if err != nil { + ix.logf("no fingerprint is written by this pass: the packages the module graph publishes cannot be read: %v", err) + return fmt.Errorf("no fingerprint is written: %w", err) + } series := ix.SeriesAll(ctx) // each package's series, the newest a user accepting it takes (DLV-I6) type result struct { fp, none string @@ -308,11 +314,11 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc r.none = strings.Join(missing, "; ") case noToolchain != "": r.none = noToolchain - if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, series); ok { + if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, series, mesh); ok { r = result{fp: fp, tcs: k.held.Toolchains, pkgs: pkgs} } default: - f := formOf(module, k.cur.Repository, &kept, k.reported, toolchains, k.held, held, pub, pins, ix.logf) + f := formOf(module, k.cur.Repository, &kept, k.reported, mesh, toolchains, k.held, held, pub, pins, ix.logf) r.fp, r.none = f.fp, f.none if r.fp != "" { // a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167) @@ -519,7 +525,7 @@ func hasContext(m catalogue.Manifest) bool { // with the toolchains it was computed with in place of the languages agreed on none, give it again, in its form. Any // other input that moved (a merge, a base, an agreed toolchain, an imported package) gives another fingerprint, and the // module has none until they agree. -func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, series map[string]SeriesPackage) (string, sdkstep.PackageVersions, bool) { +func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, series map[string]SeriesPackage, mesh map[string]bool) (string, sdkstep.PackageVersions, bool) { if k.held.Fp2 == "" { return "", nil, false } @@ -535,7 +541,7 @@ func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, } toolchains[artifact] = meshcatalogclient.Toolchain2{Language: language, Version: used.Version, Recipe: used.Recipe} } - f := formOf(module, k.held.Repository, &kept, k.reported, toolchains, k.held, held, published, pins, nil) + f := formOf(module, k.held.Repository, &kept, k.reported, mesh, toolchains, k.held, held, published, pins, nil) if f.none != "" || f.fp == "" { return "", nil, false } -- 2.54.0 From 72373ba68d3698b8290cb062ebbd19e7895c270d Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:30:51 +0100 Subject: [PATCH 13/34] I5: a release re-pins only modules on the version line repinned names no module whose import form is set: its fingerprint takes no pin, so a release of a package it imports never moves it; a module on the version line is named as before. Builds: design 47 H2 H-A-530, H-A-538 --- .../internal/index/repin_test.go | 14 ++++++++++++++ .../internal/index/toolchains.go | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-indexer/internal/index/repin_test.go b/modules/mesh-delivery-indexer/internal/index/repin_test.go index 4b8a750c8..65baaf3ad 100644 --- a/modules/mesh-delivery-indexer/internal/index/repin_test.go +++ b/modules/mesh-delivery-indexer/internal/index/repin_test.go @@ -77,6 +77,20 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) { if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", GoModule: "git.novox.be/novox/mesh-sdk/go", Version: "0.1.27", Published: true}); err != nil { t.Fatal(err) } + // I5/AC1 (design 47 H2 H-A-530): a module on the import form (its import form set, H-A-538) is named by no re-pin; + // I5/AC2: on the version line, as g is, it is. + onImports := g + in := *g.Inputs2 + in.Imports, in.ImportForm = []string{"git.novox.be/novox/mesh-sdk/go"}, "src2:"+strings.Repeat("a", 64) + onImports.Inputs2 = &in + mods.put("g", mustEncode(t, onImports)) + if only, err := ix.repinned(ctx, "mesh-sdk"); err != nil || only["g"] { + t.Errorf("a re-pin of mesh-sdk names %v (%v), want no module on the import form", only, err) + } + mods.put("g", mustEncode(t, g)) + if only, err := ix.repinned(ctx, "mesh-sdk"); err != nil || !only["g"] { + t.Errorf("a re-pin of mesh-sdk names %v (%v), want g, on the version line", only, err) + } if n, err := ix.Repin(ctx, "mesh-sdk", "0.1.27"); err != nil || n != 2 { t.Errorf("a release of mesh-sdk re-pinned %d modules (%v), want g on each of the two branches, which requires it with no pin", n, err) } diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index a6935710a..64dcdb86d 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -702,7 +702,9 @@ func (ix *Indexer) repinModules(ctx context.Context, branch string, modules []st } // repinned are the modules the indexer's modules state holds whose packages name a package of module: by their pins, and -// by their kept requirements, which name a package they hold no pin of yet (design 47 H-A-204, H-A-165, H-A-167). +// by their kept requirements, which name a package they hold no pin of yet (design 47 H-A-204, H-A-165, H-A-167). Only a +// module on the version line is named: one on the import form (its import form set, H2 H-A-538) takes no pin into its +// fingerprint, so a release never moves it (H-A-530). func (ix *Indexer) repinned(ctx context.Context, module string) (map[string]bool, error) { held, err := ix.heldModules(ctx) if err != nil { @@ -710,6 +712,9 @@ func (ix *Indexer) repinned(ctx context.Context, module string) (map[string]bool } only := map[string]bool{} for key, m := range held { + if m.Inputs2 != nil && m.Inputs2.ImportForm != "" { + continue + } names := slices.Collect(maps.Keys(m.Packages)) if m.Inputs2 != nil { names = append(names, m.Inputs2.Packages...) -- 2.54.0 From a72428a00f7ea395827fa5e43b6e3cd6d04a477a Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:32:18 +0100 Subject: [PATCH 14/34] I7: a take-in's movers by import grain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A module of any repository whose import set is reported moves when its fingerprint moved, and only then: a reported set holding no changed package names no mover. A module with no reported set keeps the fallback that exists, moving by its requirements. Builds: design 47 H2 H-A-520, H-A-528, H-A-536, H-A-538; design 47 H §743; ADR 0593 §3 --- .../internal/index/movers.go | 21 ++++++++++++------- .../internal/index/movers_test.go | 18 ++++++++++++++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/movers.go b/modules/mesh-delivery-indexer/internal/index/movers.go index e18eaf5de..a1cd9efef 100644 --- a/modules/mesh-delivery-indexer/internal/index/movers.go +++ b/modules/mesh-delivery-indexer/internal/index/movers.go @@ -8,11 +8,14 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" ) -// moversOf are the movers of one take-in (design 47 H §743, A-476a): of the modules registered for a repository the source -// revision moved (moved, by the entry's repository), those whose fingerprint differs from their entry in before, the branch's -// newest catalog revision (one it does not hold included); and every module, in any repository, that imports a package one of -// them publishes. A module with no fingerprint (no build) is no mover. One {module, commit, fingerprint, repository} per mover, -// by module name. +// moversOf are the movers of one take-in (design 47 H §743, A-476a as H2 H-A-520 amends it): of the modules registered for +// a repository the source revision moved (moved, by the entry's repository), those whose fingerprint differs from their +// entry in before, the branch's newest catalog revision (one it does not hold included); every module, in any repository, +// whose import set is reported (its entry's import form, H-A-536, H-A-538) and whose fingerprint differs from its entry +// in before, since its fingerprint moves only with a package it imports (H-A-520, ADR 0593 §3); and every module with no +// reported import set that requires a package one of the fingerprint's movers publishes, by its packages (the fallback +// that exists, H-A-528). A module whose reported set holds no changed package is no mover. A module with no fingerprint +// (no build) is no mover. One {module, commit, fingerprint, repository} per mover, by module name. func moversOf(before []meshcatalog.CatalogEntry, after map[string]meshcatalog.CatalogEntry, moved []string) []meshcatalog.TakeInEntry { was := make(map[string]string, len(before)) for _, e := range before { @@ -24,10 +27,12 @@ func moversOf(before []meshcatalog.CatalogEntry, after map[string]meshcatalog.Ca movers := map[string]bool{} published := map[string]bool{} // the packages the fingerprint's movers publish, by name for name, e := range after { - if e.Fp == "" || !inMoved(e.Repository) { + if e.Fp == "" { continue } - if fp, ok := was[name]; ok && fp == e.Fp { + fp, held := was[name] + _, reported := importSetOf(e) + if !inMoved(e.Repository) && !(reported && held) || held && fp == e.Fp { continue } movers[name] = true @@ -38,7 +43,7 @@ func moversOf(before []meshcatalog.CatalogEntry, after map[string]meshcatalog.Ca } } for name, e := range after { - if movers[name] || e.Fp == "" { + if _, reported := importSetOf(e); movers[name] || e.Fp == "" || reported { continue } for p := range e.Packages { diff --git a/modules/mesh-delivery-indexer/internal/index/movers_test.go b/modules/mesh-delivery-indexer/internal/index/movers_test.go index 82218d497..137d25383 100644 --- a/modules/mesh-delivery-indexer/internal/index/movers_test.go +++ b/modules/mesh-delivery-indexer/internal/index/movers_test.go @@ -7,8 +7,9 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" ) -// A take-in's movers (design 47 H §743, A-476a): the moved repository's modules whose fingerprint moved, and every module that -// imports a package of one of them; a module of another repository is no mover by its fingerprint alone. +// A take-in's movers (design 47 H §743, A-476a as H2 H-A-520 amends it): the moved repository's modules whose fingerprint +// moved, every module with a reported import set whose fingerprint moved, and every module with none that requires a package +// of one of them (H-A-528); a module of another repository with no reported set is no mover by its fingerprint alone. func TestMoversOf(t *testing.T) { sdk := func(fp string) meshcatalog.CatalogEntry { return meshcatalog.CatalogEntry{Module: "mesh-sdk", Repository: "novox/mesh-sdk", Commit: "s" + fp, Fp: fp, @@ -16,6 +17,12 @@ func TestMoversOf(t *testing.T) { } importer := meshcatalog.CatalogEntry{Module: "gate", Repository: "novox/mesh-catalog", Commit: "g1", Fp: "g", Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.20"}} + // Design 47 H2 H-A-520, H-A-536, H-A-538: an importer whose import set is reported (its import form set). + reported := func(fp string) meshcatalog.CatalogEntry { + return meshcatalog.CatalogEntry{Module: "avahi", Repository: "novox/mesh-catalog", Commit: "a1", Fp: fp, + Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.20"}, + Inputs: &meshcatalog.EntryInputs{From: &meshcatalog.FingerprintInputs{Imports: []string{"git.novox.be/novox/mesh-sdk/go/announce"}, ImportForm: "src2:a"}}} + } other := func(fp string) meshcatalog.CatalogEntry { return meshcatalog.CatalogEntry{Module: "feh", Repository: "novox/mesh-catalog", Commit: "f1", Fp: fp} } @@ -41,6 +48,13 @@ func TestMoversOf(t *testing.T) { entries(sdk("1"), other("f2")), []string{"novox/mesh-sdk"}, nil}, {"a module the newest revision does not hold moves", nil, entries(other("f")), []string{"novox/mesh-catalog"}, []string{"feh"}}, + // I7/AC1, AC2: a mesh-sdk commit changing announce moves mesh-sdk, the reported importer of announce, whose fingerprint + // moved, and gate, with no reported set, by its requirement (H-A-528). + {"a reported importer whose fingerprint moved moves", []meshcatalog.CatalogEntry{sdk("1"), importer, reported("a")}, + entries(sdk("2"), importer, reported("a2")), []string{"novox/mesh-sdk"}, []string{"avahi", "gate", "mesh-sdk"}}, + // I7/AC3: one changing buildstep alone leaves the reported importer of announce where it was: no mover. + {"a reported importer of no changed package is no mover", []meshcatalog.CatalogEntry{sdk("1"), importer, reported("a")}, + entries(sdk("2"), importer, reported("a")), []string{"novox/mesh-sdk"}, []string{"gate", "mesh-sdk"}}, {"a module with no fingerprint is no mover", nil, entries(other("")), []string{"novox/mesh-catalog"}, nil}, } { -- 2.54.0 From f8f1c6d3780d80ed950697409fd5bfd302e86c17 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:36:49 +0100 Subject: [PATCH 15/34] I10: the indexer's whole test at import grain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The whole test now reports the import sets of two requirers of mesh-sdk: the importer of buildstep and a requirer importing announce alone. A mesh-sdk commit changing buildstep moves mesh-sdk, the importer and a module with no report (by its requirement), never the requirer. The release's re-pin names only the version-line module. The bed's durable hears the Go build seat's imports-reported, as the manifest's consumes names it. Builds: design 47 test 80; design 47 G §56; design 47 H2 H-A-520, H-A-521, H-A-528, H-A-530; H-A-532 DMC-7 --- .../mesh-delivery-indexer/integration_test.go | 4 +- .../packages_integration_test.go | 61 +++++++++++++------ 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go index 8eace1c5a..bc4c1b7ba 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go @@ -802,9 +802,9 @@ func serveAssignerAssignments(t *testing.T, ctx context.Context, js jetstream.Je if _, err := js.CreateOrUpdateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-indexer", AckPolicy: jetstream.AckExplicitPolicy, // and the build seat's step-ended the manifest's consumes names (design 47 G §713: the end of a validation ask), and the // builder's version-reserved, which no stream of its own keeps (design 47 H2 §805), and the Go package registry seat's - // published, a series' newest a pin names (H-A-495 addendum). + // published, a series' newest a pin names (H-A-495 addendum), and the Go build seat's imports-reported (design 47 H2 H-A-517). FilterSubjects: []string{"mesh.mod." + assignerHolderModule + ".event.views.>", meshcatalog.SubjectRoom, nodebuildgo.SubjectStepEndedAll, meshbuilds.SubjectVersionReserved, - gopackageregistry.SubjectPublished}}); err != nil { + gopackageregistry.SubjectPublished, nodebuildgo.SubjectImportsReportedAll}}); err != nil { t.Fatal(err) } em := views.Emitter{Owner: assignerHolderModule, Subject: process.Account{Node: "n1", Module: assignerHolderModule}.EventSubject, diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go index 005612c6a..29eaca773 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go @@ -64,16 +64,18 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name return m } -// TestASourceRevisionMovingMeshSDKNamesItAndItsImporters (design 47 H §743; A-476a; ADR 0593 §2 to §4): the indexer whole against -// the bus. Two Go modules of the catalogue, importer, whose go.mod requires mesh-sdk's Go module at the zero version (no -// go.sum line names it, ADR 0573 §2; design 47 H-A-157), and plain, which requires -// nothing of it, are taken in with mesh-sdk as main's first source revision. A source revision moving mesh-sdk to a commit -// changing its buildstep package is taken in as one revision whose movers are mesh-sdk and importer, of another repository, -// and not plain; the packages key of mesh-sdk/go names that commit with a digest per package. Design 47 H2 §804: a key a dry +// TestASourceRevisionMovingMeshSDKNamesItAndItsImporters (design 47 H §743; A-476a as H2 H-A-520 amends it; ADR 0593 §2 to +// §4; test 80): the indexer whole against the bus. Four Go modules of the catalogue are taken in with mesh-sdk as main's first +// source revision: importer, requirer and legacy, whose go.mod requires mesh-sdk's Go module at the zero version (no go.sum +// line names it, ADR 0573 §2; design 47 H-A-157), and plain, which requires nothing of it. importer's build reports that it +// imports mesh-sdk's buildstep package, requirer's that it imports announce (imports-reported, H-A-517), and legacy reports +// none. A source revision moving mesh-sdk to a commit changing buildstep alone is taken in as one revision whose movers are +// mesh-sdk, importer, of another repository, and legacy, by its requirement (H-A-528), never requirer, which imports none of +// it, nor plain (I10/AC1); the packages key of mesh-sdk/go names that commit with a digest per package. Design 47 H2 §804: a key a dry // run left in the state dry-runs is gone at the start, and the take-in of a branch moving mesh-sdk again, a dry run, leaves // the trunk's packages state byte for byte as before and no key in dry-runs once it answered. // -// Design 47 H2 §802 (H-A-453 (3)): the catalogue holds 36 modules, among them lib-a and lib-b, required by app-a (a require) and +// Design 47 H2 §802 (H-A-453 (3)): the catalogue holds 38 modules, among them lib-a and lib-b, required by app-a (a require) and // app-b (a require and a replace by a directory); a source revision moving the catalogue to a commit that changes a test file // of lib-a and one of lib-b, and so their trees alone, moves lib-a, lib-b and their importers alone, never the other 32 // modules whose repository's commit moved too. @@ -81,8 +83,9 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name // Design 47 H2 §805 (H-A-453 (3)) and H-A-495 with its addendum: the builder's twenty version-reserved of mesh-sdk in that // revision's pipeline (twenty artifacts of its Go package, as repin_test.go reads them) are kept in heard and gathered, and // they and its pipeline-started move no pin: a pin names only a published version. The release of the reserved version (the -// Go package registry seat's published and every artifact's package-published) keeps one re-pin revision of main, importer -// its mover pinned to it; the next pipeline's reservation keeps none, so the revision after it is the next release's. +// Go package registry seat's published and every artifact's package-published) keeps one re-pin revision of main, legacy, +// on the version line, its mover pinned to it, and importer, on the import form, never named again (I10/AC2; H-A-521, +// H-A-530); the next pipeline's reservation keeps none, so the revision after it is the next release's. func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { const ( sdkGo = "git.novox.be/novox/mesh-sdk/go" @@ -115,13 +118,17 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { "package.json": "3333333333333333333333333333333333333333", "package-lock.json": "4444444444444444444444444444444444444444", "tsconfig.json": "5555555555555555555555555555555555555555"}}} } - var packages, dryRuns, heardKV jetstream.KeyValue + var packages, imports, dryRuns, heardKV jetstream.KeyValue var heard *takeIns js, ctx, _, _ := startIndexer(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) { var err error if packages, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.PackagesState), History: index.PackagesHistory}); err != nil { t.Fatal(err) } + // The state imports, where a reported import set is kept (H-A-527). + if imports, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.ImportsState), History: 1}); err != nil { + t.Fatal(err) + } // The state taken, which names each repository's taken commit the packages are published at (ADR 0593 §2). if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.TakenState), History: 1}); err != nil { t.Fatal(err) @@ -171,15 +178,20 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { if _, err := dryRuns.Put(ctx, index.DryRunPrefix("beta", "0123")+index.PackagesState+".left", []byte(`{"value":"e30="}`)); err != nil { t.Fatal(err) } - catalogue := repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2"}, + catalogue := repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2", "modules/requirer": "t3", "modules/legacy": "t4"}, files: map[string]string{"modules/importer/module.json": named("importer"), "modules/plain/module.json": named("plain"), + "modules/requirer/module.json": named("requirer"), "modules/legacy/module.json": named("legacy"), + "modules/requirer/go.mod": goModContent, "modules/requirer/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n", + "modules/legacy/go.mod": goModContent, "modules/legacy/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n", "modules/importer/go.mod": goModContent, "modules/importer/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n", "modules/plain/go.mod": "module plain\n\nrequire golang.org/x/sys v0.1.0\n", "modules/plain/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n"}, paths: map[string]map[string]string{"": {"modules/lib-a": "a1", "modules/lib-b": "b1"}}} registrations := []meshcatalog.Registration{{V: 1, Module: "importer", Origin: "novox/mesh-catalog", Path: "modules/importer", Branches: []string{"main"}}, {V: 1, Module: "plain", Origin: "novox/mesh-catalog", Path: "modules/plain", Branches: []string{"main"}}, + {V: 1, Module: "requirer", Origin: "novox/mesh-catalog", Path: "modules/requirer", Branches: []string{"main"}}, + {V: 1, Module: "legacy", Origin: "novox/mesh-catalog", Path: "modules/legacy", Branches: []string{"main"}}, {V: 1, Module: "mesh-sdk", Origin: "novox/mesh-sdk", Path: ".", Branches: []string{"main", "beta"}}} - // §802: 34 more modules of the catalogue, 36 with importer and plain: the libraries, their importers and 30 others. + // §802: 34 more modules of the catalogue, 38 with importer, requirer, legacy and plain: the libraries, their importers and 30 others. goMods := map[string]string{"lib-a": "module " + catalogModule + "lib-a\n", "lib-b": "module " + catalogModule + "lib-b\n", "app-a": "module app-a\n\nrequire " + catalogModule + "lib-a v0.0.0-00010101000000-000000000000\n", "app-b": "module app-b\n\nrequire " + catalogModule + "lib-b v0.0.0-00010101000000-000000000000\n\nreplace " + catalogModule + "lib-b => ../lib-b\n"} @@ -251,6 +263,17 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { if _, ok := plain.Packages[sdkGo]; ok { t.Fatalf("plain requires %s: %+v", sdkGo, plain.Packages) } + // importer's and requirer's builds end, reporting their import sets (H-A-517), kept in the state imports; their + // fingerprints stay as they were (ADR 0593 §4, H-A-529), so requirer is no mover below. + for module, imported := range map[string]string{"importer": sdkGo + "/buildstep", "requirer": sdkGo + "/announce"} { + held := untilModule(t, ctx, js, module, func(m meshcatalog.ModulesByModuleValue) bool { return m.Fp2 != "" }) + raw, _ := json.Marshal(nodebuildgo.ImportsReported{Node: "n1", Module: module, Fingerprint: held.Fp2, Commit: catalogMerge, Imports: []string{imported}}) + if _, err := js.Publish(ctx, nodebuildgo.SubjectImportsReported("n1"), raw); err != nil { + t.Fatal(err) + } + key, _ := meshcatalogclient.ModulesKey(module) + untilKey(t, ctx, imports, key, func(v []byte) bool { return v != nil }) + } say(11, false, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-sdk", Commit: m2}) taken := heard.next(t, "main", 11) @@ -259,8 +282,8 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { movers = append(movers, e.Module) } slices.Sort(movers) - if !slices.Equal(movers, []string{"importer", "mesh-sdk"}) { - t.Errorf("the take-in of mesh-sdk at %s names the movers %v, want mesh-sdk and its importer, not plain", m2, movers) + if !slices.Equal(movers, []string{"importer", "legacy", "mesh-sdk"}) { + t.Errorf("the take-in of mesh-sdk at %s names the movers %v, want mesh-sdk, the importer of buildstep and legacy by its requirement, not requirer or plain", m2, movers) } key, _ := index.PackagesKey(sdkGo) untilKey(t, ctx, packages, key, func(v []byte) bool { @@ -278,7 +301,7 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { } slices.Sort(movers) if !slices.Equal(movers, []string{"app-a", "app-b", "lib-a", "lib-b"}) { - t.Errorf("the catalogue's commit changing lib-a's and lib-b's tests moves %v of its 36 modules, want lib-a, lib-b and their importers alone", movers) + t.Errorf("the catalogue's commit changing lib-a's and lib-b's tests moves %v of its 38 modules, want lib-a, lib-b and their importers alone", movers) } // §805, H-A-495: twenty reservations of mesh-sdk's packages in main's revision of source 12, kept and gathered, and its @@ -365,17 +388,17 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { started(r) release(r, "0.1.28") if rev := untilRevision(r + 1); rev.CallKind != meshcatalog.CatalogRevisionCallKindRelease || rev.Call != index.ReleaseCall("mesh-sdk", "0.1.28") || - len(rev.Movers) != 1 || rev.Movers[0].Module != "importer" { - t.Errorf("main.%d = %+v, want the re-pin revision of the release of mesh-sdk 0.1.28, importer its mover: twenty reservations move no pin", r+1, rev) + len(rev.Movers) != 1 || rev.Movers[0].Module != "legacy" { + t.Errorf("main.%d = %+v, want the re-pin revision of the release of mesh-sdk 0.1.28, legacy (the version line) its one mover: twenty reservations move no pin, and importer and requirer (the import form) are never named again", r+1, rev) } - untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.28" }) + untilModule(t, ctx, js, "legacy", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.28" }) reserve(r+1, "0.1.29", 1) started(r + 1) release(r+1, "0.1.29") if rev := untilRevision(r + 2); rev.Call != index.ReleaseCall("mesh-sdk", "0.1.29") { t.Errorf("main.%d = %+v, want the re-pin of the release of mesh-sdk 0.1.29: the reservation of 0.1.29 keeps no revision", r+2, rev) } - untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.29" }) + untilModule(t, ctx, js, "legacy", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.29" }) // A branch's take-in moving mesh-sdk to m3 is a dry run: its packages stay in dry-runs while it runs, the trunk's are // untouched, and its keys go once it answered (§804). -- 2.54.0 From 481d1f255be245a0569b94708d6167b4cbb9d016 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:47:59 +0100 Subject: [PATCH 16/34] B1a: the builder's version floor and its wait go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The numbering from before G goes with its floor wait (design 47 H §756): the builder asks no floor (seat git.tags, the registry seats' versions, the entries' requirements), keeps no state floor-waits, serves neither builder_floor_again nor builder_floor_waits, raises no floor-silent finding and hears no take-in.taken or condition-cleared to wake one. The claim numbering that asked the floor (Numberer.Number, build.Numbers) goes with it; the reservation is the one place a version is numbered. Builds: design 47 H §756, G §372, spec 29, 41, 47, 48 --- .../cmd/mesh-delivery-builder-tools/main.go | 22 +- .../reservedname_test.go | 2 +- .../cmd/mesh-delivery-builder/catalog.go | 5 - .../cmd/mesh-delivery-builder/findings.go | 18 - .../mesh-delivery-builder/integration_test.go | 39 +- .../cmd/mesh-delivery-builder/main.go | 32 +- .../cmd/mesh-delivery-builder/names.go | 7 +- .../cmd/mesh-delivery-builder/names_test.go | 11 +- .../cmd/mesh-delivery-builder/reasks.go | 14 +- .../cmd/mesh-delivery-builder/refused_test.go | 49 +-- .../cmd/mesh-delivery-builder/reserve_test.go | 4 +- .../cmd/mesh-delivery-builder/seats.go | 36 +- .../cmd/mesh-delivery-builder/versions.go | 132 +------ .../internal/build/entry_test.go | 5 - .../internal/build/numbers.go | 83 ---- .../internal/build/run.go | 20 - .../internal/build/run_test.go | 77 +--- .../internal/build/stuck.go | 19 +- .../internal/versions/again.go | 17 - .../internal/versions/claim.go | 205 +--------- .../internal/versions/entrynames.go | 17 - .../internal/versions/entrynames_test.go | 19 - .../internal/versions/floor.go | 332 ---------------- .../internal/versions/heard.go | 19 +- .../internal/versions/oldform.go | 2 + .../internal/versions/store.go | 68 ---- .../internal/versions/tools.go | 1 - .../internal/versions/versions.go | 119 ------ .../internal/versions/versions_test.go | 364 ++---------------- .../mesh-delivery-builder/manifest_test.go | 13 +- modules/mesh-delivery-builder/module.json | 6 - 31 files changed, 97 insertions(+), 1660 deletions(-) delete mode 100644 modules/mesh-delivery-builder/internal/versions/floor.go diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go index 9e164d827..84cb5a258 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go @@ -44,7 +44,7 @@ type queueAsker func(key string, value []byte) (json.RawMessage, error) // builder_versions, asked by a name, answers also what the verb reserved answers for it (reserve; design 47 G §572): the // bundle calls the seat mesh-builds through its invokes, as any caller does. Nil answers none. func Tools(r build.StuckReader, askAgain func(key string, value []byte) error, queue, buildAgain queueAsker, since build.LogSince, now func() time.Time, vs versions.Reader, - fw, of versions.Reader, reserve func(name, version string) (meshbuilds.ReservedAnswer, error)) []stdio.Tool { + of versions.Reader, reserve func(name, version string) (meshbuilds.ReservedAnswer, error)) []stdio.Tool { str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) } // handAct writes a reasks value of a versions hand act and answers the builder's answer, or its refusal as an error. handAct := func(key string, value []byte, err error) (any, error) { @@ -65,13 +65,6 @@ func Tools(r build.StuckReader, askAgain func(key string, value []byte) error, q return map[string]any{"key": key, "name": a.Name, "answer": a.Answer}, nil } return []stdio.Tool{ - {Name: versions.FloorAgainTool, Description: versions.FloorAgainDescription, - Input: map[string]any{"type": "object", "required": []string{"name", "why"}, "properties": map[string]any{ - "name": map[string]any{"type": "string", "description": "the numbered name, /"}, - "why": map[string]any{"type": "string", "description": "why, in plain words"}}}, - Run: func(args map[string]any) (any, error) { - return handAct(build.NewFloorAgain(str(args, "name"), str(args, "why"), stdio.CallerOf(args), now())) - }}, {Name: versions.OldFormTool, Description: versions.OldFormDescription, Input: map[string]any{"type": "object", "properties": map[string]any{ "drop": map[string]any{"type": "string", "description": "a retired node to drop from the count by hand"}, @@ -82,9 +75,6 @@ func Tools(r build.StuckReader, askAgain func(key string, value []byte) error, q } return versions.AnswerOldForm(of) }}, - {Name: versions.FloorWaitsTool, Description: versions.FloorWaitsDescription, - Input: map[string]any{"type": "object", "properties": map[string]any{}}, - Run: func(map[string]any) (any, error) { return versions.AnswerFloorWaits(fw) }}, {Name: versions.VersionsTool, Description: versions.VersionsDescription, Input: map[string]any{"type": "object", "required": []string{"name"}, "properties": map[string]any{ "name": map[string]any{"type": "string", "description": "the package, image, bundle or archive name"}, @@ -366,14 +356,6 @@ func main() { } return e.Value, true, nil }} - fs := stdio.State(versions.FloorWaitsState) - fr := versions.Reader{Keys: fs.Keys, Get: func(key string) (json.RawMessage, bool, error) { - e, err := fs.Get(key) - if err != nil || e == nil { - return nil, false, err - } - return e.Value, true, nil - }} ofs := stdio.State(versions.OldFormState) ofr := versions.Reader{Keys: ofs.Keys, Get: func(key string) (json.RawMessage, bool, error) { e, err := ofs.Get(key) @@ -429,7 +411,7 @@ func main() { var a meshbuilds.ReservedAnswer return a, json.Unmarshal(raw, &a) } - tools := Tools(r, put, askQueue(stdio.State(build.QueuesState), 25*time.Second), buildAgain, stdio.Log(builds.BuilderLog).Since, time.Now, vr, fr, ofr, reserve) + tools := Tools(r, put, askQueue(stdio.State(build.QueuesState), 25*time.Second), buildAgain, stdio.Log(builds.BuilderLog).Since, time.Now, vr, ofr, reserve) tools = append(tools, buildTool(&build.BuildReader{Builds: read(stdio.State("builds")), Entry: entryOf(stdio.State("builds").Get), Asked: read(stdio.State("asked")), Newest: newestVia(stdio.Ask), Steps: r})) tools = append(tools, reservedTools(rr, buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reservedname_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reservedname_test.go index a91daa9e8..79a91bde9 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reservedname_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reservedname_test.go @@ -28,7 +28,7 @@ func TestBuilderVersionsByNameCallsReserved(t *testing.T) { called = append(called, name+"@"+version) return want, nil } - tools := Tools(build.StuckReader{}, nil, nil, nil, nil, time.Now, none, none, none, reserve) + tools := Tools(build.StuckReader{}, nil, nil, nil, nil, time.Now, none, none, reserve) for _, tl := range tools { if tl.Name == versions.VersionsTool { out, err := tl.Run(map[string]any{"name": "@novox/mesh-sdk", "version": "0.1.2"}) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go index 5ff5f0bd4..ff2b00580 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go @@ -75,8 +75,6 @@ type catalogHalf struct { halves map[string]*views.Follower once sync.Once ctx context.Context - // floor is told each entry change: a floor whose tags or requirements were silent is asked again (design 47 G A-119). - floor func(context.Context) // holders is told each entry change: a claim of a build seat may have moved (design 47 G A-82). holders func() } @@ -112,9 +110,6 @@ func (c *catalogHalf) Changed(ctx context.Context) func(branch, module string, e c.logf("%v", err) } c.b.Entry(ctx, origin, e) - if c.floor != nil { - defer c.floor(ctx) - } c.mu.Lock() was := c.named[module] now := namesOf(e) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go index b50b6af37..8e0db2c85 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go @@ -13,8 +13,6 @@ import ( mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-sdk/go/views" - - "mesh-delivery-builder/internal/versions" ) // heldWriter is the builder's finding writer: its findings are raised as they happen, so the writer holds them (design 47 G @@ -151,19 +149,3 @@ func (f *findings) notHeard(ctx context.Context) heard.Writer { return f.w.Clear(ctx, scope, rest[:i], rest[i+1:], "the builder hears it") }} } - -// floorSaid is the floor finding (design 51 *Health and conditions*: a floor source silent): raised for a name waiting on -// its floor, about that name, cleared once all three sources answered. -func (f *findings) floorSaid(ctx context.Context) func(versions.FloorWait, bool) { - return func(w versions.FloorWait, raised bool) { - if !raised { - f.clear(ctx, versions.FloorSilent, mcc.ScopeModule, w.Name) - return - } - f.raise(ctx, finding{kind: versions.FloorSilent, scope: mcc.ScopeModule, id: w.Name, summary: w.Finding(), - headline: "A version's floor is not known", - explanation: "The builder numbers a name only once its registry seat, the forge bridge's tags and the indexer's requirements all answered; one of them did not.", - resolved: "All three answered.", - needs: "builder_floor_waits names the silent source; builder_floor_again asks again by hand."}) - } -} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go index ca19716f6..36e202b03 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go @@ -9,7 +9,6 @@ import ( "encoding/json" "errors" "fmt" - "maps" "os" "path/filepath" "slices" @@ -323,7 +322,7 @@ func startBedWith(t *testing.T, closed bool) *bed { // each have their durable consumer. b.catalog = newCatalogHolder(t, ctx, js, ctl) b.catalog.buildSeats(t, ctl, map[string]string{"node-build-go": testGo, "node-build-node": testNode, "node-build-image": testImage, - "git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer", // the floor's sources are the holders of git and mesh-catalog + "git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer", "mesh-builds": builds.BuilderModule}) // the builder's own seat, whose verb reserved it answers once its definition is read (A-115, A-278) readers := []string{"n1_" + builds.BuilderModule, "n2_" + builds.BuilderModule} // Design 47 G §717, A-298: the catalog half names testAssigner the claimant of mesh-module-assigner, and its seat-holders view @@ -571,7 +570,7 @@ func isState(state string) func(builds.BuilderBuild) bool { // the digests of both bundles, both build modules' toolchains, after a fetch and a build on one node (ADR 0478 clause 4). func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7 b := startBed(t) - // The builder's versions, findings and the floor's three sources are on the bus, the seat answering 0.1.4; two merges close + // The builder's versions and findings are on the bus, the seat answering 0.1.4; two merges close // together, the first replaced before its claim. The builder numbers neither in its state versions (design 47 H H-A-159, // G §348, §369): the reservation is the one place a version is numbered. reg := b.registry(t, "n1", "0.1.4") @@ -622,7 +621,7 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7 for _, e := range b.logged(t, "netcheck") { if e.Event != builds.BuildSaidEvent { ended = append(ended, e) - } else if e.Why == versions.SaidNumbered || e.Why == versions.SaidKept { + } else if e.Why == "numbered" || e.Why == "kept" { // the narrations of the numbering from before G (design 47 H §756) t.Errorf("said = %+v, want no version of the builder's own numbered (H-A-159)", e) } } @@ -669,29 +668,6 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7 if _, err := reg.versions.Put(b.ctx, versions.Key("netcheck/tools-go", "0.1.6"), refusable); err != nil { t.Fatal(err) } - // Running-testing note (review round 1): two claims never get one number on the bus's own compare-and-set, as - // the builder's state versions keeps them: eight claims of one name at once, eight versions. - store := versions.Versions{Store: awaitedVersions{b: process.AwaitBucket(b.ctx, b.js, nil, builds.StateBucket(builds.BuilderModule, versions.State), "", t.Logf)}} - numbers := make(chan string, 8) - var claims sync.WaitGroup - for i := range 8 { - claims.Go(func() { - d, _, err := store.Number(b.ctx, versions.Claim{Name: "netcheck/race", Kind: versions.KindBundle, Fingerprint: fmt.Sprintf("f%d", i)}) - if err != nil { - t.Error(err) - } - numbers <- d.Version - }) - } - claims.Wait() - close(numbers) - got := map[string]bool{} - for v := range numbers { - got[v] = true - } - if len(got) != 8 { - t.Errorf("eight claims of one name at once were numbered %v, want eight versions", slices.Sorted(maps.Keys(got))) - } if got := reg.numberedOf("netcheck/tools-go"); len(got) != 0 { t.Errorf("version.numbered of netcheck/tools-go said %v, want none", got) } @@ -1154,10 +1130,9 @@ func TestARestartedBuilderPutsNoSecondAsk(t *testing.T) { } } -// registry is the part of the bed design 51's builder cases need: the builder's states versions, findings, floor-waits and -// reasks, EVENTS with the seat oci-artifact-registry's outcomes and the builder's durable consumer of it, the builder's -// own events kept, and the floor's three sources served on the bus as their holders answer through the tool runner -// ({result}): the seat's versions, the seat git's tags and the indexer's indexer_requirements. +// registry is the part of the bed design 51's builder cases need: the builder's states versions, findings and reasks, EVENTS +// with the seat oci-artifact-registry's outcomes and the builder's durable consumer of it, the builder's own events kept, and +// the seat's versions served on the bus as its holder answers through the tool runner ({result}). type registry struct { b *bed versions, findings, reasks jetstream.KeyValue @@ -1176,7 +1151,6 @@ func (b *bed) registry(t *testing.T, node string, seatVersions ...string) *regis return kv } r.versions, r.findings, r.reasks = mk(builds.StateBucket(builds.BuilderModule, versions.State)), mk(builds.StateBucket(builds.BuilderModule, mcseat.StateFindings)), mk(builds.StateBucket(builds.BuilderModule, build.ReAsksState)) - mk(builds.StateBucket(builds.BuilderModule, versions.FloorWaitsState)) // EVENTS with two seats' outcomes, and the forge bridge's stream (a branch's end): each with the builder's durable consumer. for stream, subjects := range map[string][]string{ eventsStream: {"mesh.mod.*.event.>", "mesh.seat.*.event.>"}, @@ -1206,7 +1180,6 @@ func (b *bed) registry(t *testing.T, node string, seatVersions ...string) *regis } for subject, answer := range map[string]any{ "mesh.seat." + ociartifactregistry.Seat + ".call.versions.>": map[string]any{"versions": listed}, - "mesh.seat.git.call.tags.>": map[string]any{"tags": []string{}}, } { reply, _ := json.Marshal(map[string]any{"result": answer, "node": "ctl"}) s, err := nc.Subscribe(subject, func(m *nats.Msg) { _ = m.Respond(reply) }) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 8ec595725..e7df9c9d1 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -163,22 +163,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // it, bound once the bus holds it; the builder numbers nothing in it (design 47 H H-A-159). versionsKV := process.AwaitBucket(ctx, js, conn, own.versions, "builder_versions answers nothing of the versions numbered before G", logger.Printf) found := &findings{module: cred.Module, w: fw, logf: logger.Printf, now: time.Now} - floorWaits := &versions.FloorWaits{Holder: versions.HolderOf(branches), Logf: logger.Printf, Said: found.floorSaid(context.WithoutCancel(ctx))} - // The names waiting on their floor are kept in the state floor-waits (DLV-B4): a restarted builder takes them in, so - // their silent sources' events still wake them; until the state is bound they are kept here only. - process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, versions.FloorWaitsState), "the names waiting on their floor are kept in memory only, and builder_floor_waits shows none", logger.Printf). - Ready(func(kv jetstream.KeyValue) { - floorWaits.Keep(kvKeeper{ctx: ctx, kv: kv}, heldFloorWaits(ctx, kv, logger.Printf)) - }) - // A package is numbered under its name in its ecosystem, read from the catalog half's entries (design 32, design 47 G §348). - numberer := &versions.Numberer{Versions: versions.Versions{Store: awaitedVersions{b: versionsKV}}, Floor: floorVia(calls.Call, versions.RequirementsFrom(versions.EntriesOf(branches))), Waits: floorWaits, - Names: versions.NamesFrom(versions.EntriesOf(branches))} + // The state versions kept from before G: the registry seats' words still mark its entries (design 47 H §756 removes it). + numberer := &versions.Numberer{Versions: versions.Versions{Store: awaitedVersions{b: versionsKV}}} // A publish that ends badly is a finding (design 51 *Health and conditions*): a holder's refused, a version no holder // answered within its bound (a key of the state bounds with its own time to live), a seat's outcome that does not read. pubBoundsKV := process.AwaitBucket(ctx, js, conn, own.bounds, "a publish no holder answers, and a node holding the old form seven days, are not raised", logger.Printf) stepReads.bounds, stepReads.findings = func() jetstream.KeyValue { return pubBoundsKV.KV() }, found pubs := &publishes{bounds: pubBoundsKV.KV, versions: numberer.Versions, findings: found, bound: versions.PublishBound, logf: logger.Printf} - numberer.Publishing = pubs.arm stepExpiry := &buildrun.Expiry{} var b *build.Builder seatsChanged := func(ctx context.Context) { @@ -211,9 +202,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro unput := &unputs{bounds: pubBoundsKV.KV, store: b.Claimer.Store, looking: b.Looking, findings: found, bound: meshconditionsclient.CallUnansweredAfter, now: time.Now, logf: logger.Printf} b.Left, b.Ended = unput.left, unput.ended - // The builder numbers nothing of its own (design 47 H H-A-159, G §348, §349, §369): b.Numbers stays nil, so no trunk build - // is numbered in the state versions, waits on a floor or arms a publish-unanswered bound of it; the reservation is the one - // place a version is numbered. The state, kept from before G, is still read (builder_versions) until G §372 removes it. + // The builder numbers nothing of its own and asks no floor (design 47 H §756, H H-A-159, G §348, §349, §369): the + // reservation is the one place a version is numbered. // The builder's toolchain waits (design 47 G §672): its state waits, and wait-held and wait-ended on its stream waits; its // bound is its setting toolchain-wait-minutes. waitBound, err := toolchainWaitOf(getenv("MESH_BUILDER_TOOLCHAIN_WAIT_FILE")) @@ -269,8 +259,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps) // A state bound later numbers the builds looked at without it. versionsKV.Ready(func(jetstream.KeyValue) { b.Reconsider(ctx) }) - // The versions' hand acts (builder_publish_again, builder_floor_again) come through reasks, as builder_build_again. - acts := versions.Acts{Numberer: numberer, DropReserved: reserved.dropped, Reconsider: b.Reconsider} + // The versions' hand acts (builder_publish_again, builder_reserved_drop) come through reasks, as builder_build_again. + acts := versions.Acts{Numberer: numberer, DropReserved: reserved.dropped} // A reserved version left unpublished is published again, by the builder on an event or by a person's tool (design 47 G // §588): its items on the work queue publishes, the module's own stream of its old streams section (design 47 H2 §793, H-A-454). actedKV := process.AwaitBucket(ctx, js, conn, own.acted, "no version is published again on an event or by builder_publish_again", logger.Printf) @@ -479,9 +469,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // The seat mesh-artifact-sweep says artifacts-gone when it found a key's blob gone (issue 1937, ADR 0571 §2): the // builder's durable consumer on EVENTS, made by the grants part from the manifest's consumes. Where it is not there yet the builder says // so; it still asks held at its start and at every module value. - // The same consumer carries what wakes a floor (design 51 *The floor*): the indexer's take-in.taken (design 47 H H-A-116) and the - // condition keeper's condition-cleared. - floor := floorWake{b: b, waits: floorWaits, logf: logger.Printf} // And the four registry seats' published, refused and removed (DLV-B4), which move a numbered version. seatHeard := seatHearer{n: numberer, b: b, logf: logger.Printf, pub: pubs, res: reserved} // Each part takes the events it hears in turn; a handling over the setting slow-event is said with the part that took it @@ -496,7 +483,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro {"what a node's engine reads", func(m jetstream.Msg) bool { return reads.heard(m, logger.Printf) }}, // manifest-reads-changed (ADR 0618 §4) {"the toolchains reported", func(m jetstream.Msg) bool { return heardTools.Reported(ctx, m) }}, {"the toolchains running", func(m jetstream.Msg) bool { return heardTools.Running(ctx, m) }}, - {"the floor", func(m jetstream.Msg) bool { return floor.heard(ctx, m) }}, {"the reservations", func(m jetstream.Msg) bool { return reserved.heard(ctx, m) }}, {"the registry seats' outcomes", func(m jetstream.Msg) bool { return seatHeard.heard(ctx, m) }}, } @@ -573,15 +559,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro b.SayUnbuildable(ctx) // at the start, once the first views are in: the plans no seat builds in one line (§795) } branches.Changed = half.Changed(ctx) - // A catalog revision the builder hears wakes a floor whose tags or requirements were silent (design 47 G A-119). - half.floor = func(ctx context.Context) { - (&floorWake{b: b, waits: floorWaits, logf: logger.Printf}).wake(ctx, versions.WakeRevision, "", "") - } // All of the catalog half's wiring is set before the reader starts: its views are heard on the reader's goroutines from then. reader.Start(ctx, js, cred, process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, views.StatusState), "builder_first_views reads nothing and builder_first_view_again is not heard", logger.Printf)) // Every part has registered: the hub pulls the module's durable. Where the consumer is not there yet the builder says so // and binds it at a later change (heard.Writer; ADR 0615 §5). - _ = notHeard.Bind(eventsStream, sweep.EventArtifactsGone+", what wakes a floor, the registry seats' words, the views and manifest-reads-changed are not heard until the builder starts again", func() error { + _ = notHeard.Bind(eventsStream, sweep.EventArtifactsGone+", the registry seats' words, the views and manifest-reads-changed are not heard until the builder starts again", func() error { if err := hub.Start(ctx, js, cred); err != nil { return err } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names.go index e54fac5e0..7126852f1 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names.go @@ -8,8 +8,8 @@ import ( const namedTreePrefix = "named:" // seatEventPatterns are the seats' events the builder's own handler takes off its durable consumer (its manifest's `consumes` of -// them): the registry seats' words, artifacts-gone, the build seats' toolchain-reported, condition-cleared, the node-engine -// seat's events, of the seat mesh-catalog, version-released and versions-filled, and the indexer's take-in.taken. The seat mesh-catalog's +// them): the registry seats' words, artifacts-gone, the build seats' toolchain-reported, the node-engine +// seat's events, of the seat mesh-catalog, version-released and versions-filled. The seat mesh-catalog's // catalog-revision and registration-changed and the seat mesh-delivery's source-moved are the views reader's (the branch // follower's), so no pattern here covers them: a message has one taker. var seatEventPatterns = func() []string { @@ -21,6 +21,5 @@ var seatEventPatterns = func() []string { for _, event := range []string{meshcatalog.EventVersionReleased, meshcatalog.EventVersionsFilled} { out = append(out, "mesh.seat."+meshcatalog.Seat+".event."+event, "mesh.seat."+meshcatalog.Seat+".event."+event+".>") } - // And the indexer's take-in.taken, which wakes the floor (design 47 H H-A-116). - return append(out, takenInSubject) + return out }() diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go index c22673e35..e0530af02 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go @@ -32,14 +32,11 @@ func TestTheNamesAreTheManifests(t *testing.T) { t.Errorf("the builder reads %s, its manifest's reads are %v", read, m.Reads) } } - // The catalog half (design 47 G §348, §614) is followed through the seat, and no state of the indexer is; the indexer's - // event take-in.taken wakes the floor (design 47 H H-A-116). - if !slices.Contains(m.Consumes, "mesh-delivery-indexer.take-in.taken") { - t.Errorf("the builder's floor wakes on no take-in.taken: its manifest consumes %v", m.Consumes) - } + // The catalog half (design 47 G §348, §614) is followed through the seat, and nothing of the indexer is: with the floor gone + // (design 47 H §756) not its take-in.taken either (H-A-116). for _, c := range m.Consumes { - if strings.HasPrefix(c, "mesh-delivery-indexer.") && c != "mesh-delivery-indexer.take-in.taken" { - t.Errorf("the builder follows %s, an indexer state, its manifest consumes it", c) + if strings.HasPrefix(c, "mesh-delivery-indexer.") { + t.Errorf("the builder follows %s of the indexer, its manifest consumes it", c) } } for _, view := range []string{"mesh-catalog.catalog-revision", "mesh-catalog.registration-changed", "mesh-delivery.source-moved", "seat:mesh-module-assigner.views.assignments"} { diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go index d57314066..e3951c9a6 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go @@ -65,7 +65,7 @@ func reAsked(ctx context.Context, b askAgainer, acts versions.Acts, items *publi released(ctx, b, kv, e, r, logf) return } - if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModeFloorAgain || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone { + if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone { // A version's hand act (design 51 *Tools of the builder*) may build again, so it is answered beside the watch. go versionActed(ctx, acts, kv, e, r, logf) return @@ -196,7 +196,7 @@ func emitBuildEnded(ctx context.Context, js jetstream.JetStream, cred process.Ac return nil } -// versionActed answers a reasks value of builder_publish_again, builder_floor_again or builder_old_form's drop, a hand act said in the log. +// versionActed answers a reasks value of builder_publish_again, builder_publish_drop, builder_reserve_done, builder_reserved_drop or builder_old_form's drop, a hand act said in the log. func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue, e jetstream.KeyValueEntry, r build.ReAsk, logf func(string, ...any)) { var err error if r.Mode == build.ModeRepublish { @@ -227,14 +227,10 @@ func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue } else { r.Answer, err = acts.DropReserved(ctx, r.Name, r.FP, r.By, r.Why, r.At) } - } else if r.Mode == build.ModeOldFormDrop { - if acts.DropOldForm == nil { - err = errors.New("this builder keeps no old-form window") - } else { - r.Answer, err = acts.DropOldForm(ctx, r.Name, r.By, r.Why, r.At) - } + } else if acts.DropOldForm == nil { + err = errors.New("this builder keeps no old-form window") } else { - r.Answer, err = acts.FloorAgain(ctx, r.Name) + r.Answer, err = acts.DropOldForm(ctx, r.Name, r.By, r.Why, r.At) } if err != nil { r.Answer, r.Refused = err.Error(), true diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go index 87f09a7a1..df600590a 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go @@ -42,7 +42,7 @@ import ( // its grant. The gate over the seat's assignments, and its refusal, are mesh-sdk's (buildrun.PlacedNodes, // issue 774). func TestARefusedBucketIsSaidAndThePartGoesOn(t *testing.T) { - t.Run("a floor's wake is heard on the events consumer (design 51 The floor)", aFloorsWakeIsHeard) + t.Run("a registry seat's outcome is heard on the events consumer (DLV-B4)", aSeatsOutcomeIsHeard) t.Run("a failed trunk build is a finding until a later done one (DLV-B7)", aFailedTrunkBuildIsAFinding) refused := refusingBus{err: errors.New("nats: permissions violation for publish to $JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules")} if _, err := process.EssentialBucket(context.Background(), refusingBus{refuseOpen: true, err: refused.err}, "builder", "mesh-delivery-indexer_modules", "work"); err == nil || @@ -250,33 +250,16 @@ func (m *wakeMsg) Headers() nats.Header { return nil } -func aFloorsWakeIsHeard(t *testing.T) { +func aSeatsOutcomeIsHeard(t *testing.T) { var logs bytes.Buffer - holders := map[string]string{"git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer"} - waits := &versions.FloorWaits{Holder: func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok }} - waits.Wait("m/lib", versions.SeatGoPackages, "", versions.Floor{Silent: []string{versions.SourceRequirements}}, nil, time.Unix(0, 0)) - waits.Wait("m/img", versions.SeatImages, "", versions.Floor{Silent: []string{versions.SourceTags}}, nil, time.Unix(0, 0)) - f := &floorWake{b: &build.Builder{}, waits: waits, logf: log.New(&logs, "", 0).Printf} - accepted := &wakeMsg{subject: takenInSubject} - if !f.heard(context.Background(), accepted) || !accepted.acked || !strings.Contains(logs.String(), "the floor of m/lib is asked again: take-in.taken") { - t.Fatalf("take-in.taken: acked %v, log %q", accepted.acked, logs.String()) - } - logs.Reset() - cleared := &wakeMsg{subject: conditionClearedSubject, data: []byte(`{"subject":{"scope":"probe","id":"ace/mesh-delivery-forge-bridge"}}`)} - if !f.heard(context.Background(), cleared) || !strings.Contains(logs.String(), "the floor of m/img is asked again: condition-cleared") { - t.Fatalf("condition-cleared: log %q", logs.String()) - } - if f.heard(context.Background(), &wakeMsg{subject: sweep.SubjectArtifactsGone}) { - t.Fatal("artifacts-gone was taken as a floor's wake") - } - // DLV-B4: a registry seat's outcome on the same consumer moves a version; a published wakes a name whose seat was - // silent; one the state cannot take is left for the bus to give again. - logs.Reset() - waits.Wait("m/pkg", versions.SeatGoPackages, "", versions.Floor{Silent: []string{versions.SourceSeat}}, nil, time.Unix(0, 0)) - h := &seatHearer{n: &versions.Numberer{Versions: versions.Versions{Store: noVersions{}}, Waits: waits}, b: &build.Builder{}, logf: log.New(&logs, "", 0).Printf} + // DLV-B4: a registry seat's outcome on the events consumer moves a version; a by-digest publish marks none and is taken. + h := &seatHearer{n: &versions.Numberer{Versions: versions.Versions{Store: noVersions{}}}, b: &build.Builder{}, logf: log.New(&logs, "", 0).Printf} byDigest := &wakeMsg{subject: "mesh.seat.go-package-registry.event.published", data: []byte(`{"name":"m/other","digest":"sha256:aa","kind":"package","holder":"gitea"}`)} - if !h.heard(context.Background(), byDigest) || !byDigest.acked || !strings.Contains(logs.String(), "the floor of m/pkg is asked again: go-package-registry said published") { - t.Fatalf("published: acked %v, log %q", byDigest.acked, logs.String()) + if !h.heard(context.Background(), byDigest) || !byDigest.acked || byDigest.naked { + t.Fatalf("published: acked %v, naked %v, log %q", byDigest.acked, byDigest.naked, logs.String()) + } + if h.heard(context.Background(), &wakeMsg{subject: sweep.SubjectArtifactsGone}) { + t.Fatal("artifacts-gone was taken as a seat's outcome") } // Design 47 G §369, A-415: a published of a version the reservation numbered, which the state versions does not hold, is // taken: its artifact is marked and package-published said, never left for the bus to give again. @@ -299,9 +282,6 @@ func aFloorsWakeIsHeard(t *testing.T) { if !h.heard(context.Background(), published) || !published.acked || published.naked || len(saidPub) != 1 || saidPub[0].Artifact != "m:program" { t.Fatalf("a published of a reserved version: acked %v, naked %v, said %+v, log %q", published.acked, published.naked, saidPub, logs.String()) } - if h.heard(context.Background(), &wakeMsg{subject: takenInSubject}) { - t.Fatal("take-in.taken was taken as a seat's outcome") - } // Design 47 G A-420: a message left for the bus is said given up on the last delivery its consumer allows, never before. for _, n := range []uint64{4, EventDeliveries} { logs.Reset() @@ -354,17 +334,6 @@ func aFailedTrunkBuildIsAFinding(t *testing.T) { if _, ok := st.vals[key]; ok { t.Error("a later done trunk build leaves build-failed") } - // The floor finding: raised while a name waits on its floor, cleared once it is known. - fw := &versions.FloorWaits{Said: f.floorSaid(context.Background())} - fw.Wait("m/lib", versions.SeatGoPackages, "", versions.Floor{Silent: []string{versions.SourceTags}}, nil, time.Unix(0, 0)) - floorKey := meshconditionsclient.Key(meshconditionsclient.ScopeModule, "m/lib", versions.FloorSilent) - if got, err := decodeFinding(st.vals[floorKey]); err != nil || !strings.Contains(got.Summary, "git.tags did not answer") { - t.Fatalf("the floor finding = %+v, %v", got, err) - } - fw.Answered("m/lib") - if _, ok := st.vals[floorKey]; ok { - t.Error("a known floor leaves floor-silent") - } // Design 51 *Health and conditions* (review round 1): a holder's refused is publish-refused with its reason, a version // no holder answered within its bound publish-unanswered, a seat's outcome that does not read seat-outcome-unread; // a later published of the name clears the first two, the seat's next outcome that reads the third. diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go index 6a20ddd58..279dd947f 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go @@ -689,8 +689,8 @@ func TestEventsAreHandledByAWorkerPerName(t *testing.T) { if got := eventKey(&wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"module":"m","version":"0.1.0"}`)}); got != "module m" { t.Errorf("a version-released's key is %q, want its module", got) } - if got := eventKey(&wakeMsg{subject: takenInSubject, data: []byte(`{}`)}); got != "" { - t.Errorf("a take-in's key is %q, want the shared worker's", got) + if got := eventKey(&wakeMsg{subject: "mesh.seat.mesh-artifact-sweep.event.artifacts-gone", data: []byte(`{}`)}); got != "" { + t.Errorf("an event naming no name has the key %q, want the shared worker's", got) } release := make(chan struct{}) handled := make(chan string, 4) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go index d45ffe18d..7edfc3a13 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "strconv" - "strings" "github.com/nats-io/nats.go/jetstream" @@ -44,8 +43,7 @@ var seatEvents = map[string]seatEvent{ npmpackageregistry.SubjectKept: {npmpackageregistry.Seat, npmpackageregistry.EventKept}, } -// seatHearer takes the registry seats' outcomes in: each moves a numbered version (versions.Numberer.Heard), and a -// `published` that wakes a name waiting on its floor looks at every module again. +// seatHearer takes the registry seats' outcomes in: each moves a numbered version (versions.Numberer.Heard). type seatHearer struct { n *versions.Numberer b *build.Builder @@ -83,7 +81,7 @@ func (h *seatHearer) heard(ctx context.Context, m jetstream.Msg) bool { if m.Headers() != nil { id = m.Headers().Get("x-event-id") } - wake, err := h.n.Heard(ctx, se.seat, se.event, id, o) + err := h.n.Heard(ctx, se.seat, se.event, id, o) if errors.Is(err, versions.ErrNotNumbered) { // The version is no entry of the state versions, design 51's numbering by name, which G keeps only until it is removed // (§372); the reservation numbers a version (§369, §52) and takes the outcome in (A-415). Heard again it would stay @@ -115,10 +113,6 @@ func (h *seatHearer) heard(ctx context.Context, m jetstream.Msg) bool { h.b.PackagePublished(o.Name, o.Version) } h.ack(m) - if len(wake) > 0 { - h.logf("the floor of %s is asked again: %s said %s", strings.Join(wake, ", "), se.seat, se.event) - h.b.Reconsider(ctx) - } return true } @@ -150,7 +144,7 @@ func (h *seatHearer) ack(m jetstream.Msg) { } } -// kvKeeper is the state floor-waits as versions.FloorKeeper. +// kvKeeper is a state of the builder as a keeper of keys: Put a key's value, Delete its key. type kvKeeper struct { ctx context.Context kv jetstream.KeyValue @@ -168,27 +162,3 @@ func (k kvKeeper) Delete(key string) error { } return err } - -// heldFloorWaits are the waits floor-waits holds at the builder's start; a value that is no wait is said and left. -func heldFloorWaits(ctx context.Context, kv jetstream.KeyValue, logf func(string, ...any)) []versions.FloorWait { - l, err := kv.ListKeys(ctx) - if err != nil { - logf("%s cannot be listed, so a restart's waits are asked at their next claim: %v", versions.FloorWaitsState, err) - return nil - } - defer func() { _ = l.Stop() }() - var out []versions.FloorWait - for k := range l.Keys() { - e, err := kv.Get(ctx, k) - if err != nil { - continue - } - w, err := versions.DecodeFloorWait(e.Value()) - if err != nil { - logf("%s.%s holds what is no floor wait, left: %v", versions.FloorWaitsState, k, err) - continue - } - out = append(out, w) - } - return out -} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go index 6fc60acf6..ed1107257 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go @@ -5,23 +5,19 @@ import ( "encoding/json" "errors" "fmt" - "strings" "time" "github.com/nats-io/nats.go" "github.com/nats-io/nats.go/jetstream" - "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" - gitseat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/gopackageregistry" "git.novox.be/novox/mesh-sdk/go/process" - "mesh-delivery-builder/internal/build" "mesh-delivery-builder/internal/versions" ) // awaitedVersions is the state versions as versions.Store: bound once the bus holds it (the grants part makes it, issue -// 1790); until then every use is an error, so a trunk build is built unnumbered and said (build.Builder.number). +// 1790); until then every use is an error. type awaitedVersions struct { b *process.AwaitedBucket // bucket names the state in the error of one not on the bus yet; empty is the versions'. @@ -119,70 +115,6 @@ func publishedVersionsVia(call toolCaller) func(context.Context, string) ([]stri } } -// floorVia is the floor's three sources as calls of the builder's own account (design 51 *The floor*): the seat's verb -// versions, the seat git's tags and the requirements the catalog half's entries name (A-119). A call that fails is that source -// silent. -func floorVia(call toolCaller, requirements func(context.Context, string) ([]string, error)) versions.FloorSources { - return versions.FloorSources{ - Seat: func(_ context.Context, seat, name string) ([]string, error) { - raw, err := call("seat:"+seat+".versions", map[string]any{"name": name}) - if err != nil { - return nil, err - } - var a struct { - Versions []struct { - Version string `json:"version"` - } `json:"versions"` - } - if err := json.Unmarshal(raw, &a); err != nil { - return nil, fmt.Errorf("%s's versions answered what is no list of versions: %w", seat, err) - } - var out []string - for _, v := range a.Versions { - if v.Version != "" { - out = append(out, v.Version) - } - } - return out, nil - }, - Tags: func(ctx context.Context, repository, prefix string) ([]string, error) { - tags, _, err := tagsVia(call)(ctx, repository, prefix) - out := make([]string, 0, len(tags)) - for _, t := range tags { - out = append(out, t.Tag) - } - return out, err - }, - Requirements: requirements, - } -} - -// tagsVia reads a repository's tags starting with prefix, each with the commit it names, through the seat git's verb tags, -// whichever module holds the seat (design 47 G §7, A-82), page by page; its answer is read tolerantly, form 2 naming each tag's -// commit (design 47 H2 §796, §780). away says the read met a transport fault or the error kind away (§776). -func tagsVia(call toolCaller) func(ctx context.Context, repository, prefix string) ([]gitseat.Tag, bool, error) { - return func(_ context.Context, repository, prefix string) ([]gitseat.Tag, bool, error) { - var out []gitseat.Tag - for page := int64(1); ; page++ { - raw, err := call("seat:"+gitseat.Seat+"."+gitseat.VerbTags, gitseat.TagsInput{Repository: repository, Prefix: prefix, Page: page}) - if err != nil { - return nil, true, err - } - a, _, err := gitseat.DecodeTagsAnswer(raw) - if err != nil { - return nil, false, fmt.Errorf("the seat git's tags answered what is no list of tags: %w", err) - } - if a.Error != "" { - return nil, a.ErrorKind == gitseat.ErrorKindAway, fmt.Errorf("the seat git's tags: %s (%s)", a.Error, a.ErrorKind) - } - out = append(out, a.Tags...) - if !a.More { - return out, false, nil - } - } - } -} - // emitEvent says one of the builder's events, mesh.mod..event., with the SDK's envelope headers and id as // the bus's dedup id. func emitEvent(ctx context.Context, js jetstream.JetStream, cred process.Account, event, id string, body any) error { @@ -221,65 +153,3 @@ func emitSeatEvent(ctx context.Context, js jetstream.JetStream, cred process.Acc _, err = js.PublishMsg(pub, msg, jetstream.WithMsgID(id)) return err } - -// The events on the builder's consumer of EVENTS that wake a floor (design 51 *The floor*, DLV-B3b). -var ( - // The indexer's take-in.taken, which the builder consumes in place of the retired manifest-accepted (design 47 H H-A-116). - takenInSubject = "mesh.mod.mesh-delivery-indexer.event.take-in.taken" - conditionClearedSubject = meshconditions.SubjectConditionCleared -) - -// floorWake asks the floor of the names an event wakes again, by looking at every module again: a trunk build is -// numbered before its claim (build.Builder.number). -type floorWake struct { - b *build.Builder - waits *versions.FloorWaits - logf func(string, ...any) -} - -// heard takes a message of the consumer in when it is one that wakes a floor, acknowledged, and answers whether it was. -func (f *floorWake) heard(ctx context.Context, m jetstream.Msg) bool { - switch m.Subject() { - case takenInSubject: - f.ack(m) - f.wake(ctx, versions.WakeTakenIn, "", "") - case conditionClearedSubject: - f.ack(m) - var e meshconditions.ConditionEvent - if err := json.Unmarshal(m.Data(), &e); err != nil { - f.logf("%s holds what is no condition, left: %v", m.Subject(), err) - return true - } - if e.Subject == nil { - return true - } - for _, module := range conditionModules(e.Subject.ID) { - f.wake(ctx, versions.WakeCleared, "", module) - } - default: - return false - } - return true -} - -func (f *floorWake) ack(m jetstream.Msg) { - if err := m.Ack(); err != nil { - f.logf("acknowledging %s: %v", m.Subject(), err) - } -} - -// wake looks at every module again when the event wakes a name, and says which. -func (f *floorWake) wake(ctx context.Context, kind, seat, module string) { - names := f.waits.Wake(kind, seat, module, "") - if len(names) == 0 { - return - } - f.logf("the floor of %s is asked again: %s", strings.Join(names, ", "), kind) - f.b.Reconsider(ctx) -} - -// conditionModules are the tokens of a condition's subject id (`/`, `.`): a module named -// among them is the one whose condition cleared. -func conditionModules(id string) []string { - return strings.FieldsFunc(id, func(r rune) bool { return r == '/' || r == '.' || r == ':' }) -} diff --git a/modules/mesh-delivery-builder/internal/build/entry_test.go b/modules/mesh-delivery-builder/internal/build/entry_test.go index f2e4f2f12..5511dbeb4 100644 --- a/modules/mesh-delivery-builder/internal/build/entry_test.go +++ b/modules/mesh-delivery-builder/internal/build/entry_test.go @@ -23,11 +23,6 @@ func TestAnEntryOfTheCatalogHalfIsTheFormTheBuilderBuildsBy(t *testing.T) { !reflect.DeepEqual(got.Inputs2.Paths, map[string]string{"a/b": "lib", "c": "lib"}) { t.Errorf("ModuleOf = %+v", got) } - // A module value carries no source stamp (design 47 H H-A-48): its claim is numbered per fingerprint, naming no source - // revision and no merge. - if c := ClaimOf("netcheck", got, Plan{}); c.Revision != "" || c.Merge != 0 || c.Fingerprint != "src2:f" { - t.Errorf("ClaimOf = %+v", c) - } if bare := ModuleOf(meshcatalog.CatalogEntry{Module: "m"}); bare.Inputs2 != nil || bare.Fp2 != "" { t.Errorf("ModuleOf of an entry with none = %+v, want nothing set", bare) } diff --git a/modules/mesh-delivery-builder/internal/build/numbers.go b/modules/mesh-delivery-builder/internal/build/numbers.go index 8e0cd70e6..484c18eed 100644 --- a/modules/mesh-delivery-builder/internal/build/numbers.go +++ b/modules/mesh-delivery-builder/internal/build/numbers.go @@ -11,93 +11,10 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" "mesh-delivery-builder/internal/versions" ) -// Numbers numbers a trunk build at its claim (novox/hq design 51 *The versions*, ADR 0606, ADR 0617 §1) and records the -// digests it was built with. Nil numbers nothing. -type Numbers interface { - // done is the digests of the build's key when it is done already (versions.BuildClaim.Done), nil otherwise. - Number(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, done map[string]string) (versions.Numbering, error) - Built(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, got versions.Numbering, made []builds.BuiltArtifact) error -} - -// VersionNumbers is Numbers over the builder's state versions. -type VersionNumbers struct { - N *versions.Numberer -} - -// ClaimOf is the claim a module value's trunk build is numbered by, per fingerprint: a module value carries no source stamp -// (design 47 H H-A-48), so the claim names no source revision and no merge. -func ClaimOf(module string, m meshcatalog.ModulesByModuleValue, plan Plan) versions.BuildClaim { - c := versions.BuildClaim{Module: module, Path: m.Path, Repository: trunk.RepositoryName(m.Repository), Fingerprint: m.Fp2, - Commit: m.Commit} - for _, t := range plan.Tasks { - c.Artifacts = append(c.Artifacts, versions.ClaimArtifact{Artifact: t.Artifact, Kind: t.Kind, Language: t.Language}) - } - return c -} - -func (v VersionNumbers) Number(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, done map[string]string) (versions.Numbering, error) { - c := ClaimOf(module, m, plan) - c.Done = done - return v.N.Number(ctx, c) -} - -func (v VersionNumbers) Built(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, got versions.Numbering, made []builds.BuiltArtifact) error { - digests := map[string]string{} - for _, a := range made { - digests[a.Name] = a.Digest - } - return v.N.Built(ctx, ClaimOf(module, m, plan), got, digests) -} - -// number numbers a trunk build's artifacts before its claim: false -// when it waits for its floor (a package, design 51 *The floor*), and then nothing is claimed; the floor's wake looks at -// the module again. -func (b *Builder) number(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan) (versions.Numbering, bool) { - if b.Numbers == nil { - return versions.Numbering{}, true - } - done := b.doneDigests(ctx, module, m.Fp2) - got, err := b.Numbers.Number(ctx, module, m, plan, done) - for _, s := range got.Said { - b.logf("%s at %s: %s", module, m.Fp2, s.Line) - // And in the build log (design 51 *The versions*: it says a version was kept, and why), between the build's start and end. - // A look at a key already done builds nothing and has no start or end: a version kept there says nothing new, and is - // not logged (each later look, a first view answered or a name heard, would add one). - if b.Log != nil && !(done != nil && s.Why == versions.SaidKept) { - b.Log(builds.BuildLogEntry{Event: builds.BuildSaidEvent, Module: module, FP: m.Fp2, Commit: m.Commit, Node: b.Node, - At: time.Now().UTC(), Line: s.Line, Why: s.Why}) - } - } - if err != nil { - // Said, and built as before: an unnumbered build is published by its digest (ADR 0617 §1), numbered at its next look. - b.logf("%s at %s: %v", module, m.Fp2, fmt.Errorf("not numbered, the versions cannot be used: %w", err)) - return versions.Numbering{}, true - } - if done != nil && len(got.Versions) > 0 && b.Reserved != nil { - // A late look numbered a done build: G §349 retires numbering at a look, so one with no reservation and no release is - // said aloud with the recovery that reserves it (A-455), never taken in silently. - _, reserved, rerr := b.Reserved.ReservedFor(ctx, module, m.Fp2) - released, derr := b.Reserved.ReleasedFor(ctx, module, m.Fp2) - if rerr == nil && derr == nil && !reserved && !released { - b.logf("%s at %s: a late look numbered this done build (%v) and no version is reserved for it: builder_reserve_done reserves one and queues its publish", module, m.Fp2, got.Versions) - } - } - if got.Refused != "" { - b.logf("%s at %s: %s", module, m.Fp2, got.Refused) - return got, true - } - if got.Wait != "" { - b.logf("%s at %s is not built yet: %s", module, m.Fp2, got.Wait) - return got, false - } - return got, true -} - // doneDigests are the digests of a trunk build's key by artifact when the key is done, nil otherwise or when it cannot be // read: a look at a done build numbers what it left unnumbered with them (versions.BuildClaim.Done). func (b *Builder) doneDigests(ctx context.Context, module, fp string) map[string]string { diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 5242f95ce..be7432f24 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -104,9 +104,6 @@ type Builder struct { // time.Now. Node is the node the builder runs on, which asked the build. Now func() time.Time Node string - // Numbers numbers each trunk build at its claim and records what it was built with (design 51 *The versions*); nil - // numbers nothing, as the builder's program leaves it (design 47 H H-A-159: the reservation numbers, G §369). - Numbers Numbers // Reserved reserves the version of a trunk build at its start (design 47 G §369); nil reserves nothing. Reserved Reservations // Picture answers the source revision the builder's picture of a watched branch holds, false while it holds none (design 47 @@ -719,14 +716,6 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB byEvent := b.events[key] delete(b.events, key) b.mu.Unlock() - var numbering versions.Numbering - if trunk && planErr == nil && !nothing { - var goOn bool - if numbering, goOn = b.number(ctx, module, m, plan); !goOn { - end("is not built yet: it waits for its package's floor, nothing is claimed") - return - } - } // Only a build of the registration's first watched branch reserves and releases a version (design 47 G §371). reserving := trunk && b.originOf(key).First && planErr == nil && !nothing && b.reserves(ctx, module, m, plan) if trunk && b.originOf(key).First && planErr == nil && !nothing && !reserving { @@ -805,10 +794,6 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB // A trunk build that reserves is never built without its version: it would end done and publish nothing, and its key would // stay done, never built again (A-490). The key fails with why and is taken again at the next look or by builder_build_again. result = failed("no version is reserved for this build: the builder's journal says why, and it is built again once one can be") - } else if numbering.Refused != "" && cl.Build.State != builds.BuildDone { - // Refused, naming the state it could not read, and built against no guess (ADR 0666 §15; design 47, test 70): the key - // fails with why, and is taken again at the next look. - result = failed("%s", numbering.Refused) } else if nothing { // A manifest with no artifact is built by building nothing: its key is done with no artifact, claimed and written as // any other, so the controller has a done key to register it from (issue 1613, ADR 0478 clause 1, ADR 0501 clause 1). @@ -858,11 +843,6 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB ended := LogEnded(module, m, "", b.Node, b.now(), result) ended.OutOfStep = b.takeOutOfStep(key) // the generated files the build module's compare found out of step (design 26) b.logBuild(ended) - if result.State == builds.BuildDone && b.Numbers != nil && len(numbering.Versions) > 0 { - if err := b.Numbers.Built(ctx, module, m, plan, numbering, result.Artifacts); err != nil { - b.logf("%s: %v", cl.Key, err) - } - } if result.State == builds.BuildDone && hasReserved { digests := map[string]string{} for _, a := range result.Artifacts { diff --git a/modules/mesh-delivery-builder/internal/build/run_test.go b/modules/mesh-delivery-builder/internal/build/run_test.go index 383bca35b..87ee34b31 100644 --- a/modules/mesh-delivery-builder/internal/build/run_test.go +++ b/modules/mesh-delivery-builder/internal/build/run_test.go @@ -23,8 +23,6 @@ import ( stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/keys" - - "mesh-delivery-builder/internal/versions" ) // buildModules simulates the two build modules on the nodes: a long tool answers a step and key at once and writes the @@ -552,88 +550,21 @@ func TestABundleAndAnImageOfOneModuleBuildOnOneNodeEach(t *testing.T) { // 1705a } } -func TestATrunkImageCallCarriesPublish(t *testing.T) { // 1705b; design 51 *The versions*: numbered at the claim +func TestATrunkImageCallCarriesPublish(t *testing.T) { // 1705b; design 47 H §756: a trunk build is claimed and built, asking no floor r := newRig(t, imageArt) r.puller = "ace" - nums := &fakeNumbers{wait: "m/img: the package waits for its floor"} - r.b.Numbers = nums - r.b.Module(context.Background(), "m", moduleValue(t, "modules/m")) - r.b.Wait() - if _, ok := r.st.vals[r.key]; ok || nums.numbered != 1 { - t.Fatalf("a build waiting for its floor was claimed (numbered %d times)", nums.numbered) - } - nums.wait, nums.versions = "", map[string]string{"img": "0.1.4"} r.consider(t, "modules/m") calls := r.bm.callsOf("build_image_build") if len(calls) != 1 || calls[0].body.(map[string]any)["publish"] != true { t.Errorf("calls = %+v, want publish true", calls) } - if nums.built["img"] != digest { - t.Errorf("the built digest recorded = %v, want %s for img", nums.built, digest) - } - if nums.done != nil { - t.Errorf("a build still to make was numbered with done digests %v", nums.done) - } // The indexer's packages state names a package of the module (PackageNamed): the done build is looked at again and - // numbered with its key's digests, so version.numbered carries them for the late publish; nothing is built again. - looks := nums.numbered + // nothing is built again. r.b.PackageNamed(context.Background(), "m") r.b.Wait() - if nums.numbered != looks+1 || nums.done["img"] != digest || len(r.bm.callsOf("build_image_build")) != 1 { - t.Errorf("a named package's done build: numbered %d more times with %v, %d image builds; want once with img %s and no build", - nums.numbered-looks, nums.done, len(r.bm.callsOf("build_image_build")), digest) + if n := len(r.bm.callsOf("build_image_build")); n != 1 { + t.Errorf("a named package's done build was built again: %d image builds, want 1", n) } - // A late look that numbers a done build with no reservation is said aloud, naming builder_reserve_done (G §349, A-455). - late := &logged{} - r.b.Logf, r.b.Reserved = late.logf, &fakeReservations{filled: true} - r.b.PackageNamed(context.Background(), "m") - r.b.Wait() - if !late.has("late look numbered", "builder_reserve_done") { - t.Errorf("a late look numbered a done build with no reservation and said %v", late.lines) - } - r.b.Reserved = nil - looks = nums.numbered - r.b.PackageNamed(context.Background(), "other") - r.b.Wait() - if nums.numbered != looks { - t.Errorf("a module the builder does not know was looked at") - } - // D-B5 (ADR 0666 §15; design 47, test 70): a build whose published packages cannot be read is refused, naming the - // state: its key fails with why, and nothing is built. - unread := newRig(t, imageArt) - unread.puller = "ace" - unread.b.Numbers = &fakeNumbers{refused: "m/img: refused: the builder's state versions (bucket mesh-delivery-builder_versions) cannot be read"} - unread.b.Module(context.Background(), "m", moduleValue(t, "modules/m")) - unread.b.Wait() - if v := valueOf(t, unread.st, unread.key); v.State != builds.BuildFailed || !strings.Contains(v.Error, "state versions") || len(unread.bm.callsOf("build_image_build")) != 0 { - t.Errorf("a build with its versions unread: key %+v, %d builds; want failed naming the state, none built", v, len(unread.bm.callsOf("build_image_build"))) - } -} - -// fakeNumbers is Numbers that answers what it is set to and keeps the digests a done build recorded. -type fakeNumbers struct { - wait string - versions map[string]string - numbered int - built map[string]string - done map[string]string // the done key's digests the last look numbered with - refused string // answered as Numbering.Refused -} - -func (f *fakeNumbers) Number(_ context.Context, _ string, _ meshcatalog.ModulesByModuleValue, _ Plan, done map[string]string) (versions.Numbering, error) { - f.done = done - f.numbered++ - return versions.Numbering{Wait: f.wait, Versions: f.versions, Refused: f.refused}, nil -} - -func (f *fakeNumbers) Built(_ context.Context, _ string, _ meshcatalog.ModulesByModuleValue, _ Plan, got versions.Numbering, made []builds.BuiltArtifact) error { - f.built = map[string]string{} - for _, a := range made { - if got.Versions[a.Name] != "" { - f.built[a.Name] = a.Digest - } - } - return nil } func TestAnUnpinnedUpstreamFailsNotPinnedAndIsNeverBuiltAgain(t *testing.T) { // B3, ADR 0498 clause 4 diff --git a/modules/mesh-delivery-builder/internal/build/stuck.go b/modules/mesh-delivery-builder/internal/build/stuck.go index 84f08cc4c..a2c8173db 100644 --- a/modules/mesh-delivery-builder/internal/build/stuck.go +++ b/modules/mesh-delivery-builder/internal/build/stuck.go @@ -56,7 +56,7 @@ type ReAsk struct { Failed string `json:"failed,omitempty"` Revision uint64 `json:"revision,omitempty"` Asks map[string]string `json:"asks,omitempty"` - // Name is the numbered name (`/`) of a ModeFloorAgain value; Version is a ModeRepublish value's + // Name is the module or node a hand act names; Version is a ModeRepublish value's // request and Queued the builder's answer to it: the versions it queued, ` `. Name string `json:"name,omitempty"` Version string `json:"version,omitempty"` @@ -92,9 +92,6 @@ func NewPublishAct(mode, module, version, why, by string, at time.Time) (string, return mode + "." + strconv.FormatInt(at.UnixNano(), 10), data, err } -// ModeFloorAgain is the Mode of a reasks value of builder_floor_again (design 51 *The floor*). -const ModeFloorAgain = "floor-again" - // NewRepublish is the value builder_publish_again writes (design 47 G §588): its key, `republish.` // (a call is one value, never a build key), and the value. Module and version are each optional. func NewRepublish(module, version, why, by string, at time.Time) (string, []byte, error) { @@ -109,20 +106,6 @@ func NewRepublish(module, version, why, by string, at time.Time) (string, []byte return "republish." + strconv.FormatInt(at.UnixNano(), 10), data, err } -// NewFloorAgain is the value builder_floor_again writes for a name: the key `floor.`, never a build key, -// and the value. -func NewFloorAgain(name, why, by string, at time.Time) (string, []byte, error) { - name = strings.TrimSpace(name) - if module, artifact, ok := strings.Cut(name, "/"); !ok || module == "" || artifact == "" { - return "", nil, fmt.Errorf("name %q is not a numbered name, /, as builder_versions lists it", name) - } - if strings.TrimSpace(why) == "" { - return "", nil, errors.New("say why the floor is asked again (why)") - } - data, err := json.Marshal(ReAsk{V: 1, Why: strings.TrimSpace(why), By: by, At: at.UTC(), Mode: ModeFloorAgain, Name: name}) - return "floor." + versions.EscapeToken(name), data, err -} - // ModeOldFormDrop is the Mode of a reasks value of builder_old_form's drop (design 51 *Every build keeps the old // reference form*): a retired node dropped from the count by hand; Name is the node. const ModeOldFormDrop = "old-form-drop" diff --git a/modules/mesh-delivery-builder/internal/versions/again.go b/modules/mesh-delivery-builder/internal/versions/again.go index 3c3798756..2621ffbb5 100644 --- a/modules/mesh-delivery-builder/internal/versions/again.go +++ b/modules/mesh-delivery-builder/internal/versions/again.go @@ -2,22 +2,12 @@ package versions import ( "context" - "fmt" "time" ) -// The tools' descriptions. -const ( - FloorAgainDescription = "Refused for every name: the builder numbers nothing of its own and asks no floor (design 47 H H-A-159); " + - "a version is numbered by the reservation (design 47 G §369, builder_reserved). Kept until design 47 G §372 removes it with " + - "the state versions." -) - // Acts are the builder's hand acts on its versions, answered by its program (the tools bundle writes them to reasks). type Acts struct { Numberer *Numberer - // Reconsider looks at every module again, so a claim asks a name's floor. - Reconsider func(ctx context.Context) // Republish queues the reserved versions builder_publish_again names (design 47 G §588): the versions it queued. Republish func(ctx context.Context, module, version string) ([]string, error) // DropOldForm drops a retired node from the old form's count by hand (builder_old_form): its answer, or why not. @@ -30,10 +20,3 @@ type Acts struct { // PublishDrop terminates one publish item (builder_publish_drop, design 47 H2 §793): the answer, or why not. PublishDrop func(ctx context.Context, module, version, by, why string) (string, error) } - -// FloorAgain is builder_floor_again of name: refused, since the builder numbers nothing of its own and no claim asks a floor -// (design 47 H H-A-159; the reservation numbers, G §369). The tool stays until G §372 removes it with the state versions. -func (a Acts) FloorAgain(_ context.Context, name string) (string, error) { - return "", fmt.Errorf("the floor of %s is not asked: the builder numbers nothing of its own and asks no floor (design 47 H H-A-159); "+ - "a version is numbered by the reservation (G §369, builder_reserved)", name) -} diff --git a/modules/mesh-delivery-builder/internal/versions/claim.go b/modules/mesh-delivery-builder/internal/versions/claim.go index b54113236..86c67c3e5 100644 --- a/modules/mesh-delivery-builder/internal/versions/claim.go +++ b/modules/mesh-delivery-builder/internal/versions/claim.go @@ -2,10 +2,7 @@ package versions import ( "context" - "fmt" - "sort" "strings" - "time" ) // The registry seats a version is published to (design 51 *The seats*), by what is published. @@ -55,206 +52,8 @@ func TagPrefix(path string) string { return path + "/v" } -// ClaimArtifact is one artifact of a trunk build to number. -type ClaimArtifact struct { - Artifact, Kind, Language string -} - -// BuildClaim is a trunk build at its claim: what Numberer.Number numbers. -type BuildClaim struct { - Module, Path, Repository, Fingerprint, Commit, Series string - // Revision is the source revision of the merge (a package is numbered per revision); Merge its sequence, for order. - Revision string - Merge uint64 - Artifacts []ClaimArtifact - // Done are the digests of the build's done key, by artifact, when the claim is a look at a build already done: what it - // left unnumbered (a package whose name was not known yet, a floor that was silent) is numbered with them, so - // version.numbered carries the digest its build module publishes late. Nil for a build still to make. - Done map[string]string -} - -// Numbering is what the claim got. -type Numbering struct { - // Versions are each artifact's version, by artifact; an artifact built unnumbered (its floor not known) has none. - Versions map[string]string - // Unnumbered are the artifacts built and published by digest, numbered once their floor answers (ADR 0617 §1). - Unnumbered []string - // Wait is why the build waits: a package whose floor is not known (design 51 *The floor*). Nothing is claimed. - Wait string - // Said are the builder's narrations of each decision, for its process log and its build log (build.said). - Said []Narration - // Names are the names each numbered artifact was numbered under, by artifact (NameOf, or a package's name in its - // ecosystem). - Names map[string]string - // Refused is why the build is refused: a package's published versions could not be read (ADR 0666 §15). Nothing else - // is numbered. - Refused string -} - -// NameOf is the name artifact of module was numbered under in this numbering. -func (g Numbering) NameOf(module, artifact string) string { - if name := g.Names[artifact]; name != "" { - return name - } - return NameOf(module, artifact) -} - -// Narration is one line the builder says in its build log (design 51: the build log says a version was kept, and -// why), and what it narrates. -type Narration struct{ Line, Why string } - -// What a narration of the build log narrates (the build.said entry's why). -const ( - SaidNumbered = "numbered" - SaidKept = "kept" - SaidWaiting = "waiting" - SaidUnnumbered = "unnumbered" - SaidOldFormClosed = "old-form-closed" -) - -// narrationOf is a decision's narration. -func narrationOf(name string, d Decision) Narration { - why := SaidNumbered - switch { - case d.Keep: - why = SaidKept - case d.Wait: - why = SaidWaiting - case d.Unnumbered: - why = SaidUnnumbered - } - return Narration{Line: name + ": " + d.Why, Why: why} -} - -// Numberer numbers trunk builds at their claim (design 51 *The versions*, DLV-B2, B3): it asks a name's floor only -// when versions holds nothing for it, and records a silent floor as a wait (FloorWaits, woken by its source's event). +// Numberer holds the state versions kept from before G (design 51 *The versions*): the builder numbers nothing in it at a +// claim and asks no floor (design 47 H §756, H H-A-159); the registry seats' words still mark its entries (Heard). type Numberer struct { Versions Versions - Floor FloorSources - Waits *FloorWaits - // Holder is the module holding a seat, whose health condition's clear wakes a silent seat source; nil names none. - Holder func(seat string) string - // Names answers a package's name in its ecosystem; nil numbers a package as NameOf names it. - Names PackageNames - // Publishing is told each version Built recorded that is still numbered, its holder's word not heard yet: the - // builder arms its publish bound (publish.go); nil arms none. - Publishing func(ctx context.Context, e Entry) - Now func() time.Time -} - -// Number numbers every numbered artifact of c. An error is a store that cannot be read or written: the claim is then -// built as before, unnumbered, and said. -func (n *Numberer) Number(ctx context.Context, c BuildClaim) (Numbering, error) { - out := Numbering{Versions: map[string]string{}, Names: map[string]string{}} - arts := append([]ClaimArtifact(nil), c.Artifacts...) - sort.Slice(arts, func(i, j int) bool { return arts[i].Artifact < arts[j].Artifact }) - for _, a := range arts { - seat, kind, ok := SeatOf(a.Kind, a.Language) - if !ok { - continue - } - name := NameOf(c.Module, a.Artifact) - if kind == KindPackage && n.Names != nil { - // A package is numbered, asked for its floor and published under its name in its ecosystem (design 32), the - // name the holder's builder_versions question and the seat's versions name it by. - named, known, err := n.Names(ctx, c.Module, a.Artifact) - if err != nil || !known { - why := "the indexer's packages state names no name of it in its ecosystem yet (it writes one at the module's next trunk merge)" - if err != nil { - why = "the indexer's packages state cannot be read: " + err.Error() - } - out.Unnumbered = append(out.Unnumbered, a.Artifact) - out.Said = append(out.Said, Narration{Line: name + ": built unnumbered: " + why, Why: SaidUnnumbered}) - continue - } - name = named - } - out.Names[a.Artifact] = name - entries, err := n.Versions.Of(ctx, name) - if err != nil && kind == KindPackage { - // A build that cannot read the published packages refuses, naming the unread state, never building against a - // guess (ADR 0666 §15; design 51 *The versions*, line 287). - out.Refused = fmt.Sprintf("%s: refused: the builder's state %s cannot be read, so its published versions are not known: %v", name, State, err) - return out, nil - } - if err != nil { - return out, err - } - var floor Floor - var why map[string]string - if len(entries) == 0 { - floor, why = n.askFloor(ctx, seat, name, c) - } - d, _, err := n.Versions.Number(ctx, Claim{Name: name, Kind: kind, Series: c.Series, Module: c.Module, Fingerprint: c.Fingerprint, - Commit: c.Commit, Revision: c.Revision, Digest: c.Done[a.Artifact], Seat: seat, Merge: c.Merge, Floor: floor}) - if err != nil { - return out, err - } - out.Said = append(out.Said, narrationOf(name, d)) - switch { - case d.Wait: - n.wait(name, seat, floor, why) - out.Wait = name + ": " + d.Why - return out, nil - case d.Unnumbered: - n.wait(name, seat, floor, why) - out.Unnumbered = append(out.Unnumbered, a.Artifact) - continue - } - if n.Waits != nil { - n.Waits.Answered(name) - } - out.Versions[a.Artifact] = d.Version - } - return out, nil -} - -func (n *Numberer) askFloor(ctx context.Context, seat, name string, c BuildClaim) (Floor, map[string]string) { - return n.Floor.Ask(ctx, FloorOf{Seat: seat, Name: name, Repository: c.Repository, Prefix: TagPrefix(c.Path)}) -} - -func (n *Numberer) wait(name, seat string, f Floor, why map[string]string) { - if n.Waits == nil { - return - } - holder := "" - if n.Holder != nil { - holder = n.Holder(seat) - } - now := time.Now() - if n.Now != nil { - now = n.Now() - } - n.Waits.Wait(name, seat, holder, f, why, now) -} - -// Built records the digest each numbered artifact was built with, on an entry that holds none yet or was never published: what the holder's -// builder_versions question compares (ADR 0605 §4). -func (n *Numberer) Built(ctx context.Context, c BuildClaim, got Numbering, digests map[string]string) error { - var errs []string - for artifact, version := range got.Versions { - d := digests[artifact] - if d == "" { - continue - } - e, err := n.Versions.Mark(ctx, got.NameOf(c.Module, artifact), version, func(e *Entry) { - // The new digest replaces the recorded one only while no published was said for the number (design 51 - // *Tools of the builder*): a rebuild of a gone file under the same number. - if e.Digest == "" || e.State == Numbered || e.State == Refused { - e.Digest = d - } - }) - if err != nil { - errs = append(errs, err.Error()) - continue - } - if e.State == Numbered && n.Publishing != nil { - n.Publishing(ctx, e) - } - } - if len(errs) > 0 { - sort.Strings(errs) - return fmt.Errorf("the built digests could not be recorded: %s", strings.Join(errs, "; ")) - } - return nil } diff --git a/modules/mesh-delivery-builder/internal/versions/entrynames.go b/modules/mesh-delivery-builder/internal/versions/entrynames.go index e317b4a52..4d5ab9f08 100644 --- a/modules/mesh-delivery-builder/internal/versions/entrynames.go +++ b/modules/mesh-delivery-builder/internal/versions/entrynames.go @@ -122,20 +122,3 @@ func EntriesOf(branches *meshcatalogclient.Branches) Entries { func HolderOf(branches *meshcatalogclient.Branches) func(seat string) (string, bool) { return branches.Claimant } - -// RequirementsFrom answers the versions of a package the entries of every followed half require, each once, in order: what a -// consumer's entry names for it in its packages (design 47 G A-119), the floor's third source. -func RequirementsFrom(all Entries) func(ctx context.Context, name string) ([]string, error) { - return func(_ context.Context, name string) ([]string, error) { - seen := map[string]bool{} - var out []string - for _, e := range all() { - if v := e.Packages[name]; v != "" && !seen[v] { - seen[v] = true - out = append(out, v) - } - } - sort.Strings(out) - return out, nil - } -} diff --git a/modules/mesh-delivery-builder/internal/versions/entrynames_test.go b/modules/mesh-delivery-builder/internal/versions/entrynames_test.go index 7cb1276b3..4d94d3ce6 100644 --- a/modules/mesh-delivery-builder/internal/versions/entrynames_test.go +++ b/modules/mesh-delivery-builder/internal/versions/entrynames_test.go @@ -66,22 +66,3 @@ func TestPackageNamesAreReadFromTheCatalogHalfsEntries(t *testing.T) { t.Errorf("CarriersFrom(twin) = %v, want %v", got, want) } } - -// Design 47 G A-119: the floor's requirements are what the catalog half's entries name for the package, each version once. -func TestRequirementsFromAreTheVersionsEntriesNameForAPackage(t *testing.T) { - entries := func() []meshcatalog.CatalogEntry { - return []meshcatalog.CatalogEntry{ - {Module: "a", Packages: map[string]string{"x/sdk": "v0.0.0-2026-aaa", "y": "v1.0.0"}}, - {Module: "b", Packages: map[string]string{"x/sdk": "v0.0.0-2026-bbb"}}, - {Module: "c", Packages: map[string]string{"x/sdk": "v0.0.0-2026-aaa"}}, - {Module: "d"}, - } - } - got, err := RequirementsFrom(entries)(context.Background(), "x/sdk") - if err != nil || !reflect.DeepEqual(got, []string{"v0.0.0-2026-aaa", "v0.0.0-2026-bbb"}) { - t.Errorf("requirements = %v, %v", got, err) - } - if got, _ := RequirementsFrom(entries)(context.Background(), "none"); len(got) != 0 { - t.Errorf("a package no entry names has requirements %v", got) - } -} diff --git a/modules/mesh-delivery-builder/internal/versions/floor.go b/modules/mesh-delivery-builder/internal/versions/floor.go deleted file mode 100644 index a186bcb3f..000000000 --- a/modules/mesh-delivery-builder/internal/versions/floor.go +++ /dev/null @@ -1,332 +0,0 @@ -package versions - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "slices" - "sort" - "strings" - "sync" - "time" -) - -// FloorSources are the three sources of a name's floor (design 51 *The floor*): each a tool call that answers the -// versions it knows of a name, or an error when it does not answer. -type FloorSources struct { - // Seat is `seat:.versions` of the registry seat the name is published to. - Seat func(ctx context.Context, seat, name string) ([]string, error) - // Tags is the seat git's tags: the git tags of the repository the name is built from, under prefix. - Tags func(ctx context.Context, repository, prefix string) ([]string, error) - // Requirements are the versions of a package the catalog half's entries require (design 47 G A-119). - Requirements func(ctx context.Context, name string) ([]string, error) -} - -// FloorOf names what a floor is asked for: the name on its seat, and the repository and tag prefix of its git tags. -type FloorOf struct{ Seat, Name, Repository, Prefix string } - -// Ask asks the three sources of a name; a source that errs, or is not wired, is named in Silent with its error in why. -func (s FloorSources) Ask(ctx context.Context, of FloorOf) (Floor, map[string]string) { - seat, name := of.Seat, of.Name - var f Floor - why := map[string]string{} - ask := func(source string, call func() ([]string, error), into *[]string) { - if call == nil { - f.Silent, why[source] = append(f.Silent, source), "not asked: the builder has no path to it" - return - } - got, err := call() - if err != nil { - f.Silent, why[source] = append(f.Silent, source), err.Error() - return - } - *into = got - } - var seatCall, tagsCall, reqCall func() ([]string, error) - if s.Seat != nil { - seatCall = func() ([]string, error) { return s.Seat(ctx, seat, name) } - } - if s.Tags != nil { - tagsCall = func() ([]string, error) { return s.Tags(ctx, of.Repository, of.Prefix) } - } - if s.Requirements != nil { - reqCall = func() ([]string, error) { return s.Requirements(ctx, name) } - } - ask(SourceSeat, seatCall, &f.Seat) - ask(SourceTags, tagsCall, &f.Tags) - ask(SourceRequirements, reqCall, &f.Requirements) - return f, why -} - -// What wakes a name waiting on its floor, never a timer (design 51, DLV-B3b): the source that was silent saying -// something, or its module's health condition clearing. -const ( - // WakePublished is the holder's `published` on the builder's durable consumer of `.events`. - WakePublished = "published" - // WakeRevision is a catalog revision the builder hears (the catalog half's entry changed): tags and requirements are asked again. - WakeRevision = "catalog-revision" - // WakeTakenIn is the indexer's next `take-in.taken`, in place of the retired manifest-accepted: the floor looks at every - // module again (design 47 H H-A-116). - WakeTakenIn = "take-in.taken" - // WakeCleared is the condition keeper's clear of a silent module's health condition on `mesh-conditions`. - WakeCleared = "condition-cleared" - // WakeByHand is builder_floor_again, a hand act. - WakeByHand = "by hand" -) - -// sourceOfWake is the floor source each event says something of; a clear names the source by its module. -var sourceOfWake = map[string]string{WakePublished: SourceSeat, WakeTakenIn: SourceRequirements} - -// SourceSeats are the seats whose holders are the floor's tag and requirement sources (design 47 G A-82): the seat git (tags) -// and the seat mesh-catalog (requirements), the holders read from the seat list and the catalog half. -var SourceSeats = map[string]string{SourceTags: "git", SourceRequirements: "mesh-catalog"} - -// FloorWait is one name waiting on its floor: the sources still silent and why, since when; the finding the builder -// writes names them, cleared once all three answer. -type FloorWait struct { - Name string `json:"name"` - Seat string `json:"seat"` - Silent []string `json:"silent"` - Why map[string]string `json:"why,omitempty"` - Since time.Time `json:"since"` - // Holder is the module holding the name's seat: its condition's clear wakes the seat source. - Holder string `json:"holder,omitempty"` -} - -// Finding is the floor finding's words. -func (w FloorWait) Finding() string { - var parts []string - for _, s := range w.Silent { - p := s - if why := w.Why[s]; why != "" { - p += " (" + why + ")" - } - parts = append(parts, p) - } - return fmt.Sprintf("the floor of %s is not known since %s: %s did not answer; nothing of it is numbered until all three answer", - w.Name, w.Since.UTC().Format(time.RFC3339), strings.Join(parts, ", ")) -} - -// The builder's state floor-waits (DLV-B4): each name waiting on its floor, keyed by its escaped name, so a restarted -// builder still knows which names its silent sources' events wake; builder_floor_waits reads it. -const ( - FloorWaitsState = "floor-waits" - FloorWaitsTool = "builder_floor_waits" -) - -// FloorWaitKey is a wait's key in floor-waits. -func FloorWaitKey(name string) string { return EscapeToken(name) } - -// FloorKeeper keeps the waits on the bus: Put a wait's value, Delete its key. -type FloorKeeper interface { - Put(key string, value []byte) error - Delete(key string) error -} - -// FloorWaits are the names waiting on their floor. Wake answers which names to ask again for an event, Answered drops -// a name once all three answered; the builder's finding for each is the wait's Finding. Once Kept, every change is -// written to the state floor-waits as well. -type FloorWaits struct { - mu sync.Mutex - waits map[string]FloorWait - keeper FloorKeeper - // Logf says a wait that could not be kept; nil says nothing. - Logf func(string, ...any) - // Holder finds the module holding a seat (the catalog half's claim); a source's module is the holder of its SourceSeats seat. - Holder func(seat string) (string, bool) - // Said is told each wait recorded (raised) and each answered (not raised): the builder's finding floor-silent. - Said func(w FloorWait, raised bool) -} - -// FloorSilent is the kind of the floor finding. -const FloorSilent = "floor-silent" - -// Keep binds the state: the waits it holds that are not known here are taken in (a restarted builder's), every wait -// known here is written to it, and every change from now on is. -func (fw *FloorWaits) Keep(k FloorKeeper, held []FloorWait) { - fw.mu.Lock() - if fw.waits == nil { - fw.waits = map[string]FloorWait{} - } - for _, w := range held { - if _, had := fw.waits[w.Name]; !had && w.Name != "" { - fw.waits[w.Name] = w - } - } - fw.keeper = k - all := make([]FloorWait, 0, len(fw.waits)) - for _, w := range fw.waits { - all = append(all, w) - } - fw.mu.Unlock() - for _, w := range all { - fw.put(k, w) - } -} - -func (fw *FloorWaits) put(k FloorKeeper, w FloorWait) { - if k == nil { - return - } - data, err := json.Marshal(w) - if err == nil { - err = k.Put(FloorWaitKey(w.Name), data) - } - if err != nil && fw.Logf != nil { - fw.Logf("the floor wait of %s is not kept in %s (a restart forgets it until its next claim): %v", w.Name, FloorWaitsState, err) - } -} - -// DecodeFloorWait reads one value of floor-waits. -func DecodeFloorWait(raw []byte) (FloorWait, error) { - var w FloorWait - if err := json.Unmarshal(raw, &w); err != nil { - return FloorWait{}, err - } - if w.Name == "" { - return FloorWait{}, errors.New("a floor wait names no name") - } - return w, nil -} - -// Wait records that name's floor is not known. -func (fw *FloorWaits) Wait(name, seat, holder string, f Floor, why map[string]string, now time.Time) FloorWait { - fw.mu.Lock() - if fw.waits == nil { - fw.waits = map[string]FloorWait{} - } - w, had := fw.waits[name] - if !had { - w.Since = now - } - w.Name, w.Seat, w.Holder, w.Silent, w.Why = name, seat, holder, slices.Clone(f.Silent), why - fw.waits[name] = w - k := fw.keeper - fw.mu.Unlock() - fw.put(k, w) - if fw.Said != nil { - fw.Said(w, true) - } - return w -} - -// Answered drops name: its floor is known. It says whether the name waited, so its finding is cleared. -func (fw *FloorWaits) Answered(name string) bool { - fw.mu.Lock() - w, had := fw.waits[name] - delete(fw.waits, name) - k := fw.keeper - fw.mu.Unlock() - if had && fw.Said != nil { - fw.Said(w, false) - } - if had && k != nil { - if err := k.Delete(FloorWaitKey(name)); err != nil && fw.Logf != nil { - fw.Logf("the floor wait of %s is not cleared from %s: %v", name, FloorWaitsState, err) - } - } - return had -} - -// FloorWaitsAnswer is what builder_floor_waits answers: every name waiting on its floor, oldest first, with its finding. -type FloorWaitsAnswer struct { - Waits []FloorWaitRead `json:"waits"` -} - -// FloorWaitRead is one wait as builder_floor_waits shows it. -type FloorWaitRead struct { - FloorWait - Finding string `json:"finding"` -} - -// AnswerFloorWaits is builder_floor_waits, read from the state floor-waits. -func AnswerFloorWaits(r Reader) (FloorWaitsAnswer, error) { - keys, err := r.Keys() - if err != nil { - return FloorWaitsAnswer{}, err - } - out := FloorWaitsAnswer{Waits: []FloorWaitRead{}} - for _, k := range keys { - raw, ok, err := r.Get(k) - if err != nil { - return FloorWaitsAnswer{}, err - } - if !ok { - continue - } - w, err := DecodeFloorWait(raw) - if err != nil { - return FloorWaitsAnswer{}, fmt.Errorf("%s.%s: %w", FloorWaitsState, k, err) - } - out.Waits = append(out.Waits, FloorWaitRead{FloorWait: w, Finding: w.Finding()}) - } - sort.Slice(out.Waits, func(i, j int) bool { - if !out.Waits[i].Since.Equal(out.Waits[j].Since) { - return out.Waits[i].Since.Before(out.Waits[j].Since) - } - return out.Waits[i].Name < out.Waits[j].Name - }) - return out, nil -} - -// FloorWaitsDescription is builder_floor_waits' description. -const FloorWaitsDescription = "The names waiting on their floor (the builder's state floor-waits, design 51 *The floor*), oldest first: " + - "each name, its registry seat, the sources still silent and why, since when, and the finding the builder says for it. " + - "Nothing of a waiting name is numbered until all three sources answer; builder_floor_again asks one again by hand. Read-only." - -// Wake answers the names to ask their floor again on an event: kind one of the Wake constants; seat the seat a -// `published` came on; module the module whose condition cleared. A name is woken only when the event says something -// of a source it waits on; WakeByHand with a name wakes that name alone. -func (fw *FloorWaits) Wake(kind, seat, module, name string) []string { - fw.mu.Lock() - defer fw.mu.Unlock() - var out []string - for n, w := range fw.waits { - switch kind { - case WakeByHand: - if n == name { - out = append(out, n) - } - case WakeCleared: - for _, s := range w.Silent { - if fw.holds(SourceSeats[s], module) || (s == SourceSeat && w.Holder != "" && w.Holder == module) { - out = append(out, n) - break - } - } - default: - src := sourceOfWake[kind] - if kind == WakeRevision { - if slices.Contains(w.Silent, SourceTags) || slices.Contains(w.Silent, SourceRequirements) { - out = append(out, n) - } - } else if slices.Contains(w.Silent, src) && (kind != WakePublished || seat == "" || seat == w.Seat) { - out = append(out, n) - } - } - } - sort.Strings(out) - return out -} - -// Waiting is every wait, by name. -func (fw *FloorWaits) Waiting() []FloorWait { - fw.mu.Lock() - defer fw.mu.Unlock() - out := make([]FloorWait, 0, len(fw.waits)) - for _, w := range fw.waits { - out = append(out, w) - } - sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name }) - return out -} - -// holds is whether module holds seat on the catalog half. -func (fw *FloorWaits) holds(seat, module string) bool { - if seat == "" || module == "" || fw.Holder == nil { - return false - } - holder, ok := fw.Holder(seat) - return ok && holder == module -} diff --git a/modules/mesh-delivery-builder/internal/versions/heard.go b/modules/mesh-delivery-builder/internal/versions/heard.go index 12dc34c6b..9c8d6380b 100644 --- a/modules/mesh-delivery-builder/internal/versions/heard.go +++ b/modules/mesh-delivery-builder/internal/versions/heard.go @@ -30,15 +30,10 @@ type Outcome struct { // Heard takes one seat event in: a numbered version's entry turns published (with its digest when it held none), // refused with the holder's reason, removed with its reason and the event's id, or kept (another tag names its digest) // with the other tags; a by-digest publish (no version) -// marks nothing. It answers the names waiting on their floor that the event wakes: a `published` says the seat -// answers (design 51 *The floor*). -func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome) ([]string, error) { - var wake []string - if event == HeardPublished && n.Waits != nil { - wake = n.Waits.Wake(WakePublished, seat, "", "") - } +// marks nothing. +func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome) error { if o.Version == "" { - return wake, nil + return nil } var change func(*Entry) switch event { @@ -46,7 +41,7 @@ func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome) // A published of other bytes than an entry records under its number is no publish of that entry: the reservation // numbered it and takes it in (design 47 H H-A-159, G §369, A-415; ADR 0605 §4), and the entry stays as it is. if e, ok, _, err := n.Versions.Recorded(ctx, o.Name, o.Version, o.Digest); err == nil && !ok && e.Digest != "" && o.Digest != "" && e.Digest != o.Digest { - return wake, fmt.Errorf("%s@%s is recorded with digest %s, so %s's published of %s is %w", o.Name, o.Version, e.Digest, seat, o.Digest, ErrNotNumbered) + return fmt.Errorf("%s@%s is recorded with digest %s, so %s's published of %s is %w", o.Name, o.Version, e.Digest, seat, o.Digest, ErrNotNumbered) } change = func(e *Entry) { e.State, e.Reason = Published, "" @@ -72,10 +67,10 @@ func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome) } } default: - return wake, fmt.Errorf("%s says %q, which the builder does not hear", seat, event) + return fmt.Errorf("%s says %q, which the builder does not hear", seat, event) } if _, err := n.Versions.Mark(ctx, o.Name, o.Version, change); err != nil { - return wake, fmt.Errorf("%s's %s of %s@%s: %w", seat, event, o.Name, o.Version, err) + return fmt.Errorf("%s's %s of %s@%s: %w", seat, event, o.Name, o.Version, err) } - return wake, nil + return nil } diff --git a/modules/mesh-delivery-builder/internal/versions/oldform.go b/modules/mesh-delivery-builder/internal/versions/oldform.go index f7730ac48..c51f62c8f 100644 --- a/modules/mesh-delivery-builder/internal/versions/oldform.go +++ b/modules/mesh-delivery-builder/internal/versions/oldform.go @@ -25,6 +25,8 @@ import ( const ( OldFormState = "old-form" OldFormKey = "window" + // SaidOldFormClosed is the why of the build log's line saying the window closed (build.said). + SaidOldFormClosed = "old-form-closed" ) // OldFormHeld is the finding of a node holding the window open for FindingAfter, about that node, cleared when the diff --git a/modules/mesh-delivery-builder/internal/versions/store.go b/modules/mesh-delivery-builder/internal/versions/store.go index 5cdb30ca5..a24ac8fa9 100644 --- a/modules/mesh-delivery-builder/internal/versions/store.go +++ b/modules/mesh-delivery-builder/internal/versions/store.go @@ -68,58 +68,6 @@ func (v Versions) Of(ctx context.Context, name string) ([]Entry, error) { return InOrder(out), nil } -// Claim is one numbering asked of the builder. -type Claim struct { - Name, Kind, Series, Module, Fingerprint, Commit, Revision, Digest, Seat string - Merge uint64 - Floor Floor - // Fresh numbers anew a fingerprint or revision already numbered: builder_publish_again after a published (design 51 - // *Tools of the builder*). - Fresh bool -} - -// Number numbers a claim under compare-and-set: two claims of one name never get one number, the second reading the -// first's key and taking the next (ADR 0606 §2). It answers the decision and, when it numbered or kept a version, its -// entry. Attempts are bounded by the claims the name can meet at once; a store that keeps conflicting is an error. -func (v Versions) Number(ctx context.Context, c Claim) (Decision, Entry, error) { - if c.Series == "" { - c.Series = DefaultSeries - } - for attempt := 0; attempt < 16; attempt++ { - entries, err := v.Of(ctx, c.Name) - if err != nil { - return Decision{}, Entry{}, err - } - d := Decide(fresh(entries, c), c.Kind, c.Series, c.Fingerprint, c.Revision, c.Floor) - if d.Version == "" { - return d, Entry{}, nil - } - if d.Keep { - for _, e := range entries { - if e.Version == d.Version { - return d, e, nil - } - } - } - e := Entry{Name: c.Name, Kind: c.Kind, Series: c.Series, Version: d.Version, Module: c.Module, - Fingerprint: c.Fingerprint, Commit: c.Commit, Revision: c.Revision, Digest: c.Digest, Seat: c.Seat, - State: Numbered, At: v.now(), Merge: c.Merge} - raw, err := Encode(e) - if err != nil { - return Decision{}, Entry{}, err - } - _, err = v.Store.Create(ctx, Key(c.Name, d.Version), raw) - if errors.Is(err, ErrConflict) { - continue // another claim took this number: read again and take the next - } - if err != nil { - return Decision{}, Entry{}, fmt.Errorf("%s@%s: %w", c.Name, d.Version, err) - } - return d, e, nil - } - return Decision{}, Entry{}, fmt.Errorf("%s: the versions kept changing under 16 claims", c.Name) -} - // ErrNotNumbered is a version the state versions does not hold (design 51's numbering by name): a version the reservation // numbered (§369) is never held there. var ErrNotNumbered = errors.New("not numbered by the builder") @@ -186,22 +134,6 @@ func (v Versions) now() time.Time { return time.Now().UTC() } -// fresh is entries as Decide reads them for c: with Fresh, the entries of c's fingerprint and revision still count for the -// next number but keep none. -func fresh(entries []Entry, c Claim) []Entry { - if !c.Fresh { - return entries - } - out := make([]Entry, len(entries)) - for i, e := range entries { - if e.Tag == "" && (e.Fingerprint == c.Fingerprint || (c.Revision != "" && e.Revision == c.Revision)) { - e.Fingerprint, e.Revision = "", "" - } - out[i] = e - } - return out -} - // All is every entry of every name, by name in order: what the versions' readers read. func (v Versions) All(ctx context.Context) ([]Entry, error) { keys, err := v.Store.KeysOf(ctx, AllFilter) diff --git a/modules/mesh-delivery-builder/internal/versions/tools.go b/modules/mesh-delivery-builder/internal/versions/tools.go index 8a562cbf5..499c99ce9 100644 --- a/modules/mesh-delivery-builder/internal/versions/tools.go +++ b/modules/mesh-delivery-builder/internal/versions/tools.go @@ -14,7 +14,6 @@ import ( const ( VersionsTool = "builder_versions" PublishAgainTool = "builder_publish_again" - FloorAgainTool = "builder_floor_again" OldFormTool = "builder_old_form" // OldFormClosedEvent is the builder's own family `version`, kept seven days, // apart from its builds' ends, so a waiter on a build's end does not wake on them. diff --git a/modules/mesh-delivery-builder/internal/versions/versions.go b/modules/mesh-delivery-builder/internal/versions/versions.go index b04dd7ca9..4488bf049 100644 --- a/modules/mesh-delivery-builder/internal/versions/versions.go +++ b/modules/mesh-delivery-builder/internal/versions/versions.go @@ -182,125 +182,6 @@ func Patch(series, version string) (int, bool) { return n, true } -// Floor is what the three sources answered for a name (design 51 *The floor*, ADR 0606 §3): the seat's versions, the -// package's git tags (the seat git's tags) and the pseudo-versions consumers require (the catalog half's -// indexer_requirements). A source not answered is listed in Silent. -type Floor struct { - Seat []string `json:"seat,omitempty"` - Tags []string `json:"tags,omitempty"` - Requirements []string `json:"requirements,omitempty"` - // Silent names the sources that did not answer: "seat", "git.tags", "catalog.requirements". - Silent []string `json:"silent,omitempty"` -} - -// The floor's sources, as Floor.Silent names them. -const ( - SourceSeat = "seat" - SourceTags = "git.tags" - SourceRequirements = "catalog.requirements" -) - -// Known is whether every source answered. -func (f Floor) Known() bool { return len(f.Silent) == 0 } - -// Highest is the highest count of series the floor's three sources name, -1 when none names one. A pseudo-version -// (`v0.1.14-0.2026…-abc`) counts as the version below it was cut from, so its base (`0.1.13`) counts: Go orders it -// before `0.1.14`. -func (f Floor) Highest(series string) int { - high := -1 - for _, list := range [][]string{f.Seat, f.Tags, f.Requirements} { - for _, v := range list { - n, ok := Patch(series, v) - if !ok { - n, ok = pseudoBase(series, v) - } - if ok && n > high { - high = n - } - } - } - return high -} - -// pseudoBase is the count a Go pseudo-version stands on: `v0.1.14-0.