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
Open
airowe
wants to merge
11
commits into
callstack:main
Choose a base branch
from
airowe:worktree-fix-4171-leased-session-admission
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+809
−69
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9524a5f
fix(daemon): refuse leased requests that name no session at admission
airowe 2c7953c
fix(daemon): close the remaining unnamed lease paths at admission
airowe 3f24cf8
fix(daemon): keep session-held leases out of unnamed artifacts and qu…
airowe 6a2fdf3
fix(daemon): refuse unnamed doctor and capabilities on a leased session
airowe 8c61837
fix(daemon): treat a blank session as the default one at intake
airowe c5987ee
fix(daemon): refuse the Node client on a provider lease when it names…
airowe 7644201
fix(contracts): forward a session named in flags on the lease RPC
airowe 0dc46ec
refactor(kernel): home the session-naming predicate in the record module
airowe 071a06e
docs(daemon): say batch steps also carry the session-omitted marker
airowe 3707e62
Merge remote-tracking branch 'origin/main' into worktree-fix-4171-lea…
airowe fac7ed5
Merge remote-tracking branch 'origin/main' into worktree-fix-4171-lea…
airowe 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,29 @@ | ||
| 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: 'default', ...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,24 @@ | ||
| 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 or blank session runs under `default`. The Node client always sends | ||
| * that literal 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 { session } = request; | ||
| const named = typeof session === 'string' && session.trim().length > 0; | ||
| const omitted = | ||
| !named || (request.meta?.sessionExplicit === false && !namesSessionExplicitly(request)); | ||
| return { | ||
| session: named ? session : '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.