Repository navigation
feat(state): keep attached sessions in their own store file - #230
Open
wh1ter4bb1t-js wants to merge 3 commits into
Open
wh1ter4bb1t-js wants to merge 3 commits into
wh1ter4bb1t-js wants to merge 3 commits into
Conversation
added 3 commits
November 10, 2026 17:23
A session attached to a runtime the CLI did not create must never be unassigned by an older CLI that cannot tell it apart. StateStore now keeps attached records in a second owner-only locked file derived from the sessions path (sessions.attached.json by default, <stem>.attached.json for --config), reads and lists both files and removes from both, so existing callers work unchanged. The file a record is read from decides its attached flag, so refreshing a record writes it back to the file it came from and never moves it to the other one. Records in sessions.json gain an "attached": false key, which older versions ignore because they do not forbid extra fields.
A name can end up in both the sessions file and the attached file, for example when `colab new -s NAME` (in this or an older version) creates a session under a name that is already attached. StateStore now raises DuplicateSessionError for such a name from get and list, so commands that read the store stop before any Colab request, and the CLI prints the error with the recovery command: colab stop -s NAME forgets the attached record without unassigning and leaves the session the CLI created.
Reading one store's attached file as another store's sessions file, for example with `--config ~/.config/colab-cli/sessions.attached.json`, would stamp its records as CLI sessions and write them back that way; the reverse, a derived attached path that links to another store's sessions file, would stamp CLI records as attached. StateStore now refuses a sessions path ending in .attached.json (in any case, or a symlink to one) and a path whose derived attached path resolves to a file not named *.attached.json, before touching any file. The CLI runs the same check on --config at startup, because the store opens lazily and `colab new` or `colab run` would otherwise assign a runtime before the refusal and record it nowhere. Hard links and renamed copies are not detected in either direction: an attached file linked or copied under a sessions name, or a derived attached path hard-linked to another store's sessions file. DuplicateSessionError and the new AttachedStorePathError share StoreError, which the CLI reports as an error message instead of a traceback.
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.
why? the coming
colab ssh --attachneeds its own file, since older CLIs would unassign anything insessions.json. Adds an owner-only<stem>.attached.json, refuses a name in both files (colab stop -s NAMErecovers) and an attached--config. First of a stack.Tested:
python -m pytest tests/passes at each commit; 570 passed, 19 skipped at the tip.ruff checkpasses.