Keep a refused registration left to the build records, in the store and the process, so the look fails the plan rather than settling it built; and forget a deleted module and say what was never sent when the records settle (issue 1708)
mesh/merge-gate head 0e0c775bfa5e merged into trunk f10fbda1f619 — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head 0e0c775bfa5e merged into trunk f10fbda1f619 — pass: its merge-check.sh passed
mesh/delivery delivered

This commit is contained in:
2026-10-21 15:03:23 +02:00
parent 61c8b56107
commit 0e0c775bfa
6 changed files with 257 additions and 4 deletions
@@ -0,0 +1,10 @@
-- A build's outcome whose registration the mesh refused, by the build's id (novox/hq issue 1708). The build record says
-- what the builder said, which worked; an outcome the event loop could not take into the plans (another act held them)
-- is settled from the records by the look, and without this it would read the refused build as built. Kept in the
-- store so a controller replaced before the settle still fails the plan.
create table build_refused (
id text primary key,
module text not null,
why text not null,
at timestamptz not null default now()
);
+33
View File
@@ -0,0 +1,33 @@
package inventory
import "context"
// RecordRefused keeps that the mesh refused to register a build's outcome, and why (novox/hq issue 1708): the build
// record says the builder's words, which worked, and the look that settles a plan from the records reads this to fail
// it instead. The first refusal of an id stands.
func (i *Inventory) RecordRefused(ctx context.Context, id, module, why string) error {
_, err := i.store.Pool().Exec(ctx,
`insert into build_refused (id, module, why) values ($1, $2, $3) on conflict (id) do nothing`, id, module, why)
return err
}
// RefusedOf is why each of these builds' registration was refused, by id; a build not refused is absent.
func (i *Inventory) RefusedOf(ctx context.Context, ids []string) (map[string]string, error) {
out := map[string]string{}
if len(ids) == 0 {
return out, nil
}
rows, err := i.store.Pool().Query(ctx, `select id, why from build_refused where id = any($1)`, ids)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
var id, why string
if err := rows.Scan(&id, &why); err != nil {
return nil, err
}
out[id] = why
}
return out, rows.Err()
}
+28
View File
@@ -0,0 +1,28 @@
//go:build integration
package inventory
import "testing"
// novox/hq issue 1708 (1708/AC6): a refused registration is kept by its build's id, the first refusal standing, and
// read back for the builds asked about only.
func TestARefusedRegistrationIsKeptByItsBuild(t *testing.T) {
inv := ForTest(t)
ctx := t.Context()
if err := inv.RecordRefused(ctx, "build-1708-a", "nodered", "a port is taken"); err != nil {
t.Fatal(err)
}
if err := inv.RecordRefused(ctx, "build-1708-a", "nodered", "said again"); err != nil {
t.Fatalf("a refusal said twice was refused: %v", err)
}
got, err := inv.RefusedOf(ctx, []string{"build-1708-a", "build-1708-b"})
if err != nil {
t.Fatal(err)
}
if len(got) != 1 || got["build-1708-a"] != "a port is taken" {
t.Fatalf("the refusals read back are %v", got)
}
if none, err := inv.RefusedOf(ctx, nil); err != nil || len(none) != 0 {
t.Fatalf("no builds asked about answered %v %v", none, err)
}
}