Files
extension-skills/skills/isa-extension-development/references/dashboard-workspace-files.md
T

32 KiB
Raw Blame History

Dashboard Workspace Files

This document describes the dashboard workspace file and folder model used by isa_dashboard, chat-ui-3, and hosted extensions.

Persisted Files And Folders

Workspace files and folders are stored as real workspace_file records in SurrealDB. Each record has a canonical absolute path and a stable record id.

Examples:

/models/model.gguf
/groups/team-alpha/extensions/rsx-bestekanalyser/diagnostics

File and folder identity is the workspace_file id. Paths are display and lookup metadata; clients must not invent virtual ids for missing parent folders. If a UI needs breadcrumbs for a file path, it should derive them for display without treating those breadcrumbs as browseable folders.

Workspace-file content reads and the generic download, replacement, and deletion APIs resolve files only by canonical path. They do not accept a workspace-file id as a lookup selector. Authoritative download and upload replies still return the persisted workspace-file id for cache identity, synchronization, and compare-and-swap bookkeeping, and replacement artifacts retain the resolved id as trusted server metadata. Administrative mutations may continue to address an already-selected record by its id.

The hosted-extension read surface uses filesystem_list_dir for one recursively or directly listed path and filesystem_get_files for one or a bounded batch of file contents. Listing merges dashboard inventory with locally available syncable files and reports whether the result is authoritative. With cachePolicy: "cache-only", listing performs no dashboard RPC and returns only pending or complete clean files whose bytes are locally readable. Content reads always attempt a complete clean local sync-cache entry first for syncable files, then retrieve only unresolved files from the dashboard with bounded concurrency and shared HTTP connection pooling. Optional sync revision and server content-hash preconditions are checked before bytes are exposed. Missing, incomplete, corrupt, pending, or mismatched cache entries are not evidence of dashboard deletion. Use cachePolicy: "cache-only" when polling local availability must never request a dashboard link or download; a content miss is returned per item as non-authoritative unavailable with reason: "cache-miss". Use cachePolicy: "dashboard-required" for canonical application, authoritative absence, or CAS preparation; the default local-first policy is suitable for ordinary reads and presentation hydration.

Group Visibility

Workspace inventory and group usability are separate.

  • A workspace file or folder can exist without being visible to every group.
  • A folder linked to a group grants that group visibility to descendants.
  • A file linked directly to a group grants visibility to that file only.
  • A direct file link does not make the parent folder browseable and does not expose sibling files.
  • If the first accessible item is below hidden parent folders, file browsers may show that item at the nearest visible level for navigation. The stored workspace_file id and canonical path do not change.
  • Removing a group link removes only that group availability. It does not delete the workspace file or folder.

Administrative file browsers may show workspace inventory according to the admin's workspace permissions. Group-context reads and writes must use the group-link visibility model and must not fall back to workspace-wide access.

Extension Group Folders

Extensions do not receive an automatic workspace tree at launch. When an extension needs shared group storage, it asks the host to ensure a group folder. The host sends the immutable launch workspace id, group id, and extension id to the dashboard's atomic EnsureExtensionGroupFolder operation. The operation verifies group membership and extension assignment, resolves or creates one real workspace_file folder, links it to the group, and enables its sync root in one SurrealDB transaction.

A source-mounted developer extension is the sole exception to the dashboard extension-assignment check. The trusted desktop host marks that install type, and the dashboard accepts the exception only when the authenticated user is a full workspace administrator. Its root remains unlinked from the group, so ordinary group members do not inherit access. Packaged extensions and non-administrators always require the normal workspace inventory plus explicit group assignment. The host does not expose developer mounts or their commands to non-administrators.

The folder id and its persisted group link are the storage authority. Group names and path slugs are not identities. Newly provisioned roots use a reserved, group-ID-derived path whose identity segments are deterministic hashes:

/groups/_group_ids/<stable-identity>/extensions/<id>

The selected launch group's extension assignment permits the ensure operation; the resulting folder link authorizes that folder and its descendants for the group. Workspace-file permission checks, sync authorization, mutation checks, and RIBLT snapshots use this persisted link and folder ancestry. They do not recompute a path from the current group name. The technical path may omit real records for its display-only intermediate breadcrumb segments; the returned root is the first real folder and descendants store its folder id as their parent.

Existing linked extension roots keep their real folder id and persisted path across group renames, including legacy paths of the form /groups/<group-name-slug>/extensions/<id>. When a group has no linked root, the ensure operation may adopt exactly one unlinked folder at its current legacy path. Adoption links and syncs that existing folder without copying or moving content. New roots never use the mutable group-name path, so groups whose names produce the same slug receive different folders.

The operation fails with FailedPrecondition instead of guessing when it finds structural ambiguity: more than one matching root linked to the group, one root linked to multiple groups, multiple rows at a candidate canonical path, an occupant of the wrong kind or extension at that path, or competing legacy and stable candidates. The diagnostic includes workspace, group, folder, path, and conflicting-group identifiers as applicable. An administrator should inspect the reported workspace_file rows and workspace_folder_group_link records, remove or relink only the incorrect structural records, and retry. Automatic repair never merges, copies, or deletes extension project JSON based on names, timestamps, or content similarity.

The host returns the real folder id, persisted path, and display-only group name. Extensions should store syncable files below the returned path. The selected group is captured when the extension starts; changing the active group elsewhere in the app must not silently move an already running extension to a different group.

For deployment, first audit existing extension roots and resolve ambiguous links, then deploy dashboard/proto stable-root support, then deploy the host's immutable-context and atomic ensure integration, and finally deploy extension reconciliation changes. Do not enable new-root creation from a newer host against a dashboard that does not understand linked legacy-root adoption.

Shared Project Registry

Shared projects are canonical identities for workflows that span multiple extensions. For each group the dashboard owns one registry root:

/groups/id-<hex-group-id>/projects

The root may have no persisted structural ancestor; its canonical path remains the same. The root and every direct project child are deterministic workspace_file records owned by system:shared-projects, with no extension owner, artifact, or sync state. They are user-private and read-only. One exact folder link makes the root and its children visible only to the matching group. The real project identity exposed to extensions is the child workspace_file id, not its mutable presentation in an extension.

Only the dedicated ListSharedProjects, CreateSharedProject, and SetSharedProjectArchived routes access this namespace. They validate workspace/group scope and current group membership or workspace-admin access. Mutations recheck authorization inside their transaction. Create adds the root, group link, and project atomically. IDs are derived from workspace, group, and the trimmed case-sensitive project name, which makes concurrent and repeated creates idempotent. Generic workspace-file creation is blocked below system-owned registry folders, including for extension contexts and admins.

Archiving sets optional archived_at metadata on the project record and updates its timestamp in one transaction. Restore clears that metadata. Both operations are idempotent and preserve the project id, name, parent, canonical path, root link, and all extension-owned data associated with the id. The default list excludes archived records; callers opt in with include_archived when they need an archive or restore view. The dashboard advertises this lifecycle extension as shared-projects-archive-v1.

Creating the first shared project also enables group artifact resources in the same transaction, matching ordinary folder-link behavior. Registry folders are not sync roots and are not writable project storage. Extensions keep their own files in their extension group folder and associate those files with the shared project id. Project names are case-sensitive, limited to 160 characters and 512 UTF-8 bytes, and a group is capped at 500 registry entries including archived projects.

The normative extension-level persistence, commit, reconciliation, and validation contract is documented in chat-ui-3/docs/extensions/20-dashboard-backed-project-sync.md. It distinguishes ordinary dashboard-backed writes from files explicitly opted into the optional offline file-sync queue.

User-Selected Grants

Extensions cannot read or write arbitrary group-visible files just because the current user can see them in the dashboard. Access to existing workspace files is local to the user's profile and granted through explicit user interaction:

  • openWorkspaceFile grants one file.
  • openWorkspaceFolder grants a folder subtree.
  • Grants are scoped by extension id, workspace id, and selected launch group.
  • Read-only grants allow list/read/download but reject upload, replacement, and delete.
  • Users can review and revoke local extension file grants in Settings.

These local grants are not synced to the dashboard and are not visible to other users.

Syncable Extension Files

Small shared extension files can be marked syncable with metadata such as:

{ "syncable": "true" }

Syncable files under the extension group folder are cached locally for the uploader, queued when offline, and synced to other users in the same group when dashboard sync is available. Extensions should not implement their own offline sync layer for these files. Merge conflicts remain dashboard-managed through the workspace file conflict flow.

The opt-in is the exact string value syncable = "true" and applies to text, base64 byte, and snapshotted local-file upload sources, including empty files. The extension group folder and writable local grant must already have been created while authenticated; first-time provisioning remains online-only. Once provisioned, a local save can replace an existing synced file or create a new file below that folder without dashboard availability. Successful local save means the bytes are durable and available to offline reads and lists after an app restart, not that the server has accepted them.

The single sync worker is woken after enqueue and replays pending content in the original extension and group scope. Repeated saves are latest-write-wins, and a reply for older bytes cannot clear newer pending content. Accepted uploads stay awaiting confirmation until reconciliation observes their revision and hash; conflicts retain the local bytes and stop retrying. Invalid paths, missing provisioned grants, read-only or revoked grants, and group mismatches are rejected before local persistence. Non-syncable uploads remain online-only.

The Filesystem API uses filesystem_upload_files as the only upload command for bounded batches of up to 256 files in one workspace and launch group; uploading one file uses a one-item list. Dashboard-first and syncable files share this envelope. The host validates every path and source before atomically publishing the syncable subset to the local sync index, returns one result per file, and leaves syncable dashboard replay to the sync worker. Syncable items use the exact metadata.syncable = "true" opt-in.

ISA Quote stores the canonical supplier-enrichment map as the ordinary workspace file suppliers/enrichments.json below its ensured extension root. Atomic JSON commands may target any canonical workspace path allowed by the extension's ordinary exact-file or folder grant, and accept every valid JSON root. atomic_json_apply takes an optional boolean syncable creation hint: exact true makes an absent file syncable, while omission or false uses dashboard-first creation. The hint never changes an existing file's authoritative sync_enabled mode. Non-syncable reads and applies require the dashboard; syncable files use the committed RIBLT cache plus a durable operation-only journal and can accept offline changes after their writable scope is provisioned.

The dashboard applies each accepted batch to the valid JSON currently at the path, or recreates an absent target from {}, writes one immutable artifact generation, and transactionally advances the ordinary workspace-file pointer and revision. Acknowledgment immediately removes exactly that in-flight batch from the journal, so the committed cache may temporarily remain older or unavailable until RIBLT reconciliation; extensions must distinguish that state from absence. Pending and reconciled changes use scoped filesystem-index-changed notifications. Atomic JSON has no separate document store, synthetic committed row, whole-file pending upload, or tombstone: a delete removes the file, a later apply recreates it, and atomic batches, deletes, and ordinary replacements take effect in dashboard arrival order.

Pending replay prioritizes smaller files and overlaps at most eight file uploads per workspace. Chunks within one file remain ordered, parent-folder creation remains scoped to the provisioned extension root, and one failed file does not stop sibling uploads before the worker reports the aggregate retry condition. Extensions may observe per-file pending, uploading, awaiting-confirmation, conflict, and error transitions or query the local file index, but local availability must not wait for those dashboard transitions.

Large read-only local downloads for non-syncable files are intentionally not a runtime contract yet. Add that path only when a concrete extension needs it.

Remote Cache Reconciliation

Exactly compatible remote dashboards advertise the workspace-file-riblt-v1 capability after the dashboard boot migration has completed. The desktop app then reconciles each workspace every 60 seconds over one bounded bidirectional RIBLT stream. A version mismatch, unknown version, missing capability, or unimplemented stream disables file synchronization and does not fall back to the legacy list/link polling path. Embedded local dashboards do not start the worker; a remote dashboard whose artifact provider is named local still synchronizes through its authenticated HTTP URL.

The available-resources response supplies a separate, explicit file-sync workspace list derived from persisted group and direct workspace memberships. Only IDs in that list start reconciliation. Display inventory remains a wider UI contract: the synthetic Public workspace and invitation-only workspace placeholders stay visible where applicable, but do not start file sync. A workspace that disappears or becomes unavailable after the response is retired only for the current worker epoch; reconciliation continues for the other eligible workspaces, and a later resource refresh starts a new epoch from the server's current eligibility list.

The server snapshot is the app-level readable union (extension_id = None) of file-kind records that are sync-enabled and reference a complete artifact. Normal workspace permissions, ownership, group file links, linked-folder ancestry, and extension group folders determine this union. Hashless legacy files remain eligible. Hidden rows contribute no symbols, counts, metadata, or download links.

Manifest version 1 contains only stable file ID, canonical persisted path, tagged optional extension ID, artifact ID, sync revision, tagged optional server-declared SHA-256, file size, and tagged optional content type. It is postcard encoded and BLAKE3 domain separated. The terminal digest hashes the sorted manifest-symbol set. Any canonicalization change requires a new manifest/capability version and a coordinated dashboard/app release.

Orphan Quarantine

A sync-enabled file is eligible for a RIBLT snapshot only when its persisted topology reaches its declared sync root. The declared root must exist in the same workspace, be a sync-enabled folder rooted in itself, and the file's real parent_id chain must be acyclic and reach that root. Display-only breadcrumb segments do not require rows. A legacy path, old revision, absent client-operation metadata, or adopted extension-root naming convention is never evidence of an orphan by itself.

When snapshot construction finds a missing or invalid root, missing parent, parent cycle, or parent chain that does not reach the declared root, it excludes that file while continuing to synchronize valid accessible siblings. Runtime discovery marks the file quarantined_orphan and creates or reopens one deterministic orphaned_sync_file attention record for the workspace and file. Failure to persist that review bookkeeping is logged, but does not admit the invalid file to the snapshot or abort healthy synchronization.

Workspace administrators can resolve the attention record by deleting the file or retrying after an explicit structural repair. Retry restores normal synchronization only after the same topology validation succeeds; it never guesses a parent or changes group availability. Deletion removes the file, its group links, and open quarantine records transactionally. An artifact record is removed only when a transaction-scoped reference check proves it is exclusive, and physical object cleanup occurs after commit so storage failures can be reported without restoring unsafe database state.

The stream phases are:

  1. client start; server challenge and ordered coded cells;
  2. client resolved server-only symbols; server bounded metadata batches;
  3. client requests only content it cannot reuse; server returns one expiring link wave at a time and waits for its acknowledgement;
  4. both peers verify exact totals and the terminal digest before the client applies anything.

Snapshot, cell, difference, batch, file, byte, time, per-user, global-session, and client staging limits are enforced. Protocol, authorization, integrity, snapshot-drift, or resource-limit failures retain the prior local generation and retry only with a fresh stream. Signed URLs are never persisted. A present server SHA-256 is checked against downloaded bytes before it is used as a reuse key. An absent hash is normal; a mismatching hash remains server metadata while the actual local SHA-256 addresses the immutable blob and produces a diagnostic.

The desktop cache stores immutable content-addressed blobs and one complete workspace index generation. It flushes the new generation and atomically moves a small recoverable CURRENT pointer only after all required downloads and terminal checks succeed. Readers therefore see either the complete old or the complete new generation. Startup recovers a previous pointer and migrates the old per-scope indexes without inventing unavailable artifact/hash state. Before index mutation, every reused blob is authorized by current server artifact/hash metadata, checked for existence and expected size, and leased under the workspace cache lock. Reused and downloaded blob leases remain held through the atomic generation commit, so concurrent generation cleanup cannot remove in-flight content. If the planned cache generation changed before apply, the attempt aborts without mutation and reconciles again from fresh state.

Pending edits keep their last accepted manifest and symbol unchanged, with pending bytes and optimistic revision/hash stored separately. Upload results are durable accepted, conflict, or pending outcomes. Accepted edits remain awaiting confirmation until a terminal reconciliation observes the resulting server revision; conflicts keep the local bytes. Zero-byte creates and replacements use the authenticated finalize operation so provider storage and replacement semantics complete on the server.

RIBLT Boot Migration And Sync Inheritance

Dashboard startup runs the resumable workspace-file-riblt-v1 migration before publishing the database handle. Each workspace is normalized transactionally, then recorded in dashboard_migration_state; the global completion marker is written and the capability advertised only after all workspaces succeed. The migration preserves absent hashes, clears malformed declared hashes, reconciles size/content type and a nonzero revision from complete canonical artifacts, and leaves ambiguous incomplete uploads untouched.

Existing descendants of a synced folder inherit the nearest valid persisted sync root. New folders and uploaded files inherit the same sync_enabled, sync_root_id, and revision state in their creation transaction. This changes sync eligibility only: it does not change ownership, permissions, workspace inventory, group links, or group visibility.

  • isa_dashboard/isa_dashboard_server_lib/src/routes/workspace_file_common.rs implements common file operations.
  • isa_dashboard/isa_dashboard_server_lib/src/routes/workspace_file_proto.rs converts workspace file records into proto objects.
  • isa_dashboard/isa_dashboard_server_lib/src/routes/workspace_file_access.rs validates canonical paths and enforces workspace-file authorization.
  • isa_dashboard/isa_dashboard_server_lib/src/routes/workspace_file_permissions.rs contains group-link and permission helpers.
  • chat-ui-3/src/routes/components/dashboard/WorkspaceFileBrowser.svelte displays workspace inventory and group-visible files.
  • chat-ui-3/src/routes/components/dashboard/WorkspaceFileModal.svelte edits file and folder metadata.

Unified file selection

The shared FileSelectionModal.svelte is mounted once inside the platform shell. Chat, extension import actions, extension file/folder grants, and administrative upload/replacement flows open it through requestFileSelection. Computer selection starts with a private snapshot; native snapshots use unique managed filenames, and browser snapshots use File bytes. Computer imports never grant access to the original file. Import-only callers have a fixed read-only notice; an editing-capable extension must declare filesystem-write permission and the user must explicitly enable editing of a selected group reference.

ListWorkspaceFiles, CreateWorkspaceFileDownloadLink, and workspace upload initialization accept optional group_id. When present, the server requires current membership in exactly that group and uses only its persisted file/folder links, including inherited descendants and directly linked files with hidden parents. Administrator status, ownership, and another group's links do not expand that inventory. Unscoped dashboard management retains its administrative behavior. Scoped browsing includes folders and complete readable file generations; hashless files remain selectable but cannot produce duplicate offers.

“Also upload to group” starts unchecked and uses an inline folder tree rooted at the captured group’s display name. Names and authorized parent IDs form the tree; canonical technical path prefixes, including a legacy general segment, are not displayed. The group root is navigation only; uploads require a real writable ordinary folder. Search retains ancestors, disclosure and selection are separate, and readable read-only parents remain navigable. The upload session persists that scope and rechecks membership, visibility, and write permission at initialization and completion. A filename collision is a conflict; changing the filename creates a separate file, while replacement remains an explicitly configured administrative action. Completed uploads retain canonical ID, path, accepted hash, and revision and are reused on retries within the same selection request. Duplicate reuse requires explicit selection and fresh authorization; content equality never grants access or changes a read-only grant.

User-facing selection sends user_picker=true. The dashboard requires the selected group and excludes extension-owned/scoped rows, system-owned rows, and their descendants by persisted ancestry and canonical containment. The same restriction covers listing/counting, downloads, uploads and completion, duplicate suggestions, folder creation, and explicit extension picker grants. Dedicated extension roots and administrative storage management retain their separate authorization. A versioned picker_context supplies the current group name and root-creation capability; clients disable group selection against older dashboards without this policy.

CreateGroupFolder accepts the selected group, optional real parent ID, folder name, and retry operation ID. Root creation preserves existing administrator/link permissions and atomically creates the folder, links only the selected group, and enables its artifact resources. Subfolders require current ordinary-parent write access and inherit its existing links and sync configuration. Stable group-ID paths remain canonical storage metadata. Duplicate names conflict; retries reuse the same committed result. Inline creation retains pending files, shows errors beside the name, and selects the newly created folder after refreshing inventory. Cancelling the picker does not remove a committed folder.

Native user-picker grants are versioned after dashboard validation. Legacy unvalidated grants require reselection. Current grants retain the ordinary-resource constraint on subsequent operations; they do not grant access to an extension subtree nested inside an ordinary folder. Native user-picked resources require current dashboard authorization instead of serving offline cached bytes; cache-only requests return unavailable or an explicit online-validation error. Dedicated extension-root caching retains its existing behavior.

Selection captures workspace/group and caller scope, accepts an abort signal, and holds completion open for retryable upload, grant, and storage errors. Scope changes cancel outstanding work and discard late results. Private remote documents use dashboard attachment records outside workspace inventory and group browsing, bound to owner, workspace, captured group and conversation. They are processed on the dashboard and become scoped conversation document IDs; originals and derived indexes share the workspace retention deadline. Native local documents retain original source paths and only derived data expires. See docs/model-execution-and-managed-servers.md for deployment routing.

Ongoing extension filesystem operations also revalidate the captured group. Native legacy list, download, folder-create, delete, upload, and explicit-replacement requests carry WorkspaceFileExtensionScope; uploads persist this scope through transactional completion. A native Developer installation may retain its own unlinked extension root only through a host-derived developer_root_id: the server requires a current full administrator, a real extension-owned folder, and no links to another group. User-picked resources never receive this exception. Packaged browser extensions always use strict selected-group authorization.

Browser group-file downloads use the authenticated, same-origin /web-files/download streaming endpoint, which checks the session, origin, CSRF token, selected-group authorization, and expected canonical generation before and after transfer. It resolves the signed object URL on the server, so selecting a group file does not require S3 bucket CORS headers. Native downloads stream through downloadSelectedFileSnapshot into managed copies with size/hash validation, cancellation, and partial-file cleanup. Both adapters recheck the selected inventory before returning a downloaded snapshot.

Private Conversation Attachments

Private chat uploads use resource_type = "private_attachment" through InitUpload, with a selected group_id and metadata.conversation_id. The upload transaction creates a separate conversation_document row; private sources never create workspace_file rows or group file links. Group sharing remains an independent workspace-file operation. A private upload requires current selected-group membership and the workspace artifact endpoint, without requiring the group to enable persistent shared artifacts.

ProcessConversationAttachment resolves a completed private artifact owned by the caller, or an explicitly selected workspace_file_id with workspace, group and optional expected sync revision. Group sources retain their canonical artifact references without downloading through a desktop. Its reply identifies the derived document by opaque document_id; display names and source artifact IDs are not document selectors. StreamChat.attachment_ids captures those document IDs separately from the client-provided thread JSON. Every tool call resolves the captured owner, workspace, execution group, conversation, lifetime and current group-file authorization again.

Document extraction, page rendering/OCR orchestration and Markdown chunking live in the Tauri-independent isa-document-processing crate. Dashboard processing resolves authorized group auxiliary models server-side, preserves the embedding model revision and dimensions, and publishes a complete chunk generation in one transaction. Text-only processing does not request OCR; hybrid PDF/DOCX and OCR-only processing require an authorized OCR deployment. Query embedding uses the same recorded deployment and revision. GetConversationAttachmentIndex and EmbedConversationDocumentQuery expose authorized preprocessing results to local hosts without disclosing model credentials.

The workspace private_attachment_retention_ms policy defaults to seven days and can be changed by UpdateWorkspaceChatSettings. The creation deadline applies to source bytes and all extracted text, embeddings and staging; reads do not extend it. A native switch or fallback may submit its original expires_at_unix_ms in upload metadata; the server accepts only a deadline at or before its own workspace-policy deadline. Expired rows deny access immediately. Periodic cleanup first marks rows expired and clears their chunk payload transactionally, then delegates physical artifact removal to retryable artifact lifecycle cleanup. Late processing completions must match their operation ID and a live document before publication. Group-file source artifacts and user originals are preserved. Interrupted processing becomes retryable after its bounded processing deadline.

CreateConversationAttachmentDownloadLink requires document, workspace, group and conversation IDs and rechecks their exact server-owned scope before issuing a bounded source URL. Local artifact originals live under a reserved private prefix; raw GET/HEAD requests to that prefix fail. Opaque local download grants bind the authenticated owner, document, source artifact and deadline, and the local listener rechecks current source/group authorization and expiry on every request. Deleting physical bytes later never makes an expired local grant usable.

Extension-derived group-file snapshots preserve their source authorization. Browser snapshots retain a hash of the live launch capability, source path and picker grant identity; generation, document tools and private download grants recheck the current launch, manifest and source access. Replacing or restarting a browser launch requires rebuilding these snapshots. Native grant removal immediately invalidates matching local snapshots and durably queues remote snapshot deletion; reconnect and remote document or generation entry points flush that queue before use. Cleanup deletes derived data and never deletes shared source files.