Add sandboxed owner mode and automatic coordinator recovery
Co-Authored-By: Astra <noreply@openai.com>
50 files changed,
+1,383
−346
docs/superpowers/plans/CONTROLLER-REPORT-owner-mode.md+157 −0docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+3 −0internal/e2elivetest/e2e_live_certificate_test.go+0 −72internal/e2elivetest/e2e_live_helpers_test.go+25 −15internal/e2elivetest/e2e_live_test.go+45 −27internal/equipo/connection_selection.go+15 −23internal/equipo/connections.go+24 −48internal/equipo/conversation/coordinator_application.go+1 −1internal/equipo/conversation/coordinator_engine.go+3 −0internal/equipo/conversation/coordinator_execution.go+13 −2internal/equipo/conversation/coordinator_fallback.go+36 −0internal/equipo/conversation/coordinator_poll.go+35 −11internal/equipo/conversation/coordinator_refusal.go+3 −0internal/equipo/conversation/coordinator_setup.go+39 −29internal/equipo/conversation/coordinator_status.go+5 −32internal/equipo/coordinator.go+2 −1internal/equipo/coordinator_execution.go+1 −1internal/equipo/coordinator_setup.go+1 −1internal/equipo/copy.go+6 −0internal/equipo/owner_defaults.go+29 −0internal/equipo/ownermode/blocked.go+9 −0internal/equipo/ownermode/budget_test.go+9 −0internal/equipo/ownermode/candidate.go+19 −0internal/equipo/ownermode/connections.go+59 −0internal/equipo/ownermode/defaults.go+53 −0internal/equipo/ownermode/guards_test.go+55 −0internal/equipo/ownermode/report.go+61 −0internal/equipo/{conversation/coordinator_selection.go => ownermode/selection.go}+4 −4internal/equipo/ownermode/status.go+44 −0internal/equipo/team/git_evidence.go+11 −1internal/equipo/team/owner_publication_test.go+28 −0internal/equipo/team/publication.go+19 −2internal/equipo/templates/connections.html+1 −1internal/equipo/templates/conversation_card.html+1 −1internal/equipo/templates/task_card.html+1 −1internal/ownermodetest/budget_test.go+9 −0internal/ownermodetest/owner_mode_test.go+15 −0internal/plan3test/coordinator_fixes_test.go+3 −2internal/plan3test/owner_mode_fixture.go+141 −0internal/runner/certified/discovery.go+18 −3internal/runner/certified/discoverytest/owner_test.go+51 −0internal/runner/certified/dispatch.go+5 −0internal/runner/certified/owner.go+17 −0internal/runner/certified/owner_test.go+32 −0internal/runner/owner_harness.go+26 −0internal/runner/ownerlive/owner_live_test.go+147 −0internal/runner/provider/types.go+1 −0internal/runner/runtime_direct.go+36 −11internal/runnerproto/types.go+2 −1scripts/runner-reference-allowlist.json+63 −56
Intent
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-owner-mode.md b/docs/superpowers/plans/CONTROLLER-REPORT-owner-mode.md| new file mode 100644 |
| index 00000000..7bc94248 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-owner-mode.md |
| @@ -0,0 +1,157 @@ |
| +# Owner mode controller report |
| + |
| +Branch `owner-mode` starts at `e953698`, after the coordinator merge. The work |
| +is for commit only. Production data, the installed service and release |
| +certifications were not changed. No copy-review server was started. |
| + |
| +## Behavior |
| + |
| +An owner connection becomes available after pinned executable verification, |
| +production policy construction and account preflight. Its report carries an |
| +owner-mode marker. Instance selection checks the current runner and roster in |
| +the transaction; the runner repeats the person and runner-ID comparison against |
| +its credential before launching. Unknown actions still fail profile lookup. |
| +Non-owner launches still require the release action and exact policy certificate. |
| + |
| +Owner mode skips certificate matching, including certified path matching. It |
| +keeps the production policy builder, account lease and identity checks, |
| +executable digests, bubblewrap namespaces, deny rules, protected paths, egress |
| +relay, native-tool inventory checks, fenced tool proxy and containment. Publishing |
| +and the human merge boundary are unchanged. The release/install manifest and its |
| +certification evidence are unchanged. |
| + |
| +Connections show the owner-mode label and explanation. Claims and launches carry |
| +that mode into the journal. Coordinator turns get an owner-mode conversation |
| +note. Task steps and publication evidence retain the mode; evidence cannot erase |
| +it by relabelling the same isolation tuple. |
| + |
| +Both a new message and coordinator polling can replace an unusable binding with |
| +an available connection on that person's own runner. This uses the existing |
| +binding-change transaction, generations, cancellation and containment checks. |
| +It posts the existing auto-bound note. Pending requests survive the change. |
| +Task polling waits at most two seconds, so it no longer holds up coordinator |
| +polling for 25 seconds. Waiting states produce conversation updates and plain |
| +notes. Admission-paused and other pre-claim refusals have a visible denial state. |
| + |
| +## Saved defaults |
| + |
| +Only verified, available subscription connections in owner mode trigger defaults. |
| +Heartbeat and coordinator admission use the same transaction-bound operation. |
| +Existing settings are preserved; errors never become an unset budget. |
| + |
| +| Monthly limit | Team | Person's coordinator | |
| +| --- | ---: | ---: | |
| +| Calls | 500 | 100 | |
| +| Input tokens | 16,000,000 | 3,200,000 | |
| +| Output tokens | 2,000,000 | 400,000 | |
| +| Seconds | 360,000 | 120,000 | |
| + |
| +Coordinator defaults are capped by each existing team limit. The ordinary team |
| +budget record and coordinator-limit record are saved with revisions and audit |
| +events, so the existing settings forms can edit them. There is no currency cap |
| +for subscription use. Non-owner connections do not create defaults. |
| + |
| +## Verification |
| + |
| +The initial discovery test failed because an uncertified owner connection was |
| +unavailable. The initial instance test failed because an owner turn received no |
| +offer. Both passed after implementation. |
| + |
| +Targeted commands: |
| + |
| +- `CGO_ENABLED=0 go test ./internal/ownermodetest ./internal/equipo/ownermode ./internal/runner/certified/... -run '^TestOwner' -count=1` |
| +- `CGO_ENABLED=0 go test ./internal/plan3test ./internal/runnerproto ./internal/runner/certified/... ./internal/equipo/conversation ./internal/equipo/team -run 'TestOwner|TestCoordinator|TestConnectionAvailable|TestStarterDispatch|TestIsolation|TestPublication' -count=1` |
| + |
| +Mutation checks deliberately removed binary verification, preflight, cleanup |
| +failure propagation, person matching, runner matching, taint rejection, instance |
| +ownership, evidence mode retention, default budgets, fallback and denial notes. |
| +Each corresponding test failed, then passed with the guard restored. The first |
| +cleanup mutation matched part of `err` and failed to compile; the corrected, |
| +exact-line mutation produced the intended assertion failure. No mutation remains. |
| + |
| +`TestOwnerPublicationLabels` also failed first when a description retained owner |
| +metadata but changed its displayed label to confined. Publication and evidence |
| +labels now retain owner mode or the stronger unconfined warning. The targeted |
| +team publication, Git and isolation tests passed after that change. |
| + |
| +The owner live harness builds the real instance and runner without a certificate |
| +overlay, signs in normally, enrols a disposable runner and uses only `claude-a`. |
| +It verifies a coordinator reply and `propose_project` through the HTTP forms, |
| +runner protocol and rendered conversation. It starts with no budgets and checks |
| +that defaults were saved. The implementation leg runs the production launch |
| +path, Claude adapter, namespace, tool proxy and journal in a separate harness |
| +process against a local Git repository. Claude writes the requested change; |
| +the harness commits it on `equipo/owner-mode` and checks that `main` is unchanged. |
| +That repository has no remote. This leg does not exercise remote publication or |
| +the complete queued task workflow. |
| + |
| +Earlier harness attempts caught two setup mistakes: supplying a different |
| +executable to the containment manager, and omitting the implement profile's |
| +`submit_render` tool. The exact process-identity and tool-inventory guards rejected |
| +both. The harness was fixed; neither production guard was relaxed. |
| + |
| +The complete live gate passed twice consecutively in **51.75 s and 52.51 s**. |
| +The final follow-up run passed in **49.57 s** after the certificate checks were |
| +made explicit short-circuits and unused harness configuration was removed. |
| +Across eight harness invocations there were **18 attempted turns**, conservatively |
| +including two turns rejected during CLI initialization. Twelve coordinator turns |
| +and four implementation turns completed. The other harness failure happened |
| +before an implementation turn. This stays below the authorized 25-turn ceiling; |
| +all live model use was through the harness and only on `claude-a`. |
| + |
| +The first full `make -k ci` found an unused alias, review-inventory rows placed |
| +outside the inventory section, and missing timing entry points in the two new |
| +test packages. Those were corrected. A later targeted test also exposed a stale |
| +binding revision that returned a refusal without posting a waiting note; it now |
| +keeps the authority refusal and posts `admission_denied`. The second full run |
| +caught an older test expecting the turn to remain silently queued. The revised |
| +test requires both the original forbidden error and the visible denial state. |
| +Known missing connections still use `waiting_connection`; failed database lookups |
| +still roll back. The focused tests pass. No admission check was removed. |
| + |
| +The first run's other gates passed. Its test receipt covered 37 packages with |
| +one failing package, the copy inventory. Local timing warnings were runner |
| +349.601 s (330 s limit), discovery 10.144 s (10 s), provider 21.420 s (15 s), |
| +Claude 46.618 s (45 s) and Codex 39.033 s (35 s). These are warnings locally but |
| +failures when CI enforces timing. No limit was raised. The third and final full invocation ran **38 test packages with zero failed**. |
| +Adapter, namespace, migration and performance checks passed; cold boot was |
| +104 ms against 500 ms. It exited **2 solely because the size gate had already |
| +seen the conversation package at 5,005 lines against 5,000**. The shared blocked |
| +turn query was moved into the helper package. On the final files, |
| +`make build vet fmt-check staticcheck budget` exited **0**, with all 50 directories |
| +inside their unchanged limits. Focused owner/coordinator polling and acceptance |
| +tests passed after that move, as did the reference scan. There was no fourth |
| +full invocation, respecting the brief's two-rerun limit. Do not describe this as |
| +a clean exit from the complete CI command. |
| + |
| +Final local timing warnings were runner 354.056 s, discovery 10.238 s, provider |
| +22.234 s, Claude 47.484 s and Codex 39.758 s against the same limits above. |
| +The controller must retain that hosted-CI timing caveat. |
| + |
| +The recorded coordinator contracts passed with |
| +`CGO_ENABLED=0 go test ./internal/runner/transporttest ./internal/runnerproto -run '^TestCoordinatorRecorded' -count=1`. |
| +The publication-label regression was checked with |
| +`CGO_ENABLED=0 go test ./internal/equipo/team -run 'TestOwnerPublicationLabels|TestPublication|TestGit|TestIsolation' -count=1`. |
| + |
| +Mutation commands used `CGO_ENABLED=0 go test <package> -run <filter> -count=1`, |
| +one guard at a time. Each row below failed with its guard broken and passed after |
| +restoration: |
| + |
| +| Package | Individual filters | |
| +| --- | --- | |
| +| `./internal/runner/certified/discoverytest` | `^TestOwnerConnectionGuards/binary$`, `^TestOwnerConnectionGuards/preflight$`, `^TestOwnerConnectionGuards/cleanup$` | |
| +| `./internal/runner/certified` | `^TestOwnerRouteGuards/person$`, `^TestOwnerRouteGuards/runner$`, `^TestOwnerRouteGuards/tainted$` | |
| +| `./internal/equipo/ownermode` | `^TestOwnerEligibilityGuards/foreign$`, `^TestOwnerEvidenceCannotLoseMode$` | |
| +| `./internal/ownermodetest` | `^TestOwnerModeSelectionAndDefaults$`, `^TestOwnerModeFallback$`, `^TestOwnerModeDenialNote$` | |
| + |
| +## Pending copy and controller action |
| + |
| +Three new entries in `internal/equipo/copy.go` are individually marked |
| +`COPY REVIEW PENDING`: `isolation.owner_mode`, `connections.owner_mode` and |
| +`coordinator.admission_denied`. They are also in the existing review inventory. |
| +They remain a release review item under the brief's explicit no-server instruction. |
| +The README is unchanged. |
| + |
| +Review and push the resulting commit through the controller. No merge, push or |
| +deployment is authorized by this brief. All harness processes stopped and their scratch directories were removed. Session |
| +logs are removed after their results are recorded here. |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 1f65cf09..88726d5e 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -5195,6 +5195,9 @@ records remain unchanged. |
| | `conversation.sending` | Sending | Optimistic conversation send state | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) | |
| | `conversation.retry` | Retry | Failed optimistic conversation send | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) | |
| | `coordinator.connection_unavailable` | Unavailable | Coordinator connection choices | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) | |
| +| `isolation.owner_mode` | owner mode | Owner mode | Runtime; COPY REVIEW REQUIRED | |
| +| `connections.owner_mode` | Your runner uses the sandbox without requiring an exact policy certificate for your work. | Owner mode | Runtime; COPY REVIEW REQUIRED | |
| +| `coordinator.admission_denied` | Your coordinator cannot start work yet. Check the team settings. | Owner mode | Runtime; COPY REVIEW REQUIRED | |
| ## Task 21 |
diff --git a/internal/e2elivetest/e2e_live_certificate_test.go b/internal/e2elivetest/e2e_live_certificate_test.go| deleted file mode 100644 |
| index 4d744009..00000000 |
| --- a/internal/e2elivetest/e2e_live_certificate_test.go |
| +++ /dev/null |
| @@ -1,72 +0,0 @@ |
| -//go:build e2elive |
| - |
| -package e2elivetest |
| - |
| -import ( |
| - "context" |
| - "crypto/sha256" |
| - "encoding/json" |
| - "fmt" |
| - "os" |
| - "path/filepath" |
| - "testing" |
| - |
| - "amadan.net/oficina/equipo/internal/equipo/team" |
| - "amadan.net/oficina/equipo/internal/release" |
| - "amadan.net/oficina/equipo/internal/runner" |
| - "amadan.net/oficina/equipo/internal/runner/certified" |
| - "amadan.net/oficina/equipo/internal/runner/provider" |
| -) |
| - |
| -// Scratch paths change the exact deny policy. Only the harness's binaries embed |
| -// this certificate; the checked-in release manifest and evidence stay untouched. |
| -func liveCertificate(t *testing.T, root string, env map[string]string) string { |
| - t.Helper() |
| - ctx := context.Background() |
| - cfg, err := runner.LoadConfig(func(k string) string { return env[k] }) |
| - executionMust(t, err) |
| - raw, err := os.ReadFile(cfg.AccountBindingsPath) |
| - executionMust(t, err) |
| - var bs []runner.AccountBinding |
| - executionMust(t, json.Unmarshal(raw, &bs)) |
| - b, err := cfg.DirectBinding(bs[0]) |
| - executionMust(t, err) |
| - lease, err := provider.OpenAccount(ctx, b) |
| - executionMust(t, err) |
| - defer lease.Close() |
| - b = lease.Binding() |
| - work := filepath.Join(cfg.WorkspaceRoot, "certificate") |
| - scratch := filepath.Join(cfg.ScratchRoot, "certificate") |
| - executionMust(t, os.Mkdir(work, 0700)) |
| - executionMust(t, os.Mkdir(scratch, 0700)) |
| - defer os.RemoveAll(work) |
| - defer os.RemoveAll(scratch) |
| - in, err := runner.CertificationInputs(ctx, cfg, provider.Selection{ConnectionID: bs[0].LocalID, Provider: bs[0].Provider, Family: bs[0].Family, AccountID: bs[0].AccountID, Model: bs[0].Model}, b, work, "coordinate", scratch) |
| - executionMust(t, err) |
| - m := release.BuildManifest() |
| - executionMust(t, m.VerifyInstalled(map[string]string{"claude": cfg.ClaudePath, "codex": cfg.CodexPath, "codex-code-mode-host": cfg.CodexCodeModeHostPath, "bwrap": cfg.BwrapPath, "equipo-tool-proxy": cfg.ToolProxyPath})) |
| - if !m.HasCertifiedAction("claude", "coordinate") { |
| - t.Fatal("stage certification: release has no coordinator certification") |
| - } |
| - policy, err := certified.BuildPolicy(b, in, m) |
| - executionMust(t, err) |
| - raw, err = json.Marshal(policy) |
| - executionMust(t, err) |
| - evidence := filepath.Join(root, "harness-policy.json") |
| - executionMust(t, os.WriteFile(evidence, raw, 0600)) |
| - m.DirectPolicies = []release.PolicyCertificate{{Action: "coordinate", Provider: "claude", ProviderVersion: "2.1.312", LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: policy.Hash, NoRefreshReason: "Harness-only certificate; credential refresh remains denied."}} |
| - m.Certifications = []release.Certification{{Provider: "claude", PolicyHash: policy.Hash, Path: evidence, SHA256: fmt.Sprintf("%x", sha256.Sum256(raw))}} |
| - m.VerifiedIsolationTuples = []team.IsolationTuple{{Provider: "claude", ProviderVersion: "2.1.312", LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyVersion: m.PolicyVersion, IsolationConfigHash: policy.Hash}} |
| - raw, err = json.Marshal(m) |
| - executionMust(t, err) |
| - manifest := filepath.Join(root, "manifest.json") |
| - executionMust(t, os.WriteFile(manifest, raw, 0600)) |
| - source, err := filepath.Abs("../release/manifest.json") |
| - executionMust(t, err) |
| - raw, err = json.Marshal(map[string]any{"Replace": map[string]string{source: manifest}}) |
| - executionMust(t, err) |
| - overlay := filepath.Join(root, "overlay.json") |
| - executionMust(t, os.WriteFile(overlay, raw, 0600)) |
| - t.Logf("harness-only certified policy: %s", policy.Hash) |
| - return overlay |
| -} |
diff --git a/internal/e2elivetest/e2e_live_helpers_test.go b/internal/e2elivetest/e2e_live_helpers_test.go| index 2d5a5c72..8b289cc9 100644 |
| --- a/internal/e2elivetest/e2e_live_helpers_test.go |
| +++ b/internal/e2elivetest/e2e_live_helpers_test.go |
| @@ -9,6 +9,7 @@ import ( |
| "path/filepath" |
| "strconv" |
| "strings" |
| + "sync" |
| "syscall" |
| "testing" |
| "time" |
| @@ -64,9 +65,10 @@ func liveEnvironment(t *testing.T, root string) map[string]string { |
| executionMust(t, os.WriteFile(env["EQUIPO_AMADAN_CREDENTIAL_PATH"], []byte(`{"repositories":{"amadan.net/oficina/e2e-unknown-repo":""}}`), 0600)) |
| return env |
| } |
| -func liveBuild(t *testing.T, path, pkg, overlay string) { |
| +func liveBuild(t *testing.T, path, pkg string) { |
| t.Helper() |
| - cmd := exec.Command("go", "build", "-overlay", overlay, "-o", path, pkg) |
| + args := []string{"build", "-o", path, pkg} |
| + cmd := exec.Command("go", args...) |
| cmd.Dir = "../.." |
| cmd.Env = append(os.Environ(), "CGO_ENABLED=0") |
| if raw, err := cmd.CombinedOutput(); err != nil { |
| @@ -74,6 +76,10 @@ func liveBuild(t *testing.T, path, pkg, overlay string) { |
| } |
| } |
| func liveStart(t *testing.T, root string, env map[string]string, bin string, args ...string) string { |
| + log, _ := liveProcess(t, root, env, bin, args...) |
| + return log |
| +} |
| +func liveProcess(t *testing.T, root string, env map[string]string, bin string, args ...string) (string, func()) { |
| t.Helper() |
| path := filepath.Join(root, filepath.Base(bin)+".log") |
| f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0600) |
| @@ -92,19 +98,23 @@ func liveStart(t *testing.T, root string, env map[string]string, bin string, arg |
| cmd.Stdout = f |
| cmd.Stderr = f |
| executionMust(t, cmd.Start()) |
| - t.Cleanup(func() { |
| - cmd.Process.Signal(syscall.SIGTERM) |
| - done := make(chan error, 1) |
| - go func() { done <- cmd.Wait() }() |
| - select { |
| - case <-done: |
| - case <-time.After(35 * time.Second): |
| - cmd.Process.Kill() |
| - <-done |
| - } |
| - f.Close() |
| - }) |
| - return path |
| + var once sync.Once |
| + stop := func() { |
| + once.Do(func() { |
| + cmd.Process.Signal(syscall.SIGTERM) |
| + done := make(chan error, 1) |
| + go func() { done <- cmd.Wait() }() |
| + select { |
| + case <-done: |
| + case <-time.After(35 * time.Second): |
| + cmd.Process.Kill() |
| + <-done |
| + } |
| + f.Close() |
| + }) |
| + } |
| + t.Cleanup(stop) |
| + return path, stop |
| } |
| func liveWait(t *testing.T, stage string, limit time.Duration, ready func() bool) { |
| t.Helper() |
diff --git a/internal/e2elivetest/e2e_live_test.go b/internal/e2elivetest/e2e_live_test.go| index 324d4d78..80ba1dbb 100644 |
| --- a/internal/e2elivetest/e2e_live_test.go |
| +++ b/internal/e2elivetest/e2e_live_test.go |
| @@ -10,6 +10,7 @@ import ( |
| "log/slog" |
| "net" |
| "os" |
| + "os/exec" |
| "path/filepath" |
| "regexp" |
| "strings" |
| @@ -66,7 +67,7 @@ func TestCoordinatorE2ELive(t *testing.T) { |
| x, err := equipo.OpenExecution(ctx, d, path, cfg, s) |
| check(err) |
| t.Cleanup(func() { x.Close() }) |
| - // Two prompts, at most six admitted model turns; no redispatch on failure. |
| + // Two coordinator turns and one isolated implementation turn per full run. |
| stage = "runner enrolment" |
| code, key := beginDevice(t, s) |
| approveDevice(t, s, code, "paul@tito.io") |
| @@ -76,9 +77,12 @@ func TestCoordinatorE2ELive(t *testing.T) { |
| check(err) |
| check(os.WriteFile(filepath.Join(env["EQUIPO_RUNNER_STATE_DIR"], "credentials.json"), raw, 0600)) |
| check(x.Close()) |
| - overlay := liveCertificate(t, root, env) |
| - liveBuild(t, instance, "./cmd/equipo", overlay) |
| - liveBuild(t, runnerBin, "./cmd/equipo-runner", overlay) |
| + liveBuild(t, instance, "./cmd/equipo") |
| + liveBuild(t, runnerBin, "./cmd/equipo-runner") |
| + if os.Getenv("EQUIPO_OWNER_IMPLEMENT_ONLY") == "1" { |
| + runLiveImplement(t, root, env) |
| + return |
| + } |
| instanceLog := liveStart(t, root, env, instance, "-addr", addr, "-db", path) |
| c := signinClient(t, origin) |
| liveWait(t, "instance HTTP", 20*time.Second, func() bool { |
| @@ -103,8 +107,8 @@ func TestCoordinatorE2ELive(t *testing.T) { |
| if response.StatusCode != 303 { |
| t.Fatalf("stage %s: HTTP %d", stage, response.StatusCode) |
| } |
| - stage = "runner heartbeat and certification" |
| - runnerLog := liveStart(t, root, env, runnerBin, "run") |
| + stage = "runner heartbeat and owner mode" |
| + runnerLog, stopRunner := liveProcess(t, root, env, runnerBin, "run") |
| t.Cleanup(func() { |
| if t.Failed() { |
| raw, _ := os.ReadFile(runnerLog) |
| @@ -119,9 +123,9 @@ func TestCoordinatorE2ELive(t *testing.T) { |
| var r []runnerproto.ConnectionReport |
| check(json.Unmarshal([]byte(reports), &r)) |
| if len(r) > 0 && !r[0].Available { |
| - t.Fatalf("stage heartbeat certification: %s, policy %s", r[0].UnavailableReason, r[0].IsolationConfigHash) |
| + t.Fatalf("stage heartbeat owner mode: %s, policy %s", r[0].UnavailableReason, r[0].IsolationConfigHash) |
| } |
| - return len(r) == 1 && r[0].Available && r[0].ReadIsolation |
| + return len(r) == 1 && r[0].Available && r[0].ReadIsolation && r[0].OwnerMode |
| }) |
| prompts := []struct{ body, query, feed string }{ |
| {"Reply using post_message with exactly: e2e coordinator ready. Do not use any other tool.", "SELECT count(*) FROM conversation_messages WHERE author_kind='coordinator' AND body LIKE '%e2e coordinator ready%'", "e2e coordinator ready"}, |
| @@ -133,25 +137,6 @@ func TestCoordinatorE2ELive(t *testing.T) { |
| fields := formFields(t, page, "/conversation") |
| fields.Set("body", p.body) |
| pagePost(t, c, origin, "/conversation", origin, fields, 303) |
| - if i == 0 { |
| - liveWait(t, "missing coordinator limits blocks claim", 40*time.Second, func() bool { |
| - var state string |
| - return d.Writer().QueryRow("SELECT state FROM coordinator_turns ORDER BY sequence DESC LIMIT 1").Scan(&state) == nil && state == "budget_needed" |
| - }) |
| - teamPage := pageBody(t, c, origin, "/settings") |
| - budget := formFields(t, teamPage, "/team/budgets") |
| - for k, v := range map[string]string{"team_calls": "6", "team_input": "192000", "team_output": "24000", "team_seconds": "7200"} { |
| - budget.Set(k, v) |
| - } |
| - pagePost(t, c, origin, "/team/budgets", origin, budget, 303) |
| - settings := pageBody(t, c, origin, "/settings/coordinator") |
| - limits := formFields(t, settings, "/settings/coordinator") |
| - for k, v := range map[string]string{"action": "limits", "revision": "0", "calls": "6", "input_tokens": "192000", "output_tokens": "24000", "seconds": "7200"} { |
| - limits.Set(k, v) |
| - } |
| - pagePost(t, c, origin, "/settings/coordinator", origin, limits, 303) |
| - t.Log("missing budgets blocked claim; owner team and coordinator forms supplied the six-call budget") |
| - } |
| liveWait(t, fmt.Sprintf("message %d claim, model turn and delivery", i+1), 150*time.Second, func() bool { |
| var count int |
| check(d.Writer().QueryRow(p.query).Scan(&count)) |
| @@ -169,6 +154,9 @@ func TestCoordinatorE2ELive(t *testing.T) { |
| return n == i+1 |
| }) |
| page = pageBody(t, c, origin, "/conversation") |
| + if !strings.Contains(page, "owner mode") { |
| + t.Fatal("rendered owner label absent") |
| + } |
| if !strings.Contains(page, p.feed) { |
| t.Fatalf("stage rendered feed: missing %q", p.feed) |
| } |
| @@ -186,10 +174,40 @@ func TestCoordinatorE2ELive(t *testing.T) { |
| } |
| t.Logf("message %d: form -> heartbeat -> poll -> claim -> Claude -> tool -> delivered -> feed", i+1) |
| } |
| + var defaults int |
| + check(d.Writer().QueryRow("SELECT count(*) FROM budget_records").Scan(&defaults)) |
| + if defaults != 1 { |
| + t.Fatal("owner defaults absent") |
| + } |
| saveRecording() |
| var turns int |
| check(d.Writer().QueryRow("SELECT count(*) FROM coordinator_turns WHERE job_id>0").Scan(&turns)) |
| if turns != 2 { |
| t.Fatalf("stage turn budget: got %d claims", turns) |
| } |
| + stopRunner() |
| + stage = "local implement branch" |
| + runLiveImplement(t, root, env) |
| +} |
| + |
| +func runLiveImplement(t *testing.T, root string, env map[string]string) { |
| + t.Helper() |
| + check := func(err error) { |
| + t.Helper() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + |
| + raw, err := json.Marshal(env) |
| + check(err) |
| + harnessPath := filepath.Join(root, "harness.json") |
| + check(os.WriteFile(harnessPath, raw, 0600)) |
| + cmd := exec.Command("go", "test", "-tags", "e2elive", "./internal/runner/ownerlive", "-run", "^TestOwnerImplementE2ELive$", "-count=1", "-timeout=4m", "-v") |
| + cmd.Dir = "../.." |
| + cmd.Env = append(os.Environ(), "CGO_ENABLED=0", "EQUIPO_OWNER_HARNESS="+harnessPath) |
| + output, err := cmd.CombinedOutput() |
| + t.Log(string(output)) |
| + check(err) |
| + |
| } |
diff --git a/internal/equipo/connection_selection.go b/internal/equipo/connection_selection.go| index 77c5020a..bef7f02f 100644 |
| --- a/internal/equipo/connection_selection.go |
| +++ b/internal/equipo/connection_selection.go |
| @@ -3,6 +3,7 @@ package equipo |
| import ( |
| "amadan.net/oficina/equipo/internal/equipo/conversation" |
| "amadan.net/oficina/equipo/internal/equipo/library" |
| + "amadan.net/oficina/equipo/internal/equipo/ownermode" |
| "amadan.net/oficina/equipo/internal/equipo/planning" |
| "amadan.net/oficina/equipo/internal/taskplan" |
| "context" |
| @@ -13,28 +14,23 @@ import ( |
| "gorm.io/gorm" |
| ) |
| -func freshConnection(c connectionRecord, now time.Time) bool { |
| - return !c.LastSeen.After(now) && now.Sub(c.LastSeen) < 90*time.Second |
| -} |
| -func (s *Store) eligible(tx *gorm.DB, c connectionRecord, r ConnectionReport, now time.Time) (bool, IsolationAcknowledgement, error) { |
| - if !freshConnection(c, now) || !r.Available || !routingValid(r) || !s.confined(r) { |
| - return false, IsolationAcknowledgement{}, nil |
| - } |
| +func (s *Store) runnerOwner(tx *gorm.DB, id string) (string, error) { |
| instance, err := runnerInstance(tx) |
| if err != nil { |
| - return false, IsolationAcknowledgement{}, err |
| + return "", err |
| } |
| - _, err = runnerAt(tx, instance, c.RunnerID) |
| - if errors.Is(err, ErrForbidden) { |
| - return false, IsolationAcknowledgement{}, nil |
| - } |
| - return err == nil, IsolationAcknowledgement{}, err |
| + r, err := runnerAt(tx, instance, id) |
| + return r.Person, err |
| } |
| - |
| -func specialistAllows(sp Specialist, r ConnectionReport) bool { |
| - return library.ModelAllowed(sp, r.Provider, r.Family, r.Model) && (sp.ModelSelection == "best_fit" || sp.ModelSelection == "fixed" && sp.Provider == r.Provider && sp.ModelFamily == r.Family && sp.Model == r.Model) |
| +func (s *Store) eligible(tx *gorm.DB, c connectionRecord, r ConnectionReport, now time.Time) (bool, IsolationAcknowledgement, error) { |
| + ok, err := ownermode.Eligible(tx, c, r, now, s.confined, s.runnerOwner, ErrForbidden) |
| + return ok, IsolationAcknowledgement{}, err |
| } |
| -func knownFamily(s string) bool { return s == "claude" || s == "gpt" } |
| + |
| +var specialistAllows = ownermode.SpecialistAllows |
| + |
| +var knownFamily = ownermode.KnownFamily |
| + |
| func specialistAt(tx *gorm.DB, key string) (Specialist, error) { |
| return library.ExecutionSpecialist(tx, key, ErrUnavailable, storeError) |
| } |
| @@ -210,10 +206,6 @@ func (s *Store) selectStepConnectionConfirmed(tx *gorm.DB, person string, projec |
| } |
| return result, nil |
| } |
| -func (s *Store) isolationSnapshot(_ *gorm.DB, _ connectionRecord, r ConnectionReport) (team.IsolationSnapshot, error) { |
| - status := "unverified" |
| - if s.confined(r) { |
| - status = "confined" |
| - } |
| - return team.IsolationSnapshot{Status: status, ObservedTuples: []team.IsolationTuple{reportTuple(r)}}, nil |
| +func (s *Store) isolationSnapshot(tx *gorm.DB, c connectionRecord, r ConnectionReport) (team.IsolationSnapshot, error) { |
| + return ownermode.Snapshot(tx, c, r, s.confined, s.runnerOwner, ErrForbidden) |
| } |
diff --git a/internal/equipo/connections.go b/internal/equipo/connections.go| index 12f133f2..9577bbaf 100644 |
| --- a/internal/equipo/connections.go |
| +++ b/internal/equipo/connections.go |
| @@ -1,11 +1,12 @@ |
| package equipo |
| import ( |
| + "amadan.net/oficina/equipo/internal/equipo/ownermode" |
| "amadan.net/oficina/equipo/internal/equipo/personapi" |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| "context" |
| "crypto/rand" |
| - "crypto/sha256" |
| - "encoding/hex" |
| + |
| "encoding/json" |
| "errors" |
| "slices" |
| @@ -14,58 +15,23 @@ import ( |
| "time" |
| "amadan.net/oficina/equipo/internal/equipo/planning" |
| - "amadan.net/oficina/equipo/internal/equipo/team" |
| "amadan.net/oficina/equipo/internal/runnerproto" |
| "gorm.io/gorm" |
| ) |
| -func reportTuple(r ConnectionReport) team.IsolationTuple { |
| - return team.IsolationTuple{Provider: r.Provider, ProviderVersion: r.ProviderVersion, PaseoVersion: r.PaseoVersion, LauncherVersion: r.LauncherVersion, BwrapVersion: r.BwrapVersion, PolicyVersion: r.PolicyVersion, IsolationConfigHash: r.IsolationConfigHash} |
| -} |
| +var reportTuple = ownermode.Tuple |
| + |
| func (s *Store) confined(r ConnectionReport) bool { |
| - return r.PaseoVersion == "" && r.LauncherVersion != "" && r.BwrapVersion != "" && r.PolicyVersion != "" && !r.TrialReady && r.ReadIsolation && slices.Contains(s.verifiedIsolation, reportTuple(r)) |
| -} |
| -func hexHash(s string) bool { |
| - b, err := hex.DecodeString(s) |
| - return err == nil && len(b) == 32 && s == strings.ToLower(s) |
| -} |
| -func routingValid(r ConnectionReport) bool { |
| - v := r.Routing |
| - return v.BindingID != "" && v.AccountID != "" && v.AccountID == v.ObservedAccountID && hexHash(v.CredentialHomeHash) && v.AccountPinned && v.NoFailover && v.TimelineRecovery && v.ProcessOwnership |
| -} |
| -func reportValid(r ConnectionReport) bool { |
| - if !((r.Provider == "claude" && r.Family == "claude") || (r.Provider == "codex" && r.Family == "gpt")) { |
| - return false |
| - } |
| - if r.LocalID == "" || r.Provider == "" || (r.Available && (r.ProviderVersion == "" || r.LauncherVersion == "" || r.BwrapVersion == "" || r.PolicyVersion == "")) || r.Family == "" || r.Model == "" || !hexHash(r.IsolationConfigHash) || (r.Kind != "subscription" && r.Kind != "api") || r.AllowanceRemaining < 0 { |
| - return false |
| - } |
| - for _, v := range []string{r.LocalID, r.Provider, r.ProviderVersion, r.PaseoVersion, r.LauncherVersion, r.BwrapVersion, r.PolicyVersion, r.Family, r.Model, r.AccountLabel, r.UnavailableReason, r.Routing.BindingID, r.Routing.AccountID, r.Routing.ObservedAccountID} { |
| - if len(v) > 256 || strings.ContainsAny(v, "\x00\r\n") { |
| - return false |
| - } |
| - } |
| - if !r.Available { |
| - return routingValid(r) || r.UnavailableReason != "" && r.Routing.BindingID != "" && r.Routing.AccountID != "" && hexHash(r.Routing.CredentialHomeHash) |
| - } |
| - return routingValid(r) |
| -} |
| -func sameProfile(a, b ConnectionReport) bool { |
| - return a.LocalID == b.LocalID && a.Provider == b.Provider && a.Family == b.Family && a.Kind == b.Kind && a.Routing.BindingID == b.Routing.BindingID && a.Routing.AccountID == b.Routing.AccountID |
| -} |
| -func securityHash(r ConnectionReport) string { |
| - // Models and allowance changes do not change the security binding. Every |
| - // model in one profile must have the same effective security configuration. |
| - r.Model = "" |
| - r.AccountLabel = "" |
| - r.Available = false |
| - r.UnavailableReason = "" |
| - r.AllowanceKnown = false |
| - r.AllowanceRemaining = 0 |
| - data, _ := json.Marshal(r) |
| - sum := sha256.Sum256(data) |
| - return hex.EncodeToString(sum[:]) |
| + return r.PaseoVersion == "" && r.LauncherVersion != "" && r.BwrapVersion != "" && r.PolicyVersion != "" && !r.TrialReady && r.ReadIsolation && (slices.Contains(s.verifiedIsolation, reportTuple(r)) || r.OwnerMode && hexHash(r.IsolationConfigHash)) |
| } |
| + |
| +var hexHash = ownermode.HexHash |
| + |
| +var reportValid = ownermode.ReportValid |
| + |
| +var sameProfile = ownermode.SameProfile |
| +var securityHash = ownermode.SecurityHash |
| + |
| func decodeConnection(c *connectionRecord) error { |
| return storeError(json.Unmarshal([]byte(c.ReportsJSON), &c.Reports)) |
| } |
| @@ -242,6 +208,16 @@ func (s *Store) ReportConnections(ctx context.Context, principal RunnerPrincipal |
| return storeError(err) |
| } |
| } |
| + if s.execution != nil { |
| + for _, r := range reports { |
| + if r.OwnerMode && r.Available && r.Kind == "subscription" && s.confined(r) { |
| + if err = s.execution.ownerDefaults(tx.Statement.Context, tx, Selection{RunnerID: runner.ID, Person: runner.Person, Isolation: team.IsolationSnapshot{Mode: "owner mode"}}); err != nil { |
| + return err |
| + } |
| + break |
| + } |
| + } |
| + } |
| return appendAudit(tx, Actor{Address: runner.Person}, "connection.report", runner.ID) |
| }) |
| if err != nil { |
diff --git a/internal/equipo/conversation/coordinator_application.go b/internal/equipo/conversation/coordinator_application.go| index 1b36fe85..4a782369 100644 |
| --- a/internal/equipo/conversation/coordinator_application.go |
| +++ b/internal/equipo/conversation/coordinator_application.go |
| @@ -155,7 +155,7 @@ func (s *Application) changeCoordinator(ctx context.Context, actor Actor, runner |
| if err != nil { |
| return err |
| } |
| - if err = tx.Model(&TurnRecord{}).Where("binding_id=? AND state IN ('queued','waiting_connection','waiting_task','budget_needed','context_limit','context_unavailable')", b.ID).Select("state", "revision").Updates(map[string]any{"state": "superseded", "revision": gorm.Expr("revision+1")}).Error; err != nil { |
| + if err = tx.Model(&TurnRecord{}).Where("binding_id=? AND state IN ('queued','waiting_connection','waiting_task','budget_needed','admission_denied','context_limit','context_unavailable')", b.ID).Select("state", "revision").Updates(map[string]any{"state": "superseded", "revision": gorm.Expr("revision+1")}).Error; err != nil { |
| return err |
| } |
| result = b.CoordinatorBinding |
diff --git a/internal/equipo/conversation/coordinator_engine.go b/internal/equipo/conversation/coordinator_engine.go| index d344ebbf..36635d21 100644 |
| --- a/internal/equipo/conversation/coordinator_engine.go |
| +++ b/internal/equipo/conversation/coordinator_engine.go |
| @@ -13,6 +13,9 @@ type RunnerPrincipal = runnerproto.RunnerPrincipal |
| type Assignment = runnerproto.Assignment |
| type RunnerRequest = runnerproto.RunnerRequest |
| type Engine struct { |
| + Defaults func(context.Context, *gorm.DB, runnerproto.Selection) error |
| + Copy func(string) string |
| + Rebind func(*gorm.DB, Actor, BindingRecord) (BindingRecord, error) |
| ContextLimit error |
| ContextUnavailable error |
| ContextSource ContextSource |
diff --git a/internal/equipo/conversation/coordinator_execution.go b/internal/equipo/conversation/coordinator_execution.go| index 1384f865..a9e0577c 100644 |
| --- a/internal/equipo/conversation/coordinator_execution.go |
| +++ b/internal/equipo/conversation/coordinator_execution.go |
| @@ -1,6 +1,7 @@ |
| package conversation |
| import ( |
| + "amadan.net/oficina/equipo/internal/equipo/ownermode" |
| "amadan.net/oficina/equipo/internal/equipo/team" |
| "amadan.net/oficina/equipo/internal/runnerproto" |
| "context" |
| @@ -39,10 +40,10 @@ func (e *Engine) claimCoordinator(ctx context.Context, p RunnerPrincipal, turnID |
| _, err = e.Core.AdmitOnce(ctx, result.Scope, result.Handle, result.Admission.Dispatch.Action, row.RequestID) |
| return err |
| } |
| - if row.State != "queued" && row.State != "waiting_connection" && row.State != "waiting_task" && row.State != "budget_needed" { |
| + if row.State != "queued" && row.State != "waiting_connection" && row.State != "waiting_task" && row.State != "budget_needed" && row.State != "admission_denied" { |
| return e.Conflict |
| } |
| - blocked, err := coordinatorBlocked(tx, row) |
| + blocked, err := ownermode.CoordinatorBlocked(tx, row.TeamID, row.Person, row.ID, row.Generation, row.Sequence) |
| if err != nil { |
| return err |
| } |
| @@ -92,6 +93,11 @@ func (e *Engine) claimCoordinator(ctx context.Context, p RunnerPrincipal, turnID |
| return err |
| } |
| } |
| + if e.Defaults != nil { |
| + if err = e.Defaults(ctx, tx, sel); err != nil { |
| + return err |
| + } |
| + } |
| limits, _, err := e.Core.CoordinatorLimits(ctx, team.AccountID(row.TeamID), p.Person) |
| if err != nil { |
| return err |
| @@ -155,6 +161,11 @@ func (e *Engine) claimCoordinator(ctx context.Context, p RunnerPrincipal, turnID |
| if err = tx.Model(&TurnRecord{}).Where("id=?", row.ID).Select("state", "job_id", "attempt_id", "fence", "claim", "selection", "context_hash", "project_revision").Updates(&row).Error; err != nil { |
| return err |
| } |
| + if sel.Isolation.Mode == "owner mode" && e.Copy != nil { |
| + if err = e.Conversation(tx).SystemNote(row.ConversationID, e.Copy("isolation.owner_mode")); err != nil { |
| + return err |
| + } |
| + } |
| return e.Audit(tx, b, "coordinator.claim", row.ID) |
| }) |
| if err != nil { |
diff --git a/internal/equipo/conversation/coordinator_fallback.go b/internal/equipo/conversation/coordinator_fallback.go| new file mode 100644 |
| index 00000000..5c778857 |
| --- /dev/null |
| +++ b/internal/equipo/conversation/coordinator_fallback.go |
| @@ -0,0 +1,36 @@ |
| +package conversation |
| + |
| +import ( |
| + "errors" |
| + "gorm.io/gorm" |
| +) |
| + |
| +func (s *Application) FallbackCoordinator(tx *gorm.DB, actor Actor, b BindingRecord) (BindingRecord, error) { |
| + _, err := s.BindingSelection(tx, b) |
| + if err == nil { |
| + return b, nil |
| + } |
| + if !errors.Is(err, s.WaitingConnection) && !errors.Is(err, s.Forbidden) { |
| + return b, err |
| + } |
| + next, note, err := s.autoCoordinator(tx, actor) |
| + if errors.Is(err, s.Conflict) { |
| + return b, nil |
| + } |
| + if err != nil { |
| + return b, err |
| + } |
| + if next.ID == "" { |
| + return b, nil |
| + } |
| + if note != "" { |
| + var main Main |
| + if err = tx.Where("person=? AND team_id=?", actor.Address, b.TeamID).First(&main).Error; err != nil { |
| + return b, err |
| + } |
| + if err = s.Conversation(tx).SystemNote(main.ID, note); err != nil { |
| + return b, err |
| + } |
| + } |
| + return next, nil |
| +} |
diff --git a/internal/equipo/conversation/coordinator_poll.go b/internal/equipo/conversation/coordinator_poll.go| index 88f23ea3..cd13a498 100644 |
| --- a/internal/equipo/conversation/coordinator_poll.go |
| +++ b/internal/equipo/conversation/coordinator_poll.go |
| @@ -2,9 +2,11 @@ package conversation |
| import ( |
| "amadan.net/oficina/equipo/internal/equipo/kernel" |
| + "amadan.net/oficina/equipo/internal/equipo/ownermode" |
| "amadan.net/oficina/equipo/internal/equipo/team" |
| "context" |
| "errors" |
| + "fmt" |
| "gorm.io/gorm" |
| "gorm.io/gorm/clause" |
| "strconv" |
| @@ -12,13 +14,11 @@ import ( |
| func (e *Engine) PollCoordinator(ctx context.Context, p RunnerPrincipal) ([]CoordinatorTurn, error) { |
| out := []CoordinatorTurn{} |
| + var denied error |
| err := e.Atomic(ctx, func(ctx context.Context, tx *gorm.DB) error { |
| if err := e.RunnerCurrent(tx, p); err != nil { |
| return err |
| } |
| - if err := e.Core.AdmissionAvailable(ctx); err != nil { |
| - return err |
| - } |
| b, err := e.Conversation(tx).Binding(kernel.Actor{Address: p.Person}) |
| if errors.Is(err, e.NotFound) { |
| return nil |
| @@ -26,6 +26,12 @@ func (e *Engine) PollCoordinator(ctx context.Context, p RunnerPrincipal) ([]Coor |
| if err != nil { |
| return err |
| } |
| + if e.Rebind != nil { |
| + b, err = e.Rebind(tx, kernel.Actor{Address: p.Person}, b) |
| + if err != nil { |
| + return err |
| + } |
| + } |
| if b.RunnerID != p.RunnerID { |
| return nil |
| } |
| @@ -46,20 +52,32 @@ func (e *Engine) PollCoordinator(ctx context.Context, p RunnerPrincipal) ([]Coor |
| if row.State == "running" || row.State == "uncertain" || row.State == "context_limit" || row.State == "context_unavailable" { |
| continue |
| } |
| - blocked, err := coordinatorBlocked(tx, row) |
| + if err := e.Core.AdmissionAvailable(ctx); err != nil { |
| + return e.waitCoordinator(tx, b, row, "admission_denied") |
| + } |
| + blocked, err := ownermode.CoordinatorBlocked(tx, row.TeamID, row.Person, row.ID, row.Generation, row.Sequence) |
| if err != nil { |
| return err |
| } |
| if blocked { |
| continue |
| } |
| - _, _, _, err = e.Current(ctx, tx, p, row.ID) |
| + _, _, sel, err := e.Current(ctx, tx, p, row.ID) |
| if err != nil { |
| + if errors.Is(err, e.Forbidden) { |
| + denied = err |
| + return e.waitCoordinator(tx, b, row, "admission_denied") |
| + } |
| if errors.Is(err, e.WaitingConnection) { |
| return e.waitCoordinator(tx, b, row, "waiting_connection") |
| } |
| return err |
| } |
| + if e.Defaults != nil { |
| + if err = e.Defaults(ctx, tx, sel); err != nil { |
| + return err |
| + } |
| + } |
| var busy int64 |
| if err = tx.Table("runner_assignments").Where("person=? AND state IN ('claimed','reconcile','fenced') AND attempt_id IN (SELECT id FROM attempts WHERE containment='pending') AND json_extract(selection,'$.ConnectionID')=?", p.Person, b.ConnectionID).Count(&busy).Error; err != nil { |
| return err |
| @@ -80,15 +98,12 @@ func (e *Engine) PollCoordinator(ctx context.Context, p RunnerPrincipal) ([]Coor |
| } |
| return nil |
| }) |
| + if err == nil { |
| + err = denied |
| + } |
| return out, err |
| } |
| -func coordinatorBlocked(tx *gorm.DB, row TurnRecord) (bool, error) { |
| - var n int64 |
| - err := tx.Model(&TurnRecord{}).Where("team_id=? AND person=? AND id<>? AND (state='running' OR (generation=? AND (state='uncertain' OR (sequence<? AND state NOT IN ('delivered','superseded','fenced')))) OR attempt_id IN (SELECT id FROM attempts WHERE containment='pending'))", row.TeamID, row.Person, row.ID, row.Generation, row.Sequence).Count(&n).Error |
| - return n > 0, err |
| -} |
| - |
| func (e *Engine) waitCoordinator(tx *gorm.DB, b BindingRecord, row TurnRecord, state string) error { |
| var taskID string |
| if state == "waiting_task" { |
| @@ -118,5 +133,14 @@ func (e *Engine) waitCoordinator(tx *gorm.DB, b BindingRecord, row TurnRecord, s |
| if err := tx.Model(&Main{}).Where("id=?", row.ConversationID).Select("revision").Updates(map[string]any{"revision": gorm.Expr("revision+1")}).Error; err != nil { |
| return err |
| } |
| + if e.Copy != nil && row.State != state { |
| + note := e.Copy("coordinator." + state) |
| + if state == "waiting_task" { |
| + note = fmt.Sprintf(note, taskID) |
| + } |
| + if err := e.Conversation(tx).SystemNote(row.ConversationID, note); err != nil { |
| + return err |
| + } |
| + } |
| return e.Audit(tx, b, "coordinator."+state, row.ID) |
| } |
diff --git a/internal/equipo/conversation/coordinator_refusal.go b/internal/equipo/conversation/coordinator_refusal.go| index fb6b75c7..588fa9c9 100644 |
| --- a/internal/equipo/conversation/coordinator_refusal.go |
| +++ b/internal/equipo/conversation/coordinator_refusal.go |
| @@ -30,6 +30,9 @@ func (e *Engine) coordinatorRefusal(ctx context.Context, p RunnerPrincipal, id s |
| return nil |
| } |
| if row.State != "uncertain" && row.State != "superseded" && row.State != "fenced" && b.Generation == row.Generation { |
| + if row.JobID == 0 && (row.State == "queued" || row.State == "admission_denied") { |
| + return e.waitCoordinator(tx, b, row, "admission_denied") |
| + } |
| return nil |
| } |
| if row.AttemptID != 0 { |
diff --git a/internal/equipo/conversation/coordinator_setup.go b/internal/equipo/conversation/coordinator_setup.go| index 27015f9b..6d72dae2 100644 |
| --- a/internal/equipo/conversation/coordinator_setup.go |
| +++ b/internal/equipo/conversation/coordinator_setup.go |
| @@ -1,12 +1,13 @@ |
| package conversation |
| import ( |
| - "amadan.net/oficina/equipo/internal/equipo/planning" |
| + "amadan.net/oficina/equipo/internal/equipo/ownermode" |
| "amadan.net/oficina/equipo/internal/release" |
| "crypto/rand" |
| "errors" |
| "fmt" |
| "gorm.io/gorm" |
| + "strconv" |
| ) |
| func (s *Application) setupMessage(tx *gorm.DB, actor Actor, msg Message) error { |
| @@ -22,12 +23,18 @@ func (s *Application) setupMessage(tx *gorm.DB, actor Actor, msg Message) error |
| if exists { |
| _, err = s.BindingSelection(tx, b) |
| switch { |
| - case errors.Is(err, s.WaitingConnection): |
| - note = s.Copy("coordinator.setup_offline") |
| - err = nil |
| - case errors.Is(err, s.Forbidden): |
| - note = s.Copy("coordinator.setup_binding") |
| - err = nil |
| + case errors.Is(err, s.WaitingConnection), errors.Is(err, s.Forbidden): |
| + key := "coordinator.setup_offline" |
| + if errors.Is(err, s.Forbidden) { |
| + key = "coordinator.setup_binding" |
| + } |
| + b, err = s.FallbackCoordinator(tx, actor, b) |
| + if err == nil { |
| + if _, selectionErr := s.BindingSelection(tx, b); selectionErr != nil { |
| + note = s.Copy(key) |
| + } |
| + } |
| + |
| } |
| } |
| if errors.Is(err, s.NotFound) { |
| @@ -55,20 +62,14 @@ func (s *Application) autoCoordinator(tx *gorm.DB, actor Actor) (BindingRecord, |
| if err != nil { |
| return empty, "", err |
| } |
| - var runners int64 |
| - if err = tx.Table("runners").Where("person=? AND instance_id=? AND revoked_at IS NULL", actor.Address, teamID).Count(&runners).Error; err != nil { |
| - return empty, "", err |
| - } |
| - if runners == 0 { |
| - return empty, s.Copy("coordinator.setup_runner"), nil |
| - } |
| - var connections []planning.ConnectionRecord |
| - if err = tx.Where("person=? AND revoked_at IS NULL AND runner_id IN (SELECT id FROM runners WHERE person=? AND instance_id=? AND revoked_at IS NULL)", actor.Address, actor.Address, teamID).Order("id").Find(&connections).Error; err != nil { |
| + connections, key, err := ownermode.OwnConnections(tx, actor.Address, teamID) |
| + if err != nil { |
| return empty, "", err |
| } |
| - if len(connections) == 0 { |
| - return empty, s.Copy("coordinator.setup_connection"), nil |
| + if key != "" { |
| + return empty, s.Copy(key), nil |
| } |
| + |
| manifest := release.BuildManifest() |
| if s.BindingRelease != nil { |
| manifest = *s.BindingRelease |
| @@ -79,27 +80,36 @@ func (s *Application) autoCoordinator(tx *gorm.DB, actor Actor) (BindingRecord, |
| return empty, "", err |
| } |
| for _, r := range c.Reports { |
| - if !manifest.HasCertifiedAction(r.Provider, "coordinate") { |
| - continue |
| - } |
| - certified = true |
| - if r.ProviderVersion != map[string]string{"claude": manifest.Claude, "codex": manifest.Codex}[r.Provider] || r.LauncherVersion != manifest.LauncherVersion || r.BwrapVersion != manifest.BwrapVersion || r.PolicyVersion != manifest.PolicyVersion || r.Kind != "subscription" { |
| - continue |
| - } |
| - ok, err := s.BindingEligible(tx, c, r) |
| + allowed, known, err := ownermode.AutoCandidate(tx, c, r, manifest, s.BindingEligible) |
| + certified = certified || known |
| if err != nil { |
| return empty, "", err |
| } |
| - if !ok { |
| + if !allowed { |
| continue |
| } |
| + |
| memberRevision, connectionRevision, err := s.BindingIdentity(tx, actor, c.RunnerID, c.ID) |
| if err != nil { |
| return empty, "", err |
| } |
| b := BindingRecord{CoordinatorBinding: CoordinatorBinding{ID: rand.Text(), Person: actor.Address, RunnerID: c.RunnerID, ConnectionID: c.ID, Generation: 1, Revision: 1}, TeamID: teamID, PersonKey: actor.Address, MemberRevision: memberRevision, ConnectionRevision: connectionRevision} |
| - if err = tx.Create(&b).Error; err != nil { |
| - return empty, "", err |
| + old, oldErr := s.Conversation(tx).Binding(actor) |
| + if oldErr == nil { |
| + changed, changeErr := s.changeCoordinator(tx.Statement.Context, actor, c.RunnerID, c.ID, false, Mutation{Revision: old.Revision, RequestID: "fallback:" + old.ID + ":" + strconv.FormatInt(old.Revision, 10) + ":" + c.ID + ":" + strconv.FormatInt(c.Revision, 10)}) |
| + if changeErr != nil { |
| + return empty, "", changeErr |
| + } |
| + b = BindingRecord{} |
| + if err = tx.First(&b, "id=?", changed.ID).Error; err != nil { |
| + return empty, "", err |
| + } |
| + } else if errors.Is(oldErr, s.NotFound) { |
| + if err = tx.Create(&b).Error; err != nil { |
| + return empty, "", err |
| + } |
| + } else { |
| + return empty, "", oldErr |
| } |
| if err = s.Audit(tx, actor, "coordinator.auto_bind", b.ID); err != nil { |
| return empty, "", err |
diff --git a/internal/equipo/conversation/coordinator_status.go b/internal/equipo/conversation/coordinator_status.go| index 7ad7e53c..ef5c368c 100644 |
| --- a/internal/equipo/conversation/coordinator_status.go |
| +++ b/internal/equipo/conversation/coordinator_status.go |
| @@ -1,9 +1,6 @@ |
| package conversation |
| -import ( |
| - "amadan.net/oficina/equipo/internal/equipo/kernel" |
| - "time" |
| -) |
| +import "amadan.net/oficina/equipo/internal/equipo/ownermode" |
| func (s *Store) coordinatorStatus(page ConversationPage, b BindingRecord) (ConversationPage, error) { |
| var turns []TurnRecord |
| @@ -11,35 +8,11 @@ func (s *Store) coordinatorStatus(page ConversationPage, b BindingRecord) (Conve |
| return page, err |
| } |
| for _, turn := range turns { |
| - state := turn.State |
| - if state == "running" { |
| - var attempt struct{ LeaseDeadline string } |
| - if err := s.tx.Table("attempts").Select("lease_deadline").Where("id=?", turn.AttemptID).Take(&attempt).Error; err != nil { |
| - return page, err |
| - } |
| - var claim CoordinatorClaim |
| - if err := decodeCoordinator(turn.Claim, &claim); err != nil { |
| - return page, err |
| - } |
| - now := time.Now().UTC() |
| - if !now.Before(kernel.ReadTime(attempt.LeaseDeadline)) || !claim.AttemptDeadline.IsZero() && !now.Before(claim.AttemptDeadline) { |
| - state = "timed_out" |
| - } |
| + state, actions, show, err := ownermode.TurnStatus(s.tx, turn.State, turn.AttemptID, turn.Claim) |
| + if err != nil { |
| + return page, err |
| } |
| - var actions []string |
| - switch state { |
| - case "context_limit", "context_unavailable", "fenced": |
| - actions = []string{"coordinator.reset", "coordinator.retry"} |
| - case "uncertain": |
| - var n int64 |
| - if err := s.tx.Table("attempts").Where("id=? AND containment='contained'", turn.AttemptID).Count(&n).Error; err != nil { |
| - return page, err |
| - } |
| - if n == 1 { |
| - actions = []string{"coordinator.reset", "coordinator.retry"} |
| - } |
| - case "waiting_connection", "budget_needed", "timed_out": |
| - default: |
| + if !show { |
| continue |
| } |
| page.Cards = append(page.Cards, Card{ID: turn.ID, Kind: "coordinator", ResourceID: turn.ID, Revision: turn.Revision, CopyKey: "coordinator." + state, ActionKeys: actions}) |
diff --git a/internal/equipo/coordinator.go b/internal/equipo/coordinator.go| index 541a20fd..551e7cf4 100644 |
| --- a/internal/equipo/coordinator.go |
| +++ b/internal/equipo/coordinator.go |
| @@ -2,6 +2,7 @@ package equipo |
| import ( |
| "amadan.net/oficina/equipo/internal/equipo/conversation" |
| + "amadan.net/oficina/equipo/internal/equipo/ownermode" |
| "amadan.net/oficina/equipo/internal/equipo/setup" |
| "amadan.net/oficina/equipo/internal/equipo/team" |
| "amadan.net/oficina/equipo/internal/runnerproto" |
| @@ -24,7 +25,7 @@ func CoordinatorGrantRef(person string) string { |
| var errCoordinatorWaitingConnection = &refusal{copyText("coordinator.waiting_connection"), ErrUnavailable} |
| func (s *Store) coordinatorSelection(tx *gorm.DB, b conversation.BindingRecord) (Selection, error) { |
| - return conversation.SelectBinding(tx, b, func(tx *gorm.DB, person string) (int64, error) { |
| + return ownermode.SelectBinding(tx, b.CoordinatorBinding, b.MemberRevision, b.ConnectionRevision, func(tx *gorm.DB, person string) (int64, error) { |
| m, err := currentRunnerMember(tx, person) |
| return m.Revision, err |
| }, decodeConnection, s.coordinatorEligible, s.isolationSnapshot, ErrForbidden, errCoordinatorWaitingConnection, storeError) |
diff --git a/internal/equipo/coordinator_execution.go b/internal/equipo/coordinator_execution.go| index 3abb5419..5e383878 100644 |
| --- a/internal/equipo/coordinator_execution.go |
| +++ b/internal/equipo/coordinator_execution.go |
| @@ -11,7 +11,7 @@ import ( |
| ) |
| func (e *Execution) coordinatorEngine() *conversation.Engine { |
| - return &conversation.Engine{ContextUnavailable: &refusal{copyText("coordinator.context_unavailable"), ErrInvalid}, ContextLimit: &refusal{copyText("coordinator.context_limit"), ErrInvalid}, ToolCopy: CoordinatorToolCopy(), Tools: conversation.ToolOperations{ProjectHeading: copyText("project_setup.heading"), AmbiguousProject: pageCopy["coordinator.project_question"], Planning: e.store.planningAt}, Core: e.Core, Atomic: e.atomic, Selection: e.store.coordinatorSelection, StoreError: storeError, NotFound: ErrNotFound, CheckProject: func(tx *gorm.DB, p string, id int64, sel Selection) (int64, error) { |
| + return &conversation.Engine{Defaults: e.ownerDefaults, Copy: copyText, Rebind: e.store.coordinatorApplication().FallbackCoordinator, ContextUnavailable: &refusal{copyText("coordinator.context_unavailable"), ErrInvalid}, ContextLimit: &refusal{copyText("coordinator.context_limit"), ErrInvalid}, ToolCopy: CoordinatorToolCopy(), Tools: conversation.ToolOperations{ProjectHeading: copyText("project_setup.heading"), AmbiguousProject: pageCopy["coordinator.project_question"], Planning: e.store.planningAt}, Core: e.Core, Atomic: e.atomic, Selection: e.store.coordinatorSelection, StoreError: storeError, NotFound: ErrNotFound, CheckProject: func(tx *gorm.DB, p string, id int64, sel Selection) (int64, error) { |
| project, err := e.store.coordinatorProject(tx, p, id, sel) |
| return project.Revision, err |
| }, Conversation: conversationAt, Now: func() time.Time { return e.store.runnerClock.Now().UTC() }, Audit: coordinatorAudit, Invalid: ErrInvalid, Conflict: ErrConflict, Forbidden: ErrForbidden, Unavailable: ErrUnavailable, WaitingConnection: errCoordinatorWaitingConnection, Events: e.validators.Events, Receipt: e.validators.Receipt, Containment: e.validators.Containment, Delivery: e.validators.CoordinatorDelivery, Redact: func(raw []byte) []byte { return runner.RedactJSON(raw, nil) }, |
diff --git a/internal/equipo/coordinator_setup.go b/internal/equipo/coordinator_setup.go| index f64c741c..e4aa6461 100644 |
| --- a/internal/equipo/coordinator_setup.go |
| +++ b/internal/equipo/coordinator_setup.go |
| @@ -3,7 +3,7 @@ package equipo |
| import "amadan.net/oficina/equipo/internal/release" |
| // WithCoordinatorRelease supplies the release used to choose an initial binding. |
| -// Runner admission still verifies its own exact policy and executable digests. |
| +// Runner admission verifies executable digests and owner or certified routing. |
| func WithCoordinatorRelease(m release.Manifest) StoreOption { |
| return func(s *Store) { s.coordinatorRelease = &m } |
| } |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 487cb934..e1ab4b3a 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -46,6 +46,12 @@ const BootLog = "Equipo could not start." |
| // COPY APPROVED BY DELEGATION (Luna pass, 2026-11-01, house rules). |
| var pageCopy = map[string]string{ |
| + // COPY REVIEW PENDING: coordinator.admission_denied |
| + "coordinator.admission_denied": "Your coordinator cannot start work yet. Check the team settings.", |
| + // COPY REVIEW PENDING: isolation.owner_mode |
| + "isolation.owner_mode": "owner mode", |
| + // COPY REVIEW PENDING: connections.owner_mode |
| + "connections.owner_mode": "Your runner uses the sandbox without requiring an exact policy certificate for your work.", |
| "coordinator.setup_binding": "Your coordinator connection changed. Choose your connection again in Your coordinator.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "coordinator.auto_bound": "Your coordinator uses %s. Change it in Your coordinator.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "coordinator.setup_runner": "Your coordinator needs a runner. Add your machine in Connections.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
diff --git a/internal/equipo/owner_defaults.go b/internal/equipo/owner_defaults.go| new file mode 100644 |
| index 00000000..8e6bdffb |
| --- /dev/null |
| +++ b/internal/equipo/owner_defaults.go |
| @@ -0,0 +1,29 @@ |
| +package equipo |
| + |
| +import ( |
| + "context" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/ownermode" |
| + "gorm.io/gorm" |
| +) |
| + |
| +func (e *Execution) ownerDefaults(ctx context.Context, tx *gorm.DB, sel Selection) error { |
| + if sel.Isolation.Mode != "owner mode" { |
| + return nil |
| + } |
| + instance, err := runnerInstance(tx) |
| + if err != nil { |
| + return err |
| + } |
| + runner, err := runnerAt(tx, instance, sel.RunnerID) |
| + if err != nil { |
| + return err |
| + } |
| + if runner.Person != sel.Person { |
| + return ErrForbidden |
| + } |
| + if _, err = currentRunnerMember(tx, sel.Person); err != nil { |
| + return err |
| + } |
| + return ownermode.Defaults(ctx, tx, e.Core, instance, sel, executionTx, appendAudit) |
| +} |
diff --git a/internal/equipo/ownermode/blocked.go b/internal/equipo/ownermode/blocked.go| new file mode 100644 |
| index 00000000..69c745d1 |
| --- /dev/null |
| +++ b/internal/equipo/ownermode/blocked.go |
| @@ -0,0 +1,9 @@ |
| +package ownermode |
| + |
| +import "gorm.io/gorm" |
| + |
| +func CoordinatorBlocked(tx *gorm.DB, teamID, person, id string, generation, sequence int64) (bool, error) { |
| + var n int64 |
| + err := tx.Table("coordinator_turns").Where("team_id=? AND person=? AND id<>? AND (state='running' OR (generation=? AND (state='uncertain' OR (sequence<? AND state NOT IN ('delivered','superseded','fenced')))) OR attempt_id IN (SELECT id FROM attempts WHERE containment='pending'))", teamID, person, id, generation, sequence).Count(&n).Error |
| + return n > 0, err |
| +} |
diff --git a/internal/equipo/ownermode/budget_test.go b/internal/equipo/ownermode/budget_test.go| new file mode 100644 |
| index 00000000..c5239182 |
| --- /dev/null |
| +++ b/internal/equipo/ownermode/budget_test.go |
| @@ -0,0 +1,9 @@ |
| +package ownermode |
| + |
| +import ( |
| + "amadan.net/rastrillo/rastrillo/budget" |
| + "os" |
| + "testing" |
| +) |
| + |
| +func TestMain(m *testing.M) { os.Exit(budget.Main(m)) } |
diff --git a/internal/equipo/ownermode/candidate.go b/internal/equipo/ownermode/candidate.go| new file mode 100644 |
| index 00000000..b5e6e7fb |
| --- /dev/null |
| +++ b/internal/equipo/ownermode/candidate.go |
| @@ -0,0 +1,19 @@ |
| +package ownermode |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/planning" |
| + "amadan.net/oficina/equipo/internal/release" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "gorm.io/gorm" |
| +) |
| + |
| +func AutoCandidate(tx *gorm.DB, c planning.ConnectionRecord, r runnerproto.ConnectionReport, m release.Manifest, eligible func(*gorm.DB, planning.ConnectionRecord, runnerproto.ConnectionReport) (bool, error)) (bool, bool, error) { |
| + if !r.OwnerMode && !m.HasCertifiedAction(r.Provider, "coordinate") { |
| + return false, false, nil |
| + } |
| + if r.ProviderVersion != map[string]string{"claude": m.Claude, "codex": m.Codex}[r.Provider] || r.LauncherVersion != m.LauncherVersion || r.BwrapVersion != m.BwrapVersion || r.PolicyVersion != m.PolicyVersion || r.Kind != "subscription" { |
| + return false, true, nil |
| + } |
| + ok, err := eligible(tx, c, r) |
| + return ok, true, err |
| +} |
diff --git a/internal/equipo/ownermode/connections.go b/internal/equipo/ownermode/connections.go| new file mode 100644 |
| index 00000000..21e70bb8 |
| --- /dev/null |
| +++ b/internal/equipo/ownermode/connections.go |
| @@ -0,0 +1,59 @@ |
| +package ownermode |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/planning" |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "errors" |
| + "gorm.io/gorm" |
| + "time" |
| +) |
| + |
| +func OwnConnections(tx *gorm.DB, person, teamID string) ([]planning.ConnectionRecord, string, error) { |
| + var n int64 |
| + if err := tx.Table("runners").Where("person=? AND instance_id=? AND revoked_at IS NULL", person, teamID).Count(&n).Error; err != nil { |
| + return nil, "", err |
| + } |
| + if n == 0 { |
| + return nil, "coordinator.setup_runner", nil |
| + } |
| + var cs []planning.ConnectionRecord |
| + if err := tx.Where("person=? AND revoked_at IS NULL AND runner_id IN (SELECT id FROM runners WHERE person=? AND instance_id=? AND revoked_at IS NULL)", person, person, teamID).Order("id").Find(&cs).Error; err != nil { |
| + return nil, "", err |
| + } |
| + if len(cs) == 0 { |
| + return nil, "coordinator.setup_connection", nil |
| + } |
| + return cs, "", nil |
| +} |
| +func Eligible(tx *gorm.DB, c planning.ConnectionRecord, r runnerproto.ConnectionReport, now time.Time, confined func(runnerproto.ConnectionReport) bool, owner func(*gorm.DB, string) (string, error), forbidden error) (bool, error) { |
| + if c.RevokedAt != nil || c.LastSeen.After(now) || now.Sub(c.LastSeen) >= 90*time.Second || !r.Available || !RoutingValid(r) || !confined(r) { |
| + return false, nil |
| + } |
| + person, err := owner(tx, c.RunnerID) |
| + if errors.Is(err, forbidden) { |
| + return false, nil |
| + } |
| + if err == nil && r.OwnerMode && person != c.Person { |
| + return false, nil |
| + } |
| + return err == nil, err |
| +} |
| +func Snapshot(tx *gorm.DB, c planning.ConnectionRecord, r runnerproto.ConnectionReport, confined func(runnerproto.ConnectionReport) bool, owner func(*gorm.DB, string) (string, error), forbidden error) (team.IsolationSnapshot, error) { |
| + status := "unverified" |
| + if confined(r) { |
| + status = "confined" |
| + } |
| + mode := "" |
| + if r.OwnerMode { |
| + person, err := owner(tx, c.RunnerID) |
| + if err != nil { |
| + return team.IsolationSnapshot{}, err |
| + } |
| + if person != c.Person { |
| + return team.IsolationSnapshot{}, forbidden |
| + } |
| + mode = "owner mode" |
| + } |
| + return team.IsolationSnapshot{Mode: mode, Status: status, ObservedTuples: []team.IsolationTuple{Tuple(r)}}, nil |
| +} |
diff --git a/internal/equipo/ownermode/defaults.go b/internal/equipo/ownermode/defaults.go| new file mode 100644 |
| index 00000000..c8ee77dd |
| --- /dev/null |
| +++ b/internal/equipo/ownermode/defaults.go |
| @@ -0,0 +1,53 @@ |
| +package ownermode |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/kernel" |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "context" |
| + "database/sql" |
| + "encoding/json" |
| + "errors" |
| + "gorm.io/gorm" |
| +) |
| + |
| +func Defaults(ctx context.Context, tx *gorm.DB, core *team.Store, instance string, sel runnerproto.Selection, sqlTx func(*gorm.DB) (*sql.Tx, error), audit func(*gorm.DB, kernel.Actor, string, string) error) error { |
| + var row kernel.BudgetRecord |
| + err := tx.Where("team_id=?", instance).Take(&row).Error |
| + if errors.Is(err, gorm.ErrRecordNotFound) { |
| + config := kernel.BudgetConfig{Revision: 1, Team: team.PeriodLimits{Calls: 500, InputTokens: 16000000, OutputTokens: 2000000, Seconds: 360000}} |
| + raw, err := json.Marshal(config) |
| + if err != nil { |
| + return err |
| + } |
| + row = kernel.BudgetRecord{TeamID: instance, Revision: 1, Config: string(raw)} |
| + if err = tx.Create(&row).Error; err != nil { |
| + return err |
| + } |
| + sqltx, err := sqlTx(tx) |
| + if err != nil { |
| + return err |
| + } |
| + if err = core.SyncBudgetsTx(ctx, sqltx, team.AccountID(instance), team.BudgetSet{Revision: 1, Team: config.Team}); err != nil { |
| + return err |
| + } |
| + if err = audit(tx, kernel.Actor{Address: sel.Person}, "budget.owner_defaults", instance); err != nil { |
| + return err |
| + } |
| + } else if err != nil { |
| + return err |
| + } |
| + _, _, err = core.CoordinatorLimits(ctx, team.AccountID(instance), sel.Person) |
| + if !errors.Is(err, team.ErrBudget) { |
| + return err |
| + } |
| + var config kernel.BudgetConfig |
| + if err = json.Unmarshal([]byte(row.Config), &config); err != nil { |
| + return err |
| + } |
| + limits := team.Limits{Calls: min(100, config.Team.Calls), InputTokens: min(3200000, config.Team.InputTokens), OutputTokens: min(400000, config.Team.OutputTokens), Seconds: min(120000, config.Team.Seconds)} |
| + if err = core.ConfigureCoordinatorLimits(ctx, team.AccountID(instance), sel.Person, 0, limits); err != nil { |
| + return err |
| + } |
| + return audit(tx, kernel.Actor{Address: sel.Person}, "coordinator.owner_defaults", sel.Person) |
| +} |
diff --git a/internal/equipo/ownermode/guards_test.go b/internal/equipo/ownermode/guards_test.go| new file mode 100644 |
| index 00000000..99778cce |
| --- /dev/null |
| +++ b/internal/equipo/ownermode/guards_test.go |
| @@ -0,0 +1,55 @@ |
| +package ownermode |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/planning" |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "errors" |
| + "gorm.io/gorm" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +func TestOwnerEligibilityGuards(t *testing.T) { |
| + now := time.Now() |
| + for _, fault := range []string{"none", "foreign", "lookup", "stale", "future", "unavailable", "routing", "isolation", "revoked"} { |
| + t.Run(fault, func(t *testing.T) { |
| + c := planning.ConnectionRecord{Connection: planning.Connection{Person: "owner", RunnerID: "runner", LastSeen: now}} |
| + r := runnerproto.ConnectionReport{OwnerMode: true, Available: true, Routing: runnerproto.ConnectionRouting{BindingID: "binding", AccountID: "account", ObservedAccountID: "account", CredentialHomeHash: strings.Repeat("a", 64), AccountPinned: true, NoFailover: true, TimelineRecovery: true, ProcessOwnership: true}} |
| + person := "owner" |
| + var lookup error |
| + switch fault { |
| + case "foreign": |
| + person = "peer" |
| + case "lookup": |
| + lookup = errors.New("lookup failed") |
| + case "stale": |
| + c.LastSeen = now.Add(-90 * time.Second) |
| + case "future": |
| + c.LastSeen = now.Add(time.Second) |
| + case "unavailable": |
| + r.Available = false |
| + case "routing": |
| + r.Routing.NoFailover = false |
| + case "revoked": |
| + c.RevokedAt = &now |
| + } |
| + ok, err := Eligible(nil, c, r, now, func(runnerproto.ConnectionReport) bool { return fault != "isolation" }, func(*gorm.DB, string) (string, error) { return person, lookup }, errors.New("forbidden")) |
| + if ok != (fault == "none") || fault == "lookup" && err == nil { |
| + t.Fatal("eligibility guard failed", fault, ok, err) |
| + } |
| + }) |
| + } |
| +} |
| +func TestOwnerEvidenceCannotLoseMode(t *testing.T) { |
| + need := team.IsolationSnapshot{Mode: "owner mode", Status: "confined", ObservedTuples: []team.IsolationTuple{{Provider: "claude", ProviderVersion: "v", LauncherVersion: "v", BwrapVersion: "v", PolicyVersion: "v", IsolationConfigHash: strings.Repeat("a", 64)}}} |
| + have := need |
| + if !team.IsolationContains(have, need) { |
| + t.Fatal("owner evidence rejected") |
| + } |
| + have.Mode = "" |
| + if team.IsolationContains(have, need) { |
| + t.Fatal("owner evidence relabelled as certified") |
| + } |
| +} |
diff --git a/internal/equipo/ownermode/report.go b/internal/equipo/ownermode/report.go| new file mode 100644 |
| index 00000000..cb346f3b |
| --- /dev/null |
| +++ b/internal/equipo/ownermode/report.go |
| @@ -0,0 +1,61 @@ |
| +package ownermode |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/library" |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "encoding/json" |
| + "strings" |
| +) |
| + |
| +func Tuple(r runnerproto.ConnectionReport) team.IsolationTuple { |
| + return team.IsolationTuple{Provider: r.Provider, ProviderVersion: r.ProviderVersion, PaseoVersion: r.PaseoVersion, LauncherVersion: r.LauncherVersion, BwrapVersion: r.BwrapVersion, PolicyVersion: r.PolicyVersion, IsolationConfigHash: r.IsolationConfigHash} |
| +} |
| +func HexHash(s string) bool { |
| + b, err := hex.DecodeString(s) |
| + return err == nil && len(b) == 32 && s == strings.ToLower(s) |
| +} |
| +func RoutingValid(r runnerproto.ConnectionReport) bool { |
| + v := r.Routing |
| + return v.BindingID != "" && v.AccountID != "" && v.AccountID == v.ObservedAccountID && HexHash(v.CredentialHomeHash) && v.AccountPinned && v.NoFailover && v.TimelineRecovery && v.ProcessOwnership |
| +} |
| +func ReportValid(r runnerproto.ConnectionReport) bool { |
| + if !((r.Provider == "claude" && r.Family == "claude") || (r.Provider == "codex" && r.Family == "gpt")) { |
| + return false |
| + } |
| + if r.LocalID == "" || r.Provider == "" || (r.Available && (r.ProviderVersion == "" || r.LauncherVersion == "" || r.BwrapVersion == "" || r.PolicyVersion == "")) || r.Family == "" || r.Model == "" || !HexHash(r.IsolationConfigHash) || (r.Kind != "subscription" && r.Kind != "api") || r.AllowanceRemaining < 0 { |
| + return false |
| + } |
| + for _, v := range []string{r.LocalID, r.Provider, r.ProviderVersion, r.PaseoVersion, r.LauncherVersion, r.BwrapVersion, r.PolicyVersion, r.Family, r.Model, r.AccountLabel, r.UnavailableReason, r.Routing.BindingID, r.Routing.AccountID, r.Routing.ObservedAccountID} { |
| + if len(v) > 256 || strings.ContainsAny(v, "\x00\r\n") { |
| + return false |
| + } |
| + } |
| + if !r.Available { |
| + return RoutingValid(r) || r.UnavailableReason != "" && r.Routing.BindingID != "" && r.Routing.AccountID != "" && HexHash(r.Routing.CredentialHomeHash) |
| + } |
| + return RoutingValid(r) |
| +} |
| +func SameProfile(a, b runnerproto.ConnectionReport) bool { |
| + return a.LocalID == b.LocalID && a.Provider == b.Provider && a.Family == b.Family && a.Kind == b.Kind && a.Routing.BindingID == b.Routing.BindingID && a.Routing.AccountID == b.Routing.AccountID |
| +} |
| +func SecurityHash(r runnerproto.ConnectionReport) string { |
| + // Models and allowance changes do not change the security binding. Every |
| + // model in one profile must have the same effective security configuration. |
| + r.Model = "" |
| + r.AccountLabel = "" |
| + r.Available = false |
| + r.UnavailableReason = "" |
| + r.AllowanceKnown = false |
| + r.AllowanceRemaining = 0 |
| + data, _ := json.Marshal(r) |
| + sum := sha256.Sum256(data) |
| + return hex.EncodeToString(sum[:]) |
| +} |
| + |
| +func KnownFamily(s string) bool { return s == "claude" || s == "gpt" } |
| +func SpecialistAllows(sp library.Specialist, r runnerproto.ConnectionReport) bool { |
| + return library.ModelAllowed(sp, r.Provider, r.Family, r.Model) && (sp.ModelSelection == "best_fit" || sp.ModelSelection == "fixed" && sp.Provider == r.Provider && sp.ModelFamily == r.Family && sp.Model == r.Model) |
| +} |
diff --git a/internal/equipo/conversation/coordinator_selection.go b/internal/equipo/ownermode/selection.go| similarity index 72% |
| rename from internal/equipo/conversation/coordinator_selection.go |
| rename to internal/equipo/ownermode/selection.go |
| index 7decf967..0fc18777 100644 |
| --- a/internal/equipo/conversation/coordinator_selection.go |
| +++ b/internal/equipo/ownermode/selection.go |
| @@ -1,4 +1,4 @@ |
| -package conversation |
| +package ownermode |
| import ( |
| "amadan.net/oficina/equipo/internal/equipo/planning" |
| @@ -8,12 +8,12 @@ import ( |
| "gorm.io/gorm" |
| ) |
| -func SelectBinding(tx *gorm.DB, b BindingRecord, memberRevision func(*gorm.DB, string) (int64, error), decode func(*planning.ConnectionRecord) error, eligible func(*gorm.DB, planning.ConnectionRecord, runnerproto.ConnectionReport) (bool, error), snapshot func(*gorm.DB, planning.ConnectionRecord, runnerproto.ConnectionReport) (team.IsolationSnapshot, error), forbidden, waiting error, storeError func(error) error) (runnerproto.Selection, error) { |
| +func SelectBinding(tx *gorm.DB, b runnerproto.CoordinatorBinding, memberRev, connectionRev int64, memberRevision func(*gorm.DB, string) (int64, error), decode func(*planning.ConnectionRecord) error, eligible func(*gorm.DB, planning.ConnectionRecord, runnerproto.ConnectionReport) (bool, error), snapshot func(*gorm.DB, planning.ConnectionRecord, runnerproto.ConnectionReport) (team.IsolationSnapshot, error), forbidden, waiting error, storeError func(error) error) (runnerproto.Selection, error) { |
| m, err := memberRevision(tx, b.Person) |
| if err != nil { |
| return runnerproto.Selection{}, err |
| } |
| - if m != b.MemberRevision { |
| + if m != memberRev { |
| return runnerproto.Selection{}, forbidden |
| } |
| var c planning.ConnectionRecord |
| @@ -23,7 +23,7 @@ func SelectBinding(tx *gorm.DB, b BindingRecord, memberRevision func(*gorm.DB, s |
| } |
| return runnerproto.Selection{}, storeError(err) |
| } |
| - if c.Person != b.Person || c.RunnerID != b.RunnerID || c.Revision != b.ConnectionRevision { |
| + if c.Person != b.Person || c.RunnerID != b.RunnerID || c.Revision != connectionRev { |
| return runnerproto.Selection{}, forbidden |
| } |
| if err = decode(&c); err != nil { |
diff --git a/internal/equipo/ownermode/status.go b/internal/equipo/ownermode/status.go| new file mode 100644 |
| index 00000000..121b39e3 |
| --- /dev/null |
| +++ b/internal/equipo/ownermode/status.go |
| @@ -0,0 +1,44 @@ |
| +package ownermode |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/kernel" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "encoding/json" |
| + "gorm.io/gorm" |
| + "time" |
| +) |
| + |
| +func TurnStatus(tx *gorm.DB, state string, attemptID int64, claimJSON string) (string, []string, bool, error) { |
| + |
| + if state == "running" { |
| + var attempt struct{ LeaseDeadline string } |
| + if err := tx.Table("attempts").Select("lease_deadline").Where("id=?", attemptID).Take(&attempt).Error; err != nil { |
| + return "", nil, false, err |
| + } |
| + var claim runnerproto.CoordinatorClaim |
| + if err := json.Unmarshal([]byte(claimJSON), &claim); err != nil { |
| + return "", nil, false, err |
| + } |
| + now := time.Now().UTC() |
| + if !now.Before(kernel.ReadTime(attempt.LeaseDeadline)) || !claim.AttemptDeadline.IsZero() && !now.Before(claim.AttemptDeadline) { |
| + state = "timed_out" |
| + } |
| + } |
| + var actions []string |
| + switch state { |
| + case "context_limit", "context_unavailable", "fenced": |
| + actions = []string{"coordinator.reset", "coordinator.retry"} |
| + case "uncertain": |
| + var n int64 |
| + if err := tx.Table("attempts").Where("id=? AND containment='contained'", attemptID).Count(&n).Error; err != nil { |
| + return "", nil, false, err |
| + } |
| + if n == 1 { |
| + actions = []string{"coordinator.reset", "coordinator.retry"} |
| + } |
| + case "admission_denied", "waiting_connection", "budget_needed", "timed_out": |
| + default: |
| + return "", nil, false, nil |
| + } |
| + return state, actions, true, nil |
| +} |
diff --git a/internal/equipo/team/git_evidence.go b/internal/equipo/team/git_evidence.go| index 47a83353..a5ee59f8 100644 |
| --- a/internal/equipo/team/git_evidence.go |
| +++ b/internal/equipo/team/git_evidence.go |
| @@ -50,6 +50,7 @@ type IsolationTuple struct { |
| } |
| type IsolationSnapshot struct { |
| + Mode string `json:"mode,omitempty"` |
| ProfileApprovals []ProfileApproval `json:"profile_approvals,omitempty"` |
| Trial *TrialSnapshot `json:"trial,omitempty"` |
| Status string `json:"status"` |
| @@ -92,6 +93,9 @@ func gitCandidate(a *Artifact, j jobRow) (GitCandidate, error) { |
| func (p IsolationSnapshot) Valid() bool { return p.valid() } |
| func (p IsolationSnapshot) valid() bool { |
| + if p.Mode != "" && p.Mode != "owner mode" { |
| + return false |
| + } |
| if !validProfileApprovals(p.ProfileApprovals) || !p.Trial.valid() || (p.Trial != nil && (p.Status != "unconfined" || !p.RunnerTainted)) { |
| return false |
| } |
| @@ -121,7 +125,7 @@ func (p IsolationSnapshot) valid() bool { |
| } |
| // ValidForDirectLaunch checks the shape of direct isolation evidence. A caller |
| -// must also match the exact tuple against release certification before dispatch. |
| +// must also authorize owner mode or match release certification before dispatch. |
| // Historical snapshots remain readable through Valid, but grant no direct work. |
| func (p IsolationSnapshot) ValidForDirectLaunch() bool { |
| // Valid unconfined and trial snapshots are always tainted. |
| @@ -151,6 +155,9 @@ func (v IsolationTuple) direct() bool { |
| } |
| func mergeIsolation(a, b IsolationSnapshot) IsolationSnapshot { |
| + if b.Mode == "owner mode" { |
| + a.Mode = b.Mode |
| + } |
| a.ProfileApprovals = MergeProfileApprovals(a.ProfileApprovals, b.ProfileApprovals) |
| a.Trial = MergeTrial(a.Trial, b.Trial) |
| if a.Trial != nil { |
| @@ -285,6 +292,9 @@ func publicationMatches(p publication, cand *Artifact, j jobRow) bool { |
| } |
| func isolationContains(have, need IsolationSnapshot) bool { |
| + if need.Mode != "" && have.Mode != need.Mode { |
| + return false |
| + } |
| if !profileApprovalsContain(have.ProfileApprovals, need.ProfileApprovals) || !trialContains(have.Trial, need.Trial) || !have.valid() || !need.valid() || need.RunnerTainted && !have.RunnerTainted { |
| return false |
| } |
diff --git a/internal/equipo/team/owner_publication_test.go b/internal/equipo/team/owner_publication_test.go| new file mode 100644 |
| index 00000000..f3cfa969 |
| --- /dev/null |
| +++ b/internal/equipo/team/owner_publication_test.go |
| @@ -0,0 +1,28 @@ |
| +package team |
| + |
| +import ( |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +func TestOwnerPublicationLabels(t *testing.T) { |
| + iso := IsolationSnapshot{Mode: "owner mode", Status: "confined", ObservedTuples: []IsolationTuple{{Provider: "claude", ProviderVersion: "v", LauncherVersion: "v", BwrapVersion: "v", PolicyVersion: "v", IsolationConfigHash: strings.Repeat("a", 64)}}} |
| + original := PublicationDescription{Label: "owner mode", Isolation: iso, Evidence: []PublicationEvidence{{Label: "owner mode", Provenance: Provenance{Isolation: iso}}}} |
| + need, _ := json.Marshal(original) |
| + for _, field := range []string{"publication", "evidence"} { |
| + t.Run(field, func(t *testing.T) { |
| + have := original |
| + have.Evidence = append([]PublicationEvidence(nil), original.Evidence...) |
| + if field == "publication" { |
| + have.Label = "confined" |
| + } else { |
| + have.Evidence[0].Label = "confined" |
| + } |
| + raw, _ := json.Marshal(have) |
| + if publicationDescriptionContains(string(raw), string(need)) { |
| + t.Fatal("owner label erased", field) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/equipo/team/publication.go b/internal/equipo/team/publication.go| index 64a82123..1e574d5e 100644 |
| --- a/internal/equipo/team/publication.go |
| +++ b/internal/equipo/team/publication.go |
| @@ -44,6 +44,9 @@ func publicationDescription(ctx context.Context, tx *sql.Tx, j jobRow, isolation |
| return "", ErrEvidence |
| } |
| desc := PublicationDescription{RenderedApprovals: j.Evidence.RenderedApprovals, Version: 1, Target: j.Target, Label: isolation.Status, Isolation: isolation} |
| + if isolation.Mode != "" { |
| + desc.Label = isolation.Mode |
| + } |
| if isolation.RunnerTainted { |
| desc.Label = "unconfined" |
| } |
| @@ -61,6 +64,9 @@ func publicationDescription(ctx context.Context, tx *sql.Tx, j jobRow, isolation |
| return "", ErrEvidence |
| } |
| e := PublicationEvidence{Step: a.Step, Attempt: a.Attempt, Role: a.Role, Hash: a.Hash, Provenance: a.Provenance, Label: a.Provenance.Isolation.Status} |
| + if a.Provenance.Isolation.Mode != "" { |
| + e.Label = a.Provenance.Isolation.Mode |
| + } |
| if isolation.RunnerTainted || a.Provenance.Isolation.RunnerTainted { |
| e.Label = "unconfined" |
| } |
| @@ -191,12 +197,12 @@ func publicationDescriptionContains(have, need string) bool { |
| if strictJSON([]byte(have), &a) != nil || strictJSON([]byte(need), &b) != nil || len(a.Evidence) != len(b.Evidence) { |
| return false |
| } |
| - if !isolationContains(a.Isolation, b.Isolation) || (b.Label == "unconfined" && a.Label != "unconfined") { |
| + if !isolationContains(a.Isolation, b.Isolation) || !publicationLabelContains(a.Label, b.Label) { |
| return false |
| } |
| a.Isolation, a.Label = b.Isolation, b.Label |
| for i := range a.Evidence { |
| - if !isolationContains(a.Evidence[i].Provenance.Isolation, b.Evidence[i].Provenance.Isolation) || (b.Evidence[i].Label == "unconfined" && a.Evidence[i].Label != "unconfined") { |
| + if !isolationContains(a.Evidence[i].Provenance.Isolation, b.Evidence[i].Provenance.Isolation) || !publicationLabelContains(a.Evidence[i].Label, b.Evidence[i].Label) { |
| return false |
| } |
| a.Evidence[i].Provenance.Isolation = b.Evidence[i].Provenance.Isolation |
| @@ -204,3 +210,14 @@ func publicationDescriptionContains(have, need string) bool { |
| } |
| return reflect.DeepEqual(a, b) |
| } |
| + |
| +func publicationLabelContains(have, need string) bool { |
| + switch need { |
| + case "unconfined": |
| + return have == need |
| + case "owner mode": |
| + return have == need || have == "unconfined" |
| + default: |
| + return true |
| + } |
| +} |
diff --git a/internal/equipo/templates/connections.html b/internal/equipo/templates/connections.html| index d70a5094..7742d041 100644 |
| --- a/internal/equipo/templates/connections.html |
| +++ b/internal/equipo/templates/connections.html |
| @@ -1,3 +1,3 @@ |
| {{define "content"}}<h1>{{copy "nav.connections"}}</h1><a rst-btn href="/runners/enrol">{{copy "connections.enrol"}}</a>{{template "region:activity" .}} |
| <a rst-btn href="/onboarding">{{copy "account_setup.add"}}</a><h2>{{copy "connections.personal"}}</h2>{{range .Choices}}<form equipo-form method="post" action="/projects/{{.Project.ID}}/connections"><h3>{{.Project.Name}}</h3><input type="hidden" name="revision" value="{{.Revision}}">{{range .Options}}<label><input type="checkbox" name="connection_id" value="{{.ID}}"{{if .Enabled}} checked{{end}}>{{copy "connections.enable"}}: {{.Label}}</label>{{end}}<label>{{copy "connections.reason"}}<select rst-input name="mode"><option value="best_fit"{{if eq .Mode "best_fit"}} selected{{end}}>{{copy "connections.best_fit"}}</option><option value="pinned"{{if eq .Mode "pinned"}} selected{{end}}>{{copy "connections.pinned"}}</option><option value="ask"{{if eq .Mode "ask"}} selected{{end}}>{{copy "connections.ask"}}</option></select></label><label>{{copy "connections.pin"}}<select rst-input name="pinned_id"><option value="">{{copy "value.none"}}</option>{{$pinned:=.PinnedID}}{{range .Options}}<option value="{{.ID}}"{{if eq .ID $pinned}} selected{{end}}>{{.Label}}</option>{{end}}</select></label><button rst-btn>{{copy "form.save"}}</button></form>{{end}}{{end}} |
| -{{define "region:activity"}}<div id="activity" {{.Live.Attrs .Topic}}>{{range .Connections}}<section equipo-card><h2>{{.Report.AccountLabel}}</h2><p>{{.Person}}</p><p>{{copy "connections.counted_usage"}}</p>{{if .Report.AllowanceKnown}}<span equipo-value>{{.Report.AllowanceRemaining}}</span>{{else}}<p>{{copy "connections.remaining_unknown"}}</p>{{end}}{{if not .Available}}<p>{{if eq .Report.UnavailableReason "account.sign_in_again"}}{{copy "account.sign_in_again"}}{{else}}{{copy "runner.preflight.unavailable"}}{{end}}</p>{{end}}{{template "trial-label" .Isolation}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.LauncherVersion}} / {{.Report.BwrapVersion}}</p>{{if .Unverified}}<p>{{copy "isolation.unverified"}}</p>{{else}}<p>{{copy "isolation.confined"}}</p>{{end}}</section>{{else}}<p data-empty-state="connections.empty">{{copy "connections.empty"}}</p>{{end}}</div>{{end}} |
| +{{define "region:activity"}}<div id="activity" {{.Live.Attrs .Topic}}>{{range .Connections}}<section equipo-card><h2>{{.Report.AccountLabel}}</h2><p>{{.Person}}</p><p>{{copy "connections.counted_usage"}}</p>{{if .Report.AllowanceKnown}}<span equipo-value>{{.Report.AllowanceRemaining}}</span>{{else}}<p>{{copy "connections.remaining_unknown"}}</p>{{end}}{{if not .Available}}<p>{{if eq .Report.UnavailableReason "account.sign_in_again"}}{{copy "account.sign_in_again"}}{{else}}{{copy "runner.preflight.unavailable"}}{{end}}</p>{{end}}{{template "trial-label" .Isolation}}{{if eq .Isolation.Mode "owner mode"}}<p>{{copy "connections.owner_mode"}}</p>{{end}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.LauncherVersion}} / {{.Report.BwrapVersion}}</p>{{if .Unverified}}<p>{{copy "isolation.unverified"}}</p>{{else}}<p>{{copy "isolation.confined"}}</p>{{end}}</section>{{else}}<p data-empty-state="connections.empty">{{copy "connections.empty"}}</p>{{end}}</div>{{end}} |
diff --git a/internal/equipo/templates/conversation_card.html b/internal/equipo/templates/conversation_card.html| index 4db3b311..ac73075e 100644 |
| --- a/internal/equipo/templates/conversation_card.html |
| +++ b/internal/equipo/templates/conversation_card.html |
| @@ -65,7 +65,7 @@ |
| <div equipo-chat-task> |
| <h2><a equipo-task-link href="/tasks/{{.Task.ID}}/thread">{{.Task.Description}}</a></h2> |
| <p equipo-secondary>{{.Project.Name}} · {{copy (printf "task.kind.%s" .Task.Kind)}} {{if .ChatAge}}· <time datetime="{{.CreatedAt.Format "2006-01-02T15:04:05Z07:00"}}" title="{{.CreatedAt.Format "2 January 2006 15:04 MST"}}">{{.ChatAge}}</time>{{end}}<span equipo-visually-hidden>{{copy .StateKey}}</span></p> |
| -<ol equipo-steps>{{range .Steps}}<li equipo-step data-step="{{.Key}}" data-state="{{.State}}"><strong>{{icon .CategoryIcon}}{{if .CategoryName}}{{.CategoryName}}{{else}}{{copy (printf "nav.%s" .Category)}}{{end}}</strong><span title="{{copy (printf "plan.action.%s" .Action)}}">{{copy (printf "plan.action.%s" .Action)}}</span><span equipo-step-state equipo-visually-hidden>{{copy (printf "step.%s" .State)}}</span><span equipo-value title="{{.Model}} {{.Account}}{{.Person}}">{{.Model}}{{if and .Model .Account}} · {{end}}{{.Account}}{{.Person}}</span></li>{{end}}</ol> |
| +<ol equipo-steps>{{range .Steps}}<li equipo-step data-step="{{.Key}}" data-state="{{.State}}"><strong>{{icon .CategoryIcon}}{{if .CategoryName}}{{.CategoryName}}{{else}}{{copy (printf "nav.%s" .Category)}}{{end}}</strong><span title="{{copy (printf "plan.action.%s" .Action)}}">{{copy (printf "plan.action.%s" .Action)}}</span><span equipo-step-state equipo-visually-hidden>{{copy (printf "step.%s" .State)}}</span><span equipo-value title="{{.Model}} {{.Account}}{{.Person}}">{{.Model}}{{if and .Model .Account}} · {{end}}{{.Account}}{{.Person}}</span>{{template "trial-label" .Isolation}}</li>{{end}}</ol> |
| <div equipo-actions><a rst-btn href="/tasks/{{.Task.ID}}/plan">{{copy "plan.edit"}}</a><details equipo-models><summary rst-btn>{{copy "conversation.why_models"}}</summary><ul>{{range .Steps}}{{if .Reason}}<li><strong>{{copy (printf "plan.action.%s" .Action)}}</strong>: {{.Reason}}</li>{{end}}{{end}}</ul><a href="/tasks/{{.Task.ID}}/plan">{{copy "plan.edit"}}</a> <a href="/tasks/{{.Task.ID}}/plan#project">{{copy "plan.correct_project"}}</a></details></div> |
| {{range .Evidence}}{{if eq .Role "candidate"}}<p equipo-value>{{copy "task.evidence"}}: {{.Hash}}</p>{{end}}{{end}} |
| {{if .Evidence}}<details equipo-task-details><summary>{{copy "task.evidence"}}</summary><a href="/tasks/{{.Task.ID}}">{{copy "task.evidence"}}</a><a href="/tasks/{{.Task.ID}}/plan#project">{{copy "plan.correct_project"}}</a></details>{{end}} |
diff --git a/internal/equipo/templates/task_card.html b/internal/equipo/templates/task_card.html| index f743f21a..c4ad764c 100644 |
| --- a/internal/equipo/templates/task_card.html |
| +++ b/internal/equipo/templates/task_card.html |
| @@ -6,4 +6,4 @@ |
| {{end}} |
| {{define "task-groups"}}{{range $group := taskGroups}}<section><h2>{{copy (printf "task.group.%s" $group)}}</h2>{{range $.Tasks}}{{if eq .Group $group}}{{template "task-card" .}}{{end}}{{end}}</section>{{end}}{{if not .Tasks}}<p data-empty-state="{{.Key}}.empty">{{copy "task.empty"}}</p>{{end}}{{end}} |
| -{{define "trial-label"}}{{if .ProfileApprovals}}<span equipo-isolation>{{copy "isolation.approved_beyond_profile"}}</span>{{end}}{{with .Trial}}<span equipo-isolation>{{copy "trial.label"}}: {{range .UnverifiedChecks}}<span>{{copy (printf "trial.check.%s" .)}}</span> {{end}}<span>{{copy "trial.observed_locally"}}</span></span>{{end}}{{end}} |
| +{{define "trial-label"}}{{if eq .Mode "owner mode"}}<span equipo-isolation>{{copy "isolation.owner_mode"}}</span>{{end}}{{if .ProfileApprovals}}<span equipo-isolation>{{copy "isolation.approved_beyond_profile"}}</span>{{end}}{{with .Trial}}<span equipo-isolation>{{copy "trial.label"}}: {{range .UnverifiedChecks}}<span>{{copy (printf "trial.check.%s" .)}}</span> {{end}}<span>{{copy "trial.observed_locally"}}</span></span>{{end}}{{end}} |
diff --git a/internal/ownermodetest/budget_test.go b/internal/ownermodetest/budget_test.go| new file mode 100644 |
| index 00000000..8eb5641e |
| --- /dev/null |
| +++ b/internal/ownermodetest/budget_test.go |
| @@ -0,0 +1,9 @@ |
| +package ownermodetest |
| + |
| +import ( |
| + "amadan.net/rastrillo/rastrillo/budget" |
| + "os" |
| + "testing" |
| +) |
| + |
| +func TestMain(m *testing.M) { os.Exit(budget.Main(m)) } |
diff --git a/internal/ownermodetest/owner_mode_test.go b/internal/ownermodetest/owner_mode_test.go| new file mode 100644 |
| index 00000000..38371c43 |
| --- /dev/null |
| +++ b/internal/ownermodetest/owner_mode_test.go |
| @@ -0,0 +1,15 @@ |
| +package ownermodetest |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/plan3test" |
| + "testing" |
| +) |
| + |
| +func TestOwnerModeSelectionAndDefaults(t *testing.T) { plan3test.RunOwnerModeSelectionAndDefaults(t) } |
| +func TestOwnerModeForeignRunnerDenied(t *testing.T) { plan3test.RunOwnerModeForeignRunnerDenied(t) } |
| +func TestOwnerModeFallback(t *testing.T) { plan3test.RunOwnerModeFallback(t) } |
| +func TestOwnerModeDenialNote(t *testing.T) { plan3test.RunOwnerModeDenialNote(t) } |
| +func TestOwnerModeConfiguredLimitsStay(t *testing.T) { plan3test.RunOwnerModeConfiguredLimitsStay(t) } |
| +func TestOwnerModePausedNote(t *testing.T) { plan3test.RunOwnerModePausedNote(t) } |
| + |
| +func TestOwnerModeStaleBindingNote(t *testing.T) { plan3test.RunOwnerModeStaleBindingNote(t) } |
diff --git a/internal/plan3test/coordinator_fixes_test.go b/internal/plan3test/coordinator_fixes_test.go| index f9b87651..b1dc4000 100644 |
| --- a/internal/plan3test/coordinator_fixes_test.go |
| +++ b/internal/plan3test/coordinator_fixes_test.go |
| @@ -3,6 +3,7 @@ package plan3test |
| import ( |
| "context" |
| "encoding/json" |
| + "errors" |
| "testing" |
| "time" |
| @@ -218,8 +219,8 @@ func TestCoordinatorFixPollMissingConnection(t *testing.T) { |
| } |
| turns, err := x.PollCoordinator(ctx, p) |
| if change == "revision" { |
| - if err == nil || f.count(t, "SELECT count(*) FROM coordinator_turns WHERE id=? AND state='queued'", turn.ID) != 1 { |
| - t.Fatal("authority mismatch became connection absence") |
| + if !errors.Is(err, equipo.ErrForbidden) || f.count(t, "SELECT count(*) FROM coordinator_turns WHERE id=? AND state='admission_denied'", turn.ID) != 1 { |
| + t.Fatal("authority mismatch must remain denied and visible") |
| } |
| return |
| } |
diff --git a/internal/plan3test/owner_mode_fixture.go b/internal/plan3test/owner_mode_fixture.go| new file mode 100644 |
| index 00000000..e1d67505 |
| --- /dev/null |
| +++ b/internal/plan3test/owner_mode_fixture.go |
| @@ -0,0 +1,141 @@ |
| +package plan3test |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "encoding/json" |
| + "errors" |
| + "testing" |
| +) |
| + |
| +func ownerReports(t *testing.T, f *fixture) { |
| + t.Helper() |
| + var raw string |
| + must(t, f.DB.Writer().QueryRow("SELECT reports_json FROM connections WHERE id='claude'").Scan(&raw)) |
| + var reports []equipo.ConnectionReport |
| + must(t, json.Unmarshal([]byte(raw), &reports)) |
| + reports[0].OwnerMode = true |
| + reports[0].LauncherVersion = "direct-v3" |
| + reports[0].PolicyVersion = "direct-v1" |
| + reports[0].IsolationConfigHash = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" |
| + rawBytes, err := json.Marshal(reports) |
| + must(t, err) |
| + f.exec(t, "UPDATE connections SET reports_json=? WHERE id='claude'", string(rawBytes)) |
| +} |
| + |
| +func RunOwnerModeSelectionAndDefaults(t *testing.T) { |
| + f, x, p, _ := coordinatorFixture(t) |
| + ownerReports(t, f) |
| + f.exec(t, "DELETE FROM coordinator_limits") |
| + f.exec(t, "DELETE FROM budget_records") |
| + f.exec(t, "DELETE FROM period_budgets") |
| + turn := queueCoordinator(t, f, "hello", "owner-mode") |
| + offers, err := x.PollCoordinator(ctx, p) |
| + must(t, err) |
| + if len(offers) != 1 { |
| + t.Fatalf("owner mode did not offer turn: %+v", offers) |
| + } |
| + claim, err := x.ClaimCoordinator(ctx, p, turn.ID, turn.Revision) |
| + must(t, err) |
| + if claim.Brief.Selection.Isolation.Mode != "owner mode" { |
| + t.Fatal("claim lost mode") |
| + } |
| + if f.count(t, "SELECT count(*) FROM coordinator_limits") != 1 || f.count(t, "SELECT count(*) FROM budget_records") != 1 { |
| + t.Fatal("defaults not saved") |
| + } |
| +} |
| + |
| +func RunOwnerModeForeignRunnerDenied(t *testing.T) { |
| + f, x, p, _ := coordinatorFixture(t) |
| + ownerReports(t, f) |
| + queueCoordinator(t, f, "hello", "foreign-owner-mode") |
| + f.exec(t, "UPDATE runners SET person=? WHERE id=?", peer.Address, p.RunnerID) |
| + offers, err := x.PollCoordinator(ctx, p) |
| + if err == nil && len(offers) > 0 { |
| + t.Fatal("foreign runner admitted owner work") |
| + } |
| +} |
| + |
| +func RunOwnerModeFallback(t *testing.T) { |
| + f, x, p, b := coordinatorFixture(t) |
| + ownerReports(t, f) |
| + queueCoordinator(t, f, "hello", "fallback-owner") |
| + // The current binding points at a broken profile; claude remains available. |
| + f.exec(t, "UPDATE coordinator_bindings SET connection_id='codex' WHERE id=?", b.ID) |
| + f.exec(t, "UPDATE connections SET reports_json=json_set(reports_json,'$[0].Available',json('false')) WHERE id='codex'") |
| + offers, err := x.PollCoordinator(ctx, p) |
| + must(t, err) |
| + if len(offers) != 1 { |
| + t.Fatal("fallback did not release queued turn", offers) |
| + } |
| + if f.count(t, "SELECT count(*) FROM coordinator_bindings WHERE id=? AND connection_id='claude' AND generation=2", b.ID) != 1 { |
| + t.Fatal("fallback binding not saved") |
| + } |
| + if f.count(t, "SELECT count(*) FROM conversation_messages WHERE author_kind='system' AND body LIKE '%coordinator%'") == 0 { |
| + t.Fatal("fallback note absent") |
| + } |
| +} |
| + |
| +func RunOwnerModeDenialNote(t *testing.T) { |
| + f, x, p, _ := coordinatorFixture(t) |
| + ownerReports(t, f) |
| + queueCoordinator(t, f, "hello", "denial-owner") |
| + f.exec(t, "UPDATE connections SET reports_json=json_set(reports_json,'$[0].Available',json('false'))") |
| + offers, err := x.PollCoordinator(ctx, p) |
| + must(t, err) |
| + if len(offers) != 0 { |
| + t.Fatal("unavailable admitted") |
| + } |
| + page, err := f.Store.Conversation(ctx, owner, "", 50) |
| + must(t, err) |
| + if len(page.Cards) == 0 { |
| + t.Fatal("blocked turn missing conversation card") |
| + } |
| + if f.count(t, "SELECT count(*) FROM conversation_messages WHERE author_kind='system' AND body LIKE '%connection%'") == 0 { |
| + t.Fatal("denial note absent") |
| + } |
| +} |
| + |
| +func RunOwnerModeConfiguredLimitsStay(t *testing.T) { |
| + f, x, p, _ := coordinatorFixture(t) |
| + ownerReports(t, f) |
| + before, revision, err := x.Core.CoordinatorLimits(ctx, team.AccountID(f.TeamID), owner.Address) |
| + must(t, err) |
| + queueCoordinator(t, f, "hello", "limits-stay") |
| + _, err = x.PollCoordinator(ctx, p) |
| + must(t, err) |
| + after, next, err := x.Core.CoordinatorLimits(ctx, team.AccountID(f.TeamID), owner.Address) |
| + must(t, err) |
| + if before != after || revision != next { |
| + t.Fatal("configured limits overwritten") |
| + } |
| +} |
| +func RunOwnerModePausedNote(t *testing.T) { |
| + f, x, p, _ := coordinatorFixture(t) |
| + ownerReports(t, f) |
| + queueCoordinator(t, f, "hello", "paused-note") |
| + f.exec(t, "UPDATE service SET admission_paused=1 WHERE id=1") |
| + offers, err := x.PollCoordinator(ctx, p) |
| + must(t, err) |
| + if len(offers) > 0 || f.count(t, "SELECT count(*) FROM coordinator_turns WHERE state='admission_denied'") != 1 { |
| + t.Fatal("paused admission not visible") |
| + } |
| + if f.count(t, "SELECT count(*) FROM conversation_messages WHERE author_kind='system' AND body LIKE '%cannot start%'") != 1 { |
| + t.Fatal("admission note absent") |
| + } |
| +} |
| + |
| +func RunOwnerModeStaleBindingNote(t *testing.T) { |
| + f, x, p, _ := coordinatorFixture(t) |
| + ownerReports(t, f) |
| + queueCoordinator(t, f, "hello", "stale-note") |
| + f.exec(t, "UPDATE coordinator_bindings SET connection_revision=99") |
| + f.exec(t, "UPDATE connections SET reports_json=json_set(reports_json,'$[0].Available',json('false'))") |
| + offers, err := x.PollCoordinator(ctx, p) |
| + if !errors.Is(err, equipo.ErrForbidden) { |
| + t.Fatal("authority denial lost", err) |
| + } |
| + if len(offers) > 0 || f.count(t, "SELECT count(*) FROM coordinator_turns WHERE state='admission_denied'") != 1 { |
| + t.Fatal("stale binding denial hidden") |
| + } |
| +} |
diff --git a/internal/runner/certified/discovery.go b/internal/runner/certified/discovery.go| index 65e180e6..54ce78d3 100644 |
| --- a/internal/runner/certified/discovery.go |
| +++ b/internal/runner/certified/discovery.go |
| @@ -14,9 +14,14 @@ import ( |
| ) |
| func ConnectionReport(ctx context.Context, b runnersetup.AccountBinding, m release.Manifest, installed bool, construct func(string) (provider.Launch, func() error, error), preflight func(provider.Launch) error) (runnerproto.ConnectionReport, error) { |
| + return connectionReport(ctx, b, m, installed, construct, preflight, false) |
| +} |
| + |
| +func connectionReport(ctx context.Context, b runnersetup.AccountBinding, m release.Manifest, installed bool, construct func(string) (provider.Launch, func() error, error), preflight func(provider.Launch) error, owner bool) (runnerproto.ConnectionReport, error) { |
| homeHash := sha256.Sum256([]byte(b.ProviderHome)) |
| - report := runnerproto.ConnectionReport{AccountLabel: b.Label, LocalID: b.LocalID, Provider: b.Provider, Family: b.Family, Model: b.Model, Kind: b.Kind, ProviderVersion: b.ExpectedIdentity.ProviderVersion, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyVersion: m.PolicyVersion, ProviderVersionSource: "direct-cli", UnavailableReason: "capability_unverified", IsolationConfigHash: runnerproto.EventHash(b), Routing: runnerproto.ConnectionRouting{BindingID: b.ID, AccountID: b.AccountID, CredentialHomeHash: hex.EncodeToString(homeHash[:])}} |
| + report := runnerproto.ConnectionReport{OwnerMode: owner, AccountLabel: b.Label, LocalID: b.LocalID, Provider: b.Provider, Family: b.Family, Model: b.Model, Kind: b.Kind, ProviderVersion: b.ExpectedIdentity.ProviderVersion, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyVersion: m.PolicyVersion, ProviderVersionSource: "direct-cli", UnavailableReason: "capability_unverified", IsolationConfigHash: runnerproto.EventHash(b), Routing: runnerproto.ConnectionRouting{BindingID: b.ID, AccountID: b.AccountID, CredentialHomeHash: hex.EncodeToString(homeHash[:])}} |
| if !installed { |
| + report.UnavailableReason = "binary_verification_failed" |
| return report, nil |
| } |
| policies := slices.Clone(m.DirectPolicies) |
| @@ -33,9 +38,12 @@ func ConnectionReport(ctx context.Context, b runnersetup.AccountBinding, m relea |
| } |
| return 0 |
| }) |
| + if owner { |
| + policies = []release.PolicyCertificate{{Provider: b.Provider, Action: "coordinate"}} |
| + } |
| seen := map[string]bool{} |
| for _, c := range policies { |
| - if c.Provider != b.Provider || seen[c.Action] || !m.HasCertifiedAction(b.Provider, c.Action) { |
| + if c.Provider != b.Provider || seen[c.Action] || (!owner && !m.HasCertifiedAction(b.Provider, c.Action)) { |
| continue |
| } |
| seen[c.Action] = true |
| @@ -45,7 +53,11 @@ func ConnectionReport(ctx context.Context, b runnersetup.AccountBinding, m relea |
| launch, cleanup, err := construct(c.Action) |
| if err == nil { |
| report.IsolationConfigHash = launch.Policy.Hash |
| - if hash, ok := m.CertifiedPolicyHash(b.Provider, c.Action, b.ExpectedIdentity.ProviderVersion, launch.Policy); ok { |
| + hash, ok := launch.Policy.Hash, owner |
| + if !owner { |
| + hash, ok = m.CertifiedPolicyHash(b.Provider, c.Action, b.ExpectedIdentity.ProviderVersion, launch.Policy) |
| + } |
| + if ok { |
| err = preflight(launch) |
| if err == nil { |
| report.IsolationConfigHash = hash |
| @@ -65,6 +77,9 @@ func ConnectionReport(ctx context.Context, b runnersetup.AccountBinding, m relea |
| return report, e |
| } |
| } |
| + if err != nil && owner { |
| + report.UnavailableReason = "preflight_failed" |
| + } |
| if errors.Is(err, provider.ErrAccountMaintenance) { |
| report.UnavailableReason = "account.sign_in_again" |
| } |
diff --git a/internal/runner/certified/discoverytest/owner_test.go b/internal/runner/certified/discoverytest/owner_test.go| new file mode 100644 |
| index 00000000..ddc1e976 |
| --- /dev/null |
| +++ b/internal/runner/certified/discoverytest/owner_test.go |
| @@ -0,0 +1,51 @@ |
| +package discoverytest |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/runner/certified" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "testing" |
| +) |
| + |
| +func TestOwnerConnectionGuards(t *testing.T) { |
| + for _, fault := range []string{"none", "binary", "preflight", "policy", "cleanup"} { |
| + t.Run(fault, func(t *testing.T) { |
| + f := availableFixture(t) |
| + f.m.Certifications = nil |
| + f.m.DirectPolicies = nil |
| + build := f.build |
| + probe := f.probe |
| + if fault == "policy" { |
| + build = func(string) (provider.Launch, func() error, error) { return provider.Launch{}, nil, provider.ErrPolicy } |
| + } |
| + if fault == "cleanup" { |
| + build = func(a string) (provider.Launch, func() error, error) { |
| + l, close, e := f.build(a) |
| + return l, func() error { _ = close(); return provider.ErrContainment }, e |
| + } |
| + } |
| + if fault == "preflight" { |
| + probe = func(provider.Launch) error { return provider.ErrIdentity } |
| + } |
| + r, err := certified.OwnerConnectionReport(ctx, f.b, f.m, fault != "binary", build, probe) |
| + if fault == "cleanup" { |
| + if err == nil { |
| + t.Fatal("cleanup failure hidden") |
| + } |
| + return |
| + } |
| + must(t, err) |
| + if r.Available != (fault == "none") { |
| + t.Fatalf("owner availability %v: %+v", fault, r) |
| + } |
| + if !r.OwnerMode { |
| + t.Fatal("owner mode label absent") |
| + } |
| + if r.Available && (!r.ReadIsolation || r.UnavailableReason != "" || !r.Routing.AccountPinned) { |
| + t.Fatal("owner lost isolation or identity", r) |
| + } |
| + if !r.Available && r.UnavailableReason == "" { |
| + t.Fatal("fault missing reason") |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/runner/certified/dispatch.go b/internal/runner/certified/dispatch.go| index 5e939316..8a775104 100644 |
| --- a/internal/runner/certified/dispatch.go |
| +++ b/internal/runner/certified/dispatch.go |
| @@ -13,3 +13,8 @@ func RequireAction(m release.Manifest, family, action string) error { |
| } |
| return nil |
| } |
| + |
| +func CoordinatorLaunchCertified(l provider.Launch) bool { |
| + _, ok := release.BuildManifest().CertifiedPolicyHash(l.Selection.Provider, "coordinate", l.Binding.Expected.ProviderVersion, l.Policy) |
| + return ok |
| +} |
diff --git a/internal/runner/certified/owner.go b/internal/runner/certified/owner.go| new file mode 100644 |
| index 00000000..327ebe93 |
| --- /dev/null |
| +++ b/internal/runner/certified/owner.go |
| @@ -0,0 +1,17 @@ |
| +package certified |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/release" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + runnersetup "amadan.net/oficina/equipo/internal/runner/setup" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "context" |
| +) |
| + |
| +func OwnerConnectionReport(ctx context.Context, b runnersetup.AccountBinding, m release.Manifest, installed bool, construct func(string) (provider.Launch, func() error, error), preflight func(provider.Launch) error) (runnerproto.ConnectionReport, error) { |
| + return connectionReport(ctx, b, m, installed, construct, preflight, true) |
| +} |
| + |
| +func OwnerRoute(person, runner string, s runnerproto.Selection) bool { |
| + return s.Isolation.Mode == "owner mode" && s.Isolation.Status == "confined" && !s.Isolation.RunnerTainted && s.Person != "" && s.Person == person && s.RunnerID != "" && s.RunnerID == runner |
| +} |
diff --git a/internal/runner/certified/owner_test.go b/internal/runner/certified/owner_test.go| new file mode 100644 |
| index 00000000..43c3ed9c |
| --- /dev/null |
| +++ b/internal/runner/certified/owner_test.go |
| @@ -0,0 +1,32 @@ |
| +package certified |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "testing" |
| +) |
| + |
| +func TestOwnerRouteGuards(t *testing.T) { |
| + for _, fault := range []string{"none", "person", "runner", "empty", "mode", "isolation", "tainted"} { |
| + t.Run(fault, func(t *testing.T) { |
| + s := runnerproto.Selection{Person: "owner", RunnerID: "runner", Isolation: team.IsolationSnapshot{Mode: "owner mode", Status: "confined"}} |
| + switch fault { |
| + case "person": |
| + s.Person = "peer" |
| + case "runner": |
| + s.RunnerID = "peer" |
| + case "empty": |
| + s.Person = "" |
| + case "mode": |
| + s.Isolation.Mode = "" |
| + case "isolation": |
| + s.Isolation.Status = "unconfined" |
| + case "tainted": |
| + s.Isolation.RunnerTainted = true |
| + } |
| + if OwnerRoute("owner", "runner", s) != (fault == "none") { |
| + t.Fatal("owner authority guard failed", fault) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/runner/owner_harness.go b/internal/runner/owner_harness.go| new file mode 100644 |
| index 00000000..b10757c9 |
| --- /dev/null |
| +++ b/internal/runner/owner_harness.go |
| @@ -0,0 +1,26 @@ |
| +//go:build e2elive |
| + |
| +package runner |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/workspace" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "context" |
| +) |
| + |
| +type OwnerHarness struct { |
| + Journal *Journal |
| + Credential runnerproto.RunnerCredential |
| + Launcher provider.Launcher |
| + Launch func(context.Context, RunClaim, workspace.Workspace, *ToolProxy) (provider.Launch, func() error, error) |
| + Close func() error |
| +} |
| + |
| +func OpenOwnerHarness(ctx context.Context, cfg Config) (OwnerHarness, error) { |
| + r, err := openRuntime(ctx, cfg) |
| + if err != nil { |
| + return OwnerHarness{}, err |
| + } |
| + return OwnerHarness{r.journal, r.api.bearer, r.launchers["claude"], r.directLaunch, r.Close}, nil |
| +} |
diff --git a/internal/runner/ownerlive/owner_live_test.go b/internal/runner/ownerlive/owner_live_test.go| new file mode 100644 |
| index 00000000..29da64ec |
| --- /dev/null |
| +++ b/internal/runner/ownerlive/owner_live_test.go |
| @@ -0,0 +1,147 @@ |
| +//go:build e2elive |
| + |
| +package ownerlive |
| + |
| +import ( |
| + "context" |
| + "database/sql" |
| + "encoding/json" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + . "amadan.net/oficina/equipo/internal/runner" |
| + "amadan.net/oficina/equipo/internal/runner/containment" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/workspace" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| +) |
| + |
| +// Invoked only by the disposable HTTP harness, after its runner has stopped. |
| +func TestOwnerImplementE2ELive(t *testing.T) { |
| + path := os.Getenv("EQUIPO_OWNER_HARNESS") |
| + if path == "" { |
| + t.Skip("invoked by make e2e-live") |
| + } |
| + raw, err := os.ReadFile(path) |
| + mustJournal(t, err) |
| + var env map[string]string |
| + mustJournal(t, json.Unmarshal(raw, &env)) |
| + cfg, err := LoadConfig(func(k string) string { return env[k] }) |
| + mustJournal(t, err) |
| + ctx, cancel := context.WithTimeout(context.Background(), 150*time.Second) |
| + defer cancel() |
| + r, err := OpenOwnerHarness(ctx, cfg) |
| + mustJournal(t, err) |
| + defer func() { mustJournal(t, r.Close()) }() |
| + raw, err = os.ReadFile(cfg.AccountBindingsPath) |
| + mustJournal(t, err) |
| + var bs []AccountBinding |
| + mustJournal(t, json.Unmarshal(raw, &bs)) |
| + if len(bs) != 1 || bs[0].LocalID != "claude-a" { |
| + t.Fatal("harness account changed") |
| + } |
| + b := bs[0] |
| + work := filepath.Join(cfg.WorkspaceRoot, "owner-implement") |
| + mustJournal(t, os.Mkdir(work, 0700)) |
| + git := func(args ...string) string { |
| + t.Helper() |
| + c := exec.Command(cfg.GitPath, append([]string{"-C", work}, args...)...) |
| + c.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") |
| + out, e := c.CombinedOutput() |
| + if e != nil { |
| + t.Fatalf("local git: %v: %s", e, out) |
| + } |
| + return strings.TrimSpace(string(out)) |
| + } |
| + git("init", "-b", "main") |
| + git("config", "user.name", "Harness") |
| + git("config", "user.email", "harness@example.test") |
| + mustJournal(t, os.WriteFile(filepath.Join(work, "value.txt"), []byte("before\n"), 0600)) |
| + git("add", "value.txt") |
| + git("commit", "-m", "Initial fixture") |
| + base := git("rev-parse", "main") |
| + git("checkout", "-b", "equipo/owner-mode") |
| + sel := runnerproto.Selection{RunnerID: r.Credential.RunnerID, Person: r.Credential.Person, ConnectionID: b.LocalID, Provider: b.Provider, Family: b.Family, Model: b.Model, AccountID: b.AccountID, Isolation: team.IsolationSnapshot{Status: "confined", Mode: "owner mode"}} |
| + launcher := r.Launcher |
| + var session provider.Session |
| + proxy, err := OpenToolProxy(ctx, ToolBinding{InstanceID: cfg.InstanceID, TaskID: "owner-implement", Attempt: 1, Fence: 1, Tools: []string{"submit_candidate", "submit_render", "ask_person"}, LeaseDeadline: time.Now().Add(150 * time.Second), Journal: r.Journal, Isolation: sel.Isolation, Copy: ToolCopy{Accepted: "accepted", Rejected: "rejected", Candidate: "submit candidate", Render: "submit render", Ask: "ask"}, Agent: provider.Agent{Provider: b.Provider, Family: b.Family, Model: b.Model, AccountID: b.AccountID, ServerID: "direct"}, Current: func(ctx context.Context) error { return ctx.Err() }, Permission: func(ctx context.Context, raw json.RawMessage) (json.RawMessage, error) { |
| + return launcher.(interface { |
| + Permission(context.Context, provider.Session, json.RawMessage) (json.RawMessage, error) |
| + }).Permission(ctx, session, raw) |
| + }}) |
| + mustJournal(t, err) |
| + defer proxy.Close() |
| + claim := RunClaim{Assignment: runnerproto.Assignment{StepKey: "implement", Selection: sel}, ClaimResponse: runnerproto.ClaimResponse{Scope: team.Scope{Account: "harness", Job: 1}, Handle: team.Handle{Attempt: 1, Fence: 1}, Brief: runnerproto.RunnerBrief{Step: runnerproto.StepBrief{Action: "implement"}, Selection: sel}}} |
| + launch, cleanup, err := r.Launch(ctx, claim, workspace.Workspace{Path: work}, proxy) |
| + mustJournal(t, err) |
| + defer func() { mustJournal(t, cleanup()) }() |
| + if launch.Mode != "owner mode" { |
| + t.Fatal("launch mode absent") |
| + } |
| + session, err = launcher.Open(ctx, launch) |
| + mustJournal(t, err) |
| + defer launcher.Close(context.Background(), session) |
| + events, err := launcher.Events(ctx, session) |
| + mustJournal(t, err) |
| + mustJournal(t, DispatchDirectTurn(ctx, proxy, launcher, session, provider.Turn{ID: "implement", AdmissionID: "owner-harness-one-turn", Prompt: "Implement this tiny local fixture change. Use the Write tool to replace /workspace/value.txt with exactly owner mode implemented followed by a newline. Do not run shell commands, use the network, or call Equipo tools. After writing, end your turn. The harness will commit your change on the already checked-out branch."})) |
| + for { |
| + select { |
| + case <-ctx.Done(): |
| + t.Fatal("implement timed out") |
| + case event, ok := <-events: |
| + if !ok { |
| + t.Fatal("implement stream ended") |
| + } |
| + _, err = r.Journal.ObserveDirect(ctx, session, event) |
| + mustJournal(t, err) |
| + if event.Kind == "request" { |
| + mustJournal(t, launcher.Respond(ctx, session, provider.Answer{RequestID: event.RequestID, TurnID: event.TurnID, Behavior: "deny"})) |
| + } |
| + if event.Kind == "turn.failed" { |
| + t.Fatalf("implement failed: %s", RedactJSON(event.Payload, nil)) |
| + } |
| + if event.Kind == "turn.completed" { |
| + goto finished |
| + } |
| + } |
| + } |
| +finished: |
| + mustJournal(t, launcher.Close(context.Background(), session)) |
| + raw, err = os.ReadFile(filepath.Join(work, "value.txt")) |
| + mustJournal(t, err) |
| + if string(raw) != "owner mode implemented\n" { |
| + t.Fatalf("model change absent: %q", raw) |
| + } |
| + git("add", "value.txt") |
| + git("commit", "-m", "Implement owner mode fixture") |
| + if git("branch", "--show-current") != "equipo/owner-mode" || git("rev-parse", "HEAD") == base || git("rev-parse", "main") != base { |
| + t.Fatal("branch or default ref changed incorrectly") |
| + } |
| + journal, err := sql.Open("sqlite", filepath.Join(cfg.StateDir, "journal.db")) |
| + mustJournal(t, err) |
| + defer journal.Close() |
| + var mode string |
| + mustJournal(t, journal.QueryRow("SELECT json_extract(launch,'$.Mode') FROM direct_attempts WHERE attempt=?", launch.AttemptKey).Scan(&mode)) |
| + if mode != "owner mode" { |
| + t.Fatal("journal launch lost owner label") |
| + } |
| + t.Log("one Claude implement turn; sandboxed file change committed on local equipo/owner-mode; main unchanged; no remote configured") |
| +} |
| + |
| +func mustJournal(t *testing.T, err error) { |
| + t.Helper() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| +func TestMain(m *testing.M) { |
| + if len(os.Args) > 1 && os.Args[1] == "__namespace" { |
| + os.Exit(containment.NamespaceMain(os.Args[2:])) |
| + } |
| + os.Exit(m.Run()) |
| +} |
diff --git a/internal/runner/provider/types.go b/internal/runner/provider/types.go| index 3683c139..174d58a9 100644 |
| --- a/internal/runner/provider/types.go |
| +++ b/internal/runner/provider/types.go |
| @@ -56,6 +56,7 @@ type Policy struct { |
| } |
| type Launch struct { |
| + Mode string `json:",omitempty"` |
| // ToolSocket is the runner-created per-attempt endpoint, pinned by containment. |
| ToolSocket string |
| AttemptKey, Workspace, ResumeSessionID string |
diff --git a/internal/runner/runtime_direct.go b/internal/runner/runtime_direct.go| index c1f797f0..60f472ee 100644 |
| --- a/internal/runner/runtime_direct.go |
| +++ b/internal/runner/runtime_direct.go |
| @@ -61,25 +61,44 @@ func (r *Runtime) directLaunch(ctx context.Context, c RunClaim, ws workspace.Wor |
| if action == "scope" && c.Brief.Target.Kind == "project_read" { |
| action = "recommend" |
| } |
| - if err := certified.RequireAction(release.BuildManifest(), c.Assignment.Selection.Provider, action); err != nil { |
| + owner := r.ownerSelection(c.Assignment.Selection) |
| + if c.Assignment.Selection.Isolation.Mode != "" && !owner { |
| + return provider.Launch{}, nil, provider.ErrIdentity |
| + } |
| + if _, err := provider.Profile(action); err != nil { |
| return provider.Launch{}, nil, err |
| } |
| + if !owner { |
| + if err := certified.RequireAction(release.BuildManifest(), c.Assignment.Selection.Provider, action); err != nil { |
| + return provider.Launch{}, nil, err |
| + } |
| + } |
| l, cleanup, err := r.constructDirect(ctx, selection(c.Assignment), ws.Path, action) |
| if err != nil { |
| return l, cleanup, err |
| } |
| - _, policyCertified := release.BuildManifest().CertifiedPolicyHash(l.Selection.Provider, action, l.Binding.Expected.ProviderVersion, l.Policy) |
| - if r.verifyRelease() != nil || c.Assignment.Selection.Isolation.Status != "confined" || !policyCertified { |
| + policyCertified := owner |
| + if !owner { |
| + _, policyCertified = release.BuildManifest().CertifiedPolicyHash(l.Selection.Provider, action, l.Binding.Expected.ProviderVersion, l.Policy) |
| + } |
| + if r.verifyRelease() != nil || c.Assignment.Selection.Isolation.Status != "confined" || (!owner && !policyCertified) { |
| return l, cleanup, provider.ErrPolicy |
| } |
| + l.Mode = c.Assignment.Selection.Isolation.Mode |
| l.AttemptKey = attemptKey(c.Scope, c.Handle) + "/model" |
| l.ToolSocket = proxy.SocketPath |
| return l, cleanup, nil |
| } |
| func (r *Runtime) coordinatorLaunch(ctx context.Context, c runnerproto.CoordinatorClaim, proxy *ToolProxy) (provider.Launch, func() error, error) { |
| - if err := certified.RequireAction(release.BuildManifest(), c.Brief.Selection.Provider, "coordinate"); err != nil { |
| - return provider.Launch{}, nil, err |
| + owner := r.ownerSelection(c.Brief.Selection) && c.Binding.Person == c.Brief.Selection.Person |
| + if c.Brief.Selection.Isolation.Mode != "" && !owner { |
| + return provider.Launch{}, nil, provider.ErrIdentity |
| + } |
| + if !owner { |
| + if err := certified.RequireAction(release.BuildManifest(), c.Brief.Selection.Provider, "coordinate"); err != nil { |
| + return provider.Launch{}, nil, err |
| + } |
| } |
| work, err := os.MkdirTemp(r.cfg.WorkspaceRoot, "coordinator-") |
| if err != nil { |
| @@ -98,17 +117,14 @@ func (r *Runtime) coordinatorLaunch(ctx context.Context, c runnerproto.Coordinat |
| if err != nil { |
| return l, cleanup, err |
| } |
| - if r.verifyRelease() != nil || sel.Isolation.Status != "confined" || !releaseCertifiedCoordinator(l) { |
| + if r.verifyRelease() != nil || sel.Isolation.Status != "confined" || (!owner && !certified.CoordinatorLaunchCertified(l)) { |
| return l, cleanup, provider.ErrPolicy |
| } |
| + l.Mode = sel.Isolation.Mode |
| l.AttemptKey = attemptKey(c.Scope, c.Handle) + "/coordinator" |
| l.ToolSocket = proxy.SocketPath |
| return l, cleanup, nil |
| } |
| -func releaseCertifiedCoordinator(l provider.Launch) bool { |
| - _, ok := release.BuildManifest().CertifiedPolicyHash(l.Selection.Provider, "coordinate", l.Binding.Expected.ProviderVersion, l.Policy) |
| - return ok |
| -} |
| func (r *Runtime) discoverNamespaces(ctx context.Context) ([]runnerproto.ConnectionReport, error) { |
| bs, err := loadDirectBindings(r.cfg.AccountBindingsPath) |
| @@ -119,7 +135,7 @@ func (r *Runtime) discoverNamespaces(ctx context.Context) ([]runnerproto.Connect |
| manifest := release.BuildManifest() |
| installed := r.verifyRelease() == nil |
| for _, b := range bs { |
| - report, err := certified.ConnectionReport(ctx, b, manifest, installed, func(action string) (provider.Launch, func() error, error) { |
| + report, err := certified.OwnerConnectionReport(ctx, b, manifest, installed, func(action string) (provider.Launch, func() error, error) { |
| work, err := os.MkdirTemp(r.cfg.WorkspaceRoot, "preflight-") |
| if err != nil { |
| return provider.Launch{}, nil, err |
| @@ -157,3 +173,12 @@ func (r *Runtime) discoverNamespaces(ctx context.Context) ([]runnerproto.Connect |
| func (r *Runtime) verifyRelease() error { |
| return release.BuildManifest().VerifyInstalled(map[string]string{"claude": r.cfg.ClaudePath, "codex": r.cfg.CodexPath, "codex-code-mode-host": r.cfg.CodexCodeModeHostPath, "bwrap": r.cfg.bwrap(), "equipo-tool-proxy": r.cfg.toolProxy()}) |
| } |
| + |
| +func (r *Runtime) ownerSelection(s runnerproto.Selection) bool { |
| + if r.api == nil { |
| + return false |
| + } |
| + r.api.mu.Lock() |
| + defer r.api.mu.Unlock() |
| + return certified.OwnerRoute(r.api.bearer.Person, r.api.bearer.RunnerID, s) |
| +} |
diff --git a/internal/runnerproto/types.go b/internal/runnerproto/types.go| index 753e818c..337cf116 100644 |
| --- a/internal/runnerproto/types.go |
| +++ b/internal/runnerproto/types.go |
| @@ -64,7 +64,7 @@ type ErrorResponse struct { |
| const ( |
| CleanupAudience = "cleanup" |
| - LongPollSeconds = 25 |
| + LongPollSeconds = 2 |
| RenewSeconds = 15 |
| MaxActionBytes = 64 << 10 |
| MaxEventBytes = 16 << 10 |
| @@ -121,6 +121,7 @@ type ConnectionRouting struct { |
| } |
| type ConnectionReport struct { |
| + OwnerMode bool `json:",omitempty"` |
| LauncherVersion, BwrapVersion, PolicyVersion string |
| TrialReady bool |
| ProviderVersionSource string |
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json| index 6e44b4b9..04e3c276 100644 |
| --- a/scripts/runner-reference-allowlist.json |
| +++ b/scripts/runner-reference-allowlist.json |
| @@ -4276,34 +4276,6 @@ |
| "count": 1, |
| "reason": "Retained historical storage or decoding field; it confers no launch authority." |
| }, |
| - { |
| - "path": "internal/equipo/connections.go", |
| - "line_sha256": "373d2b48654cf5243a8f245e916a1703c5bfced4be31a95b662828363e332084", |
| - "match": "Paseo", |
| - "count": 2, |
| - "reason": "Rejects or invalidates legacy report authority; eligibility requires a certified direct tuple." |
| - }, |
| - { |
| - "path": "internal/equipo/connections.go", |
| - "line_sha256": "0718294e9c1eeb01e7a1361bdc6ac9bf8f4dbdf441b9f12db80b83518f7bcb47", |
| - "match": "Paseo", |
| - "count": 1, |
| - "reason": "Rejects or invalidates legacy report authority; eligibility requires a certified direct tuple." |
| - }, |
| - { |
| - "path": "internal/equipo/connections.go", |
| - "line_sha256": "0718294e9c1eeb01e7a1361bdc6ac9bf8f4dbdf441b9f12db80b83518f7bcb47", |
| - "match": "Trial", |
| - "count": 1, |
| - "reason": "Rejects or invalidates legacy report authority; eligibility requires a certified direct tuple." |
| - }, |
| - { |
| - "path": "internal/equipo/connections.go", |
| - "line_sha256": "9553588565009dfb8b7ce242f36c2d94bbee99da2f5470bf8408b38af0a3b419", |
| - "match": "Paseo", |
| - "count": 1, |
| - "reason": "Rejects or invalidates legacy report authority; eligibility requires a certified direct tuple." |
| - }, |
| { |
| "path": "internal/equipo/connections.go", |
| "line_sha256": "fa536f104649f70d89ca05cb9f0bb96f79d3a45529d6328f834d8dc0586aba3b", |
| @@ -5270,20 +5242,6 @@ |
| "count": 1, |
| "reason": "Read-only display of historical consent or tainted evidence; enabling forms were removed." |
| }, |
| - { |
| - "path": "internal/equipo/templates/task_card.html", |
| - "line_sha256": "bd21869f5d81f7d49d49bdab4e4b4c2b0908c29f19a93726ded3a6f40d18ef5c", |
| - "match": "trial", |
| - "count": 4, |
| - "reason": "Read-only display of historical consent or tainted evidence; enabling forms were removed." |
| - }, |
| - { |
| - "path": "internal/equipo/templates/task_card.html", |
| - "line_sha256": "bd21869f5d81f7d49d49bdab4e4b4c2b0908c29f19a93726ded3a6f40d18ef5c", |
| - "match": "Trial", |
| - "count": 1, |
| - "reason": "Read-only display of historical consent or tainted evidence; enabling forms were removed." |
| - }, |
| { |
| "path": "internal/equipotest/approval_once_test.go", |
| "line_sha256": "484de8d436b4c0011083faf8fe0fb0f0c875c59b2cfb388f9db296ab07762718", |
| @@ -7083,13 +7041,6 @@ |
| "count": 1, |
| "reason": "Existing official native runner account-login command in the copy catalog." |
| }, |
| - { |
| - "path": "internal/equipo/templates/connections.html", |
| - "line_sha256": "31657bcc0c461b756221f0110fe7925cdbf51ccd4851e35d5ec18a38c9f8ef0d", |
| - "match": "trial", |
| - "count": 1, |
| - "reason": "Existing isolation label partial retained beside the account-maintenance state." |
| - }, |
| { |
| "path": "internal/runner/provider/login.go", |
| "line_sha256": "da193333198730752996cb5d0094e23f5e2bd57d28b0181f399d7811cadb574f", |
| @@ -9925,13 +9876,6 @@ |
| "count": 1, |
| "reason": "Opt-in local end-to-end harness builds and runs the retained production runner executable in scratch storage." |
| }, |
| - { |
| - "path": "internal/e2elivetest/e2e_live_test.go", |
| - "line_sha256": "f11c813f4b7dc3f2f2bc3be850195594d64359b15d6394f17cd10dc9a7779ef8", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Opt-in local end-to-end harness builds and runs the retained production runner executable in scratch storage." |
| - }, |
| { |
| "path": "internal/equipo/static/chat-send.js", |
| "line_sha256": "24e6c89454841a23dce8540bb6058174baf37761b31bfb8d95a07aeab78ef5f1", |
| @@ -10015,5 +9959,68 @@ |
| "match": "Node", |
| "count": 1, |
| "reason": "Browser DOM node operations in optimistic chat or its tests; no external runtime." |
| + }, |
| + { |
| + "path": "internal/equipo/connections.go", |
| + "line_sha256": "0f7f2e64554e8eb66d4706757a1dce1c7504a85054a31e27d47ebba139857614", |
| + "match": "Paseo", |
| + "count": 1, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| + }, |
| + { |
| + "path": "internal/equipo/connections.go", |
| + "line_sha256": "0f7f2e64554e8eb66d4706757a1dce1c7504a85054a31e27d47ebba139857614", |
| + "match": "Trial", |
| + "count": 1, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| + }, |
| + { |
| + "path": "internal/equipo/ownermode/report.go", |
| + "line_sha256": "373d2b48654cf5243a8f245e916a1703c5bfced4be31a95b662828363e332084", |
| + "match": "Paseo", |
| + "count": 2, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| + }, |
| + { |
| + "path": "internal/equipo/ownermode/report.go", |
| + "line_sha256": "9553588565009dfb8b7ce242f36c2d94bbee99da2f5470bf8408b38af0a3b419", |
| + "match": "Paseo", |
| + "count": 1, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| + }, |
| + { |
| + "path": "internal/equipo/templates/connections.html", |
| + "line_sha256": "7d70e15d5b3f7ab7f80bf887fb3670090ed16239b95304c5228ad339416e9b0c", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| + }, |
| + { |
| + "path": "internal/equipo/templates/task_card.html", |
| + "line_sha256": "60b6fcc845e3cb2d2352abea2cca0dc77b95c3fec54baa2686c68ab3a0b32adc", |
| + "match": "Trial", |
| + "count": 1, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| + }, |
| + { |
| + "path": "internal/equipo/templates/task_card.html", |
| + "line_sha256": "60b6fcc845e3cb2d2352abea2cca0dc77b95c3fec54baa2686c68ab3a0b32adc", |
| + "match": "trial", |
| + "count": 4, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| + }, |
| + { |
| + "path": "internal/e2elivetest/e2e_live_test.go", |
| + "line_sha256": "d753919b59e44f2517c91334dd1a5c24c0307805c8ee3d626534737ca6c3aeac", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| + }, |
| + { |
| + "path": "internal/equipo/templates/conversation_card.html", |
| + "line_sha256": "c4675b2a4918c364b15f30a39ecec979a6a0963f87ce14fef3fd974ba59b4ab2", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Owner-mode implementation retains direct runner containment and historical isolation labels; harness references describe local verification." |
| } |
| ] |