carlos / platform Public

claim unit-shape policy: only the installation's own work may go on without a registry row (fix round 2, Astra on 4dd4c436)

4dd4c436 let every empty-identity work pass the unit-shape refusal on a host
with no registry row, not just the fresh install that needed it. Astra's P2:
a timer delivering to its cached route could register a producer and run
MarkTimerFired after the route was removed (claimtimer.go:40,
schedule/runner.go:640).

Now Reconciler.installWithWork marks the work it selects as installation
work (hostbox.Selection.Installation, settable only inside hostbox), and
claimUnitShapeCheck, split out of claimUnitShapePolicy, admits a missing
row only under that mark. Everything else on a host whose row is absent
refuses with ErrChanged as before 4dd4c436.

Witnesses: TestClaimTimerRefusedAfterRouteRemoval (no delivery, no
MarkTimerFired, unchanged timer row after the route goes); the
fresh-install and unit-shape tests cover both kinds of work; the hostbox
mark test. Mutation checks: without the mark check, the timer and policy
tests fail; without the mark in installWithWork, the fresh-install witness
and all seven TestClaimBinding* witnesses fail.

Census: overlay plan14-root-reads-claim-fresh-install.tsv updated in place
(claimUnitShapePolicy @remove, reads pinned on claimUnitShapeCheck at
authority/E2, installWithWork re-pinned at authority/C, both envelopes
re-pinned), still PROPOSED-claim-fresh-install. The census note carries the
owed caller table: which guard refuses an absent row for a retired or
deleted host, per production caller.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev f0faf8cd3bdfb0e3304afc8fdb90c8c1d5220906 parent 4dd4c43
9 files changed, +293 −59
  • docs/superpowers/notes/census-proposal-claim-step8-readiness.md +45 −14
  • internal/host/claim_fresh_install_policy_linux_test.go +95 −0
  • internal/host/claimunit_policy.go +34 −18
  • internal/host/claimunit_policy_test.go +46 −20
  • internal/hostbox/reconcile.go +1 −0
  • internal/hostbox/work.go +23 −0
  • internal/hostbox/work_installation_test.go +36 −0
  • internal/provision/plan14_root_reads_test.go +7 −4
  • internal/provision/testdata/plan14-root-reads-claim-fresh-install.tsv +6 −3

CI failed — run details

diff --git a/docs/superpowers/notes/census-proposal-claim-step8-readiness.md b/docs/superpowers/notes/census-proposal-claim-step8-readiness.md
index cdad9a6f0..ce81663c8 100644
--- a/docs/superpowers/notes/census-proposal-claim-step8-readiness.md
+++ b/docs/superpowers/notes/census-proposal-claim-step8-readiness.md
@@ -358,26 +358,57 @@ At 8.2 the harness's G10 re-run (2026-10-20, 23:25Z) stopped with `migration cen
## Fresh install
-Status: PROPOSED (rev3=PROPOSED-claim-fresh-install).
+Status: PROPOSED (rev3=PROPOSED-claim-fresh-install). Fix round 2 follows Astra's review of 4dd4c436 (MERGE: block, one P2).
The harness's first claim-mode create on leo (G10, 2026-10-21) reached serving at 08:42:03Z, but leo never installed it. Each pass, the agent logged `provision: claim install claimtrial2.dev.harness.test: hostbox: selected authority changed`. Root's inventory stayed at revision 1 with no route entry, and no registry row was written.
-**Cause.** `claimUnitShapePolicy` (the unit-shape refusal that `productionClaimUnitShapePolicy` adds to every production claim policy) refused with `ErrChanged` whenever the host had no registry row. A fresh install has no row until `registerRemote`'s second `work.With` writes it, and the policy runs on every `work.With` before that. So every fresh claim install refused before its route entry reached root. The non-remote `Reconciler.Install` path refused the same way. The binding witnesses used an allow-all policy and never ran the refusal.
+**Cause.** The unit-shape refusal refused with `ErrChanged` whenever the host had no registry row. `productionClaimUnitShapePolicy` adds that refusal to every production claim policy. A fresh install has no row until `registerRemote`'s second `work.With` writes it, and the policy runs on every `work.With` before that. So every fresh claim install refused before its route entry reached root. The non-remote `Reconciler.Install` path refused the same way. The binding witnesses used an allow-all policy and never ran the refusal.
-**Fix.** With no row, the refusal now checks an empty route for the selected host, as `rootClaimRestartShape` already does.
-- **Still refused.** The same independent binding read refuses a host with a configured shape or a saved unit binding. That read is `checkClaimUnitShape` in instance-control and adopt modes, and root's `boundInputs` in agent mode. A row for another host also still refuses.
-- **No change for existing rows.** A row that exists is checked as before.
+**Fix (round 1, 4dd4c436).** With no row, the refusal checked an empty route for the host, as `rootClaimRestartShape` does. Astra found that this admitted all empty-identity work on a host whose row was gone, not just the install. In particular, a timer delivering to its cached route could register a producer and run `MarkTimerFired` after the route was removed.
-**Census.** Overlay `plan14-root-reads-claim-fresh-install.tsv`, loaded last, re-pins `claimUnitShapePolicy` at its existing class and task (authority, E2). Its one new site is the empty route literal. The overlay also re-pins the `internal/host` envelope. No accepted-legacy row, so the seal stands. 9B8 has no change.
+**Fix (round 2).** Only the installation's own work may go on without a row.
+- **The mark.** `Reconciler.installWithWork` marks the work it selects as installation work (`hostbox.Selection.Installation`). The mark lives in an unexported field that only `hostbox` can set, on a copy of the work `SelectAt` returned. This is the path to `registerRemote` and to the local `ownedRow` write.
+- **Why not a context key.** A context key would miss the policy calls that matter. The install closures capture the caller's context, not `installWithWork`'s: `registerRemote`'s `work.With` calls use `installRemote`'s `ctx`, and `Reconciler.Install`'s use `Install`'s. The mark rides on the selected work, so it reaches every `With` on that work and nothing else.
+- **The decision.** `claimUnitShapeCheck` is the refusal's decision, split out of `claimUnitShapePolicy`, which now passes it `s.Installation()`. Without the mark, a missing row refuses with `ErrChanged` as before 4dd4c436. With it, the check reads an empty route for the host.
+- **Still refused.** The shape and binding reads are unchanged. A configured shape or a saved unit binding refuses: through `checkClaimUnitShape` in instance-control and adopt modes, and root's `boundInputs` in agent mode. A row for another host refuses. `registerRemote` still refuses to recreate a row its inventory records as materialized.
-**Ruling 6.** No new caller. The refusal is reached only from the production claim policy, as before.
+**Census.** Overlay `plan14-root-reads-claim-fresh-install.tsv` is loaded last and updated in place.
+- `claimUnitShapePolicy` keeps no read of its own. It is removed (`@remove`), and its reads are pinned on `claimUnitShapeCheck` at the same class and task (authority, E2).
+- `Reconciler.installWithWork` is re-pinned at its existing class (authority, C). Its reads are unchanged.
+- The `internal/host` and `internal/hostbox` envelopes are re-pinned.
+- No accepted-legacy row, so the seal stands. 9B8 has no change.
+
+**Ruling 6.** No new caller. The refusal is reached only from the production claim policy, as before. Only `installWithWork` sets the mark.
+
+**Production callers and the checks that refuse a host whose row is absent for another reason** (retired, deleted or mid-retirement). This is the census owner's owed confirmation, taken from Astra's caller table with lines at this commit. The timer row is updated to round 2.
+
+| Caller | Where | What refuses a host whose row is absent for another reason |
+|---|---|---|
+| Registration | `ProductionClaimOwnerProvider.OpenClaimOwners` adds the refusal (host/claimproduction.go:217); `OpenProductionClaimAssembly` composes it (host/claimconstruction.go:414) | n/a |
+| Main consumer | `ClaimAssembly.Build` hands the policy to the shared `WorkSource` (host/claimassembly.go:165) | per operation, below |
+| Fresh or retried installation (the only marked work) | `Reconciler.installWithWork` | The claim gate: serving, no operation, `Exec` is this box, not lost (hostbox/reconcile.go:196); a deleting, purging or releasing claim refuses. The record ETag (hostbox/reconcile_adapter.go:75). The guard's retired-stamp refusal (hostguard/root.go:174). `registerRemote` refuses an absent row its inventory records as materialized (hostbox/inventory_registration.go:187). The shape and binding refusal still refuses a configured shape or saved binding |
+| Ordinary serving wake, config and release effects | `WorkSource` work with a nonempty identity | `claimInputPolicy` refuses a missing row (host/claimproduction.go:270). The unit-shape refusal refuses it too (unmarked). Cold wake also rereads the route |
+| Move and relocation work | `WorkSource` work | Operation, phase, executor and input checks. Held actions require the operation's hold. The unit-shape refusal refuses a missing row (unmarked) |
+| Timer mutation | `MutateTimer` | Requires a current, owned route (hostbox/timer_registration.go:73). The unit-shape refusal refuses a missing row (unmarked) |
+| Timer delivery and bookkeeping | `ClaimTimerDelivery` (host/claimtimer.go:40), `Runner.record`'s `MarkTimerFired` (schedule/runner.go:640) | **Round 2:** the unit-shape refusal refuses a missing row, because timer work is never marked. `TestClaimTimerRefusedAfterRouteRemoval` witnesses this |
+| Root restart requests | `rootRestartRequests` | The unit-shape refusal refuses a missing row (unmarked). It also requires a retained installation, canonical record and verified running-unit identity (host/rootrestart_requests.go:123) |
+| Root held-release work | reuses the assembly policy (host/movesheldrelease_production.go:72) | The independent authority recheck requires a current row (host/movesheldrelease_root.go:481) |
+| Admin token mint | `claimAdminTokens` (host/claimproduction.go:182) | Uses a separate base policy and never calls this refusal |
+| Stop, delete, retirement | Fence, stop-evidence and exact-inventory paths | Never obtain authority through this policy |
**Tests.**
-- `TestClaimFreshInstallUnderProductionPolicy`: an L2-style fresh remote install through root's real `commitRootInventory`, under the production policy (`hostbox.Policy` with the hold policy, `.WithRefusals(productionClaimUnitShapePolicy(...))`). Against the pre-fix refusal it fails with `install: hostbox: selected authority changed, effects=0`.
+- `TestClaimFreshInstallUnderProductionPolicy` runs an L2-style fresh remote install through root's real `commitRootInventory`, under the production policy (`hostbox.Policy` with the hold policy, `.WithRefusals(productionClaimUnitShapePolicy(...))`). It fails on 27303f54, and when the nil-row admission or `installWithWork`'s mark is removed.
+- `TestClaimTimerRefusedAfterRouteRemoval` selects a timer for an installed serving host and keeps its cached route, then removes the route. The claim, installation, timer row and producer all stay valid. It asserts:
+ - no producer registration;
+ - no `MarkTimerFired`;
+ - an unchanged timer row.
+
+ A control run, with the route present, delivers and records. The test fails on 4dd4c436 and when the mark check is dropped.
- `TestClaimUnitShapePolicyFreshInstall` covers instance-control mode:
- - with no row, it passes when there is no shape and no binding, or no binding store at all;
- - it refuses a configured shape (`ErrUnsupported`) and a saved binding, with or without the shape;
- - it refuses a row for another host;
- - matching rows pass as before.
-- `TestClaimUnitShapePolicyFreshInstallAgentReader` covers agent mode: root's `boundInputs` receives the empty route. It passes with no binding and no shape, and refuses a configured shape or a saved binding.
-- The binding witnesses (the `claim_binding_*` L2/L3 worlds and the assembly-wired agent) now run the production policy instead of allow-all. All seven fail against the pre-fix refusal.
+ - ordinary work through the production policy refuses every missing row;
+ - the installation's own work passes with no shape and no binding, or with no binding store;
+ - the installation's work refuses a configured shape (`ErrUnsupported`) and a saved binding, with or without the shape;
+ - a row for another host refuses, and matching rows pass, for both kinds of work.
+- `TestClaimUnitShapePolicyFreshInstallAgentReader` covers agent mode. Ordinary work never reaches root's reader without a row. The installation's work sends it `Route{Host}`, and root's `boundInputs` passes or refuses as above.
+- `TestInstallationWorkMarksOnlyTheInstallationsSelection` (hostbox): the mark is set only on `installWithWork`'s copy of the selected work.
+- The binding witnesses (the `claim_binding_*` L2/L3 worlds and the assembly-wired agent) run the production policy instead of allow-all, and pass.
diff --git a/internal/host/claim_fresh_install_policy_linux_test.go b/internal/host/claim_fresh_install_policy_linux_test.go
index 9e0faa14a..a13b8c9de 100644
--- a/internal/host/claim_fresh_install_policy_linux_test.go
+++ b/internal/host/claim_fresh_install_policy_linux_test.go
@@ -4,6 +4,7 @@ package host
import (
"context"
+ "fmt"
"testing"
"github.com/carlosframework/platform/internal/hostbox"
@@ -12,6 +13,7 @@ import (
"github.com/carlosframework/platform/internal/hostwrite"
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/rootstate"
+ "github.com/carlosframework/platform/internal/schedule"
)
// witnessPolicy is the production claim policy as claimconstruction.go
@@ -82,3 +84,96 @@ func TestClaimFreshInstallUnderProductionPolicy(t *testing.T) {
t.Fatalf("guard inventory revision %d (journal %d), %v", view.Installation.InventoryRevision, revision, err)
}
}
+
+// Fix round 2 (Astra on 4dd4c436): only the installation's own work may go
+// on without a registry row. A timer the runner selected for a serving host
+// keeps its cached route; when the route is removed after that read, while
+// the claim, installation, timer row and running producer all survive, the
+// production policy must refuse both the delivery's producer registration
+// (ClaimTimerDelivery) and the runner's bookkeeping (Runner.record's
+// MarkTimerFired, which runs inside the timer work's With exactly as here).
+func TestClaimTimerRefusedAfterRouteRemoval(t *testing.T) {
+ w := newBindingInstallWorld(t)
+ w.install(t)
+ ctx := t.Context()
+ host := w.rec.Host
+ if err := w.reg.UpsertTimer(registry.Timer{Host: host, Name: "nightly", Kind: schedule.KindOnce, Spec: "once", Path: "/tick", NextAt: 1}); err != nil {
+ t.Fatal(err)
+ }
+ timer, err := w.reg.GetTimer(host, "nightly")
+ if err != nil || timer == nil {
+ t.Fatal(timer, err)
+ }
+ route, err := w.reg.Get(host) // the runner's cached route
+ if err != nil || route == nil || !route.ClaimOwnership.Valid() {
+ t.Fatal(route, err)
+ }
+ timer.ClaimOwnership = route.ClaimOwnership // as a claim box's timer rows carry it
+ holder := w.f.read().Claim.Holder
+ work, err := w.source.Select(ctx, host, "timer")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if s, err := hostbox.Selected(work); err != nil || s.Installation() {
+ t.Fatal("timer work is marked as installation work", err)
+ }
+ target := hostguard.FenceTarget{Host: host, Incarnation: holder.Incarnation, Stamp: holder.Stamp, Session: holder.Session, Box: w.pinned.Box, Enrollment: w.pinned.Enrollment, ControllerID: "controller"}
+ var registered []string
+ p, err := NewClaimProducers(target, "start", func(_ context.Context, _ hostguard.FenceTarget, id string) error {
+ registered = append(registered, id)
+ return nil
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ set := &ClaimProducerSet{}
+ if err := set.Add(p); err != nil {
+ t.Fatal(err)
+ }
+ seq := 0
+ deliver := ClaimTimerDelivery(set, func() string { seq++; return fmt.Sprintf("d%d", seq) })
+ mark := func(at int64) (bool, error) {
+ var applied bool
+ err := work.With(ctx, hostwrite.Identity{}, func() error {
+ var e error
+ applied, e = w.reg.MarkTimerFired(host, timer.Name, timer.Registration, at, "200", 5, 0, 0, 0)
+ return e
+ })
+ return applied, err
+ }
+
+ // With the route present the same work delivers and records.
+ _, finish, err := deliver(ctx, work, *route, *timer)
+ if err != nil || len(registered) != 1 {
+ t.Fatalf("delivery with the route present: %v, registrations %v", err, registered)
+ }
+ finish()
+ if applied, err := mark(100); err != nil || !applied {
+ t.Fatalf("bookkeeping with the route present: applied %v, %v", applied, err)
+ }
+ before, err := w.reg.GetTimer(host, "nightly")
+ if err != nil || before == nil || before.LastAt != 100 {
+ t.Fatal(before, err)
+ }
+
+ // The route goes after the runner read it.
+ if err := w.reg.Delete(host); err != nil {
+ t.Fatal(err)
+ }
+ if rt, err := w.reg.Get(host); err != nil || rt != nil {
+ t.Fatal("route still present", rt, err)
+ }
+ if still, err := w.reg.GetTimer(host, "nightly"); err != nil || still == nil {
+ t.Fatal("the timer row went with the route; this witness needs it to survive", err)
+ }
+ if _, _, err := deliver(ctx, work, *route, *timer); err == nil || len(registered) != 1 {
+ t.Errorf("delivered after the route was removed: %v, registrations %v", err, registered)
+ }
+ if applied, err := mark(200); err == nil || applied {
+ t.Errorf("bookkeeping after the route was removed: applied %v, %v", applied, err)
+ }
+ after, err := w.reg.GetTimer(host, "nightly")
+ if err != nil || after == nil || *after != *before {
+ t.Errorf("timer row changed after the route was removed: %+v (was %+v), %v", after, before, err)
+ }
+}
diff --git a/internal/host/claimunit_policy.go b/internal/host/claimunit_policy.go
index c7cd23a39..14d83eebf 100644
--- a/internal/host/claimunit_policy.go
+++ b/internal/host/claimunit_policy.go
@@ -22,27 +22,43 @@ type claimUnitShapeReader func(context.Context, registry.Route, hostbox.Selectio
func claimUnitShapePolicy(route func(string) (*registry.Route, error), read claimUnitShapeReader) hostbox.PolicyRefusal {
return func(ctx context.Context, _ *hostclaim.Claim, s hostbox.Selection, _ hostwrite.Identity) error {
- if route == nil || read == nil {
- return os.ErrPermission
- }
- rt, err := route(s.Host)
- if err != nil {
- return err
- }
- if rt == nil {
- // A fresh install has no row until registerRemote's second
- // work.With writes it, and every work.With before that runs this
- // policy (harness G10, 2026-10-21). Check an empty route for the
- // host instead, as rootClaimRestartShape does: a host with a
- // configured shape or a saved unit binding still refuses through
- // checkClaimUnitShape (root's boundInputs in agent mode).
- rt = &registry.Route{Host: s.Host}
- }
- if rt.Host != s.Host {
+ return claimUnitShapeCheck(ctx, route, read, s, s.Installation())
+ }
+}
+
+// claimUnitShapeCheck is the unit-shape refusal's decision for selection s.
+// installation is s.Installation(): whether s is the work an installation
+// selected for itself (hostbox's installWithWork), the only work that may
+// go on without a registry row.
+func claimUnitShapeCheck(ctx context.Context, route func(string) (*registry.Route, error), read claimUnitShapeReader, s hostbox.Selection, installation bool) error {
+ if route == nil || read == nil {
+ return os.ErrPermission
+ }
+ rt, err := route(s.Host)
+ if err != nil {
+ return err
+ }
+ if rt == nil {
+ // A fresh install has no row until registerRemote's second
+ // work.With writes it, and every work.With before that runs this
+ // policy (harness G10, 2026-10-21). Only the installation's own work
+ // may go on without a row. Everything else on a host whose row is
+ // absent (a timer delivering to its cached route, a restart, a
+ // retired or deleted host) refuses as before (fix round 2). The
+ // installation checks an empty route for the host, as
+ // rootClaimRestartShape does: a host with a configured shape or a
+ // saved unit binding still refuses through checkClaimUnitShape
+ // (root's boundInputs in agent mode), and registerRemote refuses to
+ // recreate a row its inventory already records as materialized.
+ if !installation {
return hostbox.ErrChanged
}
- return read(ctx, *rt, s)
+ rt = &registry.Route{Host: s.Host}
+ }
+ if rt.Host != s.Host {
+ return hostbox.ErrChanged
}
+ return read(ctx, *rt, s)
}
func checkClaimUnitShape(ctx context.Context, b *claimUnitBindings, shapes map[string]claimUnitShape, rt registry.Route, s hostbox.Selection) error {
diff --git a/internal/host/claimunit_policy_test.go b/internal/host/claimunit_policy_test.go
index bb0a6731a..748328044 100644
--- a/internal/host/claimunit_policy_test.go
+++ b/internal/host/claimunit_policy_test.go
@@ -221,19 +221,21 @@ func TestPlan14BoundRestartShapeRefusal(t *testing.T) {
// A fresh install has no registry row until registerRemote's second
// work.With writes it, and the unit-shape refusal runs on every work.With
-// before that (harness G10, 2026-10-21). With no row the refusal checks an
-// empty route for the host: it passes only when the host has no configured
-// shape and no saved unit binding.
+// before that (harness G10, 2026-10-21). Only the installation's own work
+// (hostbox.Selection.Installation) may go on without a row, and then the
+// refusal checks an empty route for the host: it passes only when the host
+// has no configured shape and no saved unit binding. Any other work refuses
+// a missing row (fix round 2).
func TestClaimUnitShapePolicyFreshInstall(t *testing.T) {
oldOpen, oldShapes := openClaimUnitBindingsRead, productionClaimUnitShapes
defer func() { openClaimUnitBindingsRead, productionClaimUnitShapes = oldOpen, oldShapes }()
for _, tc := range []struct {
name string
- row string // "", "other", "matching"
+ row string // "", "other", "matching", "ordinary"
shape bool
binding bool
storeless bool
- want error
+ want error // for the installation's own work
}{
{name: "no row, no shape, no binding", want: nil},
{name: "no row, no binding store", storeless: true, want: nil},
@@ -276,39 +278,63 @@ func TestClaimUnitShapePolicyFreshInstall(t *testing.T) {
row = &r
}
lookups := 0
- p := productionClaimUnitShapePolicy("instance-control", func(host string) (*registry.Route, error) {
+ route := func(host string) (*registry.Route, error) {
lookups++
if host != in.Host {
t.Fatal("looked up", host)
}
return row, nil
- })
+ }
s := hostbox.Selection{Host: in.Host, Box: in.Box, Action: "reconcile", Kind: hostclaim.KindServing, Captured: hostguard.Captured{Incarnation: in.Incarnation, Stamp: in.Stamp}}
- err := p(t.Context(), &hostclaim.Claim{Host: in.Host, Op: hostclaim.Op{Kind: hostclaim.KindServing}}, s, hostwrite.Identity{})
- if lookups != 1 {
- t.Fatal("route lookups", lookups)
+ if s.Installation() {
+ t.Fatal("a selection literal is marked as installation work")
}
- if tc.want == nil && err != nil {
- t.Fatal("refused:", err)
+ check := func(name string, err, want error) {
+ t.Helper()
+ if want == nil && err != nil {
+ t.Fatalf("%s: refused: %v", name, err)
+ }
+ if want != nil && !errors.Is(err, want) {
+ t.Fatalf("%s: got %v, want %v", name, err, want)
+ }
}
- if tc.want != nil && !errors.Is(err, tc.want) {
- t.Fatalf("got %v, want %v", err, tc.want)
+ // Ordinary work, through the production policy: the selection is
+ // not an installation's, so a missing row refuses.
+ ordinary := tc.want
+ if row == nil {
+ ordinary = hostbox.ErrChanged
+ }
+ p := productionClaimUnitShapePolicy("instance-control", route)
+ check("ordinary work", p(t.Context(), &hostclaim.Claim{Host: in.Host, Op: hostclaim.Op{Kind: hostclaim.KindServing}}, s, hostwrite.Identity{}), ordinary)
+ // The installation's own work, with instance-control's reader
+ // (productionClaimUnitShapePolicy's).
+ read := func(ctx context.Context, rt registry.Route, s hostbox.Selection) error {
+ return withClaimUnitShape(ctx, rt, s, func(claimUnitBinding) error { return nil })
+ }
+ check("installation work", claimUnitShapeCheck(t.Context(), route, read, s, true), tc.want)
+ if lookups != 2 {
+ t.Fatal("route lookups", lookups)
}
})
}
}
// The agent's reader is root's boundInputs (claimunit_policy.go's agent
-// branch, over the role-launch socket). It receives the empty route a fresh
-// install checks and passes it only when root has no binding and no
-// configured shape for the host.
+// branch, over the role-launch socket). Ordinary work never reaches it
+// without a row; the installation's own work sends it the empty route, which
+// it passes only when root has no binding and no configured shape.
func TestClaimUnitShapePolicyFreshInstallAgentReader(t *testing.T) {
var seen []registry.Route
- p := claimUnitShapePolicy(func(string) (*registry.Route, error) { return nil, nil }, func(_ context.Context, rt registry.Route, _ hostbox.Selection) error {
+ route := func(string) (*registry.Route, error) { return nil, nil }
+ read := func(_ context.Context, rt registry.Route, _ hostbox.Selection) error {
seen = append(seen, rt)
return nil
- })
- if err := p(t.Context(), nil, hostbox.Selection{Host: "shop.example"}, hostwrite.Identity{}); err != nil || len(seen) != 1 || seen[0] != (registry.Route{Host: "shop.example"}) {
+ }
+ s := hostbox.Selection{Host: "shop.example"}
+ if err := claimUnitShapePolicy(route, read)(t.Context(), nil, s, hostwrite.Identity{}); !errors.Is(err, hostbox.ErrChanged) || len(seen) != 0 {
+ t.Fatal("ordinary work without a row:", err, seen)
+ }
+ if err := claimUnitShapeCheck(t.Context(), route, read, s, true); err != nil || len(seen) != 1 || seen[0] != (registry.Route{Host: "shop.example"}) {
t.Fatal(err, seen)
}
for _, tc := range []struct {
diff --git a/internal/hostbox/reconcile.go b/internal/hostbox/reconcile.go
index 821bd5b0f..9f25610bf 100644
--- a/internal/hostbox/reconcile.go
+++ b/internal/hostbox/reconcile.go
@@ -332,6 +332,7 @@ func (r Reconciler) installWithWork(ctx context.Context, selected RecordSelectio
if err != nil {
return err
}
+ work = installationWork(work)
local := r.Local
local.Guard = guard
check := func(c *hostclaim.Claim) error {
diff --git a/internal/hostbox/work.go b/internal/hostbox/work.go
index 81a9870fe..c777f6529 100644
--- a/internal/hostbox/work.go
+++ b/internal/hostbox/work.go
@@ -22,6 +22,29 @@ type Selection struct {
Captured hostguard.Captured
Kind, Op, Phase, Generation string
Session uint64
+ // installation marks the work Reconciler.installWithWork selected for
+ // one installation (Installation). Only this package sets it.
+ installation bool
+}
+
+// Installation reports whether the selection is the work an installation
+// selected for itself (Reconciler.installWithWork, the path to the remote
+// route registration and the local row write), not ordinary work on an
+// installed host. A policy may admit what only an installation can need,
+// such as a registry row the installation has not written yet (harness G10,
+// 2026-10-21); no caller outside this package can set it.
+func (s Selection) Installation() bool { return s.installation }
+
+// installationWork marks w, a selection SelectAt made, as installation
+// work. Any other work is returned unmarked, so it is refused whatever an
+// installation-only admission would allow.
+func installationWork(w hostwrite.Work) hostwrite.Work {
+ selected, ok := w.(selectedWork)
+ if !ok {
+ return w
+ }
+ selected.selection.installation = true
+ return selected
}
type WorkSource struct {
diff --git a/internal/hostbox/work_installation_test.go b/internal/hostbox/work_installation_test.go
new file mode 100644
index 000000000..6eef807ca
--- /dev/null
+++ b/internal/hostbox/work_installation_test.go
@@ -0,0 +1,36 @@
+package hostbox
+
+import (
+ "context"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/hostwrite"
+)
+
+// Only installWithWork's own selection is installation work (harness G10,
+// fix round 2): the mark is set on a copy of the selected work, never on the
+// original, and work of any other kind stays unmarked.
+func TestInstallationWorkMarksOnlyTheInstallationsSelection(t *testing.T) {
+ w := selectedWork{selection: Selection{Host: "shop.example", Action: "reconcile"}, checked: &checkedPhase{}}
+ if s, err := Selected(w); err != nil || s.Installation() {
+ t.Fatal("SelectAt's work is installation work before installWithWork marks it", s, err)
+ }
+ marked := installationWork(w)
+ if s, err := Selected(marked); err != nil || !s.Installation() || s.Host != "shop.example" || s.Action != "reconcile" {
+ t.Fatal("marked selection", s, err)
+ }
+ if s, _ := Selected(w); s.Installation() {
+ t.Fatal("the mark reached the original work")
+ }
+ other := hostwrite.Work(otherWork{})
+ if got := installationWork(other); got != other {
+ t.Fatal("non-selected work changed")
+ }
+ if (Selection{}).Installation() {
+ t.Fatal("a zero selection is installation work")
+ }
+}
+
+type otherWork struct{}
+
+func (otherWork) With(context.Context, hostwrite.Identity, func() error) error { return nil }
diff --git a/internal/provision/plan14_root_reads_test.go b/internal/provision/plan14_root_reads_test.go
index 389f75bb8..2732e41d8 100644
--- a/internal/provision/plan14_root_reads_test.go
+++ b/internal/provision/plan14_root_reads_test.go
@@ -1103,10 +1103,13 @@ func TestPlan14RootReadCensus(t *testing.T) {
}
// Census overlay claim-fresh-install (harness G10, 2026-10-21: the
// unit-shape refusal refused every fresh claim install, which has no
- // registry row until its own row write), loaded last. claimUnitShapePolicy
- // re-pinned at its existing class: a missing row is checked as an empty
- // route for the host. Marked rev3=PROPOSED-claim-fresh-install; envelope
- // re-pinned; the seal stands.
+ // registry row until its own row write; fix round 2 after Astra on
+ // 4dd4c436), loaded last. Only the installation's own work
+ // (Reconciler.installWithWork's marked selection) may go on without a
+ // row, checked as an empty route for the host; claimUnitShapePolicy's
+ // reads move to claimUnitShapeCheck at the same class, and
+ // installWithWork is re-pinned at its own. Marked
+ // rev3=PROPOSED-claim-fresh-install; envelopes re-pinned; the seal stands.
if err = loadRootReadInventory(filepath.Join(root, "internal/provision/testdata/plan14-root-reads-claim-fresh-install.tsv"), &inv, true); err != nil {
t.Fatal(err)
}
diff --git a/internal/provision/testdata/plan14-root-reads-claim-fresh-install.tsv b/internal/provision/testdata/plan14-root-reads-claim-fresh-install.tsv
index 89d189756..c64f5f386 100644
--- a/internal/provision/testdata/plan14-root-reads-claim-fresh-install.tsv
+++ b/internal/provision/testdata/plan14-root-reads-claim-fresh-install.tsv
@@ -1,3 +1,6 @@
-# Census overlay claim-fresh-install (harness G10, 2026-10-21: leo's first claim create never installed; the agent logged "selected authority changed" on every pass). claimUnitShapePolicy refused with ErrChanged whenever the host had no registry row, and a fresh install has no row until registerRemote's second work.With writes it, so the production policy refused every fresh claim install before its route entry reached root. With no row the refusal now checks an empty route for the host, as rootClaimRestartShape already does: the same reader (checkClaimUnitShape in instance-control and adopt, root's boundInputs in agent mode) still refuses a host with a configured shape or a saved unit binding, and a row for another host still refuses. Re-pinned at its existing class and task (authority, E2); the new site is the empty route literal. Envelope re-pinned. No accepted-legacy row, so the seal stands. PROPOSED-claim-fresh-install (docs/superpowers/notes/census-proposal-claim-step8-readiness.md, "Fresh install").
-internal/host/claimunit_policy.go claimUnitShapePolicy authority E2 rev3=PROPOSED-claim-fresh-install;basis=as E50: root/agent policy uses a registry candidate only to request independent binding validation, and a wrong host refuses every operation; a missing row (a fresh install before its own row write) is validated as an empty route for the selected host, which the independent binding read refuses when the host has a configured shape or a saved unit binding registry:Host@817,whole:Route@361,whole:Route@773,whole:Route@890 256da02e4de3b36d6c4094f6d3509c449645e10b5b4f6a1d0605b49146912401
-@coverage internal/host 023cf5b8535957f9f5bda6e29386a6a0dfa28df242fa27a4ea88aa702d4e4e66
+# Census overlay claim-fresh-install (harness G10, 2026-10-21: leo's first claim create never installed; the agent logged "selected authority changed" on every pass), with fix round 2 (Astra on 4dd4c436). The unit-shape refusal refused with ErrChanged whenever the host had no registry row, and a fresh install has no row until registerRemote's second work.With writes it, so the production policy refused every fresh claim install before its route entry reached root. Only the installation's own work may now go on without a row: Reconciler.installWithWork marks the work it selects (hostbox.Selection.Installation, settable only inside hostbox), and claimUnitShapeCheck, the refusal's decision split out of claimUnitShapePolicy, checks an empty route for the host only under that mark. The same reader (checkClaimUnitShape in instance-control and adopt, root's boundInputs in agent mode) still refuses a host with a configured shape or a saved unit binding, a row for another host still refuses, and every other work on a host whose row is absent (timer delivery and bookkeeping on a cached route, restarts, retired or deleted hosts) refuses as before. claimUnitShapePolicy keeps no read of its own: removed here, its reads re-pinned on claimUnitShapeCheck at its class and task (authority, E2). installWithWork re-pinned at its existing class (authority, C); its reads are unchanged. Envelopes internal/host and internal/hostbox re-pinned. No accepted-legacy row, so the seal stands. PROPOSED-claim-fresh-install (docs/superpowers/notes/census-proposal-claim-step8-readiness.md, "Fresh install").
+@remove internal/host/claimunit_policy.go claimUnitShapePolicy
+internal/host/claimunit_policy.go claimUnitShapeCheck authority E2 rev3=PROPOSED-claim-fresh-install;basis=as E50 (claimUnitShapePolicy's decision, split out with its reads): root/agent policy uses a registry candidate only to request independent binding validation, and a wrong host refuses every operation; a missing row refuses unless the selection is the installation's own work (hostbox.Selection.Installation, set only by Reconciler.installWithWork), which is validated as an empty route for the selected host, and the independent binding read refuses that when the host has a configured shape or a saved unit binding registry:Host@1136,whole:Route@1094,whole:Route@1206,whole:Route@292 5f128c9f5aa9f5690af2f695b14d6ee715ad1113eb54d58318704857557e180a
+internal/hostbox/reconcile.go Reconciler.installWithWork authority C rev3=PROPOSED-claim-fresh-install;run=18;identity=agent uid carlos;basis=as p3 (settles participation before activation and inventory creation; existing selected write checks still revalidate before each materialization); the work it selects is marked as installation work, which only the unit-shape refusal reads, to admit the installation's own missing registry row; reads unchanged file:Exec@1240,file:Prepare@1679,file:Prepare@1710,file:Read@392 cd870cfe56f818e64ebc7cb73ed3b5ad06365cb9992d3ef7b2e802041f237931
+@coverage internal/host 79915cbda626e0ad84e0626efb489d2bf2ee858682cfd06241eeefe0ac0aa494
+@coverage internal/hostbox fc40fa5df71664b0739daa11fdba00124ec2e29256c62bb76bc23d6300e0718a