Skip to content

Studio: add account-aware workspace storage roots - #10250

Closed
Imagineer99 wants to merge 2 commits into
unslothai:mainfrom
Imagineer99:feat/multi-user-storage-foundation
Closed

Imagineer99 wants to merge 2 commits into
unslothai:mainfrom
Imagineer99:feat/multi-user-storage-foundation

Conversation

@Imagineer99

Copy link
Copy Markdown
Member

Summary

This is the first, deliberately small layer extracted from #10102.

  • Add a stable, filesystem-safe workspace key for an authenticated subject.
  • Resolve private Studio storage beneath a subject-specific workspace root.
  • Keep the existing unsloth owner's historical paths exactly unchanged.
  • Scope project and temporary roots by the same key while leaving shared caches and install-wide authentication storage shared.
  • Add focused compatibility, collision, Windows-path, nested-context, and thread-propagation tests.

This PR does not add account-management endpoints, the Accounts UI, request binding, or route-specific authorization gates. Those remain in the backed-up upper-layer branch and can be reviewed after this foundation lands.

Validation

  • 282 passed across the focused workspace-root and existing storage-root suites.
  • Ruff passed on all changed Python files.
  • Deterministic worktree checks: clean, 0 findings.
  • Pre-push gate: no stray tracked files; AGPL headers valid.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T14:47:55.704371Z fbda19a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbda19a973

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


def studio_db_path() -> Path:
return studio_root() / "studio.db"
return workspace_root() / "studio.db"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Track schema initialization per workspace database

When multiple subjects use the same server process, studio_db_path() now selects a different SQLite file for each subject, but storage/studio_db.py:102,1252-1258 and the provider, MCP, credential, and chat-generation storage modules still use process-global _schema_ready flags. After the first subject initializes its database, a second subject opens a new empty file while schema creation is skipped, so normal operations fail with no such table; rag_db.py:325-330 has the same problem after rag_root() became subject-specific. Key schema readiness by database path or verify each selected database independently.

Useful? React with 👍 / 👎.


def outputs_root() -> Path:
return studio_root() / "outputs"
return workspace_root() / "outputs"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve output defaults in the active workspace

For any subject different from the one active when modules were imported, existing defaults such as utils/models/checkpoints.py:143 and :301 retain an absolute path produced by the old import-time outputs_root(). For example, routes/preview.py:184 calls list_preview_targets() without an argument, and scan_checkpoints() passes that captured path to resolve_output_dir(), which compares it with the current subject's root and raises a path-containment ValueError, breaking preview listing for managed accounts. Make these defaults nullable and resolve the root at call time.

Useful? React with 👍 / 👎.

Comment on lines 100 to +101
def assets_root() -> Path:
return studio_root() / "assets"
return workspace_root() / "assets"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Route Hub storage through account-aware roots

Once a managed subject is bound, Hub-backed routes still bypass this account-aware root: hub/utils/paths.py:73-98 independently constructs assets, outputs, exports, and temporary paths beneath studio_root(), and hub/services/datasets/local.py:37-38 captures those shared dataset paths at import time. Consequently dataset uploads/listing and Hub model output/export discovery continue reading or writing the historical shared workspace rather than the active account's private root, defeating the isolation introduced here. Re-export the canonical storage-root helpers and avoid import-time path constants.

Useful? React with 👍 / 👎.

Comment on lines +49 to +51
return target(*args, **kwargs)
finally:
reset_workspace_subject(token)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the workspace bound while awaiting async targets

When target is an async callable, run_in_workspace("alice", target) only creates and returns its coroutine; the finally block then restores the previous subject before that coroutine is awaited. A caller using await run_in_workspace(subject, async_target) therefore executes storage lookups under the outer or legacy workspace and can silently read or write another account's data. Provide an async counterpart that awaits the target before resetting the token, or explicitly reject awaitable results.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants