Skip to content

org: hosted organisations — org server, hosted chats, self-hosting stack - #2903

Merged
AbirAbbas merged 184 commits into
devfrom
org/main
Nov 25, 2026
Merged

AbirAbbas merged 184 commits into
devfrom
org/main

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

The hosted organisation line, landing on dev: a team-mode org server with one access model, hosted chats in a per-chat sandbox, bots, policy, and a self-hosting stack (Docker Compose, published images, a Railway path). Org mode only runs against a team server or codeaf chat --org; with no organisation, behaviour is unchanged. This merges into dev only; stable stays on the release before it.

What org/main holds

One PR replaces the six drafts it consolidates: #2894, #2895, #2896, #2898, #2899 and #2900.

Merged into this line since it was cut

PR What
#2904 the desktop app opens hosted chats on an organization's server (engine side)
#2905 hosted chat rows carry the asker's verbs from the server
#2907 full-suite reds fixed, test races, a knowledge opt-in race, image gates on pull requests
#2908 docs: organizations, an operator entry point, a manual that matches the code
#2910 deploy/org/.env ignored, Compose builds from source, chats.move_by
#2911 Railway path corrected after a fresh install walk (14 doc errors, including the model key's variable name)
#2912 test-round fixes: removal now ends a person's model bearers, a reused uid starts clean, reconnect works, a guest cannot wake a removed person's chat
#2913 websocket origin check, bots stay in scope, hosted limits written down
#2915 Compose path walked as a stranger: 17 doc errors fixed, operator-link.sh and gitstub profile fixes, --org in --help
#2916 a removal the chats' host could not finish is retried by itself until it confirms, across restarts; no plain-HTTP warning behind a trusted proxy
#2918 test only: the routing beat tests wait for their beat to end, fixing a synctest bubble panic that failed ci-full on this line
#2927 closes a hole where a guest with answer could approve a tool call through the question door; adds chats.approvals_by (owner by default, or answer) and chats.wake_by (view by default, run or owner)
#2936 a hosted chat at its spending limit reads the organization's sentence, not "the account cannot pay"; the door marks its own errors and a cap is written as the number it is
#2944 fixes from the production run-through: removing a person who joined by link drops them from People and ends every grant; empty person folders go with the last chat; the Railway template script works on the current CLI; a Railway backup recipe; the sandbox's missing toolchain and the factory's direct model spend written down as limits (#2940, #2941)

Test round

Layer Result
Full CI suite (ci-full) on org/main green at 0207f82f89
Keyless Compose smoke on a fresh stack 261 pass, 0 fail, including after a restart of every service
Hand end-to-end in a real terminal against Compose (claim, invite, share at each level, revoke mid-session, bots, spend and audit rows) pass; the gaps it found were fixed in #2912
Hostile wire client (each verb level sends every frame above its grant, replayed tokens, swapped chat ids, a bot reaching past its creator) 267 pass, 0 fail
Sandbox escape probes through a hosted chat's own tool, each with a fence-off control and planted canary keys every probe refused; the sessionhost refuses to start without Landlock
Spend caps under concurrent requests no overspend
Desktop app against the Compose org (Ubuntu runner, WebKit driver, xvfb), in the desk repository pass
Fresh Railway install from these sources all services healthy; proof script passes
Sandbox escape probes rerun on the Railway install, through a hosted chat's own tool, each with a fence-off control and canary keys 63 pass, 0 fail
Compose newcomer walk (README only) pass after #2915
Real model through the org model door (gpt-4o-mini), with a hash-only key-leak scan pass; 0 matches in 7,856 candidates
Production-style install from the published Docker Hub images on a fresh Railway project, with a real model (Claude Sonnet 5): real coding task, live sharing, bots, SWE-AF job to the PR step, spend reconciled to the provider, every service redeployed, removal, escape harness, backup and restore 13 of 13 steps pass; escape harness 67/0 against the images; findings fixed in #2944 or filed
Desktop app against that cloud org (desk e2e, external-org mode) 30 pass, 0 fail

