Skip to content

Code reads receive their authorized organization - #913

Merged
zlareb1 merged 2 commits into
mainfrom
fix/mcp-code-org-default
Nov 18, 2026
Merged

zlareb1 merged 2 commits into
mainfrom
fix/mcp-code-org-default

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Related: #868

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Code reads with an omitted organization use the organization already approved by authorization over HTTP and MCP. Calls no longer fail when the token supplies the organization and the deployment has no default code organization.

Why

Code input models default an omitted org to an empty string. The shared gate resolves the authorized organization from the request, code-plane default or verified token, but its handoff fills only the namespace. A handler receiving the empty organization then refuses the call when no code-plane organization is configured. MCP tool schemas omit org, so a client following the advertised schema encounters this failure.

For read-only operations, the handoff copies an absent optional organization from the authorized target. Code calls keep their repository namespace and never inherit the caller's personal memory namespace.

Scope and risk

The shared post-authorization handoff fills a read-only operation's optional organization and preserves explicit values. Writes retain their existing validated organization and canonical idempotency hash so a request can replay across adjacent builds. Existing namespace filling also remains in place for writes. Target selection, validation of required fields, namespace grants, cross-organization checks and connection-header precedence keep their existing rules. HTTP and MCP use the same helper. The architecture page describes this contract.

Compatibility, rollout and rollback

  • Wire: no operation, field, schema or setting changes.
  • Operator steps: deploy the server update. No plugin update, credential change, migration or re-index is required.
  • Rollback: reverting restores the omitted-organization refusal; stored data is unchanged.

Tests

  • Eight regressions fail before the fix and pass after it: code.symbol, code.callers, code.search and code.impact over HTTP and MCP with an explicit code namespace and omitted organization.
  • pytest tests/unit/test_code_transport_target_org.py -q: 32 checks pass, including deployment and explicit organization precedence, missing grants, cross-organization refusal, an unresolved organization, connection headers, auth-disabled defaults and required fields.
  • Four write replay regressions reproduce IDEMPOTENT_CONFLICT before the read-only restriction and replay the exact pre-upgrade hash after it. Their MCP routes retain OP_NOT_ON_MCP; no hidden write is exposed. Existing cross-transport replay checks also pass.
  • The focused transport, authorization and replay selection passes all 92 checks. The changed architecture page's link check and two public-copy checks pass.
  • Ruff, the function-length gate, the three changed transport modules' mypy check and whitespace checks pass. Full suites remain for CI; no live backend or provider is used by these checks.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex prepared the source fix, transport regressions and documentation; the authorization handoff and neighboring cases were checked.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Full formatting, lint, type, unit and integration checks pass in CI on this head.
  • No generated API, schema or plugin files require changes.
  • No migration is added.
  • No plugin version or frontend changes are required.
  • Documentation describes the identity handoff and operator steps.
  • Public text contains no deployment details or credentials.
  • Commits are signed off.

An omitted optional organization remains blank in the validated code input even when authorization resolves it from the token. Copy that approved target into the handler input without importing the caller memory namespace or replacing explicit identity.

Signed-off-by: zlareb1 <[email protected]>
Idempotent writes retain their validated organization so cached request hashes match across adjacent builds. Pass the operation into the shared target handoff while preserving existing namespace filling and explicit identity.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 81f63d4 into main Nov 18, 2026
49 checks passed
@zlareb1 zlareb1 mentioned this pull request Nov 18, 2026
6 tasks done
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