Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions contracts/file-workspace-discovery/v1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Authorized directory discovery v1

The response is generated from `FileWorkspaceDiscoveryOut` in
`sai_core/api/schemas/file_workspace_discovery.py`.

Each page contains the current actor's readable whole directory roots at one
site. Discovery reuses `file_workspace_roots(requested_role="read",
whole_roots=True)`. It reads existing authorization and directory facts without
walking the filesystem, requesting credentials, or reading wallets. Legacy
subdirectory grants do not become whole-root entries. Revocation is checked
again on each page and on every later operation.

The default page size is 50, with a maximum of 100. `next_cursor` is the existing
opaque keyset cursor. A page may contain no items and still have a cursor because
unauthorized candidates are filtered after the bounded candidate query. Continue
only when needed, retaining the actor and site. An invalid or revoked cursor
requires restarting from the first page. Database and inconsistent-fact errors
remain errors.

`workspace_ref` selects the directory. `workspace_mount_ref` binds its existing
mount lineage. `scope_ref` and `scope_label` identify its personal, organization,
or project scope. `label` uses the existing authorized directory presenter.
`path_label` is the registered relative path, while `path` is its canonical
absolute path. `account_workspace_key` identifies the account that owns the
directory. Its presence grants no account use.

`actions` are permission gates for using this directory. Browse and reference
require current read authority. Working directory, editing, terminal and BYOK
require write authority. SAI model and compute also require current permission
to use the owning account. An explicitly inactive workspace site denies those
account actions. These gates contain no balance, subscription, model allowance,
Slurm association, queue or native execution readiness promise. The existing
execution entrypoints recheck the current identity, account, site provisioning,
resources and funding before issuing grants or starting work.

An allowed action has `reason=null`. Denials use `read_only`,
`account_permission_required`, `needs_project_compute_permission`, or
`workspace_site_unavailable`. Only a current project member lacking project
compute permission receives `needs_project_compute_permission`.

The authenticated CLI route uses the existing `sai.ssh.mounts.read` metadata
consent. This directory listing does not perform SSH eligibility checks or issue
SSH credentials. `storage.read` remains quota consent and does not grant this
directory metadata. Portal and Pilot use their existing authenticated actor and
site context. The Agent request `PilotDirectoryAgentCallIn` reuses
`PilotAccountAgentCaller` and the original Session transport proof, with
`schema_version="sai-pilot-directory-read.v1"`.

Generate `schema.json` from `FileWorkspaceDiscoveryOut.model_json_schema()` with
the JSON Schema 2020-12 `$schema` declaration, and validate `example.json` with
that same model. `agent.schema.json` is generated
from `PilotDirectoryAgentCallIn.model_json_schema()` with the JSON Schema
2020-12 declaration. Response labels and paths are data, never shell fragments
or authorization selectors.

Browser callers use the existing `POST /v1/internal/pilot/browser/read` envelope
with `body={"action":"directory.list","limit":50,"cursor":null}`. Native Agent
callers use `POST /v1/internal/pilot/directories/read` and `agent.schema.json`.
The service must match the caller cell/site and validate the current native
generation and original Session transport. This read needs no default-account
management delegation and issues no execution grant. CLI callers use
`GET /v1/account/cli/file-workspaces?site_id=<site>&limit=50`, adding the returned
`cursor` when continuing. All three return the same page and private/no-store.

