From bf6d896e813457382cd2bb2e7c74b22c03ba01ca Mon Sep 17 00:00:00 2001 From: DoodleBear Date: Sun, 18 Oct 2026 15:18:59 +0900 Subject: [PATCH 1/3] Expose authorized guest workspace identity and organization filter (#3) Claim: https://github.com/BotHarness/tob/issues/3#issuecomment-6246399830 --- apps/cli/lib/commands.ts | 10 +++++++++- apps/service/src/guests.ts | 7 ++++++- docs/channel-guests.md | 8 ++++++++ docs/spec.md | 6 ++++++ docs/t1-design.md | 6 ++++++ tests/cli.node.test.ts | 3 +++ tests/service.test.ts | 6 +++++- 7 files changed, 43 insertions(+), 3 deletions(-) diff --git a/apps/cli/lib/commands.ts b/apps/cli/lib/commands.ts index bf47ea5..08764b5 100644 --- a/apps/cli/lib/commands.ts +++ b/apps/cli/lib/commands.ts @@ -221,7 +221,15 @@ export async function execute(args: string[], rt: Runtime): Promise { } if (isGuest) { const prefix = "/api/guest-channels"; - if (orgCommand === "list") return call(options["--after"] ? "?after=" + encodeURIComponent(options["--after"]) : "", {}, prefix); + if (orgCommand === "list") { + const query = new URLSearchParams(); + if (options["--after"]) query.set("after", options["--after"]); + if (options["--org"]) { + if (!/^org_[A-Za-z0-9]+$/.test(options["--org"])) throw new ClientError("INVALID_ORGANIZATION"); + query.set("organizationId", options["--org"]); + } + return call(query.size ? "?" + query : "", {}, prefix); + } const id = options["--id"]; if (!id || !/^ch_[a-f0-9]{64}$/.test(id)) throw new ClientError("INVALID_CHANNEL"); if (orgCommand === "show") return call("/" + id, {}, prefix); diff --git a/apps/service/src/guests.ts b/apps/service/src/guests.ts index f96b60a..413a063 100644 --- a/apps/service/src/guests.ts +++ b/apps/service/src/guests.ts @@ -95,11 +95,16 @@ export const guestChannels = new Hono<{ Bindings: Env }>() .use("*", limit) .get("/", async c => { const identity = await admit(c.req.header("Authorization"), c.env); + const organizationId = c.req.query("organizationId"); + if (organizationId !== undefined && !/^org_[A-Za-z0-9]+$/.test(organizationId)) throw new AccessError("INVALID_ORGANIZATION", 400); const rows = await drizzle(c.env.INSTANCE_DB).select().from(channelInvitationDirectory).where(and(eq(channelInvitationDirectory.acceptedUserId, identity.userId), gt(channelInvitationDirectory.invitationId, cursor(c.req.query("after"))))).orderBy(asc(channelInvitationDirectory.invitationId)).limit(51).all(); const channels = []; for (const row of rows.slice(0, 50)) { const view = await c.env.CHANNELS.getByName(row.channelId).guestView(row.channelId, identity.userId); - if (view?.invitationId === row.invitationId && await localOrg(c.env, view.organizationId)) channels.push(view); + if (view?.invitationId === row.invitationId && (!organizationId || view.organizationId === organizationId) && await localOrg(c.env, view.organizationId)) { + const org = await c.env.ORGS.getByName(view.organizationId).read(view.organizationId); + channels.push({ ...view, organizationName: org.name }); + } } return c.json({ channels, nextCursor: rows.length > 50 ? rows[49].invitationId : null }); }) diff --git a/docs/channel-guests.md b/docs/channel-guests.md index df86a34..b85c835 100644 --- a/docs/channel-guests.md +++ b/docs/channel-guests.md @@ -62,3 +62,11 @@ The linked PR evidence records intermediate runtime provenance and first failure ## Confirmed invitation scope The Human clarified that a channel-level invitation admits its recipient only to that channel. It does not grant organization membership, organization directory access or access to other channels. “Invite group channel” is not a group-to-group bridge or federation requirement. Existing organization members still see all organization channels; the guest grant is the only additional scope needed for this slice. + +## Workspace directory projection + +`GET /api/guest-channels` now includes `organizationName` on each currently authorized channel. The service checks the current Channel DO grant and local organization before reading its name from Org DO. It never enumerates other organizations or adds WorkOS membership. `?organizationId=org_…` optionally narrows the same authorized projection; malformed IDs return 400 and unrelated organizations return no channels. + +`node apps/cli/tob.mjs guest-channel list --server "$TOB_SERVER" --org "$TOB_ORG"` exposes the same filter. `--after` remains supported. Cursors advance through the recipient directory, so an empty page can still have a next cursor; clients must offer continuation until it is null. Revoked grants disappear on the next listing. No schema migration is needed. + +Source verification: 62 Worker tests and 20 CLI tests pass, covering authorized metadata, filter, unrelated user/org and revocation. Deployment/readback and mobile native drawer acceptance for this increment are pending. diff --git a/docs/spec.md b/docs/spec.md index 7769ddf..0353dee 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -339,3 +339,9 @@ See [channel guests](channel-guests.md) for the bounded next slice. Channel DO o ### Channel Agent interaction sub-slice The autonomous UAT goal now proceeds through [channel-scoped Agent credentials and reply](channel-agents.md), after [direct channel guest native verification](channel-guests.md#native-uat-verification--2026-10-18-jst). One initial credential hash per Channel Agent, fixed read/send scopes and a join sequence floor are the implemented narrow model; separate rotating credentials, organization-wide Agents and management roles remain target extensions. This increment does not claim work execution, WebSocket, two-Host completion or T3 closure. + +### Unified mobile workspace drawer increment + +The shared mobile drawer groups paired computers and cloud workspaces. Its cloud projection combines current membership with authorized channel-guest organization identity, deduplicated per instance/org with membership taking precedence. Guests see the organization identity but only granted channels; selecting their row never joins/selects an organization. See [guest directory contract](channel-guests.md#workspace-directory-projection). + +Acceptance: CLI and phone agree on current authorized organization/channel identity; two instances remain separate; pagination handles empty pages; guest selection lists only that organization's granted channels; no membership or sibling-channel access appears; revocation removes the guest-only workspace on refresh; switching back restores the paired Host view. Test loading/error/retry and default/intermediate/maximum text in light/dark. Source tests are verified; this increment's UAT and native evidence remain pending. Existing T1 and full collaboration gates stay open. diff --git a/docs/t1-design.md b/docs/t1-design.md index 0a74828..046f1bd 100644 --- a/docs/t1-design.md +++ b/docs/t1-design.md @@ -430,3 +430,9 @@ Acceptance: two ordinary synthetic UAT accounts receive distinct default workspa The next client tracer carries a recipient-bound invitation through service selection/trust and existing WorkOS login, then explicitly accepts it. `GET /api/{invitations|channel-invitations}/:id` only returns destination identity to the verified recipient and never creates membership. The same origin-bound URL works with CLI preview/accept and the native join screen. A pending URL is local navigation state, not an authorization record. Read the [current contract and acceptance](t1-cli-session.md#recipient-bound-invitation-links-next-tracer-validation-in-progress) for actual UAT evidence and unfinished native/QR gates. The earlier admin-only and no-organization paragraphs describe the historical T1 initialization increment; later collaboration slices have their own recorded authorizations and evidence. Assigned iOS continuation: [native invitation evidence](https://github.com/BotHarness/DeepSeekBot/blob/8b9c8dba55f13e323274fc728a3116a2df2ad9bb/.github/pr-screenshots/2161-invitation-journey/README.md) verifies pending-target cold restart, exact guest-channel entry without organization membership, one message, revocation and isolated session cleanup. Sender copy/share and new-instance trust/Hosted AuthKit return are still explicit acceptance gates; the synthetic test session does not substitute for those flows. + +### Unified mobile workspace drawer increment + +The shared mobile drawer groups paired computers and cloud workspaces. Its cloud projection combines current membership with authorized channel-guest organization identity, deduplicated per instance/org with membership taking precedence. Guests see the organization identity but only granted channels; selecting their row never joins/selects an organization. See [guest directory contract](channel-guests.md#workspace-directory-projection). + +Acceptance: CLI and phone agree on current authorized organization/channel identity; two instances remain separate; pagination handles empty pages; guest selection lists only that organization's granted channels; no membership or sibling-channel access appears; revocation removes the guest-only workspace on refresh; switching back restores the paired Host view. Test loading/error/retry and default/intermediate/maximum text in light/dark. Source tests are verified; this increment's UAT and native evidence remain pending. Existing T1 and full collaboration gates stay open. diff --git a/tests/cli.node.test.ts b/tests/cli.node.test.ts index f7e6b71..f94d556 100644 --- a/tests/cli.node.test.ts +++ b/tests/cli.node.test.ts @@ -236,6 +236,9 @@ test('channel guests use independent public routes without selecting or joining await run('channel-invite','revoke','--channel',channel,'--id',invitation); assert.deepEqual(seen[6],{path:'/api/organizations/org_owner/channels/'+channel+'/guest-invitations',method:'POST',body:{email:'b@example.test'},key:'guest-invite-0001'}); assert.equal(seen[8].path,'/api/organizations/org_owner/channels/'+channel+'/guest-invitations/'+invitation+'/revoke'); + await run('guest-channel','list','--org','org_invites','--after',invitation); + assert.equal(seen[9].path,'/api/guest-channels?after='+invitation+'&organizationId=org_invites'); + await fails(run('guest-channel','list','--org','invalid'),'INVALID_ORGANIZATION'); await fails(run('channel-invite','accept','--id','invitation_wrong'),'INVALID_CHANNEL_INVITATION'); await fails(run('guest-channel','show','--id','ch_wrong'),'INVALID_CHANNEL'); globalThis.fetch=async(url,init)=>String(url).includes('/api/guest-channels')?Response.json({error:{code:'CHANNEL_ACCESS_DENIED'}},{status:403}):previous(url,init); diff --git a/tests/service.test.ts b/tests/service.test.ts index 4e33cbe..b1461ea 100644 --- a/tests/service.test.ts +++ b/tests/service.test.ts @@ -607,7 +607,11 @@ it('a channel guest joins without organization membership and can only read/writ expect(await (await f.guest('/organizations')).json()).toMatchObject({ organizations: [] }); for (const path of ['/organizations/org_invites/access', '/organizations/org_invites', '/organizations/org_invites/channels', '/guest-channels/' + f.sibling.channelId, '/guest-channels/' + f.sibling.channelId + '/messages']) expect((await f.guest(path)).status).toBe(403); const list = await (await f.guest('/guest-channels')).json(); - expect(list).toMatchObject({ channels: [{ channelId: f.channel.channelId, access: 'guest', historyAfter: 1 }], nextCursor: null }); + expect(list).toMatchObject({ channels: [{ channelId: f.channel.channelId, organizationName: 'Invitation workspace', access: 'guest', historyAfter: 1 }], nextCursor: null }); + expect(await (await f.guest('/guest-channels?organizationId=org_invites')).json()).toMatchObject({ channels: [{ channelId: f.channel.channelId, organizationName: 'Invitation workspace' }] }); + expect(await (await f.guest('/guest-channels?organizationId=org_other')).json()).toMatchObject({ channels: [] }); + expect(await (await f.guest('/guest-channels?organizationId=org_invites', 'user_c')).json()).toMatchObject({ channels: [] }); + expect((await f.guest('/guest-channels?organizationId=invalid')).status).toBe(400); const path = '/guest-channels/' + f.channel.channelId + '/messages'; expect(await (await f.guest(path)).json()).toMatchObject({ messages: [], nextCursor: 1 }); expect((await f.guest(path, 'user_b', 'POST', { text: 'Guest text', authorId: 'user_a' })).status).toBe(400); From bac0653ea76c04d665c53cebe73dff583a90ef59 Mon Sep 17 00:00:00 2001 From: DoodleBear Date: Sun, 18 Oct 2026 15:22:56 +0900 Subject: [PATCH 2/3] Record real UAT guest workspace projection and revoke checks (#3) --- docs/channel-guests.md | 2 +- docs/evidence/2026-10-18-workspace-directory-uat.json | 11 +++++++++++ docs/spec.md | 2 +- docs/t1-design.md | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 docs/evidence/2026-10-18-workspace-directory-uat.json diff --git a/docs/channel-guests.md b/docs/channel-guests.md index b85c835..967b372 100644 --- a/docs/channel-guests.md +++ b/docs/channel-guests.md @@ -69,4 +69,4 @@ The Human clarified that a channel-level invitation admits its recipient only to `node apps/cli/tob.mjs guest-channel list --server "$TOB_SERVER" --org "$TOB_ORG"` exposes the same filter. `--after` remains supported. Cursors advance through the recipient directory, so an empty page can still have a next cursor; clients must offer continuation until it is null. Revoked grants disappear on the next listing. No schema migration is needed. -Source verification: 62 Worker tests and 20 CLI tests pass, covering authorized metadata, filter, unrelated user/org and revocation. Deployment/readback and mobile native drawer acceptance for this increment are pending. +Source verification: 62 Worker tests and 20 CLI tests pass, covering authorized metadata, filter, unrelated user/org and revocation. UAT runtime `bf6d896e813457382cd2bb2e7c74b22c03ba01ca` was deployed and read back; [formal CLI evidence](evidence/2026-10-18-workspace-directory-uat.json) verifies the authorized organization name, filter, unrelated-org empty result, absent org membership, sibling denial and revoked-channel removal. Only this run's synthetic invitation was revoked; existing CLI sessions were preserved. Mobile native drawer acceptance remains pending. diff --git a/docs/evidence/2026-10-18-workspace-directory-uat.json b/docs/evidence/2026-10-18-workspace-directory-uat.json new file mode 100644 index 0000000..1f3ca66 --- /dev/null +++ b/docs/evidence/2026-10-18-workspace-directory-uat.json @@ -0,0 +1,11 @@ +{ + "at": "2026-10-18T06:22:15.204Z", + "releaseSha": "bf6d896e813457382cd2bb2e7c74b22c03ba01ca", + "authorizedOrganizationName": true, + "organizationFilter": true, + "unrelatedOrganizationEmpty": true, + "noOrganizationMembership": true, + "siblingDenied": true, + "revokedChannelRemoved": true, + "ownTestGrantRevoked": true +} \ No newline at end of file diff --git a/docs/spec.md b/docs/spec.md index 0353dee..98bc09c 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -344,4 +344,4 @@ The autonomous UAT goal now proceeds through [channel-scoped Agent credentials a The shared mobile drawer groups paired computers and cloud workspaces. Its cloud projection combines current membership with authorized channel-guest organization identity, deduplicated per instance/org with membership taking precedence. Guests see the organization identity but only granted channels; selecting their row never joins/selects an organization. See [guest directory contract](channel-guests.md#workspace-directory-projection). -Acceptance: CLI and phone agree on current authorized organization/channel identity; two instances remain separate; pagination handles empty pages; guest selection lists only that organization's granted channels; no membership or sibling-channel access appears; revocation removes the guest-only workspace on refresh; switching back restores the paired Host view. Test loading/error/retry and default/intermediate/maximum text in light/dark. Source tests are verified; this increment's UAT and native evidence remain pending. Existing T1 and full collaboration gates stay open. +Acceptance: CLI and phone agree on current authorized organization/channel identity; two instances remain separate; pagination handles empty pages; guest selection lists only that organization's granted channels; no membership or sibling-channel access appears; revocation removes the guest-only workspace on refresh; switching back restores the paired Host view. Test loading/error/retry and default/intermediate/maximum text in light/dark. Source tests and the [real UAT CLI projection](evidence/2026-10-18-workspace-directory-uat.json) are verified; native drawer acceptance remains pending. Existing T1 and full collaboration gates stay open. diff --git a/docs/t1-design.md b/docs/t1-design.md index 046f1bd..477a845 100644 --- a/docs/t1-design.md +++ b/docs/t1-design.md @@ -435,4 +435,4 @@ Assigned iOS continuation: [native invitation evidence](https://github.com/BotHa The shared mobile drawer groups paired computers and cloud workspaces. Its cloud projection combines current membership with authorized channel-guest organization identity, deduplicated per instance/org with membership taking precedence. Guests see the organization identity but only granted channels; selecting their row never joins/selects an organization. See [guest directory contract](channel-guests.md#workspace-directory-projection). -Acceptance: CLI and phone agree on current authorized organization/channel identity; two instances remain separate; pagination handles empty pages; guest selection lists only that organization's granted channels; no membership or sibling-channel access appears; revocation removes the guest-only workspace on refresh; switching back restores the paired Host view. Test loading/error/retry and default/intermediate/maximum text in light/dark. Source tests are verified; this increment's UAT and native evidence remain pending. Existing T1 and full collaboration gates stay open. +Acceptance: CLI and phone agree on current authorized organization/channel identity; two instances remain separate; pagination handles empty pages; guest selection lists only that organization's granted channels; no membership or sibling-channel access appears; revocation removes the guest-only workspace on refresh; switching back restores the paired Host view. Test loading/error/retry and default/intermediate/maximum text in light/dark. Source tests and the [real UAT CLI projection](evidence/2026-10-18-workspace-directory-uat.json) are verified; native drawer acceptance remains pending. Existing T1 and full collaboration gates stay open. From e551ef1afbada8f7c7d123add08a1b3d3256b36d Mon Sep 17 00:00:00 2001 From: DoodleBear Date: Sun, 18 Oct 2026 15:31:18 +0900 Subject: [PATCH 3/3] Map current collaboration evidence and unresolved goal requirements (#3) --- docs/multi-user-collaboration.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/multi-user-collaboration.md b/docs/multi-user-collaboration.md index aab9f5b..4a572a7 100644 --- a/docs/multi-user-collaboration.md +++ b/docs/multi-user-collaboration.md @@ -10,6 +10,23 @@ This supersedes the admin-only application admission restriction in T1. The prot The Human confirmed that "group channel invitation" means inviting a recipient only to the selected channel. Acceptance must not create organization membership or reveal sibling channels. This is the existing direct-channel guest scope, not federation or a group-to-group bridge. +## Current acceptance map — 2026-10-18 + +This table separates recorded slice evidence from remaining work; it is not a fresh rerun of every historical UAT check. The overall goal remains open. + +| Required behavior | Recorded evidence | Remaining boundary | +| --- | --- | --- | +| Ordinary user gets a default workspace; multiple workspaces | Ordinary-user continuation below; mobile #2131 and independent CLI | Full T1 identity-event and interrupted-deployment recovery gates remain separate | +| Owner creates multiple channels; organization members see them | Channel HTTP slice below; mobile #2138 | Automatic WebSocket delivery is not implemented by the HTTP proof | +| A invites B to the organization | [Organization invitations](organization-invitations.md), mobile #2146 | Existing synthetic users do not prove provider email delivery or every new-account path | +| A invites a guest only to one channel | [Channel guests](channel-guests.md), mobile #2150 and #2169 | No org membership/sibling access; this is the confirmed meaning of “group channel invitation” | +| Invite Agents into a channel and interact | [Channel Agents](channel-agents.md), mobile #2152 | Organization-wide Agent admission is still unimplemented; channel credentials do not satisfy it | +| Phone → A → B → same-channel result through two isolated Hosts | [Native phone/Host qualification](work-forwarding.md#phone--two-native-hosts-follow-up--2026-10-18), mobile #2157 | Bounded health check only; hardware diversity, arbitrary commands and WebSocket remain unproven | +| Natural invitation entry and shared workspace navigation | Invitation #2169; guest projection UAT [evidence](evidence/2026-10-18-workspace-directory-uat.json); mobile #2170 source tests | New drawer native switch/revoke/account isolation/text-size/theme evidence pending; disk capacity currently prevents assignment | +| Share and join with URL/QR | Recipient-bound URL preview/accept is recorded in [CLI contract](t1-cli-session.md) | Sender native copy/share, QR rendering/save, new-instance Hosted AuthKit continuation and camera/Android gates remain open | + +The next assigned device run must use the final #2170 source SHA, not an earlier green candidate. Display-scope hardening is distinct from authorization: saved account identity partitions local view state while verified live identity and current server checks continue to authorize requests. Normal refresh must retain a draft; account replacement must not reveal the previous user's cached view. + ## First slice contract `POST /api/onboarding` runs after authenticated sign-in and on explicit session checks. A fixed server-derived user operation provisions "My workspace" once; it cannot be selected by caller-provided user IDs. `GET /api/me` remains read-only. Existing instance deployments retain admin-only admission until a protected operator policy change enables authenticated users and additional org creation. WorkOS registration configuration remains a separate control; invitation-only registration can coexist with normal non-admin users.