# Workspace bindings

> ROM 0.1.5. [Release artifacts](https://git.cybernomad.it/pmikstacki/ROM/releases/tag/v0.1.5).
> Matching package version: 0.1.5. Archive SHA-256: 03559d74df99f0fb29e94b9fa563c0b76ab4f3f831ec7ed9daf07103524146cc.
> Guide origin: isolated ROM checkout; guide is outside the package archive.


Import `WorkspacePreferences` and `createWorkspaceSession` from `rom-studio/workspace`.
This entry reuses the standard application controller and durable mutation recovery.
The application supplies its approved auth profile and workspace settings Resource kind.

## Host contract

Register an owned settings Resource with a `layouts` field containing a map of strings.
Each map key is compact JSON for `[resourceKind, resourceId]`. Each value is a saved native layout encoded as JSON text.
Provide a `save_layout` action with named string inputs: `kind`, `resource_id`, and `layout`.
Enforce ownership, immutable owner identity, and byte limits in ROM.
Stored preferences do not grant access to their target Resources.

The binding requires exactly one authorized settings row for the current principal.
The host controls provisioning and discovery. The binding selects the disclosed row through the standard application controller.

## Bind the session

```ts
import { createWorkspaceSession } from "rom-studio/workspace";

const binding = await createWorkspaceSession({
  base,
  profile,
  parent: appSession.lifecycle,
  resourceKind: "my-workspace-settings",
});
```

The settings session uses a separate client epoch. Rebinding it preserves the main editor's network requests.
Its principal and generation must match the authenticated parent session.
A parent session change disposes the binding. Call `binding.dispose()` when its consuming view closes.

`WorkspacePreferences` accepts a binding factory, the current Resource kind and ID, and capture/restore callbacks.
Its save and retry controls use the existing controller's revisions, original command identity, and durable intent store.
After reload, restore the saved mutation before retrying an unknown outcome.

## Restore the native view

Use `validatePaneLayout` from the matching installed `rom-ui/paneshell` package before changing the mounted document list.
Supply the host's permitted document IDs. Then restore the admitted layout under the current authority token.
Keep editor drafts in the session-owned application controller.

This binding supplies persistence composition. The host still selects document renderers, Resource permissions, and native layout admission.
Candidate browser evidence covers SQLite reload, visitor isolation, exact receipt replay, and retained drafts through native rearrangement.
Final versioned ROM 0.1.3 artifact acceptance and production deployment remain separate requirements.