Paired consumers must also understand `model_payment.state=permission_required`
and reason `needs_project_compute_permission`. Actual project SAI model and
managed-compute requests reject with 403 and this reason. No missing compute
permission is converted into a server outage or a different payer.
53 changes: 53 additions & 0 deletions contracts/file-workspace-discovery/v1/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"schema_version": "file-workspace-discovery/v1",
"site_id": "research-east",
"items": [
{
"workspace_ref": "file:2ec1aa0a-8ec3-49cb-b30a-c910cda9a801",
"workspace_mount_ref": "wm1:2ec1aa0a-8ec3-49cb-b30a-c910cda9a801:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"kind": "project_root",
"label": "共同研究",
"path_label": "org-example/proj-study",
"scope_ref": "project:6931372b-e35e-4196-9830-5bc024cd4e11",
"scope_label": "共同研究",
"path": "/org/org-example/proj-study",
"role": "write",
"account_workspace_key": "project:6931372b-e35e-4196-9830-5bc024cd4e11",
"actions": {
"browse": {
"allowed": true,
"reason": null
},
"reference": {
"allowed": true,
"reason": null
},
"work_directory": {
"allowed": true,
"reason": null
},
"edit": {
"allowed": true,
"reason": null
},
"terminal": {
"allowed": true,
"reason": null
},
"byok": {
"allowed": true,
"reason": null
},
"sai_model": {
"allowed": false,
"reason": "needs_project_compute_permission"
},
"compute": {
"allowed": false,
"reason": "needs_project_compute_permission"
}
}
}
],
"next_cursor": null
}
207 changes: 207 additions & 0 deletions contracts/file-workspace-discovery/v1/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"FileWorkspaceActionOut": {
"additionalProperties": false,
"properties": {
"allowed": {
"title": "Allowed",
"type": "boolean"
},
"reason": {
"anyOf": [
{
"enum": [
"read_only",
"account_permission_required",
"needs_project_compute_permission",
"workspace_site_unavailable"
],
"type": "string"
},
{
"type": "null"
}
],
"title": "Reason"
}
},
"required": [
"allowed",
"reason"
],
"title": "FileWorkspaceActionOut",
"type": "object"
},
"FileWorkspaceActionsOut": {
"additionalProperties": false,
"properties": {
"browse": {
"$ref": "#/$defs/FileWorkspaceActionOut"
},
"reference": {
"$ref": "#/$defs/FileWorkspaceActionOut"
},
"work_directory": {
"$ref": "#/$defs/FileWorkspaceActionOut"
},
"edit": {
"$ref": "#/$defs/FileWorkspaceActionOut"
},
"terminal": {
"$ref": "#/$defs/FileWorkspaceActionOut"
},
"byok": {
"$ref": "#/$defs/FileWorkspaceActionOut"
},
"sai_model": {
"$ref": "#/$defs/FileWorkspaceActionOut"
},
"compute": {
"$ref": "#/$defs/FileWorkspaceActionOut"
}
},
"required": [
"browse",
"reference",
"work_directory",
"edit",
"terminal",
"byok",
"sai_model",
"compute"
],
"title": "FileWorkspaceActionsOut",
"type": "object"
},
"FileWorkspaceDiscoveryItemOut": {
"additionalProperties": false,
"properties": {
"workspace_ref": {
"maxLength": 256,
"minLength": 1,
"title": "Workspace Ref",
"type": "string"
},
"workspace_mount_ref": {
"maxLength": 256,
"minLength": 1,
"title": "Workspace Mount Ref",
"type": "string"
},
"kind": {
"enum": [
"home",
"org_share",
"org_user_dir",
"project_root"
],
"title": "Kind",
"type": "string"
},
"label": {
"minLength": 1,
"title": "Label",
"type": "string"
},
"path_label": {
"minLength": 1,
"title": "Path Label",
"type": "string"
},
"scope_ref": {
"maxLength": 256,
"minLength": 1,
"title": "Scope Ref",
"type": "string"
},
"scope_label": {
"minLength": 1,
"title": "Scope Label",
"type": "string"
},
"path": {
"minLength": 2,
"pattern": "^/[^\\x00]*$",
"title": "Path",
"type": "string"
},
"role": {
"enum": [
"read",
"write"
],
"title": "Role",
"type": "string"
},
"account_workspace_key": {
"maxLength": 256,
"minLength": 1,
"title": "Account Workspace Key",
"type": "string"
},
"actions": {
"$ref": "#/$defs/FileWorkspaceActionsOut"
}
},
"required": [
"workspace_ref",
"workspace_mount_ref",
"kind",
"label",
"path_label",
"scope_ref",
"scope_label",
"path",
"role",
"account_workspace_key",
"actions"
],
"title": "FileWorkspaceDiscoveryItemOut",
"type": "object"
}
},
"additionalProperties": false,
"properties": {
"schema_version": {
"const": "file-workspace-discovery/v1",
"title": "Schema Version",
"type": "string"
},
"site_id": {
"maxLength": 64,
"minLength": 1,
"title": "Site Id",
"type": "string"
},
"items": {
"items": {
"$ref": "#/$defs/FileWorkspaceDiscoveryItemOut"
},
"maxItems": 100,
"title": "Items",
"type": "array"
},
"next_cursor": {
"anyOf": [
{
"maxLength": 101,
"pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,35}~[0-9a-f]{64}$",
"type": "string"
},
{
"type": "null"
}
],
"title": "Next Cursor"
}
},
"required": [
"schema_version",
"site_id",
"items",
"next_cursor"
],
"title": "FileWorkspaceDiscoveryOut",
"type": "object"
}
5 changes: 5 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ local query convenience or authorized Agent management from the product.
The current no-subcommand entry selects the existing account summary handler; terminal detection
changes only plain-text versus JSON presentation, not the data source or authority.

