Commit Graph
25 Commits
Author SHA1 Message Date
LegGasai efd4c8e44c Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
The lower branch now ignores stored `working-directory/change` events. On this
branch the sandbox test asserts that such an event moves neither the directory
nor the write boundary, the boundary upgrade guide says so again, and the
working-directory README drops the limitation about stored subdirectories.
2026-11-16 23:54:27 +08:00
LegGasai ad70a73280 feat(working-directory): ignore stored working-directory/change events
Earlier releases recorded both a model's `cd` and an entered worktree as
`working-directory/change`, and a log cannot tell them apart. The fold kept
such a directory when it lay inside the Session's original project. That let a
stored `cd` into a subdirectory narrow the workspace once consumers follow the
directory, and dropped a worktree outside the directory a Session was opened in.

Readers now ignore the event: a stored Session resumes in its original project,
or in the directory of its last `workspace-root/change`, and returns to a
worktree through `enter_worktree`. The fold state is the directory alone (state
version 3), and the forge worktree fold reads only `workspace-root/change`
(state version 7). Tests and Web fixtures that simulated a Host move with the
old event record `workspace-root/change`.
2026-11-16 23:34:54 +08:00
LegGasai c9b9859b74 Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
The lower branch removed `rootOf` and the `workspaceRoot` projection: a Session
has one directory, read through `ctx.workingDirectory.get`. This merge moves the
consumers of this branch to that read.

- sandbox-policy, workspace-files, and workspace-changes read `get`; the
  `recordedRootOf` read is removed. With the working-directory service mounted,
  a Session without a header directory is bounded by that service's default
  directory.
- The skill catalog, sidebar terminals, project instructions, `@` file
  candidates, the LSP workspace, and skill lookup return to the lower branch's
  code, which already reads the directory.
- The client helper exports `selectSessionDirectory` and `sessionDirectory`
  in place of the `{ root, cwd }` pair; `WorkspaceChangesSummary` keeps `cwd`,
  now the directory the turn started in.
- A stored `working-directory/change` inside the project moves the write
  boundary and file views with the directory; one outside returns to the project.
2026-11-16 22:33:13 +08:00
LegGasai 328d6204a8 refactor(working-directory): converge on one directory read
`get(session)` is the only read of a Session's directory again. `rootOf` and
the `workspaceRoot` projection are removed: the directory relative paths
resolve from is the workspace root.

The difference the second read expressed lives in the `workingDirectory` fold.
`workspace-root/change`, the event Host moves record, sets the directory. A
stored `working-directory/change`, whose directory the model could choose, sets
it only when the directory lies inside the Session's original project; a
directory outside the project returns the Session to the project, and the next
request's context reports it. The fold state gains the original project, so
its state version is 2. The forge worktree fold reads stored changes by the
same rule.

The subagent manager resolves a child's directory as on master. The compaction
snapshot fixture records its fixed directory as a Host move.
2026-11-16 21:36:30 +08:00
LegGasai 547dcea7a9 Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
The sandbox policy listens for `workspace-root/change` instead of testing the
`workspace` marker, and this branch's notes, upgrade guide, and test comments
name `working-directory/change` where they described a change without the
marker.
2026-11-13 14:22:27 +08:00
LegGasai a0cda70705 refactor(working-directory): record workspace moves as workspace-root/change
Replace the optional `workspace` marker on `working-directory/change` with a
separate `workspace-root/change` event. The directory service records the new
event for every change. `working-directory/change` keeps master's payload, is
tagged @deprecated, and has no writer.

The current-directory projection folds both events and the workspace-root
projection folds only the new one, so a stored Session keeps its original
project as its root. The Session format version is unchanged and no migration
runs; the persistence record for the marker is replaced by one for the new
event.
2026-11-13 14:13:45 +08:00
LegGasai 434ef15931 Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
Adapt the consumers to the Host-only workspace model of the base branch:

- sandbox-policy: a marked working-directory change, not an anchor, is the
  point that reads the entered root's Git layout again.
- working-directory: keep recordedRootOf on the reworked service and its
  test doubles.
- Tests that entered a checkout through relocate use set; tests that relied
  on a directory change inside the root append a change without the marker.
- SDK documents and the upgrade guide state that the workspace-write boundary
  follows setWorkingDirectory and a Host-chosen child start directory, and
  that exit_worktree leaves a worktree.
