Skip to content

Commit b807323

Browse files
committed
fix: keep unmigrated commands out of transient-exclusive claims
Live verification found `keyboard` accepting a foreign-claimed device despite declaring `transient-exclusive`: unmigrated (ADR 0019 `legacy`) commands reach their device through dispatch, not through the request scope's device binding, so the claim gate never runs for them. `keyboard`, `clipboard` and `trigger-app-event` are `require-owner` until their platform execution migrates, and the descriptor honesty test now requires `device-runtime` execution for `transient-exclusive` so the same dishonest pairing cannot be declared again.
1 parent c0217c1 commit b807323

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

‎src/core/command-descriptor/__tests__/device-claim-policy.test.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ test('sessionless device mutations are a bounded, reviewed set', () => {
3636
// changes cross-worktree behavior for everyone sharing that device (#1799).
3737
assert.deepEqual(commandsWithPolicy('transient-exclusive'), [
3838
'boot',
39-
'clipboard',
4039
'install',
4140
'install_source',
42-
'keyboard',
4341
'prepare',
4442
'push',
4543
'reinstall',
4644
'shutdown',
47-
'trigger-app-event',
4845
]);
4946
});
5047

@@ -92,16 +89,19 @@ test('ownership-projecting and claim-free commands are bounded, reviewed sets',
9289
});
9390

9491
test('a transient-exclusive command can actually reach the device binding seam', () => {
95-
// A command-scoped claim only means anything for a command the daemon routes
96-
// and that performs platform execution; declaring it anywhere else would be a
97-
// claim nobody ever acquires.
92+
// The claim gate lives on the request scope's device binding, which only ADR
93+
// 0019 `device-runtime` commands pass through: an unmigrated (`legacy`)
94+
// command reaches its device through dispatch instead, so declaring
95+
// `transient-exclusive` there would be a claim nobody ever acquires. Live
96+
// verification of #1799 caught exactly that on `keyboard`. Those commands are
97+
// `require-owner` until their platform execution migrates.
9898
for (const descriptor of commandDescriptors) {
9999
if (descriptor.deviceClaimPolicy !== 'transient-exclusive') continue;
100100
assert.ok(descriptor.daemon, `${descriptor.name}: transient-exclusive without a daemon route`);
101-
assert.notEqual(
101+
assert.equal(
102102
descriptor.platformExecution.kind,
103-
'none',
104-
`${descriptor.name}: transient-exclusive without platform execution`,
103+
'device-runtime',
104+
`${descriptor.name}: transient-exclusive cannot be enforced without device-runtime execution`,
105105
);
106106
}
107107
});

‎src/core/command-descriptor/registry.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ export const RAW_COMMAND_DESCRIPTORS = [
665665
},
666666
{
667667
name: 'clipboard',
668-
deviceClaimPolicy: 'transient-exclusive',
668+
deviceClaimPolicy: 'require-owner',
669669
...(ownerFilesEnabled ? { ownerFiles: ['src/commands/system/index.ts'] as const } : {}),
670670
catalog: { group: 'public' },
671671
recordsSessionAction: true,
@@ -683,7 +683,7 @@ export const RAW_COMMAND_DESCRIPTORS = [
683683
},
684684
{
685685
name: 'keyboard',
686-
deviceClaimPolicy: 'transient-exclusive',
686+
deviceClaimPolicy: 'require-owner',
687687
...(ownerFilesEnabled ? { ownerFiles: ['src/commands/system/index.ts'] as const } : {}),
688688
catalog: { group: 'public' },
689689
recordsSessionAction: true,
@@ -768,7 +768,7 @@ export const RAW_COMMAND_DESCRIPTORS = [
768768
},
769769
{
770770
name: 'trigger-app-event',
771-
deviceClaimPolicy: 'transient-exclusive',
771+
deviceClaimPolicy: 'require-owner',
772772
...(ownerFilesEnabled ? { ownerFiles: ['src/commands/management/push.ts'] as const } : {}),
773773
catalog: { group: 'public', key: 'triggerAppEvent' },
774774
recordsSessionAction: true,

‎src/core/command-descriptor/types.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ export type CommandTimeoutPolicy = {
8787
* - `transient-exclusive` — sessionless device mutation; acquires a
8888
* command-scoped claim before device operations reach
8989
* the handler, refuses a foreign claim, and releases
90-
* in `finally`.
90+
* in `finally`. Enforced at the request scope's
91+
* device binding, so it is available only to ADR 0019
92+
* `device-runtime` commands.
9193
* - `acquire-session` — `open`; acquires the session claim before platform
9294
* preparation or mutation.
9395
* - `release-session` — `close`; releases the session claim only after

0 commit comments

Comments
 (0)