Skip to content

fix(sandbox): warn when a task's egress allowlist comes up empty - #833

Open
hakarrr wants to merge 3 commits into
BaaRai:mainfrom
hakarrr:fix-empty-egress-warning
Open

hakarrr wants to merge 3 commits into
BaaRai:mainfrom
hakarrr:fix-empty-egress-warning

Conversation

@hakarrr

@hakarrr hakarrr commented Dec 2, 2026

Copy link
Copy Markdown

Problem

A task spawned from chat (orchestration spawn_task) inherits the operator's company selection as a task_scope row stamped source='agent', approved_by_operator=false. taskSandboxRunInfo (server/sandbox.go) builds the per-task egress allowlist only from operator-approved rows, so the proxy starts with an EMPTY allowlist and denies every connection (403 on in-scope targets). Nothing in the UI says why: the task still shows the company link, the agent's self-repair (add_task_scope / add_company_scope) writes more unapproved rows, and even an approval cannot help the running task because the allowlist freezes at spawn. The HTTP POST /api/tasks path approves the same selection, so the two operator surfaces silently disagree. Second user confirms in the issue comments.

Behavior change

Loud, not silent (the issue's suggested minimum fix; no approval or egress logic changes, no security-posture change):

  • server/sandbox.go: new emptyEgressScopeWarning(pg, tid, info) returns a warning when the computed allowlist is empty AND the task has at least one task_scope row. Empty string otherwise (approved scope, or genuinely scopeless task).
  • server/engine.go (Engine.Run, sandbox-required path, next to the existing sandbox-unavailable / sandbox=off system notices): when the warning is non-empty, log it and append a Kind:"system", IsError:true activity row to the task feed: "sandbox egress empty: this task has N scope row(s), but none currently grant egress, so every connection from the sandbox will be denied. Agent-added scope is coverage-only until an operator approves it, and the allowlist freezes at spawn: approve the scope, then restart the task."

Deliberately NOT included: the issue's option 1 (server-side conversations.company_id binding and approving chat-selected companies) is a larger architectural change for maintainers to weigh.

What was tested

New PG-backed test TestEmptyEgressScopeWarning (server/sandbox_empty_egress_warning_test.go, same ARTEX_PG_DSN harness as the existing sandbox scope tests):

  1. Trap case: task created with CompanyScopeByAgent: true (exactly the spawn_task path) - allowlist empty, warning present and points at operator approval.
  2. Operator-selected company at creation - allowlist non-empty, no warning.
  3. Scopeless task - allowlist empty by design, no warning.

Fail-first evidence: on the clean tree the test fails to build (undefined emptyEgressScopeWarning); with the implementation it passes; with the helper mutated to always return "" the test fails at the case-1 assertion; restored, green again.

Validation run locally (Postgres 14.11):

  • go test ./server/ -run 'TestEmptyEgressScopeWarning|TestSandboxScopeDrift|TestSandboxCompanyEgress' -count=1 - all 3 pass.
  • Full go test ./server/ -count=1 - only pre-existing environment failure is TestConnectWithoutPasswordRealPG (expects password auth; local test PG uses trust auth). Same failure reproduced on the clean tree, unrelated to this change.
  • go vet ./server/ and go build ./... clean.
  • Patch verified to apply cleanly on a pristine worktree of e38f58d.

Addresses #830.

hakarrr and others added 3 commits December 2, 2026 17:44
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant