Skip to content

fix(acp): align unauth tenantId fallback with SYSTEM_TENANT (#3237)#3239

Merged
OneStepAt4time merged 1 commit into
developfrom
fix/3237-acp-tenant-scope
May 12, 2026
Merged

fix(acp): align unauth tenantId fallback with SYSTEM_TENANT (#3237)#3239
OneStepAt4time merged 1 commit into
developfrom
fix/3237-acp-tenant-scope

Conversation

@OneStepAt4time

Copy link
Copy Markdown
Owner

Summary

  • Aligns four acpBackend.sendPrompt(...) call sites to use the SYSTEM_TENANT constant ('_system') as the unauth fallback, matching the acpBackend.createSession(...) create scope. Previously they fell back to the literal 'system', so the lookup missed and prompt delivery failed for every ACP-routed request without an authenticated tenant.
  • Affected routes: POST /v1/sessions (initial prompt + idle-reuse branch), POST /v1/sessions/:id/send, POST /v1/sessions/:id/command.
  • Adds the missing SYSTEM_TENANT import to src/routes/session-actions.ts.

Closes #3237

Reproduction (before fix)

AEGIS_DISABLE_AUTH=true node dist/cli.js
POST /v1/sessions { "workDir": "...", "prompt": "..." }
→ promptDelivery.delivered = false, error: "ACP session not found in the requested tenant and owner scope: <id>"

ACP child + Claude CLI spawn correctly; only the JSON-RPC session/prompt lookup fails because the scope doesn't match the create-time scope.

After fix (locally validated)

Two-round trip on develop + this patch, with Claude Code 2.1.139:

POST /v1/sessions { prompt: "Reply with exactly: ROUND_1_OK" }
  → promptDelivery.delivered = true
  → JSONL assistant text: ROUND_1_OK
POST /v1/sessions/<id>/send { text: "Now reply with exactly: ROUND_2_OK" }
  → { ok: true, delivered: true, attempts: 1 }
  → JSONL assistant text: ROUND_2_OK

Test plan

  • CI green on the affected runners (Linux + macOS).
  • Manual: with AEGIS_DISABLE_AUTH=true, POST /v1/sessions with a prompt returns promptDelivery.delivered: true and the JSONL transcript contains the assistant reply.
  • Manual: POST /v1/sessions/:id/send and POST /v1/sessions/:id/command deliver in the same unauth path.
  • Regression: authenticated tenant flows continue to use req.tenantId and are unchanged.

Gate notes (pre-existing, not introduced here)

npm run gate fails on dashboard:tokens:gate and dashboard:clickable:gate against pristine origin/develop@613fc30, and on three unrelated test files (config-yaml.test.ts, server-core-coverage.test.ts, e2e/e2e-dogfood.test.ts). All three are unrelated to ACP / sendPrompt / routes/sessions.*. Confirmed by running on pristine origin/develop without this patch.

This PR's changed paths (src/routes/sessions.ts, src/routes/session-actions.ts) pass tsc --noEmit and npm run build cleanly.

Aegis version

Developed with: v0.6.7-preview.1

acpBackend.createSession stores the session under SYSTEM_TENANT
('_system') when req.tenantId is undefined, but four sendPrompt call
sites fell back to the literal 'system'. The lookup missed every time
the request didn't carry an authenticated tenant, breaking every
ACP-routed prompt and /send/command in auth-disabled mode.

Routes affected:
- POST /v1/sessions (initial prompt + idle-reuse branch)
- POST /v1/sessions/:id/send
- POST /v1/sessions/:id/command

Closes #3237

@aegis-gh-agent aegis-gh-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved -- critical bug fix, all 9 merge gates pass.

Root cause: 4 sendPrompt() call sites used ?? 'system' but createSession() uses SYSTEM_TENANT ('_system'). The mismatch broke every unauthenticated ACP prompt delivery — this is the dogfooding blocker.

Fix: Replace all 4 fallbacks with SYSTEM_TENANT constant + add missing import. 2 files, 5 additions, 4 deletions.

All CI green. Locally validated with two-round trip. Pre-existing gate failures documented as unrelated.

This is the fix that makes ACP actually work for the dev team. Ship it.

@OneStepAt4time OneStepAt4time merged commit cd73cbf into develop May 12, 2026
18 checks passed
@OneStepAt4time OneStepAt4time deleted the fix/3237-acp-tenant-scope branch May 12, 2026 11:04
OneStepAt4time added a commit that referenced this pull request May 12, 2026
CHANGELOG entries for: #3230 (prune timer), #3231 + #3238 (aria i18n), #3232 (quickstart), #3233 + #3235 (competitive threat), #3239 (ACP tenantId fix).
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