2026-11-11 22:08:19 +08:00
LegGasai ed30d274f1 refactor(working-directory): move the workspace only through Host operations
Remove the model-facing working_directory tool and the cwd parameter of the
subagent tools, so only Host operations move a Session's directory. Every
change the service records carries `workspace: true`, and the workspace root
is the directory of the last marked change, or the original project. The
anchor field, the anchor list, relocate, inherit, and anchorsOf are gone;
get, ensure, set, and rootOf remain.

A change without the marker, recorded while the model could move the
directory, moves only the current directory, so stored Sessions keep the
root they had.

- worktree: create enters the checkout through set; exit returns the Session
  to the source checkout of the recorded worktree that contains its directory,
  and exit_worktree exposes it to the model.
- subagent: a child starts in the parent's workspace root or a Host-chosen
  directory through set.
- SDK: the working-directory methods return { cwd } again and
  getWorkspaceRoot / get_workspace_root are removed.
- Recorded sessions: the worktree scenario leaves through exit_worktree and
  covers recovery from a removed worktree; the two scenarios that only drove
  the removed tool are deleted; three compaction scenarios lower their tuned
  context window by the removed tool-schema tokens.
2026-11-11 20:10:17 +08:00
LegGasai cfce16f1bf Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
# Conflicts:
#	docs/event-producer-consumer.md
#	docs/event-producer-consumer.zh.md
#	docs/module-graph.md
#	docs/module-graph.zh.md
#	docs/subsystems/sandbox.md
#	docs/subsystems/sandbox.zh.md
#	packages/experimental/client-ui-forge/README.i18n.yaml
#	packages/experimental/client-ui-forge/README.md
#	packages/experimental/client-ui-forge/README.zh.md
#	packages/experimental/worktree/README.i18n.yaml
#	packages/experimental/worktree/README.md
#	packages/experimental/worktree/README.zh.md
#	packages/experimental/worktree/src/index.ts
#	packages/extensions/tool-cordis/src/api-catalog.ts
#	packages/sandbox/sandbox-policy/README.i18n.yaml
#	packages/sandbox/sandbox-policy/README.md
#	packages/sandbox/sandbox-policy/README.zh.md
#	packages/sandbox/sandbox-policy/src/index.ts
2026-11-09 15:37:18 +08:00
LegGasai b5c048eea8 Merge remote-tracking branch 'origin/master' into feat/session-workspace-root
# Conflicts:
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	docs/event-producer-consumer.md
#	docs/event-producer-consumer.zh.md
#	docs/persistence-catalog.i18n.yaml
#	docs/persistence-catalog.md
#	docs/persistence-catalog.zh.md
#	docs/persistence-schema.json
#	packages/experimental/worktree/README.i18n.yaml
#	packages/extensions/tool-cordis/src/api-catalog.ts
#	packages/session/working-directory/README.i18n.yaml
#	packages/session/working-directory/README.md
#	packages/session/working-directory/README.zh.md
#	packages/session/working-directory/src/index.ts
2026-11-09 15:20:13 +08:00
LegGasai 6e638d05c8 Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
# Conflicts:
#	.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.i18n.yaml
2026-11-07 14:47:10 +08:00
LegGasai a44727c4e8 feat(working-directory): own the child directory decision in inherit
The subagent manager decided whether a child registers the checkout its
parent works in, reading the parent's anchors, containment, and header
from outside the directory service. inherit(agent, source, { cwd }) moves
that decision into the service: a source working in a registered checkout
other than the starting Session's original project passes it on through
relocate when the canonical cwd lies inside it; otherwise only the
directory is set. The manager resolves the directory before the provider
prepares, as before, and hands the same value to inherit afterwards.
2026-11-07 14:45:12 +08:00
sjw1231 c92eded7e4 docs: regenerate catalogs for the shell, sandbox, and working-directory errors
Regenerated Cordis, config, and persistence catalogs pick up the new
WorkingDirectoryError and SandboxPreparationError exports and the
shifted source lines; persisted type digests are unchanged.

