carlos / platform Public

region-ha p1b-2: wiring check

TestAgentActivatorForwards: the activator RunAgent hands the edge is an
edge.HAForwarder built over the SplitBackend composition, and a box with no
activator hands the edge none.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 0e2cb7e5a7a172a7ebdce725aba2de479306aa48 parent d364d32
1 file changed, +61 −0
  • internal/host/haforward_wiring_test.go +61 −0

Intent

Human

<task-notification> <task-id>a2c8cf94f002a27be</task-id> <tool-use-id>toolu_01MMRdxM7Kyko7NP8pQYAMjm</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/953e7524-2e06-4308-b9ce-fd1b38579971/tasks/a2c8cf94f002a27be.output</output-file> <status>completed</status> <summary>Agent "Implement Task 3: activator holder cache" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Both review findings are fixed. Forwarding now works with the production backend, and sidecar refusals carry `X-Carlos-Holder: none`. Commits: 5418a27a (the task) and d364d32a (round 1 fixes). Git printed the stray `packed-refs.lock` message again, but both commits and the branch ref landed. - **P1, production backend:** holder lookups now go through `SplitBackend` to the backend that serves the route. A unit-backed route gives "" without reading the lock. `NoteForward` gets this box's identity the same way, from the exec backend. - **P2, sidecar refusals:** a forwarded HA sidecar request refused while asleep or fenced now gets `X-Carlos-Holder: none`. Status, body and Retry-After stay as today, and cancelled requests and legacy routes are unchanged. TDD: I wrote the two new tests first and ran them before changing any code. `TestForwardTargetThroughSplitBackend` got "" instead of "b". Both `TestHoppedSidecarRefusalsSayNone` cases had no holder header. Both pass after the fix; the failure output is in the report. Tests: the brief's command, `HA|SameBox|Takeover|Lease` and `Sidecar|Split|Maintenance` all pass. gofmt and vet are clean, and the linux, darwin and windows builds succeed. Concerns: none new. Report (fix round appended): /home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-p1b2/.superpowers/sdd/2026-10-29-region-ha-p1b2-forwarding/task-3-report.md</result> <usage><subagent_tokens>153485</subagent_tokens><tool_uses>14</tool_uses><duration_ms>240753</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>bjdrscl3t</task-id> <tool-use-id>toolu_01KUaUM7esqBv74ZjiSsNc8j</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/953e7524-2e06-4308-b9ce-fd1b38579971/tasks/bjdrscl3t.output</output-file> <status>completed</status> <summary>Background command "Run the scoped re-review of Task 3's fixes" completed (exit code 0)</summary> </task-notification>

diff --git a/internal/host/haforward_wiring_test.go b/internal/host/haforward_wiring_test.go
new file mode 100644
index 000000000..c58a326cf
--- /dev/null
+++ b/internal/host/haforward_wiring_test.go
@@ -0,0 +1,61 @@
+package host
+
+import (
+ "context"
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/activator"
+ "github.com/carlosframework/platform/internal/edge"
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+// The activator RunAgent hands the edge forwards born-HA requests (region HA
+// P1b-2): the edge finds the forwarder by a type assertion on its Activator,
+// so the value the agent assigns must satisfy it, built over the same
+// SplitBackend composition, and a box with no activator hands the edge none.
+// RunAgent is not callable from a test, so the agent's half is syntactic (like
+// TestAgentWiresTheHAWake); the Service half runs against the same shape.
+func TestAgentActivatorForwards(t *testing.T) {
+ src, err := os.ReadFile("agent.go")
+ if err != nil {
+ t.Fatal(err)
+ }
+ body := string(src)
+ for _, want := range []string{
+ "var act edge.Activator",
+ "svc = activator.New(*cfg, &activator.SplitBackend{",
+ "act = svc\n",
+ "edge.RunWithActivatorReady(args, act, ",
+ } {
+ if strings.Count(body, want) != 1 {
+ t.Fatalf("agent.go has %d of %q, want exactly one", strings.Count(body, want), want)
+ }
+ }
+ if strings.Count(body, "act = ") != 1 {
+ t.Fatal("the edge's activator is assigned somewhere other than the one place the Service is built")
+ }
+
+ // What the agent assigns: a Service over a SplitBackend.
+ svc := activator.New(activator.Config{Bucket: "hib", Idle: time.Hour}, &activator.SplitBackend{
+ Exec: &activator.ExecBackend{},
+ Unit: &activator.UnitBackend{},
+ }, nil)
+ var act edge.Activator = svc
+ fw, ok := act.(edge.HAForwarder)
+ if !ok {
+ t.Fatal("the activator the agent hands the edge is not an edge.HAForwarder")
+ }
+ if got := fw.ForwardTarget(context.Background(), registry.Route{Host: "shop.example.com"}); got != "" {
+ t.Fatalf("a host that is not born HA forwards to %q, want served here", got)
+ }
+
+ // No activator configured: act stays an interface with no value, and the
+ // edge's assertion finds nothing to forward with.
+ var none edge.Activator
+ if _, ok := none.(edge.HAForwarder); ok {
+ t.Fatal("a box with no activator hands the edge a forwarder")
+ }
+}