Skip to content

Hosted chats P2: private by default, guests on a verb-checked wire, bots as their creator, hosting policy - #2900

Closed
AbirAbbas wants to merge 75 commits into
devfrom
w24/sessionhost-p2
Closed

AbirAbbas wants to merge 75 commits into
devfrom
w24/sessionhost-p2

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Draft, stacked on #2898 (hosted chats P1), which is stacked on #2896 (P0). Do not merge before they land. The base is dev only so the diff shows what P2 adds on top of the stack; review w24/sessionhost-p1..w24/sessionhost-p2 for P2 alone. This branch also merges w24/org-follow (#2895: bots, loopback_trust, paged reads, private by default), so #2895 should land first or together with it. Not for merge until a person has hand-tested it.

Hosted chats P2: a hosted chat is a private resource of the organization's access core, a person it is shared with can watch it live (and, when their role says so, act in it) through a wire that only lets through what their role allows, an operator without a grant is refused, bots act as their creator and no more, and the policy says where chats may run.

What changes

  • A hosted chat is a session resource, registered when it is made (owner = the person, or the bot's creator; created_by = the bot). Private unless the policy's default for session says otherwise. The list, every chat route and the live event stream ask the same access core, so another person's list and event stream never carry it. A chat made before this change is registered on its owner's first use.
  • GET /v1/hosted/sessions keeps sessions (the caller's own chats, exactly the P1 rows) and adds shared (chats of others the caller may open: id, owner, role, access, state, times, nothing else) and hosting (local_sessions, and words when it is not allow).
  • A guest's wire. The owner (by handle, holding run) is attached through the unchanged byte-copying proxy. Any other person who may view the chat gets a wire the organization server terminates itself: the hello is rewritten to a watching one, each call is parsed with internal/remote's frame codec, checked against an allow-list method table by the caller's verbs, and forwarded re-encoded, so what the chat receives is exactly what was checked. A refused call is answered in place in plain words and never reaches the chat.
    • view: watch and read. steer: also Steer and Interrupt. answer: also ResolveQuestion. run: also send messages, files, images and commands as the chat's owner. Everything else (approvals, settings, files, stopping the chat) is the owner's whatever the role. A method nobody classified is the owner's, and a law test reads the engine's method constants so a new one cannot slip through.
  • Access taken away (revoke, a share ending, a policy change, a sign-out, a bot whose creator lost the chat) ends a guest's open window within one heartbeat (CODEAF_HOSTED_HEARTBEAT, 1s to 1m, default 5s), re-reading the sign-in, grants and policy.
  • A shared chat runs as its owner: the owner's folder, GitHub identity, model key and caps. The asker is recorded on every prompt (an owner-visible audit line naming who, never what), on every spend row (spend.asker, approximate) and on every git-credential audit line.
  • Bots may use /v1/hosted/sessions as their creator, narrowed by scope, decided again on every request; /v1/hosted/keys and /v1/hosted/git stay refused.
  • Policy: additive hosting section (local_sessions allow|warn|refuse, max_session_cost_usd). A client acting on local_sessions is not part of this change.
  • Item 0 (on the P1 branch, already in this stack): a model key the provider rejects is a plain, non-retried refusal in the transcript with one operator log line that never prints the key. It briefly turned Hosted chats P1: a metered model door, sealed personal keys, git through the org server, a port limit #2898 red on TestP1_1_UpstreamSeesOnlyTheOrgKeyAndTheChatSeesNone; the code was right and the test's sentence was stale, fixed in e987b4d (the test now requires the plain sentence and still forbids any key leak).
  • Manual pages, deploy/org/README.md (the exact refusals), a change entry and the keyless Compose smoke are in the same change.

Decisions from the product owner, built in (2026-11-24)

  1. Accounts. An organization is a separate account, switched to from a personal one. Inside an organization account with a chat host every chat is hosted, and a local run is refused with no escape inside it; the escape is the personal account, which never sees the organization's data. hosting.local_sessions stays and defaults to refuse when the organization runs a chat host; its words point at switching to the personal account. (This change reports the setting and the words; a client acting on them is a later change.)
  2. Machine strength. A separate user plus Landlock is enough for v1.
  3. Shared chats. The owner owns the chat. A person it is shared with can send messages that run with the owner's credentials (folder, GitHub, model key and caps), built verb by verb: run sends messages, steer and answer interrupt, steer and answer only, view only watches. The default share path is unchanged: sharing names a role, an omitted one is refused, and the policy's org_role is view, which does not include run; edit and full do. Taking run out of edit is a policy edit, not code. The manual says it plainly: a person you let send messages acts with your GitHub identity, files and spending limits.
  4. GitHub identity is the chat's owner, with the asker recorded.

Validation Contract

Behaviours the change must show, in caller-observable terms. Each is a test whose comment names the line (TestP2_<n>_... in internal/factory/serve unless said), and most have rows in the keyless Compose smoke.

# When this happens This must be true Tests
P2-1 A person makes a chat It is absent from every other person's list (the operator's too) and from their live event stream at create, share, revoke, stop, delete and a policy change; every door answers There is no such chat. exactly as for an unknown id TestP2_1_PrivateHostedChatsAndEvents
P2-2 Anyone lists chats sessions is their own (P1 rows), shared holds only what they may open with id, owner, role, access, state and times, an operator's row is metadata only TestP2_2_HostedListKeepsOwnRowsAndLimitsSharedMetadata, TestP2_2_HostedListFailsWhenSharedOwnerCannotBeListed
P2-3 A chat from before P2 is touched, or an unknown id is asked for It is registered once for its owner; an unknown id registers nothing; with no store P1's behaviour holds TestP2_3_LegacyChatsBackfillOnFirstTouch, TestP2_3_HostedRoutesWithoutStoreKeepP1Behavior
P2-4 Anyone attaches to a chat's wire Class is decided on every attach with the operator cleared: owner (their own, holding run) gets the byte-copy, a person who may view gets the guest wire, anyone else the 404; an operator with no grant is refused TestP2_4_HostedWireClassUsesCurrentVerbsWithoutOperator
P2-5 A guest uses the wire Hello is rewritten to a watching one; only whole, well-formed frames pass; view reads, steer steers and interrupts, answer answers, run sends messages as the owner, everything else is refused in plain words in place; bad input closes the wire; a chat that cannot be started for a guest says so in the guest's own words; the heartbeat re-decides and ends a window whose access went away; shutdown and sign-out close guest wires TestP2_5_Guest*, TestP2_5_HostedShutdownClosesGuestWires, TestP2_5_SignOutClosesGuestWire, TestP2_5_HostedGuestMethodTableLaw, TestP2_5_GuestIsToldPlainlyWhenThereIsNoRoomToStartTheChat
P2-6 A bot acts on hosted chats It acts as its creator narrowed by its scope; revoke-then-retry is refused on the next request; keys and git are refused to it; its window loses scope or token within a heartbeat TestP2_6_BotsUseCurrentHostedRights, TestP2_6_BotWireRefreshesScopeAndToken
P2-7 A chat is created, stopped or deleted Registered before the host is asked and rolled back if it fails; stop and delete need manage (Only the owner of this chat can stop or delete it.) TestP2_7_HostedCreateRegistersBeforeHostAndRollsBackFailure, TestP2_7_HostedStopAndDeleteRequireManage
P2-8 A guest with run sends a message It runs with the owner's tokens and caps (the owner's bearer, never the guest's), the asker is on the spend row, the prompt audit line and each git-credential audit line, and a guest's attach never touches the owner's sign-in GitHub TestP2_8_HostedSpendRecordsGuestWithoutMovingTheCharge, TestP2_8_HostedPushKeepsOnlyTheOwnerSignInGitHub, TestP2_8_HostedWireStampsSpendAndAudit, internal/factory/store TestP2_8_SpendAskerMigrationIsIdempotent
P2-9 The operator edits the policy hosting is additive, validated, empty local_sessions means refuse when a chat host exists, a positive max_session_cost_usd replaces the env cap, the list says it in plain words; the heartbeat setting is validated at start internal/factory/acl TestP2_9_HostingPolicyDefaultsAndValidation; TestP2_9_PolicyOverridesHostedSessionCap, TestP2_9_HostedListIncludesPolicyWords; cmd/codeaf TestP2_HostedHeartbeatSetting
P2-10 An owner uses their own chat as in P1 List, create, get, stop, delete, attach, wire bytes, model door and spend are unchanged: the owner's wire is the byte-copying proxy TestP2_10_OwnerWireStillCopiesOriginalBytes; all P1 and C-series tests

Known limits and open decisions

  • Keyboard. The engine lets one window type at a time. A guest's message or steer is refused by the engine with its own keyboard sentence while the owner's own window holds the keyboard, and goes through when the owner has no window open or after the guest takes the keyboard (Take is in the run class and moves it off the owner's window). The proper fix is an engine-side guest class, left out here. The manual and the deploy guide say so.
  • Tool-use approvals stay the owner's: a command a guest's message wants to run that needs approval under the owner's approval mode waits for the owner.
  • The asker is approximate: whoever last sent a message, steered or answered through the organization server; the owner opening their own window puts it back to the owner. The prompt audit line names who and never what.
  • edit and full hold run, so sharing at those roles lets a person send messages; changing that is a policy edit.
  • Where the earlier design note says a bot's chat is "owned by the bot and by extension its creator", the code follows the contract: owner = the bot's creator, created_by = the bot.
  • No client acts on hosting.local_sessions yet (words and setting only).
  • Two tests that arrived with the w24/org-follow merge (TestP1_5_KeyRoutesNeedASignIn, TestC9_PlainWords) assumed a request from the server's own computer is trusted; since loopback_trust is off by default they now turn it on to keep checking what they are about, and each pins the plain 401 without it.

Evidence

  • Local gates, run as the light CI gate runs them: gofmt, go vet (Linux and Windows) on the touched packages, go build ./..., packed corpora, change entry, manual gates, carried help, belt pages and make test-laws all exit 0 through make test-quick; internal/factory/acl, internal/factory/store, all of internal/factory/serve (once in full at the first commit set, then the P2/P1/C-series/item 0/access-constructor subset again after the last Go change), cmd/codeaf hosted tests and internal/manual pass. The full tui3/session/cmd/codeaf suites are left to CI's touched-packages legs.
  • The keyless Compose stack (deploy/org: codeaf, sessionhost, a model stub, a git stub; local images, no provider call, no key) on a fresh stack, images built from this branch's binary: 249 checks pass, 0 fail, SMOKE PASSED, of which 107 are P2 rows (P2-1 x21, P2-2 x4, P2-4 x4, P2-5 x35, P2-6 x14, P2-7 x1, P2-8 x8, P2-9 x10, P2-10 x3; the rest are P0/P1 rows, which still pass, including after a restart of every service). The P2 rows drive a scripted client that speaks the engine's own frames as the owner, a guest and a bot: another person's list and event stream never carry a private chat (the operator's included), a view guest is refused in the exact words and nothing reached the chat, a guest with run ran a command in the owner's chat (same user, same folder as the owner's own turn) and a git clone through the owner's GitHub access, with the asker on the spend rows, the prompt audit line and the git audit line, and the cost on the owner; taking the role away or revoking the share ended an open window with Your access to this chat was removed.; a bot lost a chat on its next request when its creator did; the policy words and validation work end to end.
  • Pinned live, so a change is noticed: while the owner's own window holds the keyboard the chat refuses a guest's message with the keyboard is in another window right now ..., a guest who may steer can still interrupt, and the guest's message goes through once the owner's window is closed.
  • What the live runs found and fixed (three runs on the way): one product fault, a guest opening a chat that was not running when the machine or the owner was at the limit read "The place chats run on is not answering."; it now reads This chat is not running, and there is no room to start it right now. Try again later. (TestP2_5_GuestIsToldPlainlyWhenThereIsNoRoomToStartTheChat, manual and README updated). The rest were faults in the new smoke rows (a stale policy revision on restore, a one-shot owner turn racing an interactive guest window, a wrong spend column, a message's own text mistaken for the command's answer, P2 people sharing running-chat slots with P1's).
  • Not exercised: P2-3's legacy backfill live (unit test only; nothing old exists on a fresh stack); the real codeaf chat window as a guest (the smoke speaks the same frames, but a person's terminal as a guest is for the hand test); a tool-use approval a guest-sent command waits on; a real provider; Windows and macOS clients.
  • Docker note for whoever reruns it: on a WSL machine whose docker socket is a Windows Docker Desktop, pass CODEAF_BINARY_FROM and GITSTUB_TOKEN to the Windows CLI through WSLENV, or the image silently builds from the published release and the chats' machine says "there is no codeaf sessionhost".