Authorized directory discovery uses Portal's existing file-access resolver.
`storage directories` is a central metadata read with its own directory consent,
returning names, paths and current permission gates. The CLI preserves those
facts and pagination. Later file and execution requests retain their own checks.

The architecture keeps the following responsibilities separate:

| Owner | Responsibility | Explicitly does not own |
Expand Down
18 changes: 18 additions & 0 deletions docs/portal-api-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,24 @@ asset verification or deployment acceptance.
Paired Portal producer: `ecb4f96e56820ac86b6f19e0a8128f289727810c`.
The placement schema/sample are byte-identical across Portal, CLI and Pilot.

## Authorized directories

Paired Portal producer: `3971c667085ccb3c4d21002615b8ebacb81139d7`.

`sai storage directories` reads `GET /v1/account/cli/file-workspaces` with the
selected `site_id`, `limit` (1–100, default 50) and optional opaque `cursor`.
The [file-workspace-discovery/v1 contract](../contracts/file-workspace-discovery/v1/README.md)
contains current authorized directory roots, their names and paths, entry roles,
scope references and structured permission actions. It uses the directory metadata
scope `sai.ssh.mounts.read`. The ordinary Identity flow owns consent.

The client checks the returned site and allowlists every modeled field. Labels
and paths remain exact data in JSON and are visibly escaped in terminal output.
An empty page may contain `next_cursor`; continue as needed using that returned
cursor. Table output provides a command preserving site, page size, profile and
format. Every later file or execution operation checks its own current authority
and funding. This metadata query performs no native scan or SSH eligibility check.

## Storage quota summary

`GET /v1/account/cli/storage/workspaces` returns the independent
Expand Down
6 changes: 6 additions & 0 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ not imply production activation or completion of a paired rollout.

## Current priority: complete human and Agent tasks

- [ ] Qualify and pair `storage directories` with Portal's authorized directory
discovery and directory metadata consent. The client candidate preserves
explicit-site pages, directory paths and permission actions. Empty pages with
a cursor permit continuing toward the requested directory. Runtime and funding
admission remain with the existing execution endpoints.

- [x] Deploy the paired existing-account project invitation sender, shared
client and optional Identity scope. Preview, one confirmed send and original
request/invitation readback reuse the existing collaboration owner.
Expand Down
7 changes: 7 additions & 0 deletions docs/runtime-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ passed bounded ordinary-user checks in [terminal scope](terminal-scope.md);
it does not expand authentication scopes.
Remote errors must not cause a silent source or authority change.

`storage directories` reads the current authorized file roots from Portal's
`/v1/account/cli/file-workspaces` endpoint. The selected site, bounded page size
and returned cursor define each request. The dedicated DTO preserves labels,
paths, entry roles and permission actions. Empty filtered pages can still have a
next cursor. Human output lists name, entry access and path, with a copyable next
page command. The existing Identity transport handles this metadata read.

The first management action uses the existing default-account preference:
`account defaults` discovers site choices and projection receipts;
`account set-default` submits a global change with the caller's last saved value
Expand Down
Loading
Loading