Refs #7869
2026-11-06 16:39:36 +08:00
LegGasai e7a1c26e04 Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
# Conflicts:
#	apps/desktop-host/package.json
#	docs/capability-seams.i18n.yaml
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	docs/event-producer-consumer.md
#	docs/event-producer-consumer.zh.md
#	docs/subsystems/sandbox.md
#	docs/subsystems/sandbox.zh.md
#	packages/api/terminal-controller/README.i18n.yaml
#	packages/api/terminal-controller/README.md
#	packages/api/terminal-controller/README.zh.md
#	packages/api/terminal-controller/src/index.ts
#	packages/client/tsdown.client.ts
#	packages/client/ui-open-in-app/src/client/index.ts
#	packages/client/ui-open-in-app/src/client/session-reveal.tsx
#	packages/experimental/client-ui-forge/README.i18n.yaml
#	packages/experimental/client-ui-forge/README.md
#	packages/experimental/client-ui-forge/README.zh.md
#	packages/experimental/worktree/src/index.ts
#	packages/extensions/tool-cordis/src/api-catalog.ts
#	packages/sandbox/sandbox-local/README.i18n.yaml
#	packages/sandbox/sandbox-local/README.md
#	packages/sandbox/sandbox-local/README.zh.md
#	packages/sandbox/sandbox-local/src/index.ts
#	packages/sandbox/sandbox-local/tests/local.spec.ts
#	packages/sandbox/sandbox-policy/README.i18n.yaml
#	packages/sandbox/sandbox-policy/README.md
#	packages/sandbox/sandbox-policy/README.zh.md
#	packages/sandbox/sandbox-policy/src/index.ts
#	packages/sandbox/sandbox/README.i18n.yaml
#	packages/sandbox/sandbox/README.md
#	packages/sandbox/sandbox/README.zh.md
#	packages/sandbox/sandbox/tests/roots.spec.ts
#	pnpm-lock.yaml
2026-11-05 20:34:00 +08:00
LegGasai 848f44ed06 Merge remote-tracking branch 'origin/master' into feat/session-workspace-root
# Conflicts:
#	docs/capability-seams.i18n.yaml
#	docs/config-catalog.md
#	docs/config-catalog.zh.md
#	docs/persistence-catalog.i18n.yaml
#	docs/persistence-catalog.md
#	docs/persistence-catalog.zh.md
#	docs/persistence-schema.json
#	packages/experimental/worktree/README.i18n.yaml
#	packages/experimental/worktree/src/index.ts
#	packages/experimental/worktree/tests/worktree.spec.ts
#	packages/extensions/tool-cordis/src/api-catalog.ts
#	snapshots/session/compaction-output-reserve/session.v4.jsonl
#	snapshots/session/compaction-summary-headroom/session.v4.jsonl
#	snapshots/session/model-switch-compaction/session.v4.jsonl
#	snapshots/session/working-directory-admission/session.v4.jsonl
#	snapshots/session/working-directory-consumers/session.v4.jsonl
#	snapshots/session/working-directory/session.v4.jsonl
#	snapshots/session/worktree/session.v4.jsonl
2026-11-05 20:10:37 +08:00
Yichen Jiang 691ebd7b6c refactor(worktrees): move archive cleanup into the worktree service
The worktree service now records each checkout it creates as a
`plugin:worktree/created` record, folds them in its own `worktree`
projection with fork-aware ownership, and reclaims a clean, unreferenced
checkout when the Session that created it is archived. The Forge panel
reads the service's record and forwards its cleanup state; it no longer
writes a `created` record, owns a retention projection, or gates every
Session's directory access.

Admission registers the attempt inside the Workspace write queue and
returns; inspection runs afterwards, reading cold Sessions through the
projection cache when mounted and from their log otherwise, with subagent
children of an archived ancestor counted as archived. Only a path being
removed holds `working-directory/access`, whose request now carries the
access's `signal`, and listeners withdraw before the drain. Ignored files
no longer retain a checkout, matching Git's non-force removal; processes
and terminals are not consulted.