🤖 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 <[email protected]>
#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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
…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 <[email protected]>
…point and never uses a fixed password

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
… 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 <[email protected]>
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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
… 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 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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 <[email protected]>
AbirAbbas and others added 25 commits November 24, 2026 07:10
…, own keys, git, limits)

The hosted-sessions manual page says what a person can rely on (spend is
measured by the organization and capped, their own keys are kept sealed, git
works without the token ever reaching the chat, and which ports a chat's
commands may reach) and what it cannot (a hostile service on an allowed port is
still reachable). PROTOCOL.md lists the new routes and the host's bearer
fingerprint. The change entry says what was believed before and what is true
now.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… chat's first command seals its calls

The first interactive hosted command printed "calls are not being sealed ... Permission denied". The furrow history helper fsyncs every ancestor folder after it first creates its group-commit file, and the 0711 folders above a chat made that open fail with EACCES for the chat's own uid. The ancestors are now 0755 (names only; the chat folders below stay owner-only), and an older 0711 ancestor is widened when it is found.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ommand's note names what the chat may reach

avoiding() used to drop every grant below a folder it could not list; it now keeps granting what lies beside and below. A port-limited fence also writes its own sentence into the transcript, through Fence.WithNote, so a refused connection says which ports a chat may reach.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The git setup reads its variables through internal/env, the hosted model funnel has an owner row in the spend ledger, and the sealed-key provider names use modelsource.DefaultID rather than a literal.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… readable folders, shorter change title

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…e reads the broker file's mode as the chat's own user