Not yet tested: the metadata-address guardrails on EC2 or GCE (#2923), pushing through the git door with a real token (#2942), Docker on native Linux and Windows.

Known limits, written down rather than fixed

🤖 Generated with Claude Code

AbirAbbas and others added 30 commits November 23, 2026 23:59
A chat is private by default (the policy's default for the kind, and what
backfill registered), but GET /v1/workstreams/{id}/chats listed every other
person's chat title, owner, state and last activity to anyone who could see the
workstream (v2 ruling C10), whatever the chat's own visibility. Abir's call of
2026-11-24: chats are private by default, and a private chat is hidden from
shared lists. The list now asks the one decider whether the viewer may view each
chat, so only the owner and the people it is shared with see a private one; the
operator sees nothing private; a chat with no registry row is hidden.

An organization that wants the old listing sets the policy's default for chats
to owner or org; it applies to chats made after the change.

CONTRACT CHANGE: two tests asserted the old listing (the C10 block of
TestMySpaceChatsRunOnTheServerAndStayPrivate and
TestContractI9SharedWorkstreamChatListKeepsOnlyMetadata); they now assert that
the chat is hidden until shared, then listed with metadata only. The new
TestContractA* tests are derived from the lane's validation contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2890 dropped santosh/work's chats.read method (#2650) because dev's
agents.entries already follows a saved remote head under the chats.read hello
word. Abir's call of 2026-11-24: nothing Santosh added is dropped. The two are
different abilities: dev's reader fetches the whole saved transcript, this one
fetches only the transcript's own objects and the chunks under one page, into
the store a later agents.take uses.

Restored from the parent of cc9ca26 (the chunk-paged reader in cellsync and
cellstore, the furrow path verbs, syncsetup.ReadChatPage, the engine method and
its tests), additively: the method is advertised under a NEW hello word,
chats.read.paged, and the chats.read word keeps exactly the meaning it has on
dev, so a client can tell which ability an engine has. agents.entries and its
tests are untouched. The embedded furrow is v0.3.7 again (it adds the path
verbs; its checksums match the release's SHA256SUMS); without them the word is
absent from hello, not present and failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…WE-AF and PR-AF

Each image runs a pinned artifact: codeaf from a published dev release checked against its
sha256, the AgentField control plane from its published image (built with sqlite_fts5) pinned
by digest, SWE-AF and PR-AF built from pinned commits of their public repositories. The
containers start as root only long enough to give a platform volume to the service's user,
then run as that user. The runner is the engine host that registers the factory on AgentField.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Railway's builder rejects a cache mount that has no id, and an id has to be
spelled with the service it belongs to, which no portable Dockerfile can know.
The two Go reasoners build in about a minute without the cache, so they build
the same way under Compose and on Railway.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One `docker compose up` runs the organization server, the AgentField control plane, the factory
runner, SWE-AF and PR-AF, each with a volume for its state, a health check, and a published port only
where a person has to reach it (on 127.0.0.1 unless the operator opens it). The scripted stub model is
an optional profile for a keyless smoke test. setup.sh writes .env with fresh random secrets and never
overwrites one; .env, the model keys and the organization token never enter an image.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The control plane's health check used a glibc busybox that the distroless base is too old to run, so it
is now the static musl one. The reasoner images now name the user they run as, so a platform volume is
handed to the right user and git finds its home (PR-AF was looking in SWE-AF's). The node entrypoint can
make a throwaway repository for the keyless smoke test to plan against.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
smoke.sh starts the stack against the scripted stub model and checks, section by section, that the nodes
are registered, the operator link claims the organization, a second person joins by invite, a factory
job reaches SWE-AF through AgentField with strict run-owner proofs and its plan question is answered by
the owner, and that a restart of every service keeps the people, the runs and the registrations.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ec into it

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…it was shared with

Sharing a private chat with one person used to un-private it, after which it
inherited the workstream's shares and grants, the workstream owner's share and
the operator. So sharing a chat with one person showed it, title and all, to
everyone who could see the workstream. A private registration with a live grant
on itself is now a closed private item: shares, organization visibility, inherited
grants and the operator (unless the policy lets it see private things) stay out,
and only its owner and the people its own grants name reach it. The grants list
shows those grants and the audience of its events names the same people.

Three older tests encoded the wider audience (the operator's chat list, the move
event's audience, the sweep's lapse audience) and are changed to the contract,
each with a comment saying so.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…point and never uses a fixed password

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…away, then runs unprivileged

The published image is distroless and runs as uid 65532, so a root-owned platform volume left it unable to
write its database, and the only way round was to run it as root. It now gets the same hand-off as the other
images, done with the one busybox binary it already carries for its health check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…uns as

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nt the Railway services

A link is only accepted with exactly the address the server names itself by, so rewriting the host in
the printed link broke it. The README now says what that address is on a laptop, and lists the variables
each Railway service takes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ontainer stub, not a send path

deploy/org/modelstub answers /chat/completions on purpose so the keyless smoke test spends nothing; like test/remote/stub
it is built into its own image and the product never runs it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A request from 127.0.0.1 with no credential used to act as the factory's owner on
every factory, so on a team server any program on the same machine, or any
same-machine proxy that did not add a forwarding header, was the owner. The host
config now has a `loopback_trust` key (true or false). Unset, it is on for a solo
factory, which is one person at one computer, and off for a team factory: a
credential-free local request is refused like one from any other machine, and one
with a token or a session acts as that identity. A team factory used by one
person at one computer can set it to true and gets the old behaviour back.

The forwarded-header rule holds whatever the key says: a request carrying
X-Forwarded-For, Forwarded, X-Real-Ip or X-Forwarded-Proto (even with an empty
value) is not local unless a listed proxy names a loopback client in
X-Forwarded-For. Tests cover an unlisted and a listed proxy with a remote client,
a Forwarded-only request, X-Real-Ip alone, garbage forwarding headers, and both
IPv6 loopback forms.

Worker attach keeps its own local door (as it had), so a runner on this machine
can still attach before its person signs in. Test fixtures that act as the host's
person on a team-mode handler now say so with an explicit LoopbackTrust.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… their creator

A person can make a bot (a name and, optionally, a narrower role) and gets its
`cbt_` token once, in that answer. The store keeps the sha256 of the token with
an eight-character hint and a last-used time, at most three live tokens per bot
and twenty bots per person. A request with a bot token acts as the bot: the
creator's verbs on the item right now, intersected with the organization policy's
scope for `bot:<id>` and with the role the person gave the bot, through the same
on-behalf-of evaluator Afi uses, with the creator as sponsor. Nothing is cached,
so a creator who loses a share takes it from the bot on its next request, and a
role that is later deleted means no verbs.

What a bot creates is owned by its creator and recorded as created by the bot
(kind `bot`, its id, the creator as sponsor); a chat it makes is private like any
other chat. Revoking a token, removing a bot, or the operator removing the creator
from the organization ends the credential on the next request with words that say
which; an unrecognised `cbt_` token is a 401 and never falls through to loopback
or the host's identity, and a bot token beside a session cookie is refused.

Bots are default-deny. A bot reaches workstreams and what is under them (except
the agent door, requests, drivers, jobs and imports), canvases, resources, My
space, and the policy, member, team and about reads. Everything else answers "a
bot cannot use this yet", and a bot cannot start an agent run. A bot cannot make
bots, mint or revoke tokens, or use the operator's routes. A person lists, mints
for, revokes and removes only their own bots; the operator lists every bot and may
remove any, but cannot mint a token for another person's bot.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
factory.org_bots, factory.org_bot_new, factory.org_bot_token_new,
factory.org_bot_token_revoke and factory.org_bot_remove follow the org_access
pattern: one fixed request each, with checked path segments, advertised only by an
engine that can reach an organization server. The minting answers carry the secret
once; nothing logs a request or reply body on this path. PROTOCOL.md names every
method and says the secret is shown once.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…isted to a workstream

The chat manual now says what bots are and are not (a token shown once, never more
than the person who made it, default-deny routes, no agent runs, ended with the
creator), what loopback_trust does and why a forwarded request is never local, and
adds probes in people's own words for both.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…f running open

A fence that can apply nothing used to let the command run as it was. A Require fence
returns ErrFenceRequired instead, in a sentence with none of the machine's words, so a
hosted chat's commands are confined or not run, never run open. Without Require nothing
changes, and the helper's spec is byte-identical.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Five tests drove a team-mode factory with no credential from the same computer and
relied on the old rule that such a request is the owner. They now say it with an
explicit loopback trust (a plan-revision handler, a team publish and a worker
fixture, the worker reply fixture), or, where the point is how a local client
reaches its factory, send the token from the discovery file as every client does
(the factory command test).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…LE shortens the idle windows

Both are read only by the engine door and only when set, so an engine started without them
is what it was. A hosted engine builds its own fence, which ignores jail.allow: off, because
a chat's own shell can write that file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…folder per chat

codeaf sessionhost serve|probe|health, plus the hidden helpers it re-executes as the chat's
user. The supervisor keeps five capabilities, fails closed when it cannot switch users or
confine commands, and answers its API only to the organization server's shared secret and a
named person.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…door a chat reaches its model through

/v1/hosted/sessions[/...] proxies to the sessionhost with the shared secret and the verified
person only; the wire is a reverse proxy that parses no frames. /v1/model/ takes a bearer the
server minted for one chat (twelve hours, ended on stop or delete) and adds the organization's
key itself. With CODEAF_HOSTED_URL unset neither exists and every path answers as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The thin client: the same surface as --at over a WebSocket to the organization server, the
bearer only in a header, a chat picked or made for the person, plain sentences for every
refusal. It advertises no client tools and drops the automation banner raiser, so nothing an
engine sends makes this computer write a file, run a program or open an address.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… people ask them

Where the chat runs, what stays on a person's computer, who can see a hosted chat, what the
operator of the machine can see, what happens when the person disconnects, the limits and the
refusal sentences, and how an operator turns it on. Probes in chat_hosted_test.go keep the
questions reaching the page.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Says what was true and what is true now for private chats, the shared-chat audience,
the paged remote read, loopback trust on a team server and bots, including the
sentence in the #2890 entry that is no longer true.

Co-Authored-By: Claude Sonnet 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 and others added 10 commits November 25, 2026 12:25
A refusal from the organization's model door is shaped like a provider's, so a
client could not tell the organization's own sentence from a service's failing
account. The error envelope now has a `door` field, and a refusal carrying
`door: organization` is flagged on the APIError, with OrgLimitWords giving the
organization's sentence for the limit refusals (402, payment-shaped) and false
for every other refusal. Terminal handling of the refusal is untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…number it is

Every error the organization's model door writes now carries the `door` mark, so
a client can show its sentence as written. A provider's refusal passed through
the door is not signed and keeps its own wording. The limit sentences wrote every
cap with two decimals, so a limit of a tenth of a cent read "$0.00"; a whole
number of cents keeps two places ($5.00, $0.50), anything finer is spelled by the
one door that spells a cap (teams.Money: $0.001).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s sentence

The engine's ending and the page's failure line put "<service> accepted the key
but the account cannot pay" in front of a door's limit sentence, blaming the
vendor and the person's account for a limit the organization set. A refusal the
organization's door signed is now shown as the door wrote it, with no service
name, and it no longer asks for a read of the person's own OpenRouter credits.
A provider's own payment refusal reads exactly as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nization's sentence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y hold

A person who joined through an anonymous access link and was then removed
stayed in People as "away" and kept the grants others had given them on
their chats. closeInvitesOf found invites by the handle they admitted, and
an anonymous link carries none.

Removal now marks the person's own use on every link that admitted them as
removed (the use stays spent, so the link never reopens for anyone else),
and deletes every grant that names them, whichever door they came in by.
A named invite is removed exactly as before. Joining again, by a new link
or by the old one, brings no old grants back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removing a person left an empty /chats/people/p_<hash> folder on the
volume. Deleting a chat now also tries to remove the person's folder, and
rmdir only succeeds when nothing else is in it, so another chat of theirs
stays put.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The production run found two calls that stopped the script on Railway CLI
5.71.0. `railway volume add --service <name>` is now `railway volume
--service <service ID> add`, with the ID read from the JSON `railway add`
prints (a name panics the CLI); an older CLI whose `volume add` still lists
--service gets the old form. The sessionhost limits edit had no --message,
so a terminal run waited forever at "Apply changes now?".

railway_scripts_test.sh now runs --apply against a stub CLI that records
its arguments and refuses what the real one refuses, so the exact volume
and edit calls are pinned, along with the older CLI and the fail-fast when
no service ID comes back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ecipe, two known limits

From the production run-through of the hosted organization:

- Railway volumes come out at 50 GB and the CLI has no size option; the
  README says so and gives the resize step (what was done, and what was
  not tried).
- `railway templates create` makes a draft; the README says what to do
  with it, and the script's closing note says the volumes need resizing.
- A backup recipe for Railway (`railway ssh` plus tar), with what the
  run checked on the restored scratch copy and what it did not do.
- Known limits: the chat sandbox has python3, git and curl but no pip,
  pytest, go, node, make or gcc; and SWE-AF, PR-AF and the runner call
  the model provider directly, so their spend is not in the spend table
  or any limit.
- The README and docs/organizations.md now say removal also drops a
  person from People and ends every share they hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emoval ends

The manual law, for the same change: organization-hosted-sessions gets a
section on what a hosted chat's machine has (and lacks) and one on why
SWE-AF, PR-AF and the runner are not in the spend or the limits;
inviting-people says removal works the same for an anonymous link and ends
every share. Five probes pin that the questions reach those pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AbirAbbas and others added 2 commits November 25, 2026 14:05
…cipe

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ays satisfied

The worker law reads the word "swe" in any manual page as a removed worker, and
SWE-AF tripped it. The page now names the factory's code-writing service, its
pull-request review service and the runner, and the probe asks about a factory job.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@AbirAbbas AbirAbbas changed the title DO NOT MERGE: org feature line (hosted org server, hosted chats, self-hosting stack) org: hosted organisations — org server, hosted chats, self-hosting stack Nov 25, 2026
@AbirAbbas
AbirAbbas marked this pull request as ready for review November 25, 2026 20:12
@AbirAbbas
AbirAbbas merged commit 1099e8b into dev Nov 25, 2026
77 checks passed
@AbirAbbas
AbirAbbas deleted the org/main branch November 25, 2026 20:13
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