test(sessions): agent with a device-token Sessions credential owns the session in its own group

Merged
KH
5d ago
+29-0

Pins the header combination a headless uploader uses (AgentWorkforce/infra#432, the Slack app's agent host): X-Relaygate-Token: rg_<pit agent> with Authorization: Bearer sh_at_<uploader device token>.

The test sets controlPrincipals to map device and launch tokens to gid 11 (local), so the device token alone uploads into local. With the agent's rg_ token present, the agent is the principal. The new session is owned by the agent in gid 22. The device token is forwarded to Sessions unchanged and is never introspected (authenticate skips Control introspection whenever X-Relaygate-Token is set, src/app.ts). A later local upload doesn't move the session.

Test only; no behaviour change.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Adds a test covering a headless uploader that sends the agent's X-Relaygate-Token alongside the uploader's device token in Authorization. The agent is the principal: the session is created in the agent's group, the device token is forwarded unchanged without introspection, and a later local upload doesn't change ownership. Test only; no behavior change.