Skip to content

org: let the team set who approves a tool call and who starts a chat that is not running - #2927

Merged
AbirAbbas merged 6 commits into
org/mainfrom
org/configurable-choices
Nov 25, 2026
Merged

AbirAbbas merged 6 commits into
org/mainfrom
org/configurable-choices

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Draft, base org/main (the hosted org feature line, #2903). Not for dev.

The owner left four product choices on the hosted org line to the team and asked that they be adjustable without changing today's behaviour. Two of them get a policy setting, two do not. One of them turned out to hide a hole, which this PR closes.

The hole. The docs said a command that needs approval waits for the owner. That was true for the ResolveConsent frame only. A guest holding answer (the edit role) could send the chat's approval question an answer through ResolveQuestion, whose payload names the question's kind, and the guest wire never read it. The chat then ran the command as its owner. The first test below fails on the old pump. It is its own commit (a6f85d0) so it can be separated. This is the one place the default is not byte-for-byte what the code did, only what the docs said.

The settings (both under the policy's chats section beside move_by, optional, validated, absent from the default policy's JSON):

  • chats.approvals_by: owner (default) or answer. With answer, a person who holds answer may allow one tool call once or refuse it. Allowing a tool for the rest of the chat stays with the owner.
  • chats.wake_by: view (default, today), run or owner. Controls who may start a shared chat that is not running. Anyone else is told to ask its owner and nothing is started.

Operators set them with PUT /v1/org/policy.

Validation contract

  • With a setting absent or at its default, every existing behaviour and test is unchanged. The default wake rule reads nothing extra from the chats' host.
  • With a setting at its other value, the other behaviour happens through the real WebSocket door, in a test on the handler with a real store; the only stand-in is the chats' host, which records what reaches it.
  • An invalid value is refused when the policy is written (422), with a sentence that names the allowed words.
  • GET /v1/org/policy shows the setting once set.

Tests, by contract item:

  • default and owner keep both approval doors with the owner: TestApprovalsByOwnerKeepsAToolApprovalWithTheOwnerOnEveryDoor
  • answer lets allow-once and refuse through and nothing wider: TestApprovalsByAnswerLetsAnAnswererAllowOnceOrRefuseAndNothingWider
  • a change reaches an open window on the next heartbeat: TestApprovalsByReachesAnOpenWindowOnTheNextHeartbeat
  • the approver is the asker: TestApprovalsByAnswerNamesTheApproverAsTheAsker
  • validation, operator only, GET: TestChatsSettingsAreValidatedAndShownByThePolicy, TestChatApprovalAndWakeRulesAreTodaysBehaviourUntilTheOrganizationChangesThem, TestChatApprovalAndWakeRulesTakeOnlyTheirWords, TestOrgPolicyStoredWithoutApprovalAndWakeRulesReadsAsToday
  • wake_by default asks the host nothing extra: TestWakeByViewIsTodaysBehaviourAndAsksTheHostNothingExtra
  • run, owner, turning it back, bots: TestWakeByRunKeepsAWatcherFromStartingAChatThatIsNotRunning, TestWakeByOwnerLeavesStartingAChatToItsOwner, TestWakeByTurnsBackToViewAndOpensTheChatAgain, TestWakeByDoesNotLetABotWithoutRunStartItsCreatorsChat
  • the manual answers each question: TestHostedChatQuestionsReachTheirPage

Docs: docs/organizations.md, deploy/org/README.md, docs/design/app-v3/PROTOCOL.md, and two new sections in the chat manual (organization-hosted-sessions.md).

The four choices

# Choice Setting Issue
1 A guest's send or steer waits while the owner's window holds the keyboard none: it needs a design for how two people's input interleaves #2928
2 Tool approvals stay with the owner chats.approvals_by: owner (default), answer #2929
3 A guest opening a stopped chat starts it in the owner's slot, a view guest's --once included chats.wake_by: view (default), run, owner. The --once lock-out under the default is not fixed #2930
4 A new share reaches an open desktop window only on focus or panel open none: the server already emits the event, the engine's relay drops it #2931 (engine half), desktop tracker #905

Gates

Local, niced: make pr-ready BASE=origin/org/main exit 0 (build, vet on linux and windows, gofmt, packed manual, change entry, the manual gates, the laws, then fresh tests of the touched packages: internal/factory/acl, serve (350 s), store, internal/manual). The change entry passes make changelog-check. No full internal/tui3 or internal/session suite was run.

🤖 Generated with Claude Code

AbirAbbas and others added 5 commits November 25, 2026 09:44
…at that is not running

The organization's policy has a `chats` section beside `hosting`, which so far held one rule, `move_by`. Two more rules
for a chat that runs on the organization's own server and is shared with other people become settings there, each
optional, each reading as what the server did before it existed:

- `chats.approvals_by`: `owner` (also what an absent value means) or `answer`. The wire that enforces it is the next
  commit.
- `chats.wake_by`: `view` (also what an absent value means), `run` or `owner`. Same.

Both are validated when the policy is written (422 with a sentence that names the allowed words), written under `chats`
by their own names, and absent from the default policy's JSON, so a policy stored before they existed reads and saves
unchanged.

Tests: TestChatApprovalAndWakeRulesAreTodaysBehaviourUntilTheOrganizationChangesThem,
TestChatApprovalAndWakeRulesTakeOnlyTheirWords (acl), TestOrgPolicyStoredWithoutApprovalAndWakeRulesReadsAsToday (store).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…approvals_by lets an organization allow it

The hosted-chat guest wire checks each call a shared chat's guest sends against a table of methods and the verb each one
needs. The table keeps the tool-approval frame, `ResolveConsent`, with the owner under every role, and the docs said a
command that needs approval waits for the owner. But a tool approval is also a question the chat asks, and the answer to
any question is `ResolveQuestion`, which the table lets a person who holds `answer` send (the `edit` role does). Its
payload names the question's kind, and the guest wire never looked: an `edit` guest could send an answer of kind
`consent` with the key for "allow once" or "allow always" and the chat ran the command as its owner. Seen through the
real wire in TestApprovalsByOwnerKeepsAToolApprovalWithTheOwnerOnEveryDoor, which fails on the code before this commit.

Now the wire reads a `ResolveQuestion` payload with the engine's own decoder into the engine's own type, and a consent
answer follows the new policy setting `chats.approvals_by`:

- `owner`, also what an absent setting means: refused with the sentence the older frame already gets ("This chat is
  shared with you. Only its owner can do that."). Every other answer, and every other call, is unchanged.
- `answer`: a person who holds `answer` may allow one call once, or refuse it, through either door. Allowing a tool for
  the rest of the chat, putting the approval away, revising an answer and the chat's own approval setting stay with the
  owner. A person who cannot answer is still told so in the words they always read.

The setting is read again on every heartbeat with the verbs, so a policy change reaches a window that is already open.
A guest's approval is noted as the chat's latest asker, the way an answer already was.

Tests: TestApprovalsByOwnerKeepsAToolApprovalWithTheOwnerOnEveryDoor,
TestApprovalsByAnswerLetsAnAnswererAllowOnceOrRefuseAndNothingWider, TestApprovalsByReachesAnOpenWindowOnTheNextHeartbeat,
TestApprovalsByAnswerNamesTheApproverAsTheAsker, TestChatsSettingsAreValidatedAndShownByThePolicy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hat is not running

Opening a shared chat that is not running starts it, for its owner and in their place among the chats they may have
running. Today anyone who can see the chat does that, and a `view` guest's `codeaf chat --org --once` is one way: it
starts the chat in one-shot mode and is then refused when it tries to send, and the owner's own window reads "already
open in a different interactive or headless mode" until the chat stops or idles.

The organization's policy now has `chats.wake_by`:

- `view`, also what an absent setting means: anyone who can see the chat opens it. Nothing changes, and the organization
  server asks the chats' host for nothing it did not ask for before.
- `run`: only a person who may send messages in the chat starts it. A person who can only watch is told "This chat is
  not running. Starting it takes permission to send messages in it. Ask its owner." and the host's wire door is never
  reached, so nothing is started.
- `owner`: only the chat's owner starts it (a bot acting for them does not count). Others read "This chat is not running.
  Only its owner can start it. Ask them to open it."

A chat that is already running opens for everyone who can see it under every setting. The owner's own window is the
byte-copying proxy and no setting touches it. If the chat's state cannot be read, a restricted setting refuses with the
"not answering" sentence instead of guessing. The rule is checked when the window opens; a chat that stops in the
instant between the check and the connection can still be started by the guest.

Tests: TestWakeByViewIsTodaysBehaviourAndAsksTheHostNothingExtra, TestWakeByRunKeepsAWatcherFromStartingAChatThatIsNotRunning,
TestWakeByOwnerLeavesStartingAChatToItsOwner, TestWakeByTurnsBackToViewAndOpensTheChatAgain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestWakeByDoesNotLetABotWithoutRunStartItsCreatorsChat: a view-scoped bot is refused on its creator's chat that is not
running under both owner and run, and a bot that may run chats starts it under run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto the manual

docs/organizations.md and deploy/org/README.md describe both settings where the policy is described, and the two known
limits that mention them (a guest's `--once` starting a chat for its owner, and a tool approval staying with the owner)
now say what the setting changes. The app protocol's policy shape lists the two fields.

The chat's own manual has a section for each setting on the hosted-chats page, in the words someone would ask with, and
the refusal, keyboard and sharing sections name the new sentences. Probes keep each question on its page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e owner, and two policy settings loosen that

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AbirAbbas
AbirAbbas merged commit dc1d5f8 into org/main Nov 25, 2026
22 checks passed
@AbirAbbas
AbirAbbas deleted the org/configurable-choices branch November 25, 2026 15:21
AbirAbbas added a commit that referenced this pull request Nov 25, 2026
…ack (#2903)

The hosted organisation line: a team-mode org server deciding every request through one access model (verbs, roles, grants and policy in SQLite), hosted chats run by the sessionhost under a per-chat uid inside a Landlock fence with minted model bearers, sealed keys and a git helper, shared chats acting through verbs, bots owned by their creator, the Hosting and chats policy settings, and a self-hosting stack (deploy/org Docker Compose, published images behind a leak gate, a Railway path).

Consolidates #2894 #2895 #2896 #2898 #2899 #2900 and the follow-ups #2904 #2905 #2907 #2908 #2910 #2911 #2912 #2913 #2915 #2916 #2918 #2927 #2936 #2944. Proven by the full suite, a keyless Compose smoke, a hostile wire client, sandbox escape probes, a real-model run and a production-style install from the published images.

Co-Authored-By: Santosh kumar <29346072+santoshkumarradha@users.noreply.github.com>
Co-Authored-By: ZeroPoint95 <329227198+ZeroPoint95@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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