From 3a9402176621677c4204bca38f0ff0af274a1e0f Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 15:25:38 +0100 Subject: [PATCH] mesh-build-node: its steps say a step's end, lint is the type-check, it has its own need MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pipeline step ask (the sdk's lib lint and unit steps) was refused with 'this build module says no step's end': its AskSteps set no SayStep, Node, Lint or Has. They are set as mesh-build-go sets them; lint runs tsc --noEmit over each TypeScript package; Puller.Prior counts only runs that started toward poison. Builds: design 47 G §328 (Lint per language), §22, §24, §25 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../cmd/mesh-build-node/asks.go | 15 ++++- .../cmd/mesh-build-node/check_test.go | 52 +++++++++++++++++ .../cmd/mesh-build-node/lint.go | 56 +++++++++++++++++++ .../cmd/mesh-build-node/module.go | 3 + 4 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 modules/mesh-build-node/cmd/mesh-build-node/lint.go diff --git a/modules/mesh-build-node/cmd/mesh-build-node/asks.go b/modules/mesh-build-node/cmd/mesh-build-node/asks.go index de769feeb..34a1d46c7 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/asks.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/asks.go @@ -41,9 +41,22 @@ func (m *Module) askSteps(steps []StepTool) steprun.AskSteps { }, Release: func(ws string) error { return m.spaces().Release(ws) }, Logf: m.Say, + Has: m.Has, + Lint: m.lintStep, + Node: m.Node, + SayStep: m.sayStep(), } } +// sayStep says a pipeline step's end on this node's subject of the seat (design 47 G §24, *Asked on a work queue, ended by an +// event*): SayStep when a test sets it, else the runtime's seat publish. +func (m *Module) sayStep() func(sdkstep.StepEnded) error { + if m.SayStep != nil { + return m.SayStep + } + return steprun.SayStepOn(sdkstep.AskNode, m.Node, stdio.SeatPublish) +} + // Puller is the module's pull of its seat's asks, on source (the runtime's seat pull when nil). func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Puller { if source == nil { @@ -79,7 +92,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul if m.SayEvent != nil { say = steprun.SayOn(sdkstep.AskNode, m.Node, m.SayEvent) } - return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskNode, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, + return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskNode, Say: say, Callers: m.Callers, Prior: steprun.PriorRuns(m.ReadSteps.Get), Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Logf: m.Say, Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) { if err := m.Prepare(ctx); err != nil { diff --git a/modules/mesh-build-node/cmd/mesh-build-node/check_test.go b/modules/mesh-build-node/cmd/mesh-build-node/check_test.go index ebc1ce0c3..fcc3a7ba4 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/check_test.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/check_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun" "git.novox.be/novox/mesh-sdk/go/forgekey" ) @@ -226,3 +227,54 @@ func TestTheTestScriptFindsTscAndEsbuildOnItsPath(t *testing.T) { t.Errorf("npm ran with %v, want NODE_OPTIONS naming the TAP reporter and its file", npm.env) } } + +// Design 47 G §328 (*Lint per language*: TypeScript's lint is the type-check) and §24: the pipeline step lint of a TypeScript +// artifact runs tsc without emitting over the module's directory; a type error fails it naming the file, a clean package passes, +// a tree with no .ts file has nothing to lint, and a tsc that cannot start is an error, not a verdict. +func TestTheLintStepIsTheTypeCheck(t *testing.T) { + for _, c := range []struct { + name string + files map[string]string + ran forgekey.Ran + failed int + nothing bool + err bool + }{ + {"a type error", map[string]string{"tools/bad.ts": `export const n: number = "text";`}, forgekey.Ran{Status: 2, Stdout: tscTypeError}, 1, false, false}, + {"a clean package", map[string]string{"index.ts": `export const a = 1;`}, forgekey.Ran{}, 0, false, false}, + {"no TypeScript", map[string]string{"package.json": `{"name":"x"}`}, forgekey.Ran{}, 0, true, false}, + {"tsc cannot start", map[string]string{"index.ts": `export const a = 1;`}, forgekey.Ran{Status: 127, Err: "no such file"}, 0, false, true}, + } { + t.Run(c.name, func(t *testing.T) { + m, f, work := newMachine(t) + workspaceWith(t, work, c.files) + f.answer["tsc"] = c.ran + out, err := m.lintStep(context.Background(), map[string]any{"workspace": "w1", "dir": "."}) + if (err != nil) != c.err { + t.Fatalf("error = %v, want error %v", err, c.err) + } + if err != nil { + return + } + la := out.(steprun.LintAnswer) + if len(la.Failed) != c.failed || la.Nothing != c.nothing { + t.Fatalf("answer = %+v, want %d failed, nothing %v", la, c.failed, c.nothing) + } + if c.failed > 0 && !strings.Contains(la.Failed[0].Cause+la.Failed[0].Output, "tools/bad.ts") { + t.Errorf("the failure %+v does not name tools/bad.ts", la.Failed[0]) + } + if !c.nothing && !strings.Contains(joined(f.calls[0]), "--noEmit") { + t.Errorf("the lint ran %s, want tsc --noEmit", joined(f.calls[0])) + } + }) + } +} + +// Design 47 G §24: the Node build module's steps carry what a step ask needs (its node, the lint body, the end's publisher and +// its own need), so the ask the first live pipeline sent is no longer refused as "says no step's end". +func TestTheNodeStepsCarryWhatAStepAskNeeds(t *testing.T) { + s := (&Module{Node: "shanks"}).askSteps(nil) + if s.Lint == nil || s.Node != "shanks" || s.SayStep == nil || s.Has == nil || !s.Has(sdkstep.NeedNodeBuildNode) || s.Has("other") { + t.Errorf("steps = %+v, want Lint, Node, SayStep and Has set", s) + } +} diff --git a/modules/mesh-build-node/cmd/mesh-build-node/lint.go b/modules/mesh-build-node/cmd/mesh-build-node/lint.go new file mode 100644 index 000000000..832a32941 --- /dev/null +++ b/modules/mesh-build-node/cmd/mesh-build-node/lint.go @@ -0,0 +1,56 @@ +package main + +import ( + "context" + "fmt" + "path/filepath" + + sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun" +) + +// **The type-check is a TypeScript artifact's pipeline step lint** (design 47 G §328 *Lint per language*: Go's lint is the Go +// build module's linter, TypeScript's the type-check; §22: lint is a step the build seats serve; §24: asked on a work queue, +// its end said as an event). It takes {"workspace", "dir"} as the lint step of mesh-build-go does and runs tsc over each +// TypeScript package of the module's directory (testTargets, the way the unit level finds them), without emitting: a package +// with no .ts file has nothing to lint, and nothing at all ends the step `nothing to run`. A failure is the step's, naming +// the tsc output as the unit level names it; a tsc that could not start is an error, never a verdict. +func (m *Module) lintStep(ctx context.Context, args map[string]any) (any, error) { + workspace, _ := args["workspace"].(string) + dir, _ := args["dir"].(string) + root, mdir, err := m.moduleDirOf(workspace, dir) + if err != nil { + return nil, err + } + targets, err := testTargets(mdir, filepath.ToSlash(filepath.Clean(dir))) + if err != nil { + return nil, err + } + var failed []Failure + linted := false + for _, tg := range targets { + sources, err := typeScriptFiles(tg.dir) + if err != nil { + return nil, err + } + if len(sources) == 0 { + continue + } + linted = true + if err := m.provide(root); err != nil { + return nil, fmt.Errorf("providing the toolchain's packages to the workspace: %w", err) + } + r := m.runIn(ctx, root, false, tg.dir, nil, "node", m.typeCheck(tg.dir, sources)...) + if r.Err != "" { + return nil, fmt.Errorf("type-check could not be run: status %d %s: %s", r.Status, r.Err, firstLine(r.Stderr)) + } + if r.Status != 0 { + failed = append(failed, testFailures(tg.where, "type-check", tg.dir, r, "")...) + } + } + return steprun.LintAnswer{Failed: failed, Nothing: !linted}, nil +} + +// Has says whether this node has a need a package's tests name (sdkstep.AskNeeds): the need node-build-node is this module's own +// (a TypeScript package's tests run through it); any other it lacks. +func (m *Module) Has(need string) bool { return need == sdkstep.NeedNodeBuildNode } diff --git a/modules/mesh-build-node/cmd/mesh-build-node/module.go b/modules/mesh-build-node/cmd/mesh-build-node/module.go index b21fbd131..4b83bc294 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/module.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/module.go @@ -34,6 +34,9 @@ type Module struct { // puller's ask-taken, step-progress and step-ended (design 47 G §496, §602). SayEvent func(subject string, body any, id string) error + // SayStep says a pipeline step's end (steprun.AskSteps.SayStep); the seat's publish on this node when nil (a test's own). + SayStep func(sdkstep.StepEnded) error + Node string // Recipe is the recipe in force. Reload, when set, reads it again at every check (the lock file the mesh // writes can change under a running module); a failure to read it is a refusal.