Repository navigation
feat(mothership): serve worker calls only for a user and chat sim granted - #10192
myxamediyar wants to merge 3 commits into
Conversation
…nted Sim's worker-facing routes and its checkpoint control requests took the user, chat and owner the worker named, behind a secret the worker holds. Sim now issues a run grant with every leg it sends: an HS256 JWT over the turn's user, chat and workspace or organization, keyed by HKDF from Sim's auth secret under its own label, lasting a day. The worker returns it on each call. - internalCopilotAuth and the checkpoint executor check the grant against the identity the call names: a forged or mismatched grant is refused; a missing or expired one is served until MOTHERSHIP_REQUIRE_RUN_GRANT, so workers that predate grants keep working during rollout. - Run control renews a verified grant past half its life after rechecking the chat and the user's access, so a run that keeps checking its control keeps a valid grant however long it runs. Only a grant Sim verified is renewed. - Grants are signed synchronously, so issuing one adds no await to the dispatch path.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
[High impact] The changes appear safe to merge. SummaryAdds signed grants that bind Mothership worker calls to the user, chat, and owner Sim approved, with optional enforcement and renewal for active runs.
No new actionable issues found in the changes since the previous review. Reviews (2) · Last reviewed commit: "fix(mothership): read the grant switch a..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 13 files
This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Turn on auto-fix | Re-trigger cubic
…th secret, and match chatless grants exactly - MOTHERSHIP_REQUIRE_RUN_GRANT arrives as a string, since env skips validation, so "false" turned enforcement on. It is now read with isTruthy. - A Sim running with DISABLE_AUTH may have no BETTER_AUTH_SECRET. It now issues no grants and treats a call's grant as missing, instead of throwing on every leg. - A grant issued for a turn with no chat matched any chat a call named. A grant's chat must now equal the call's, and absent matches only absent. - Run control renewed grants for runs that had finished without a Stop. It now renews only while the run is still going. - TSDoc on the module's exported names. Autopsy: the tests set the switch as a boolean, always had an auth secret, issued every grant with a chat, and checked renewal in the grant module rather than in run control's answer for a finished run. Each case now has a test that fails without its fix.
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Click Fix with cubic on a comment, or reply @cubic-dev-ai fix this, and cubic writes the fix.
Turn on auto-fix | Re-trigger cubic
|
Closing for now; deferred. The branch stays if this is picked up again. |
Summary
internalCopilotAuthand the checkpoint executor check it against the identity a call names: a forged or mismatched grant is refused; a missing or expired one is served untilMOTHERSHIP_REQUIRE_RUN_GRANTis set, so workers that predate grants keep working while they roll outsim-transport,run-control) gain the header, the control request'sgrantand the renewal field;.env.exampledocuments the switchCompanion: simstudioai/mothership#981
Type of Change
Testing
run-grant.test.ts: a grant admits exactly the identity it names (another user, chat, workspace or organization is refused); a token the worker could mint with the secret it holds is refused; a missing or expired grant is served only until grants are required; a verified grant is renewed past half its life for the same identity, and an unverified call gets noneinternal.test.ts: identity headers the grant names are admitted, a forged or mismatched grant is refused, and a call without one is refused once grants are requiredcontrol.test.ts: a checkpoint request whose grant names another chat is refusedrun.test.ts: every initial and resume leg, for workspace and organization owners, carries a grant that verifies for the turnlib/mothershipandlib/core/configsuites pass (3267 tests);bun run lint,bun run type-checkandbun run check:auditspassChecklist
test-auditauthoring gate)