refactor: apply repository naming contract
Apply the accepted pre-release package, service, type, directory, and role renames as one repository-wide change.
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/workspace/README.md
|
||||
README.md: 7e30f26a9854031b4907ad3e7edb35da5986d5d9
|
||||
README.zh.md: 6315ccb6b3a8b86161728e8296746efd0c334a29
|
||||
README.md: d12eb9434ec092834a7c34e424edc1d003430b35
|
||||
README.zh.md: 796c48cdbd1916c06e9bb914c6a5149769a58b4e
|
||||
|
||||
@@ -6,7 +6,7 @@ This family owns persistent workspaces: user directories with titles and ordered
|
||||
|
||||
| Package | Role | ctx key |
|
||||
|---|---|---|
|
||||
| [`workspace/`](workspace/README.md) | Registers workspaces and accounts for their sessions | `ctx.workspace` |
|
||||
| [`workspace/`](workspace/README.md) | Registers workspaces and accounts for their sessions | `ctx.workspaceRegistry` |
|
||||
|
||||
The [workspace package reference](workspace/README.md) owns lifecycle, persistence, and deletion semantics.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
| 包 | 职责 | ctx 键 |
|
||||
|---|---|---|
|
||||
| [`workspace/`](workspace/README.md) | 注册 workspace 并记录其会话归属 | `ctx.workspace` |
|
||||
| [`workspace/`](workspace/README.md) | 注册 workspace 并记录其会话归属 | `ctx.workspaceRegistry` |
|
||||
|
||||
[workspace 包参考](workspace/README.md)负责生命周期、持久化和删除语义。
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/workspace/workspace/README.md
|
||||
README.md: 4f7e2925ca7572dc3cc32c2a294bd1f40b243254
|
||||
README.zh.md: 2f4f38dea881b2c8a2bb135c8f7b1b3c88b9190a
|
||||
README.md: c1c4309efdc85f4bc7a6b0f128df6d9f4f810ae1
|
||||
README.zh.md: f44ad04be0c63061200a256c5ce8cb24a4d3c54b
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
English | [中文](README.zh.md)
|
||||
|
||||
Workspace entity registry (`ctx.workspace`) for the DeepSeek Harness: durable workspace records, stable workspace order, and a newest-first candidate session index stored through the domain data form. Consumers see the `Workspace` interface; the entity implementation stays package-private.
|
||||
Workspace entity registry (`ctx.workspaceRegistry`) for the DeepSeek Harness: durable workspace records, stable workspace order, and a newest-first candidate session index stored through the domain data form. Consumers see the `Workspace` interface; the entity implementation stays package-private.
|
||||
|
||||
The entity/storage rationale lives in the [domain Agent Note](../../../.agents/notes/proposed/architecture/2026-07-24-domain-kv-storage-and-workspace.md); header-only bootstrap and GUI ordering live in the [Workspace UI product-flow Agent Note](../../../.agents/notes/implemented/feature/2026-07-25-workspace-ui-product-flow.md).
|
||||
|
||||
## Shape
|
||||
|
||||
- `ctx.workspace.create(path, title?)` — canonicalizes `path` via `fs.realpath`, rejects a nonexistent or non-directory path, creates at most one record per canonical path, and prepends a new record to durable workspace order. Repeated calls for that path return the existing workspace without changing its title; different paths may share a display title.
|
||||
- `ctx.workspace.get(id)` / `list()` / `resolveByPath(path)` — cache-served lookups. `list()` is synchronous and follows durable registry order; `resolveByPath` is async because it applies the same `realpath` canon and rejects a missing path rather than creating it.
|
||||
- `ctx.workspace.insertBefore(id, before?)` — moves a registered Workspace within durable registry order, DOM-insertBefore-like: before the anchor, or appended when the anchor is omitted. A source or anchor absent from the registry rejects without writing; a self-anchor or move to the current position resolves without writing. The returned id list is the complete committed order.
|
||||
- `ctx.workspace.delete(id)` — removes only the Workspace registration, its durable order entry, and its session account. Unknown ids return `false`; a removed record returns `true`. The directory, user files, live Sessions, and persisted session logs are never touched, so those Sessions become Ungrouped. A table-write failure restores the prior order and published entity.
|
||||
- `ctx.workspaceRegistry.create(path, title?)` — canonicalizes `path` via `fs.realpath`, rejects a nonexistent or non-directory path, creates at most one record per canonical path, and prepends a new record to durable workspace order. Repeated calls for that path return the existing workspace without changing its title; different paths may share a display title.
|
||||
- `ctx.workspaceRegistry.get(id)` / `list()` / `resolveByPath(path)` — cache-served lookups. `list()` is synchronous and follows durable registry order; `resolveByPath` is async because it applies the same `realpath` canon and rejects a missing path rather than creating it.
|
||||
- `ctx.workspaceRegistry.insertBefore(id, before?)` — moves a registered Workspace within durable registry order, DOM-insertBefore-like: before the anchor, or appended when the anchor is omitted. A source or anchor absent from the registry rejects without writing; a self-anchor or move to the current position resolves without writing. The returned id list is the complete committed order.
|
||||
- `ctx.workspaceRegistry.delete(id)` — removes only the Workspace registration, its durable order entry, and its session account. Unknown ids return `false`; a removed record returns `true`. The directory, user files, live Sessions, and persisted session logs are never touched, so those Sessions become Ungrouped. A table-write failure restores the prior order and published entity.
|
||||
- `Workspace.attachSession(id)` — validates a live or persisted session header cwd against the workspace path and prepends a new id. Unknown sessions, absent/unresolvable/non-directory cwd values, and mismatches reject without writing. `detachSession` removes only the candidate index entry.
|
||||
- `Workspace.insertSessionBefore(id, before?)` — moves an accounted session within the manual order, DOM-insertBefore-like: before the anchor, or appended when the anchor is omitted. A session or anchor absent from the account rejects without writing; a move to the current position resolves without writing. Registry Workspace order never changes.
|
||||
- `ctx.workspace.archiveSession(id)` / `archivedSessionIds` — the registry-global archive set, layered over workspace accounting: an archived session disappears from grouping surfaces but keeps its session log and its `sessionIds` slot, so a future unarchive restores its position. Archiving accepts any live or persisted session (accounted or Ungrouped), resolves without writing for an already archived id, and rejects an unknown id. State written before the field existed parses with an empty set.
|
||||
- `ctx.workspaceRegistry.archiveSession(id)` / `archivedSessionIds` — the registry-global archive set, layered over workspace accounting: an archived session disappears from grouping surfaces but keeps its session log and its `sessionIds` slot, so a future unarchive restores its position. Archiving accepts any live or persisted session (accounted or Ungrouped), resolves without writing for an already archived id, and rejects an unknown id. State written before the field existed parses with an empty set.
|
||||
- `Workspace.sessionIds` — synchronous id-plus-canonical-cwd membership projection in durable candidate order. Missing headers, invalid cwd values, and mismatches are filtered; the next workspace mutation prunes them. A medium indexing one session under two workspaces, claiming one path from two records, or diverging from durable workspace order rejects at startup.
|
||||
- `Workspace.status()` — uncached directory check, `'ok' | 'missing-dir'`; a missing directory never mutates the record.
|
||||
|
||||
@@ -28,7 +28,7 @@ Create and delete persist an explicit pending-mutation marker before their recor
|
||||
|
||||
#### What the model sees
|
||||
|
||||
Nothing. `ctx.workspace` serves workspace records to host-side consumers only: the package registers no tools, injects no prompts, and writes no session events, so no request field ever carries this package's data.
|
||||
Nothing. `ctx.workspaceRegistry` serves workspace records to host-side consumers only: the package registers no tools, injects no prompts, and writes no session events, so no request field ever carries this package's data.
|
||||
|
||||
#### Token effect
|
||||
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
[English](README.md) | 中文
|
||||
|
||||
DeepSeek Harness 的 Workspace 实体注册表(`ctx.workspace`):通过领域数据形式存储持久 workspace 记录、稳定 workspace 顺序和按新到旧排列的候选会话索引。消费方看到 `Workspace` 接口;实体实现保持包私有。
|
||||
DeepSeek Harness 的 Workspace 实体注册表(`ctx.workspaceRegistry`):通过领域数据形式存储持久 workspace 记录、稳定 workspace 顺序和按新到旧排列的候选会话索引。消费方看到 `Workspace` 接口;实体实现保持包私有。
|
||||
|
||||
实体/存储理由见[领域 Agent Note](../../../.agents/notes/proposed/architecture/2026-07-24-domain-kv-storage-and-workspace.md);仅使用头部的引导初始化和 GUI 排序见 [Workspace UI 产品流 Agent Note](../../../.agents/notes/implemented/feature/2026-07-25-workspace-ui-product-flow.md)。
|
||||
|
||||
## 结构
|
||||
|
||||
- `ctx.workspace.create(path, title?)`:规范化 `path` 时使用 `fs.realpath`,拒绝不存在或非目录的路径,每个规范路径最多创建一条记录,并将新记录前置到持久 workspace 顺序。对同一路径重复调用会返回现有 workspace,且不改变其标题;不同路径可以共用显示标题。
|
||||
- `ctx.workspace.get(id)`/`list()`/`resolveByPath(path)`:由缓存提供的查找。`list()` 为同步操作,并遵循持久注册表顺序;`resolveByPath` 为异步操作,因为它采用相同的 `realpath` 规范化方式,并会拒绝缺失路径,而不是创建路径。
|
||||
- `ctx.workspace.insertBefore(id, before?)`:在持久注册表顺序内移动一个已注册 Workspace,语义类似 DOM 的 insertBefore:插到锚点之前,省略锚点则追加到末尾。来源或锚点不在注册表中时拒绝且不写入;以自身为锚点或移动到当前位置时直接完成且不写入。返回的 id 列表是完整的已提交顺序。
|
||||
- `ctx.workspace.delete(id)`:只移除 Workspace 注册记录、对应的持久顺序条目及会话归属记录。未知 id 返回 `false`,成功移除记录则返回 `true`。目录、用户文件、活跃会话和持久化会话日志绝不受影响,因此相关会话会进入 Ungrouped。表写入失败时会恢复原顺序和此前发布的实体。
|
||||
- `ctx.workspaceRegistry.create(path, title?)`:规范化 `path` 时使用 `fs.realpath`,拒绝不存在或非目录的路径,每个规范路径最多创建一条记录,并将新记录前置到持久 workspace 顺序。对同一路径重复调用会返回现有 workspace,且不改变其标题;不同路径可以共用显示标题。
|
||||
- `ctx.workspaceRegistry.get(id)`/`list()`/`resolveByPath(path)`:由缓存提供的查找。`list()` 为同步操作,并遵循持久注册表顺序;`resolveByPath` 为异步操作,因为它采用相同的 `realpath` 规范化方式,并会拒绝缺失路径,而不是创建路径。
|
||||
- `ctx.workspaceRegistry.insertBefore(id, before?)`:在持久注册表顺序内移动一个已注册 Workspace,语义类似 DOM 的 insertBefore:插到锚点之前,省略锚点则追加到末尾。来源或锚点不在注册表中时拒绝且不写入;以自身为锚点或移动到当前位置时直接完成且不写入。返回的 id 列表是完整的已提交顺序。
|
||||
- `ctx.workspaceRegistry.delete(id)`:只移除 Workspace 注册记录、对应的持久顺序条目及会话归属记录。未知 id 返回 `false`,成功移除记录则返回 `true`。目录、用户文件、活跃会话和持久化会话日志绝不受影响,因此相关会话会进入 Ungrouped。表写入失败时会恢复原顺序和此前发布的实体。
|
||||
- `Workspace.attachSession(id)`:对照 workspace 路径验证实时或已持久化的会话头 cwd,并将新 id 前置。未知会话、缺失/无法解析/非目录的 cwd 值和不匹配情况都会在不写入的前提下被拒绝。`detachSession` 只移除候选索引条目。
|
||||
- `Workspace.insertSessionBefore(id, before?)`:在手动顺序内移动一个已记账的会话,语义类似 DOM 的 insertBefore:插到锚点之前,省略锚点则追加到末尾。会话或锚点不在记账中时拒绝且不写入;移动到当前位置时直接完成且不写入。注册表中的 Workspace 顺序绝不改变。
|
||||
- `ctx.workspace.archiveSession(id)`/`archivedSessionIds`:覆盖在 workspace 记账之上的注册表级全局归档集合:被归档的会话从各分组视图中消失,但其会话日志和 `sessionIds` 席位保持不变,未来取消归档时可恢复原位置。归档接受任何实时或已持久化的会话(无论已记账还是 Ungrouped),对已归档的 id 直接完成而不写入,并拒绝未知 id。在该字段出现之前写入的状态解析为一个空集合。
|
||||
- `ctx.workspaceRegistry.archiveSession(id)`/`archivedSessionIds`:覆盖在 workspace 记账之上的注册表级全局归档集合:被归档的会话从各分组视图中消失,但其会话日志和 `sessionIds` 席位保持不变,未来取消归档时可恢复原位置。归档接受任何实时或已持久化的会话(无论已记账还是 Ungrouped),对已归档的 id 直接完成而不写入,并拒绝未知 id。在该字段出现之前写入的状态解析为一个空集合。
|
||||
- `Workspace.sessionIds`:按持久候选顺序提供同步 id 加规范 cwd 成员投影。缺失头部、无效 cwd 值和不匹配情况都被过滤;下一次 workspace 变更会剪除它们。如果同一存储介质将一个会话索引到两个 workspace 下、用两条记录声明同一路径,或偏离持久 workspace 顺序,启动会被拒绝。
|
||||
- `Workspace.status()`:未缓存的目录检查,返回 `'ok' | 'missing-dir'`;目录缺失绝不会改动记录。
|
||||
|
||||
@@ -28,7 +28,7 @@ DeepSeek Harness 的 Workspace 实体注册表(`ctx.workspace`):通过领
|
||||
|
||||
#### 模型看到的内容
|
||||
|
||||
没有。`ctx.workspace` 只向宿主侧消费方提供 workspace 记录:此包不注册工具、不注入提示词、不写入会话事件,因此没有请求字段会携带此包数据。
|
||||
没有。`ctx.workspaceRegistry` 只向宿主侧消费方提供 workspace 记录:此包不注册工具、不注入提示词、不写入会话事件,因此没有请求字段会携带此包数据。
|
||||
|
||||
#### Token 影响
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@deepseek-ai/dsh-workspace",
|
||||
"description": "Workspace entity registry (ctx.workspace): durable workspace records with validated session attachment over the domain data form for the DeepSeek Harness",
|
||||
"description": "Workspace entity registry (ctx.workspaceRegistry): durable workspace records with validated session attachment over the domain data form for the DeepSeek Harness",
|
||||
"version": "0.0.1-rc.2",
|
||||
"publishConfig": {
|
||||
"access": "restricted"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Workspace entity registry (`ctx.workspace`): durable workspace records,
|
||||
* Workspace entity registry (`ctx.workspaceRegistry`): durable workspace records,
|
||||
* stable registry order, and header-validated session membership over the
|
||||
* domain data form.
|
||||
* @module @deepseek-ai/dsh-workspace
|
||||
@@ -66,7 +66,7 @@ export class WorkspaceOrderInvalidError extends Error {
|
||||
|
||||
declare module '@deepseek-ai/cordis' {
|
||||
interface Context {
|
||||
workspace: WorkspaceRegistry
|
||||
workspaceRegistry: WorkspaceRegistry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ export class WorkspaceRegistry extends Service {
|
||||
}
|
||||
|
||||
constructor(ctx: Context) {
|
||||
super(ctx, 'workspace')
|
||||
super(ctx, 'workspaceRegistry')
|
||||
}
|
||||
|
||||
/** Open the domain, finish bootstrap when required, and rebuild the ordered cache. */
|
||||
|
||||
@@ -29,15 +29,15 @@ const install: InvariantInstaller = Object.assign(
|
||||
ctx.on('domain/changed', (change: DomainChanged) => {
|
||||
if (change.domain !== 'workspace' || change.table !== 'workspaces') return
|
||||
if (change.operation === 'deleted') {
|
||||
if (ctx.workspace.get(WorkspaceId(change.key)) !== undefined) {
|
||||
if (ctx.workspaceRegistry.get(WorkspaceId(change.key)) !== undefined) {
|
||||
fail(
|
||||
`workspace record '${change.key}' was deleted while the registry cache still `
|
||||
+ 'publishes it — some write path bypassed ctx.workspace',
|
||||
+ 'publishes it — some write path bypassed ctx.workspaceRegistry',
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (ctx.workspace.get(WorkspaceId(change.key)) === undefined) {
|
||||
if (ctx.workspaceRegistry.get(WorkspaceId(change.key)) === undefined) {
|
||||
fail(
|
||||
`workspace record '${change.key}' landed durably but the registry cache holds `
|
||||
+ 'no entity for it — the cache and the domain table have diverged',
|
||||
@@ -45,7 +45,7 @@ const install: InvariantInstaller = Object.assign(
|
||||
}
|
||||
})
|
||||
},
|
||||
{ inject: ['workspace'] },
|
||||
{ inject: ['workspaceRegistry'] },
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { Context } from '@deepseek-ai/cordis'
|
||||
import InvariantService from '@deepseek-ai/dsh-invariants'
|
||||
import InvariantRegistry from '@deepseek-ai/dsh-invariants'
|
||||
import type { DomainChanged } from '@deepseek-ai/dsh-storage-domain'
|
||||
import * as WorkspaceInvariant from '../src/invariant.ts'
|
||||
import { WorkspaceId } from '../src/index.ts'
|
||||
@@ -8,8 +8,8 @@ import { WorkspaceId } from '../src/index.ts'
|
||||
/** Boot the invariant service plus the companion over a stubbed registry knowing exactly `ids`. */
|
||||
async function setup(ids: string[]): Promise<Context> {
|
||||
const ctx = new Context()
|
||||
await ctx.plugin(InvariantService)
|
||||
ctx.provide('workspace', {
|
||||
await ctx.plugin(InvariantRegistry)
|
||||
ctx.provide('workspaceRegistry', {
|
||||
get: (id: WorkspaceId) => (ids.includes(id) ? { id } : undefined),
|
||||
})
|
||||
await ctx.plugin(WorkspaceInvariant)
|
||||
|
||||
@@ -69,7 +69,7 @@ async function harness(options: HarnessOptions = {}) {
|
||||
ctx,
|
||||
fiber,
|
||||
pool,
|
||||
registry: ctx.workspace,
|
||||
registry: ctx.workspaceRegistry,
|
||||
changes,
|
||||
initChanges,
|
||||
list,
|
||||
@@ -188,13 +188,13 @@ describe('WorkspaceRegistry lifecycle and bootstrap', () => {
|
||||
const pool = new MemoryMediaPool()
|
||||
const ctx = await storageContext(pool)
|
||||
const fiber = await ctx.plugin(WorkspaceRegistry)
|
||||
expect(ctx.get('workspace')).toBeUndefined()
|
||||
expect(ctx.get('workspaceRegistry')).toBeUndefined()
|
||||
expect(pool.media.has('workspace')).toBe(false)
|
||||
|
||||
const list = vi.fn(async () => [] as SessionHeader[])
|
||||
ctx.provide('sessionPersistence', { list } as never)
|
||||
await fiber.await()
|
||||
expect(ctx.workspace.list()).toEqual([])
|
||||
expect(ctx.workspaceRegistry.list()).toEqual([])
|
||||
expect(list).toHaveBeenCalledTimes(1)
|
||||
expect(storedState(pool)).toEqual({ initialized: true, workspaceIds: [], archivedSessionIds: [] })
|
||||
})
|
||||
@@ -346,7 +346,7 @@ describe('WorkspaceRegistry lifecycle and bootstrap', () => {
|
||||
const first = await result.registry.create(dir)
|
||||
await result.fiber.dispose()
|
||||
const nextFiber = await result.ctx.plugin(WorkspaceRegistry)
|
||||
expect(result.ctx.workspace.list().map(workspace => workspace.id)).toEqual([first.id])
|
||||
expect(result.ctx.workspaceRegistry.list().map(workspace => workspace.id)).toEqual([first.id])
|
||||
await nextFiber.dispose()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"path": "../../util/brand"
|
||||
},
|
||||
{
|
||||
"path": "../../support/invariants"
|
||||
"path": "../../runtime-diagnostics/invariants"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user