Repository navigation
fix(daemon): refuse leased requests that name no session at admission #4177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thymikee
merged 12 commits into
callstack:0.22
from
airowe:worktree-fix-4171-leased-session-admission
Nov 13, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
07d05e2
fix(daemon): refuse leased requests that name no session at admission
airowe 0c0edaa
fix(daemon): close the remaining unnamed lease paths at admission
airowe c3c3a6e
fix(daemon): keep session-held leases out of unnamed artifacts and qu…
airowe 3f7b64b
fix(daemon): refuse unnamed doctor and capabilities on a leased session
airowe 39b65af
fix(daemon): treat a blank session as the default one at intake
airowe 51a817a
fix(daemon): refuse the Node client on a provider lease when it names…
airowe 1e654ca
fix(contracts): forward a session named in flags on the lease RPC
airowe 2f0132a
refactor(kernel): home the session-naming predicate in the record module
airowe 06b16a8
docs(daemon): say batch steps also carry the session-omitted marker
airowe 572a1e7
fix(daemon): keep a blank session literal at intake
airowe dc7d186
fix(daemon): import the session naming check from kernel/record
airowe b36ca40
chore(gates): reconcile admission checks with 0.22 owners
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { expect, test } from 'vitest'; | ||
| import { buildDaemonRpcRequest } from '../lease-scope.ts'; | ||
|
|
||
| function leaseRpcParams( | ||
| flags: { session?: string }, | ||
| meta: { sessionExplicit?: boolean }, | ||
| ): Record<string, unknown> { | ||
| return buildDaemonRpcRequest( | ||
| { | ||
| token: 'token', | ||
| session: 'default', | ||
| command: 'lease_allocate', | ||
| positionals: [], | ||
| flags, | ||
| meta: { tenantId: 'acme', runId: 'run-a', leaseBackend: 'android-instance', ...meta }, | ||
| }, | ||
| { id: 'id', includeTokenParam: false }, | ||
| ).params as Record<string, unknown>; | ||
| } | ||
|
|
||
| test.each([ | ||
| ['a client that named none', {}, { sessionExplicit: false }, false], | ||
| ['a client that named one in its meta', {}, { sessionExplicit: true }, true], | ||
| [ | ||
| 'a client that named one in its flags', | ||
| { session: 'default' }, | ||
| { sessionExplicit: false }, | ||
| true, | ||
| ], | ||
| ['a caller that predates the fact', {}, {}, undefined], | ||
| ])('the lease method carries what %s said about its session', (_label, flags, meta, expected) => { | ||
| expect(leaseRpcParams(flags, meta).sessionExplicit).toBe(expected); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { expect, test } from 'vitest'; | ||
| import { resolveRequestSessionAtIntake } from './request-session-intake.ts'; | ||
|
|
||
| const OMITTED = { internal: { sessionOmitted: true } }; | ||
|
|
||
| test.each([ | ||
| ['a missing session', {}, { session: 'default', ...OMITTED }], | ||
| ['a blank session', { session: ' ' }, { session: ' ', ...OMITTED }], | ||
| ['an empty session', { session: '' }, { session: '', ...OMITTED }], | ||
| ['a session that is not a string', { session: 7 }, { session: 'default', ...OMITTED }], | ||
| [ | ||
| 'the literal default from a client that named none', | ||
| { session: 'default', meta: { sessionExplicit: false } }, | ||
| { session: 'default', ...OMITTED }, | ||
| ], | ||
| [ | ||
| 'a client that names the default session in its meta', | ||
| { session: 'default', meta: { sessionExplicit: true } }, | ||
| { session: 'default' }, | ||
| ], | ||
| [ | ||
| 'a client that names its session in its flags', | ||
| { session: 'default', flags: { session: 'default' }, meta: { sessionExplicit: false } }, | ||
| { session: 'default' }, | ||
| ], | ||
| ['a caller that predates the fact', { session: 'default' }, { session: 'default' }], | ||
| ['a named session', { session: 'agent-a' }, { session: 'agent-a' }], | ||
| ])('intake reads %s', (_label, request, expected) => { | ||
| expect(resolveRequestSessionAtIntake(request)).toEqual(expected); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { namesSessionExplicitly } from '@agent-device/kernel/record'; | ||
| import type { DaemonRequest } from './daemon-request.ts'; | ||
|
|
||
| /** | ||
| * What a transport takes from a request's session: the name it runs under, and whether the caller | ||
| * named one at all. A missing session runs under `default`. A blank one names no session but keeps | ||
| * its literal, so a command that validates the name, such as a web open, still refuses it. The Node | ||
| * client always sends `default` and reports the omission in `meta.sessionExplicit`, so the literal | ||
| * stays and cwd-scoped routing keeps reading it. A caller on neither carrier predates the fact and | ||
| * counts as named. | ||
| */ | ||
| export function resolveRequestSessionAtIntake(request: { | ||
| session?: unknown; | ||
| flags?: { session?: unknown } | Record<string, unknown>; | ||
| meta?: { sessionExplicit?: boolean | undefined }; | ||
| }): Pick<DaemonRequest, 'session' | 'internal'> { | ||
| const literal = typeof request.session === 'string' ? request.session : undefined; | ||
| const named = literal !== undefined && literal.trim().length > 0; | ||
| const omitted = | ||
| !named || (request.meta?.sessionExplicit === false && !namesSessionExplicitly(request)); | ||
| return { | ||
| session: literal ?? 'default', | ||
| ...(omitted ? { internal: { sessionOmitted: true } } : {}), | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.