Skip to content

feat(service): the Mac's commands are sealed for following over Neon Realtime, claimed by id - #3274

Merged
luke-agent[bot] merged 1 commit into
mainfrom
luke/neon-realtime-mac-commands
Oct 21, 2026
Merged

luke-agent[bot] merged 1 commit into
mainfrom
luke/neon-realtime-mac-commands

Conversation

@charleslpan

@charleslpan charleslpan commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Stack 4 · Mac commands, on #4228 (luke/live-same-user). The service side of following the Mac's commands through the live layer: Neon Realtime where LUKE_REALTIME=on, and the held poll (#4272) everywhere else. It replaces the always-on held read of GET /api/mac-commands.

The held read does three jobs: it marks the Mac as listening, waits for commands, and claims them. A live read writes nothing, so each job gets its own procedure, on #4273's kinds:

  • live.macCommands (GET /api/live/mac-commands?kinds=): the commands of the named kinds that no Mac of the account has claimed, as one statement (macCommandsLiveStatement: user_id = $1 AND kind IN (…) AND claimed_at IS NULL, no clock window). It goes through sealedParts and is checked by sameUser like every live read. The reader sorts the rows (macCommandsOfLiveRows, earliest queued first, a shell row's text or a browser row's params).
  • macCommands.claim (POST /api/mac-commands/claim {id}): claims one command by id. The CLAIM_WINDOW is enforced here, on the service's clock. It answers with the command or not-found. Bearer only.
  • macCommands.listening (POST /api/mac-commands/listening {kinds}): markMacListening for the named kinds. Bearer only.

The held GET /api/mac-commands and the result routes are unchanged for released desktops.

Tests:

  • mac-command-store.test.ts: the live statement delivers only the account's own commands of the named kinds, and a claim by id takes a command once, for its own account, inside the window.
  • mac-commands-procedures.test.ts: claim and listening, byte for byte. A cookie is refused.
  • live-procedures.test.ts: the read is sealed for the bearer and the named kinds, and a read naming another account gets 401.
  • live-statements.test.ts: mac.commands calls only immutable functions, and Neon's drizzleAdapter seals it.
  • mac-command-client.test.ts: live names the kinds and the user (a 401 means signed out), and claim.

Checked piece by piece: tsc for features, service and database; vitest over features, service live, mac-commands and the store; knip; oxlint.

@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
luke-web Ready Ready Preview Oct 21, 2026 12:26am UTC

Request Review

@luke-agent
luke-agent Bot changed the base branch from main to luke/neon-realtime-scope-inbox October 17, 2026 01:16
@luke-agent luke-agent Bot closed this Oct 17, 2026
@luke-agent luke-agent Bot reopened this Oct 17, 2026
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from 0a6e6cd to 35d1920 Compare October 18, 2026 19:21
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from 540286a to ec49c51 Compare October 18, 2026 19:50
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from 35d1920 to ff729c0 Compare October 18, 2026 21:12
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from ec49c51 to b3d46c5 Compare October 18, 2026 21:41
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from ff729c0 to 7c1c859 Compare October 19, 2026 18:52
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from b3d46c5 to 1fc8bac Compare October 19, 2026 18:52
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from 7c1c859 to 40e92d8 Compare October 20, 2026 00:57
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from 1fc8bac to 3612722 Compare October 20, 2026 01:24
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from a7cb527 to 39ca561 Compare October 20, 2026 01:29
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from 3612722 to f5099ab Compare October 20, 2026 01:30
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from 39ca561 to 40e1669 Compare October 20, 2026 01:43
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from f5099ab to c078c53 Compare October 20, 2026 01:53
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch 2 times, most recently from ff97170 to 9710e65 Compare October 20, 2026 15:50
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from 7516be4 to 846b137 Compare October 20, 2026 21:55
@luke-agent
luke-agent Bot changed the base branch from luke/neon-realtime-scope-inbox to luke/live-tx-wait October 20, 2026 21:55
@luke-agent
luke-agent Bot force-pushed the luke/live-tx-wait branch from 7614a60 to 53c8ce1 Compare October 20, 2026 22:20
@luke-agent
luke-agent Bot changed the base branch from luke/live-tx-wait to luke/live-same-user October 20, 2026 23:30
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from 846b137 to 372d3e2 Compare October 20, 2026 23:30
@luke-agent
luke-agent Bot marked this pull request as ready for review October 20, 2026 23:42

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Base automatically changed from luke/live-same-user to main October 20, 2026 23:55
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from 372d3e2 to 740b9b3 Compare October 21, 2026 00:07
@luke-agent
luke-agent Bot enabled auto-merge October 21, 2026 00:07
…nd listened for on their own

A Mac following its account's commands through the live layer needs
three things the held read did in one:
- the unclaimed commands of its kinds as one live statement
  (`live.macCommands`, GET /api/live/mac-commands?kinds=), under the
  same-user check and polled or sealed like every live read;
- a claim of one command by its id inside the claim window on the
  service's clock (`macCommands.claim`, POST /api/mac-commands/claim);
- its presence for its kinds said on its own (`macCommands.listening`,
  POST /api/mac-commands/listening), since a live read writes nothing.

The held read stays for released desktops.

Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-mac-commands branch from 740b9b3 to abf8d9a Compare October 21, 2026 00:21
@luke-agent
luke-agent Bot added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 0a66a13 Oct 21, 2026
13 checks passed
@luke-agent
luke-agent Bot deleted the luke/neon-realtime-mac-commands branch October 21, 2026 00:32

This branch was successfully deployed

1 active deployment
Preview — abf8d9a8 Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant