Skip to content
Closed
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
2 changes: 1 addition & 1 deletion crates/dim-app-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ dim_app_server::cli::process_entry(
)
```

`ManagedProviderRow` registers the plugin's process row given the product root's FileStorage index and returns the row name; `ServerConfig.managed_provider` carries it for embedders. It is installed only with a product home, beside `ManagedProviderBinding`, which hands the provider to the managed provider implementation. The plugin owns its account schema, authentication, token refresh and catalog normalization; the host does not interpret supplier-specific responses. Files it keeps under the product root go through FileStorage; `auth.json` is plain JSON shared with the native subscription providers, each owning its own root fields.
`ManagedProviderRow` registers the plugin's process row given the product root's FileStorage root id and returns the row name; `ServerConfig.managed_provider` carries it for embedders. It is installed only with a product home, beside `ManagedProviderBinding`, which hands the provider to the managed provider implementation. The plugin owns its account schema, authentication, token refresh and catalog normalization; the host does not interpret supplier-specific responses. Files it keeps under the product root go through FileStorage; `auth.json` is plain JSON shared with the native subscription providers, each owning its own root fields.

`process_entry` is the process entry: on Unix it closes every descriptor above standard error that the process inherited, then calls `run_with`, so a process `main` calls it before it opens anything. Linux closes the range in one `close_range` call; where that call is unavailable, and on the other Unix systems, the daemon lists `/proc/self/fd` (Linux) or `/dev/fd` and closes every number the listing names; when no listing can be read it closes 3 up to the process's descriptor limit, which is the soft limit, else the hard limit, else `sysconf(_SC_OPEN_MAX)`, else 65,536, so no inherited descriptor stays open. `run_with` and `run` do not touch the descriptors the process has open and are the entries for an embedder that keeps its own. `process_entry` and `run_with` take a native-profile installer, `fn(&mut AgentBuilder)`, called when the product-home or model-config execution profile is assembled. It contributes host-selected plugins through the existing builder API. `run` and the standalone server choose no additional native plugins; `dimcode` installs its product plugins from their own crates (`dim_session_title::install`, `dim_agent_scheduler::install`, `dim_goal::install`, `dim_report::install` and `dim_modality::install`) for both profiles. The Scheduler and the Goal are among those plugins and are no longer default TypeScript plugins, so a host that wants `schedule.*` and the `schedule` tool calls `dim_agent_scheduler::install` from its installer, one that wants `goal_update`, `session.goal.*` and continuation calls `dim_goal::install`, one that wants `modality.*` calls `dim_modality::install`, and the plain `dim-app-server` binary serves none of them.

Expand Down
6 changes: 3 additions & 3 deletions crates/dim-oauth/docs/runtime-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ terminal and returns `cancelled`. DimOAuth never writes Session metadata or choo

## Account record

`<product home>/auth.json` is the only persisted source of Dim credentials (`nextApiOauth`) and account state (`dimAccountState`, schema 1: `credentialEpoch`, `generation`, `credentialRevision`, `state`, and when authenticated `identity` and `tokenDigest`). It is plain JSON shared with the native subscription providers; other root fields belong to their owners and are preserved. Writes go through the product root's FileStorage lease, which also serializes concurrent processes, with Unix mode 0600. A lookup that finds a usable record reads the file atomically without that lease, so a fresh grant creates no `auth.json.lock` marker and no fsync; the lease is taken when a refresh, normalization or any other write is needed. The provider publishes whether the file stores a signed-in account as a watch, and moves it after every write. The startup initialization and the host's `observe_account` share one read-only observation. An observation whose validated state already equals the published one answers from the atomic read and publishes nothing; a missing `auth.json` is a home that never signed in, and the observation neither creates nor normalizes it. The first observation, or one whose state differs, takes the lease, rereads the file and publishes that validated read, whose `tokenDigest` must match its grant, before releasing the lease; a record this build cannot validate publishes nothing. The observation ends with its caller's wait: dropping the wait ends the lease wait, so a timed-out Session read leaves no retry behind. An `account.status` read whose result differs from the published state — including the first read after an uninitialized start — takes the lease and reads the file again, publishing that observation before releasing it, so a read that started earlier never overwrites a newer write or logout; an unchanged result answers from the atomic read without the lease. `tokenDigest` is the SHA-256 of the grant's RFC 8785 canonical JSON.
`<product home>/auth.json` is the only persisted source of Dim credentials (`nextApiOauth`) and account state (`dimAccountState`, schema 1: `credentialEpoch`, `generation`, `credentialRevision`, `state`, and when authenticated `identity` and `tokenDigest`). It is plain JSON shared with the native subscription providers; other root fields belong to their owners and are preserved. Writes go through FileStorage's `auth.json.lock` marker (the marker protocol in the [FileStorage contract](../../../docs/architecture/rust-agent/plugins/FileStorage.md)), which also serializes concurrent processes, with Unix mode 0600. A lookup that finds a usable record reads the file atomically without the marker, so a fresh grant creates no `auth.json.lock` marker and no fsync; the marker is taken when a refresh, normalization, observation or any other write is needed; a cancelled claim that has not returned its id removes the marker it created, and a refresh's claim is released only after the row's admitted `update_claimed` settles; a claim whose observation or normalization is cancelled or refused before its write releases the claim without writing. The provider publishes whether the file stores a signed-in account as a watch, and moves it after every write. The startup initialization and the host's `observe_account` share one read-only observation. An observation whose validated state already equals the published one answers from the atomic read and publishes nothing; a missing `auth.json` is a home that never signed in, and the observation neither creates nor normalizes it. The first observation, or one whose state differs, takes the marker, rereads the file and publishes that validated read, whose `tokenDigest` must match its grant, before releasing the marker; a record this build cannot validate publishes nothing. The observation ends with its caller's wait: dropping the wait ends the marker wait, so a timed-out Session read leaves no retry behind. An `account.status` read whose result differs from the published state — including the first read after an uninitialized start — takes the marker and reads the file again, publishing that observation before releasing it, so a read that started earlier never overwrites a newer write or logout; an unchanged result answers from the atomic read without the marker. `tokenDigest` is the SHA-256 of the grant's RFC 8785 canonical JSON.

The TypeScript plugin (0.2.0) wrote this file as a PluginFiles record `{"version":1,"text":...}`. Reading accepts that record, keeping fields other owners wrote beside it; the next write stores plain JSON. Its digests verify unchanged, so a signed-in account survives the upgrade with the same epoch and generation.

JSON or root errors and an unknown schema remain errors and are never shown as signed out. Only an explicit login or logout resets a corrupt schema-1 record: the complete original bytes are first written exclusively to `auth.json.dim-reset-backup`, then only the Dim fields are replaced by a new signed-out state. An existing backup blocks another reset and is never overwritten or removed. Explicit recovery (`account.recover`) accepts a legacy grant or a digest mismatch, confirms the identity online and starts a new epoch at generation 1.
JSON or root errors and an unknown schema remain errors and are never shown as signed out. Only an explicit login or logout resets a corrupt schema-1 record: one `update` passes `keep_replaced_as = auth.json.dim-reset-backup` (a bare name the owner joins to the target's parent), so the owner copies the current bytes exclusively under the file's lock (the key, or the credential record's marker) before the change replaces only the Dim fields with a new signed-out state. An existing copy answers `rejected` with reason `backup_exists`; it is never overwritten or removed, and it blocks another reset until it is moved. A change that refuses or writes nothing leaves no copy. Explicit recovery (`account.recover`) accepts a legacy grant or a digest mismatch, confirms the identity online and starts a new epoch at generation 1.

Login captures the record's revision before starting and compares it when committing. Logout advances the signed-out generation, including when already signed out, and revokes the refresh token on a best-effort basis. Credentials are refreshed within a 30-second freshness window, under the account lock, and a rotated grant is persisted before the lock is released; 408, 429, 5xx and network failures keep the stored grant, and an explicit rejection signs out only the grant that holds the lock. Requests resolve their credential under this window, which is the correctness boundary: a fresh grant answers from the atomic read, and only a grant inside the window waits for the lock and refreshes. While the process runs, a background task also renews the grant as it enters the window, so an idle process does not let its refresh token lapse. It renews and persists a rotated grant and signs out a rejected one, but it never normalizes the record it reads; write-on-normalize stays with the explicit account operations. It retries a transient failure after 60 seconds, and stops after a sign-out or an unusable record until this process signs in again. Quiesce ends it.
Login captures the record's revision before starting and compares it when committing. Logout advances the signed-out generation, including when already signed out, and revokes the refresh token on a best-effort basis. Credentials are refreshed within a 30-second freshness window, under the account marker claim, and a rotated grant is persisted before the claim is released; 408, 429, 5xx and network failures keep the stored grant, and an explicit rejection signs out only the grant that holds the claim. Requests resolve their credential under this window, which is the correctness boundary: a fresh grant answers from the atomic read, and only a grant inside the window waits for the marker and refreshes. While the process runs, a background task also renews the grant as it enters the window, so an idle process does not let its refresh token lapse. It renews and persists a rotated grant and signs out a rejected one, but it never normalizes the record it reads; write-on-normalize stays with the explicit account operations. It retries a transient failure after 60 seconds, and stops after a sign-out or an unusable record until this process signs in again. Quiesce ends it.

The public host contract (`ManagedProvider`, its DTOs, leases, quiesce and error mapping) is in the [App Server README](../../dim-app-server/README.md#managed-provider-contract).

Expand Down
2 changes: 1 addition & 1 deletion docs/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This index is navigation. Delivery status lives in issues, not here.
- [模型请求重试与任务续接方案](design/research/model-retry-recovery.md)(中文,#1210):请求重试的可见性、独立恢复能力的边界及所有者合同需求
- [服务面:跨语言形状的策略、盘点与第一批改造](design/service-faces.md)(中文,Draft),装配现状见[生成的服务目录](architecture/rust-agent/generated/catalog.md)。
- [插件远程化:可行性与落地路径](design/research/remote-plugins.md)(中文,研究稿):rutis 链路能跨什么、HostPlatform/exec/基础工具/存储各自能不能远程化、推荐拓扑与分阶段
- [Resource and store data faces](design/resource-faces.md) (Draft): `execHost`, `fsHost` and `store` as the only public contracts for processes, files and Session state (#1295, #1296, #1297, #1298)
- [Resource and store data faces](design/resource-faces.md) (Draft): `execHost`, `fsHost` and `store` as the only public contracts for processes, files and Session state (#1295, #1296, #1297, #2016, #1298)
- [Watch:任务观察与 side branch](design/research/side-eval.md)(中文,设计提案):Watch 与 Pursuit 的用户边界、分支切点、订阅与 prompt 的组合、管理与关注、采样开销
- [Overall design for undesigned features](design/overview.md)([中文](zh/design/overview.md))
- [Plugin designs index](design/plugins/README.md)([中文](zh/design/plugins/README.md))
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Terminal / npm launcher

Parts are rutis 0.23.0 plugins; a part that depends on services by name is a `host::DynPlugin` that keeps their keys ([How Dim uses rutis, appendix A](../design/rutis-usage.md#appendix-a-rust-binding)). Dependencies are declared once; the catalog keys each name for the instances a copy runs in. A managed provider is an optional Rust process plugin that an account build's own executable installs; without it, managed-provider requests fail explicitly while API-key providers remain available.

Plugin and part factories are pure and preserve plugin names and dependency keys. Configuration that must survive reload belongs to the captured plugin configuration; each `apply` acquires fresh I/O resources and registers their cleanup. FileStorage clones share the append-only authorized-root identities, while directory handles, operations and leases belong to one service generation. Rebuilding from the initial root list would let a later project reuse an earlier project's index.
Plugin and part factories are pure and preserve plugin names and dependency keys. Configuration that must survive reload belongs to the captured plugin configuration; each `apply` acquires fresh I/O resources and registers their cleanup. FileStorage clones share the append-only authorized-root identities, while directory handles, operations and keys belong to one service generation. Rebuilding from the initial root list would let a later project reuse an earlier project's index.

The WorkspaceTools plugin holds one file-write coordinator for every Session it serves and keeps it across reloads. `write` and `edit` share per-path admission across Sessions, retain their lock through blocking I/O and binding publication, and stage complete bytes before atomic replacement. Existing revision, identity and metadata are checked immediately before commit; new targets use create-if-absent publication. This is not compare-and-swap against unrelated processes or parent-directory replacement. Native metadata is preserved (macOS ACL/xattrs/resource forks, Linux xattrs/ACL, Windows DACL). Unchanged Linux security labels are retained without rewriting them. Windows alternate streams or ownership/security that cannot be preserved fail unchanged. An error after installation reports that the target may already have changed. Re-read before retrying.

Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/client-ui-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ HTTP to these owners, while the Web client owns mounting and selection.

| Part | Scope | Dependencies | Provides |
| --- | --- | --- | --- |
| UiExtensions | process | managementMethods, partRegistry, fileStorage | uiExtensions |
| UiResources | Session | sessionIdentity, sessionLifecycle, fileStorage | uiResources |
| UiExtensions | process | managementMethods, partRegistry, fsHost | uiExtensions |
| UiResources | Session | sessionIdentity, sessionLifecycle, fsHost | uiResources |

PluginManager registers UI content independently of code rows. UiExtensions
copies regular files through FileStorage into a private generation directory,
Expand Down
Loading