Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
82e60ca
docs: align the M3 interfaces with the implementation plan
Oct 23, 2026
870062a
feat(frontend): add the sharing schemas and query keys
Oct 23, 2026
ff23117
feat(api): add the agent and session sharing schema
Oct 23, 2026
4ac98a8
feat(api): backfill legacy agents and sessions as project-visible
Oct 23, 2026
c2d0ab9
feat(api): add the sharing domain contracts and the ownership rule
Oct 23, 2026
151b04e
feat(api): add the Postgres sharing DAO with locked writes
Oct 23, 2026
1e68115
feat(api): add the sharing resource rules, read scopes and policy caches
Oct 23, 2026
682733b
feat(api): make the resource policy step 4 of every access decision
Oct 23, 2026
c63e47f
feat(api): every session insert path writes its initial access policy
Oct 23, 2026
759a3a7
feat(api): create a private agent and its access row in one transaction
Oct 23, 2026
994b6b2
feat(api): agents get an owner at creation and private agents leave o…
Oct 23, 2026
72653b6
feat(api): session lists apply the read scope in SQL
Oct 23, 2026
a019861
feat(api): check agent and session policy at every entry point
Oct 23, 2026
45ba3f3
feat(api): authorize every heartbeat, with a verified-continuity stea…
Oct 23, 2026
dbc5db4
feat(api): check session sharing on the runner write routes, free for…
Oct 23, 2026
679ff98
fix(api): hide private agents behind embeds, and keep heartbeat refus…
Oct 23, 2026
c377e94
feat(api): admit runs at every server boundary
Oct 23, 2026
da3eefb
test(api): pin the statement counts of the sharing hot paths
Oct 23, 2026
f4690f5
fix(api): check the referenced agent when a queued request carries an…
Oct 23, 2026
8432cd7
fix(api): count a turn's admission record only while the turn is curr…
Oct 23, 2026
1ea1fa7
feat(api): list project members for sharing and build the share discl…
Oct 23, 2026
8bf0730
feat(api): sharing writes with recheck, audit events and channel guard
Oct 23, 2026
490c10f
feat(api): add the sharing routes
Oct 23, 2026
2029e2c
feat(frontend): add the sharing entity on the Fern client
Oct 23, 2026
7086236
fix(frontend): /w creates project-visible chats and agents
Oct 23, 2026
3edab80
fix(api): agent sharing needs an agent, a refused end beat drops its …
Oct 23, 2026
eef0ca0
docs: agent and session sharing
Oct 24, 2026
3216923
test(api): acceptance tests for agent and session sharing
Oct 24, 2026
1ff1094
test(api): channel acceptance fixtures bind a real project agent
Oct 24, 2026
916855e
fix(api): person-facing application and evaluator lists use the calle…
Oct 24, 2026
ac87476
fix: /w drawer-created agents are project-visible, a start creates th…
Oct 24, 2026
55a9d40
feat(frontend): add the sharing components
Oct 24, 2026
19e017e
feat(frontend): sharing in /m
Oct 24, 2026
f20a43a
feat(api): session sharing state says why a session cannot be shared,…
Oct 24, 2026
fcc9c94
feat(frontend): /m shows Slack and no-owner texts from the not-sharea…
Oct 24, 2026
963cd5c
feat(frontend): sharing in channel setup
Oct 24, 2026
97f7fa6
fix(api): every channel binding write that leaves it active checks th…
Oct 24, 2026
0dbb2eb
fix(frontend): /m chat writes only with known send access, rechecks s…
Oct 24, 2026
d993005
fix(frontend): /m sharing recheck keeps one 60 s budget, an open rewi…
Oct 24, 2026
d60d839
fix(frontend): sharing confirmations close when access is not known o…
Oct 24, 2026
c22b316
fix(frontend): a sharing confirmation left pending when its dialog cl…
Oct 24, 2026
ebdcbaa
fix(frontend): the agent privacy control shows the load error and Try…
Oct 24, 2026
ad2a672
fix(frontend): /m sharing hosts name the agent owner and the chat gra…
Oct 24, 2026
8b657bd
fix(api): the session backfill analyzes session_streams first and rea…
Oct 24, 2026
1afbb39
refactor(api): the session policy row mapping lives in the sharing ma…
Oct 24, 2026
02003fc
fix(api): a session row created after the route's check is checked be…
Oct 24, 2026
83e295c
fix(api): a send, steer or cancel whose route check found no row sett…
Oct 24, 2026
262c1e1
fix(api): an attach to a session that does not exist answers not foun…
Oct 24, 2026
adcc74d
perf(api): sharing reads ride in the access decision's one cache read…
Oct 24, 2026
9f82f37
perf(frontend): /m opens a chat and an agent with no sharing request …
Oct 24, 2026
d4afec3
fix(frontend): QA fixes: copying a share link works without a secure …
Oct 24, 2026
8aa61d6
fix: a missing session is never cached, a sharing write clears what t…
Oct 24, 2026
a38fbe7
fix(api): a failed cache write is not kept for the request, an agent …
Oct 24, 2026
800680b
perf(api): a send costs what it cost before sharing: a runner write r…
Oct 25, 2026
5887ffd
fix(api): a turn whose stream is not its own session's row is refused…
Oct 25, 2026
bae3f36
fix(api): a turn is inserted only when its stream is its session's ro…
Oct 25, 2026
699fa96
test(api): the release's new tests pass the access service its resour…
Oct 25, 2026
b921738
test(frontend): the hidden-agent workspace test keeps the drive packa…
Oct 25, 2026
b0e2309
style: format with the CI's ruff and prettier, and the CI's sharing a…
Oct 25, 2026
bb49430
fix(api): reserved tools check the agent or session they name, a dele…
Oct 25, 2026
6cccfc9
fix: no session row is created over a tombstone (one insert statement…
Oct 25, 2026
c53e251
fix(api): the create and the delete of one session id are serialized …
Oct 25, 2026
3242a0b
test(frontend): the new-chat Share test waits for the row re-read ins…
Oct 25, 2026
548a723
test(api): the hidden-reference and list-parity acceptance modules ca…
Oct 25, 2026
af7ec8d
test(api): the private-agent child-run test refuses only the private …
Oct 25, 2026
e58ad38
chore(frontend): regenerate the Fern client from the EE spec (mount c…
Oct 25, 2026
65b3816
fix(api): a person's event subscription, child run and evaluation run…
Oct 25, 2026
f122585
docs: a person's server run runs in the ownerless session it creates …
Oct 25, 2026
45fd6e6
fix(api): a turn's admission record carries the signed run origin, so…
Oct 25, 2026
4822d6e
docs: an API key cannot continue a chat that a person owns; an SDK cl…
Oct 25, 2026
22b76ac
feat: project visibility lets every member send in a web chat (releas…
Oct 25, 2026
36ae78a
fix(api): a person's first touch of a channel thread's session keeps …
Oct 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions api/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ Access layer invariants (run principal):
- `integration/access/test_run_principal_query_counts_postgres.py` pins the hot paths at
zero access-decision statements on warm caches.

Access layer invariants (agent and session sharing):

- Every agent or session access calls `AccessService.decide` with a `ResourceRef`, and
lists pass a read scope in SQL. List queries take a required read scope; there is no
unrestricted scope.
- Every point where a run starts or resumes calls `RunAdmission` (`admit`, `admit_turn` or
`admit_request`) with the stored or request envelope.
- `AccessService` requires a resource policy; every composition root passes
`SharingService`.
- Never treat a null owner as "not migrated".
- Audit events carry identifiers, never credential values.

Primary references:
- `api/entrypoints/routers.py`
- `api/ee/src/main.py`
Expand Down
21 changes: 17 additions & 4 deletions api/entrypoints/access.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Composition helper for membership and access.

`bootstrap_access()` is the only place that picks the edition's membership policy and
RBAC adapter, and builds the principals DAO. Every process that checks access calls it at startup: the API
RBAC adapter, and builds the principals DAO and the sharing service (the resource policy
of every access decision). Every process that checks access calls it at startup: the API
(`entrypoints/routers.py`) and both workers (`worker_streams.py`, `worker_queues.py`).
"""

Expand All @@ -13,14 +14,16 @@
register_memberships_service,
)
from oss.src.dbs.postgres.access.dao import PrincipalsDAO
from oss.src.core.sharing.service import SharingService, register_sharing_service
from oss.src.dbs.postgres.memberships.dao import MembershipsDAO
from oss.src.dbs.postgres.sharing.dao import SharingDAO
from oss.src.dbs.postgres.shared.engine import get_transactions_engine
from oss.src.utils.common import is_ee


def bootstrap_access() -> AccessService:
"""Build and register the memberships and access services. Idempotent: a second
call registers new instances."""
"""Build and register the memberships, sharing and access services. Idempotent: a
second call registers new instances."""

memberships_service = MembershipsService(
memberships_dao=MembershipsDAO(engine=get_transactions_engine()),
Expand All @@ -38,13 +41,23 @@ def bootstrap_access() -> AccessService:
else:
rbac = AlwaysEnforcedRbac()

principals_dao = PrincipalsDAO(engine=get_transactions_engine())

sharing_service = SharingService(
sharing_dao=SharingDAO(engine=get_transactions_engine()),
memberships_service=memberships_service,
principals_dao=principals_dao,
)

access_service = AccessService(
memberships=memberships_service,
rbac=rbac,
principals=PrincipalsDAO(engine=get_transactions_engine()),
principals=principals_dao,
resource_policy=sharing_service,
)

register_memberships_service(memberships_service=memberships_service)
register_sharing_service(sharing_service=sharing_service)
register_access_service(access_service=access_service)

return access_service
37 changes: 36 additions & 1 deletion api/entrypoints/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

# Engines
from entrypoints.access import bootstrap_access
from oss.src.core.access.service import get_access_service
from oss.src.core.sharing.admission import RunAdmission
from oss.src.core.sharing.service import get_sharing_service
from oss.src.core.memberships.service import get_memberships_service
from oss.src.dbs.postgres.shared.engine import (
get_transactions_engine,
get_analytics_engine,
Expand Down Expand Up @@ -84,6 +88,7 @@
from oss.src.dbs.postgres.events.dao import EventsDAO
from oss.src.dbs.postgres.blobs.dao import BlobsDAO
from oss.src.dbs.postgres.git.dao import GitDAO
from oss.src.dbs.postgres.workflows.dao import WorkflowsDAO
from oss.src.dbs.postgres.evaluations.dao import EvaluationsDAO
from oss.src.dbs.postgres.folders.dao import FoldersDAO

Expand Down Expand Up @@ -151,6 +156,7 @@
from oss.src.apis.fastapi.evaluations.router import SimpleQueuesRouter
from oss.src.apis.fastapi.traces.router import SimpleTracesRouter
from oss.src.apis.fastapi.sessions.router import SessionsRouter
from oss.src.apis.fastapi.sharing.router import SharingRouter
from oss.src.apis.fastapi.annotations.router import AnnotationsRouter
from oss.src.apis.fastapi.invocations.router import InvocationsRouter
from oss.src.core.annotations.service import AnnotationsService
Expand Down Expand Up @@ -750,7 +756,7 @@ def _cors_origins(web_url: str) -> list[str]:
RevisionDBE=QueryRevisionDBE,
)

workflows_dao = GitDAO(
workflows_dao = WorkflowsDAO(
engine=_transactions_engine,
ArtifactDBE=WorkflowArtifactDBE,
VariantDBE=WorkflowVariantDBE,
Expand Down Expand Up @@ -874,6 +880,12 @@ def _cors_origins(web_url: str) -> list[str]:
watch_publisher=_sessions_watch_publisher,
)

# Every run start and resume (the heartbeat first) checks the session and the agent.
run_admission = RunAdmission(
access_service=get_access_service(),
workflows_service=workflows_service,
)

environments_service = EnvironmentsService(
environments_dao=environments_dao,
)
Expand Down Expand Up @@ -1073,6 +1085,7 @@ async def _dispatch_detached_run(
_interactions_dispatcher = InteractionsDispatcher(
workflows_service=workflows_service,
interactions_service=interactions_service,
run_admission=run_admission,
records_service=records_service,
# Read-only: the resume's reference fallback, for a gate row whose own `data.references` is
# empty. Without it the invoke has nothing to resolve a service URL from.
Expand All @@ -1095,6 +1108,7 @@ async def _dispatch_detached_run(
triggers_dao=triggers_dao,
session_claims_dao=session_streams_dao,
workflows_service=workflows_service,
run_admission=run_admission,
dispatch_fn=_dispatch_detached_run,
)

Expand Down Expand Up @@ -1266,6 +1280,7 @@ async def _dispatch_detached_run(

tools = ToolsRouter(
tools_service=tools_service,
run_admission=run_admission,
workflows_service=workflows_service,
tracing_service=tracing_service,
mounts_service=mounts_service,
Expand All @@ -1284,6 +1299,9 @@ async def _dispatch_detached_run(
channels_dao=channels_dao,
adapter_registry=channels_adapter_registry,
vault_service=vault_service,
# Resolves the agent a binding runs, so an active binding never names a private
# agent.
workflows_service=workflows_service,
)

channels_identity_dao = ChannelIdentityDAO(engine=_transactions_engine)
Expand Down Expand Up @@ -1332,6 +1350,7 @@ async def _respond_channel_interaction(

_channels_inbox_dispatcher = InboxDispatcher(
channels_service=channels_service,
run_admission=run_admission,
attachments_service=session_attachments_service,
respond_interaction_fn=_respond_channel_interaction,
workflows_service=workflows_service,
Expand Down Expand Up @@ -1589,6 +1608,7 @@ async def _respond_channel_interaction(
continue_input=lambda command: deliver_continue_input(
command=command,
workflows_service=workflows_service,
run_admission=run_admission,
),
),
executions_dao=session_executions_dao,
Expand All @@ -1603,6 +1623,7 @@ async def _respond_channel_interaction(
)
session_starts_service = SessionStartsService(
inputs_service=session_inputs_service,
run_admission=run_admission,
executions_dao=session_executions_dao,
streams_dao=session_streams_dao,
workflows_service=workflows_service,
Expand Down Expand Up @@ -1671,9 +1692,17 @@ async def _respond_channel_interaction(
turns_service=session_turns_service,
sessions_service=sessions_service,
commands_service=session_commands_service,
run_admission=run_admission,
inputs_service=session_inputs_service,
)

sharing = SharingRouter(
sharing_service=get_sharing_service(),
memberships_service=get_memberships_service(),
workflows_service=workflows_service,
streams_service=session_streams_service,
)

# PLATFORM ADMIN ---------------------------------------------------------------

platform_admin_accounts_service = PlatformAdminAccountsService()
Expand Down Expand Up @@ -2242,6 +2271,12 @@ async def _respond_channel_interaction(
tags=["Sessions"],
)

# No prefix: the routes sit beside /workflows/{workflow_id} and /sessions/{session_id}.
app.include_router(
router=sharing.router,
tags=["Sharing"],
)


@app.get("/health", operation_id="health_check", tags=["Status"])
async def health_check():
Expand Down
27 changes: 23 additions & 4 deletions api/entrypoints/worker_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
from contextlib import suppress

from entrypoints.access import bootstrap_access
from oss.src.core.access.service import get_access_service
from oss.src.core.sharing.admission import RunAdmission
from oss.src.core.sessions.commands.delivery import (
deliver_continue_interaction,
)
Expand Down Expand Up @@ -77,6 +79,7 @@
)
from oss.src.dbs.postgres.evaluations.dao import EvaluationsDAO
from oss.src.dbs.postgres.git.dao import GitDAO
from oss.src.dbs.postgres.workflows.dao import WorkflowsDAO
from oss.src.dbs.postgres.queries.dbes import (
QueryArtifactDBE,
QueryRevisionDBE,
Expand Down Expand Up @@ -206,6 +209,16 @@ def _install_session_context_resolver(
)


def _run_admission(workflows_service: WorkflowsService) -> RunAdmission:
"""The admission of every run this worker starts or resumes, over the worker's own
`WorkflowsService` (one per builder). Built after `bootstrap_access()`."""

return RunAdmission(
access_service=get_access_service(),
workflows_service=workflows_service,
)


def _build_webhooks_broker() -> tuple[AsyncBroker, int]:
broker = TrimOnAckRedisStreamBroker(
url=env.redis.uri_durable,
Expand All @@ -232,7 +245,7 @@ def _build_triggers_broker() -> tuple[AsyncBroker, int]:
transactions_engine = get_transactions_engine()
triggers_dao = TriggersDAO(engine=transactions_engine)
session_streams_dao = SessionStreamsDAO(engine=transactions_engine)
workflows_dao = GitDAO(
workflows_dao = WorkflowsDAO(
ArtifactDBE=WorkflowArtifactDBE,
VariantDBE=WorkflowVariantDBE,
RevisionDBE=WorkflowRevisionDBE,
Expand Down Expand Up @@ -282,6 +295,7 @@ async def _dispatch_detached_run(
triggers_dao=triggers_dao,
session_claims_dao=session_streams_dao,
workflows_service=workflows_service,
run_admission=_run_admission(workflows_service),
dispatch_fn=_dispatch_detached_run,
)
TriggersWorker(
Expand Down Expand Up @@ -312,7 +326,7 @@ def _build_channels_inbox_broker() -> tuple[AsyncBroker, int]:
)

transactions_engine = get_transactions_engine()
workflows_dao = GitDAO(
workflows_dao = WorkflowsDAO(
ArtifactDBE=WorkflowArtifactDBE,
VariantDBE=WorkflowVariantDBE,
RevisionDBE=WorkflowRevisionDBE,
Expand Down Expand Up @@ -344,10 +358,13 @@ async def _dispatch_detached_run(
)
return result.run_id

run_admission = _run_admission(workflows_service)

# A channel's approval answer resumes the parked session the way a
# playground click does: through the interactions dispatcher.
interactions_dispatcher = InteractionsDispatcher(
workflows_service=workflows_service,
run_admission=run_admission,
interactions_service=SessionInteractionsService(
interactions_dao=SessionInteractionsDAO(engine=transactions_engine),
watch_publisher=SessionsWatchPublisher(),
Expand Down Expand Up @@ -410,6 +427,7 @@ async def _respond_interaction(

dispatcher = InboxDispatcher(
channels_service=_build_channels_service(),
run_admission=run_admission,
workflows_service=workflows_service,
identity_service=ChannelIdentityService(
identity_dao=ChannelIdentityDAO(engine=transactions_engine),
Expand Down Expand Up @@ -438,7 +456,7 @@ def _build_interactions_broker() -> tuple[AsyncBroker, int]:

transactions_engine = get_transactions_engine()
interactions_dao = SessionInteractionsDAO(engine=transactions_engine)
workflows_dao = GitDAO(
workflows_dao = WorkflowsDAO(
ArtifactDBE=WorkflowArtifactDBE,
VariantDBE=WorkflowVariantDBE,
RevisionDBE=WorkflowRevisionDBE,
Expand Down Expand Up @@ -491,6 +509,7 @@ async def _dispatch_detached_run(
interactions_dispatcher = InteractionsDispatcher(
workflows_service=workflows_service,
interactions_service=interactions_service,
run_admission=_run_admission(workflows_service),
records_service=records_service,
dispatch_fn=_dispatch_detached_run,
)
Expand All @@ -513,7 +532,7 @@ def _build_evaluations_broker() -> tuple[AsyncBroker, int]:
VariantDBE=TestsetVariantDBE,
RevisionDBE=TestsetRevisionDBE,
)
workflows_dao = GitDAO(
workflows_dao = WorkflowsDAO(
ArtifactDBE=WorkflowArtifactDBE,
VariantDBE=WorkflowVariantDBE,
RevisionDBE=WorkflowRevisionDBE,
Expand Down
Loading
Loading