Repository navigation
fix: session and job passes for outside agents - #41
Merged
Merged
Conversation
… its session A pass still lasts fifteen minutes, but a job started with it (a render, a transcription, a download) keeps it good until the job finishes, fails or is cancelled. The security middleware records the pass a request came in with; jobs.submit ties the new job to it and the job's last step lets go. An agent that keeps one pass for its connection can ask with session and its process id; the question then also offers session, and that answer gives a pass with no age limit, good until the agent ends it, its process is gone or the engine stops. GET /api/agent-access/pass says whether a pass is still good. Choosing Blocked now ends every pass at once. The MCP server asks this way, keeps a session pass across tool calls, checks it before each write and ends it when its client disconnects. The window's dialog is the shared dock module, which knows deny, once and always only, so the session answer cannot be given from the window until that module carries it.
…nd an agent's process id A pass kept alive by a job could be stretched again and again by starting a new job before the last one ended. Only a job started while the pass is under fifteen minutes old now keeps it, so the pass ends with the jobs begun in the time the person allowed. A session request's process id is now limited to the range a process id can take, and a process that cannot be looked at counts as gone, so a single odd id no longer stops every later pass from being given.
…ass for that job only
A session pass is now offered only when the process id the request names is
the process at the other end of the request's connection, found in the
system's own socket table (peer_process.py: /proc on Linux, lsof on macOS,
netstat on Windows), and only when that process's start time can be read.
The pass keeps the id and the start time and is live while a process with
both is running, so an id handed to a new process later does not keep it.
A session pass with no process id is not live.
A pass past its fifteen minutes that a job keeps now reaches only that job:
its status, result and cancel over JSON-RPC and DELETE /api/jobs/{id}.
Every other write is refused, starting a job included, so a job never
extends a pass further. However long its jobs run, a pass ends six hours
after it was given. Holds are keyed by job id and pass together and
counted, and the job hands back the pass it held when it ends, so another
job with the same id cannot end or take over a hold.
…s age The request guard now reads what a request's pass covers one time and uses that answer both to let the request in and to limit JSON-RPC to the jobs that keep the pass, so a job that ends in between cannot leave the request with no limit. The read happens only when a pass decides. A pass also keeps the wall-clock time it was given, and its age is the larger of the steady clock's and the wall clock's, so the fifteen minutes and the six hour limit count time the computer spends asleep.
The key check now answers both whether a request without the window key may go on and the job ids it was let in for, and the request guard puts exactly those ids in JOBS_ONLY. The pass is read once, inside the key check, and nothing reads it again later. A request let in for a pass's jobs with no job ids in hand is limited to an empty set, which reaches no job, rather than left without a limit.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Tests
How to ship