Alpine keeps the smart-HTTP backend in git-daemon, so the stub answered every clone with a 500. The smoke's last row globbed chat folders as the machine's root, which cannot look inside them, and found nothing; it now stats each file as the chat's own user.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…, never a retried 502

When the provider answered 401 or 403 to the organization's model key, the model
door relayed a 502, the engine retried it quietly about once a minute and the
organization's log said nothing. Now the chat's call gets a 401 with one plain
sentence (not retried, no key or provider words in it) and the server's log gets
ONE line naming the cause, repeated at most every 30 minutes and again as a new
outage once the key has worked. A person's own stored key that is rejected gets
the same treatment worded as theirs, and the organization's key is never used
in its place.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tences

The manual's cost section and deploy/org's README say the exact sentences a person
reads when the provider refuses the organization's key or their own, the change
entry records what was true before, and a probe keeps the sentence reachable.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…t, paged reads, private by default)

The one conflict was the route list in serve.go: hosted P1 registers hostedRoutes and
org-follow registers botRoutes, and both stay, in that order, because a bot's allowlist
is a table read at request time and does not depend on registration order.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The policy gains `hosting`: `local_sessions` (allow, warn or refuse; empty means refuse
when the organization runs hosted chats and allow when it does not) and
`max_session_cost_usd` (zero keeps today's cap). Both are validated in words, and the
zero value serializes to nothing so a stored policy that never named hosting is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
An additive `asker` column on `spend` (added to an existing ledger on open, idempotent)
and `Spend.Asker`, so a charge made in the owner's chat while a guest was steering it
says who asked, while `by` stays the owner.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A hosted chat is registered as a `session` resource when it is made (owner = the person,
or a bot's creator), private unless the policy says otherwise, and the list, the chat's
routes and the event stream all ask the same core, so another person's list and live
updates never carry it. The list keeps `sessions` as P1 gave it and adds `shared` and
`hosting`; a chat made before this is registered on its owner's first use; stop and
delete need the manage verb. The wire decides owner, guest or none from the access core
with the operator cleared (guests get the unchanged refusal until the wire pump lands),
a guest's attach never stores their GitHub sign-in under the owner, and the policy's
chat cost replaces the default cap.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…made the contract

TestP1_1 still expected the provider's own words ("invalid key") in what a person reads when
their own key is refused. Item 0 made that a plain sentence worded as theirs with none of
the provider's words, so the test now asserts that sentence and that the provider's words
and the key are absent; it still asserts the 401, that the key never appears in the body or
headers, and that the upstream saw exactly the keys it should. The code is right and the
test was stale: the contract said so before the code changed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…item 0's plain refusal)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…the same everywhere

The bot route allowlist gains /v1/hosted/sessions, so a bot can start, list, open, stop and delete
chats as the person who made it. The rule that turns a bot's scope into its verbs becomes one helper
(botScopeVerbs, same behaviour as before) so the guest wire can narrow a watching bot the same way
when it re-decides on each heartbeat.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Hosting.Words returns the sentence a person reads when this organization keeps their chats on its own
server: the refusal points at switching to the personal account, the warning says the chat is outside
the organization's account, and allow says nothing.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… every heartbeat

Someone a chat is shared with no longer gets the owner's byte-copied wire. The organization server
ends their WebSocket itself, rewrites their hello to a watching one, and forwards only the engine
frames their role allows: view reads, steer interrupts and steers, answer resolves a question, run
sends messages as the chat's owner. Everything else (approvals, settings, files, stopping the chat)
stays the owner's. A method nobody classified is the owner's by default, and a law test reads the
engine's method constants so a new one cannot slip through unclassified.

Each heartbeat re-reads the person's access from fresh state, so a revoked share, a changed policy or
a bot whose creator lost the chat ends the window with a plain sentence. The asker is remembered per
chat and stamped on each prompt line and each git-credential line of the owner's audit, and a guest's
prompt is recorded by who and never by what. Owner attaches keep the unchanged byte-copying proxy.

Without a store the hosted routes build their viewer through the access constructor, which keeps the
access-constructor law green.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ns the refusal without it

Since the organization server stopped trusting its own computer by default, a request from this
machine with no credential is refused before it reaches the key routes. TestP1_5_KeyRoutesNeedASignIn
still checks what it is about (a caller the server lets in without a verified person gets the sign-in
sentence) with the trust on, and now also pins that the same request with the trust off is a 401.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…s access

CODEAF_HOSTED_HEARTBEAT takes a duration from 1s to 1m and defaults to 5s. A value outside that range
stops the server at start with one plain sentence instead of running with a heartbeat nobody chose.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… send in a shared chat

Private by default and what a refusal reads; what a person with view, steer, answer or run can do and
what stays the owner's; that a person you let send messages acts with your GitHub identity, files and
spending limits; who pays and how the asker is recorded; why the operator cannot open a chat; bots and
chats; and the hosting policy with the plain words for the personal account. New probes keep each
question reaching its page. The deploy guide carries the exact refusals, the heartbeat setting and the
known keyboard limit: a guest's message waits while the owner's own window holds the keyboard.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…audit on the real stack

New rows: a private chat is missing from another person's list and from their event stream, a share
shows it in their shared list, a guest on the wire can watch and is refused for what their role lacks,
revoking the share ends an open window within a heartbeat, a bot acts as its creator and loses the
chat when the creator does, a guest's message runs as the owner with the asker on the spend row and the
audit, and the operator without a grant sees nothing. The stub heartbeat is 1s so the run stays short.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Opening a chat that is not running starts it for its owner, and the chats' machine can answer that it
has no room (its own limit, or the owner's). The guest used to read "The place chats run on is not
answering." Now the guest reads "This chat is not running, and there is no room to start it right now.
Try again later." and never the owner's own sentence or a number. Found by the live smoke.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…d's own answer, and keeps the policy revision current

The first live runs found faults in the harness, not the product: the owner shared its running-chat
slots with P1's chats (the owner is now a new person with a GitHub access of their own, and the
machine-wide limit leaves room), a policy restore used a stale revision, a one-shot owner turn raced
the guest's interactive window (the owner's window is now a real wire, which also pins the keyboard
limit), the spend query used the wrong chat column, a message's own text was mistaken for the
command's answer, and an interrupted turn is read from "Command aborted".

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
TestRunnerJoinRegistersTheMachineAsThePersonsRunnerAndStopsWithItsContext
failed about one run in four on this branch and every time in CI, with the
runner list answering "factory refused the request" for twenty seconds.

A request trace showed why. The lab's service clock runs six seconds ahead on
every read. Since a team factory stopped trusting its own computer by default
(loopback_trust off), every runner attach is decided by the runner's session,
which reads the clock several times per request, and the runner attaches in a
burst. The person's session lives only as long as the uncounted link row it
was minted from, and that row had one hour on it: about thirty attaches carried
the clock past the hour, the session ended ("factory session has ended; sign in
again", then "this link is not recognized"), and the test's own list request
was refused from then on. Under the old loopback door the attach read no clock,
so the hour was never reached.

The code is right: a session that has ended must not attach a runner, and that
is exactly what turning loopback_trust off asks for. The fixture was wrong, so
the link now lasts a year, which no number of reads can reach. The contract
the test names is unchanged: a joined runner registers as the person and shows
on the runner list.

Before: 2 of 14 and 6 of 20 focused runs failed. After: 40 of 40 pass.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@AbirAbbas

Copy link
Copy Markdown
Collaborator Author

CI was red on touched codeaf (TestRunnerJoinRegistersTheMachineAsThePersonsRunnerAndStopsWithItsContext) and the classifier was right to blame this branch. The cause is a test fixture, not a code regression: the runner lab's clock jumps 6 s per read, and with loopback_trust off every runner attach is decided by the session, which reads the clock several times per request. About 30 attaches carried the clock past the test link's one-hour expiry, which ended the person's session and refused the runner list. a6f9cc1 gives that link a year; the test now passes 40 of 40 focused runs (was 2 of 14 and 6 of 20 failing), and all checks are green at that head. A real session that has ended still cannot attach a runner, which is what turning loopback_trust off asks for.

@AbirAbbas

Copy link
Copy Markdown
Collaborator Author

Consolidated into #2903, the org/main feature line. This PR's commits are all on that branch. Closing it here so there is one place to review. Follow-ups go against org/main.

@AbirAbbas AbirAbbas closed this Nov 24, 2026
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 <[email protected]>
Co-Authored-By: ZeroPoint95 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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