The Forge bundle mounts one `worktree` service: the `forge-worktree` row
and the `optional-forge-panel` group that isolated a second service are
gone, and `forge-panel` is a top-level row. `canRemove`, `remove`, the
`forgeWorktreeRetention` projection, and `ForgeWorktreeCleanup` are
removed; `WorktreeService.cleanupOf`, `WorktreeCleanup`, and the
`worktree/cleanup` Host event replace them. The upgrade guide moves to
the current version directory and covers the id removals.
2026-11-05 12:28:50 +08:00
LegGasai dac3cfc231 refactor(working-directory): single root accessor, extras helper, and review follow-ups
workingDirectory.recordedRootOf returns the recorded root without the
deployment fallback, so sandbox-policy and workspace-files share one
"root, else header, else own fallback" rule instead of comparing anchor
counts. dsh-sandbox exports additionalWritableRoots, the canonical extra
roots beside the workspace, which sandbox-local uses for ACEs and runner
arguments instead of slicing workspaceWritableRoots. sandbox-policy keeps
a local within and reads working-directory as a type-only dependency; its
derivation filter dedupes before dropping nested candidates. tool-skill
validates the directory before reading the root, as the other root
consumers do. The capability graph names api-workspace-files and
api-terminal-controller so their nodes link, the workspace-changes README
states the per-turn repository and root, the workspace-files solution
tsconfig keeps only its face references, and the terminal spawn comment
states that the root is read after validation.

Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796752
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796760
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796781
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796818
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796826
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796841
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796849
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796855
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796861
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796879
2026-11-04 18:09:50 +08:00
LegGasai dfff0da675 Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
# Conflicts:
#	.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.i18n.yaml
#	.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.md
#	.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.zh.md
#	docs/subsystems/working-directory.i18n.yaml
#	packages/session/working-directory/README.i18n.yaml
#	packages/session/working-directory/README.md
#	packages/session/working-directory/README.zh.md
2026-11-04 13:56:03 +08:00
LegGasai 215ed13d0b fix(working-directory): record canonical project directories and anchor the recovery destination
Producers record the Session header directory by its canonical spelling:
ACP session/new, the SDK server, and the Web controller resolve the
requested directory through the execution-world filesystem before
creating the Session, so the canonical paths later directory changes
record compare with the header lexically. The directory service registers
the deployment fallback as the first anchor of a Session without a
recorded project, on its first validation or before its first relocation,
and registers a recovery destination that no anchor contains. A root
therefore no longer stays on a checkout that disappeared, and a header
spelled through a symlink recovers onto the canonical project.

Review: https://github.com/deepseek-harness/deepseek-harness/pull/7817#discussion_r4454836433
Review: https://github.com/deepseek-harness/deepseek-harness/pull/7817#discussion_r4454836528
2026-11-04 13:54:03 +08:00
LegGasai 954d0c5f31 Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers
# Conflicts:
#	.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.i18n.yaml
2026-11-04 11:05:44 +08:00
LegGasai 2c25ae6b23 fix(working-directory): return the committed workspace root from relocate
relocate reported the requested anchor as the root, while the projection
selects the longest registered anchor containing the current directory.
The two differ when an original project inside the registered root already
contains the directory. Return rootOf() after the commit and document the
rule on RelocatedDirectories and the method.

Review: https://github.com/deepseek-harness/deepseek-harness/pull/7817#discussion_r4454836504
2026-11-04 11:02:45 +08:00
LegGasai b6aa7b437c feat(working-directory): route sandbox, file views, and discovery through the Session workspace root
Every consumer that describes the project to the user or draws the write
boundary reads rootOf(session) instead of the header directory: the sandbox
workspace-write policy, the workspace file service and desktop file drag, the
change recorder, the client Files tree, deliverables, open-in-app actions and
Session rows, new sidebar terminals, @ file candidates, the skill catalog,
project-instruction discovery, and the LSP workspace. The model's relative
paths keep resolving from the current directory.

The sandbox policy derives a linked checkout's Git administration directory
and common directory from its .git pointer and grants them as extra writable
roots; tool executions wait for that derivation through prepare(), and
Session creation and directory changes start it early. Windows ACL
confinement grants each extra root a standing ACE through a repeatable
--writable runner argument instead of refusing the policy.

Refs #2658
2026-11-03 18:49:34 +08:00
LegGasai a71975faf6 feat(working-directory): add Session workspace roots with anchored relocation
Each Session now has three directories: the immutable original project in
the header, the workspace root, and the current directory. `relocate`
registers an entered checkout as an anchor through the optional `anchor`
of one working-directory/change event, and the new workspaceRoot
projection selects the longest anchor containing the current directory,
so an ordinary cd inside a checkout moves only the cursor while entering
another checkout moves the root with it. A log without anchors keeps the
original project as its only anchor.

Worktree creation relocates instead of setting the directory; a subagent
that starts inside its parent's relocated root inherits that root; the
SDK working-directory methods return the root beside cwd; the user
context names the root while it differs from the current directory, and
a notice that selects another root ends with it. Consumers keep reading
the header or the current directory until a later change moves them.

Refs #2658
2026-11-03 17:24:29 +08:00
Yichen Jiang 5c37ee0163 feat(worktrees): clean up safe UI checkouts when sessions are archived 2026-10-27 12:57:10 +08:00
Tianyi Cui 79bd3d8da7 feat(session): centralize working directories and directory context 2026-10-06 01:27:54 +08:00