Files
orchestra/internal/registry/registry_test.go
T
kami 7f12c7fc37 v3 workflow: intent, phases, review, submission, enforcement, burn-in
The v3 stack, previously an uncommitted working tree, plus this session's two
units and the burn-in instrument. This commit is the burn-in build identity:
coordinator and worker must both report this revision before a task is created.

Workflow (earlier sessions, uncommitted until now): human decision events and
reduction, source cursors and reconcile-before-launch, turn-boundary
reconciliation, internal/agentctx as the single renderer, ace-fca phases with
sealed artifacts, the trajectory gate, bounded grilling, independent review,
task pr enforcement, and human review reflection.

Capability restrictions at the agent boundary: an authz.Agent surface at
GatedWrite may ask and may not act. It also fixes two bugs the unit exposed --
gated surfaces could not reach the two endpoints written for them, and
RequestHumanDecision would block an unowned task while rejecting a question
from the session that did own it.

Turn-boundary reconcile-failure escalation: a streak of consecutive failures
asks the session to hand off, fenced on the lease epoch, with reconcile_failure
as a real handoff reason. The worker was dropping the coordinator's verdict on
the floor; it now acts on it.

Burn-in: herdr.WriteLaunchContext dumps the exact agentctx.Build result to
<worktree>/.orchestra/launch.md at every launch, local and federated. BURNIN.md
is the runbook. deploy/build.sh stamps both binaries from one commit.

go build, go vet and go test ./... pass, 20 packages.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 18:31:20 +04:00

66 lines
2.3 KiB
Go

package registry
import (
"errors"
"testing"
"time"
)
type reach map[string]bool
func (r reach) Reachable(a string, _ time.Duration) bool { return r[a] }
func TestNewValidatesTopologyAndResolvesHardAffinity(t *testing.T) {
r, err := New(Config{
Projects: []Project{{ID: "work", MachineAffinity: []string{"pc"}}},
Machines: []Machine{{ID: "server", Address: "server:1"}, {ID: "pc", Address: "pc:1"}},
Herdrs: []Herdr{{ID: "offline", MachineID: "pc", Address: "off:1"}, {ID: "online", MachineID: "pc", Address: "on:1"}, {ID: "wrong", MachineID: "server", Address: "server:1"}},
})
if err != nil {
t.Fatal(err)
}
got, err := r.Candidates("work", reach{"off:1": false, "on:1": true, "server:1": true}, time.Second)
if err != nil || len(got) != 1 || got[0].ID != "online" {
t.Fatalf("candidates=%v err=%v", got, err)
}
if _, err = r.Candidates("missing", nil, time.Second); !errors.Is(err, ErrUnknownProject) {
t.Fatalf("err=%v", err)
}
}
func TestNewRejectsBrokenReferences(t *testing.T) {
_, err := New(Config{Projects: []Project{{ID: "p", MachineAffinity: []string{"missing"}}}})
if !errors.Is(err, ErrUnknownMachine) {
t.Fatalf("err=%v", err)
}
}
func TestProjectSafeOperationsAreNarrowAndAudited(t *testing.T) {
_, err := New(Config{Projects: []Project{{ID: "p", MachineAffinity: []string{"m"}, SafeOperations: []string{"read", "network"}}}, Machines: []Machine{{ID: "m", Address: "m:1"}}})
if err == nil {
t.Fatal("network operation was accepted into no-grant policy")
}
if _, err := New(Config{Projects: []Project{{ID: "p", MachineAffinity: []string{"m"}, SafeOperations: []string{"read", "edit", "test", "git"}}}, Machines: []Machine{{ID: "m", Address: "m:1"}}}); err != nil {
t.Fatalf("safe policy rejected: %v", err)
}
}
func TestTmuxBackendIsClaudeOnlyAndUsesDistinctHealthKey(t *testing.T) {
config := Config{
Machines: []Machine{{ID: "m", Address: "host:9145"}},
Herdrs: []Herdr{{ID: "claude", MachineID: "m", Backend: "tmux", Harness: "claude"}},
}
r, err := New(config)
if err != nil {
t.Fatal(err)
}
h, _ := r.Herdr("claude")
if got := r.Endpoint(h); got != "tmux:claude" {
t.Fatalf("tmux health key=%q", got)
}
config.Herdrs[0].Harness = "codex"
if _, err := New(config); err == nil {
t.Fatal("tmux backend accepted Codex")
}
}