dsh-taskbridge 0.0.0-stage → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +754 -0
- package/LICENSE +21 -0
- package/README.md +624 -3
- package/bin/dsh-delegate-codex-agent.js +115 -0
- package/bin/dsh-delegate-control.d.ts +90 -0
- package/bin/dsh-delegate-control.js +450 -0
- package/bin/dsh-delegate-mcp.d.ts +121 -0
- package/bin/dsh-delegate-mcp.js +273 -0
- package/codex/dsh-delegate.toml +245 -0
- package/cordis.patch.yml +6 -0
- package/docs/INTRODUCTION.md +15 -0
- package/docs/INTRODUCTION.zh.md +32 -0
- package/docs/auth-contract.md +138 -0
- package/docs/claude-code.md +31 -0
- package/docs/codex-integration.md +922 -0
- package/docs/contracts-stage-b.md +443 -0
- package/docs/conversation-placement.md +293 -0
- package/docs/plugin-market.md +30 -0
- package/docs/redaction-contract.md +127 -0
- package/docs/runtime-compatibility.md +220 -0
- package/docs/silent-wait.md +191 -0
- package/docs/taskbridge-upgrade.md +28 -0
- package/docs/taskdispatch-upgrade.md +25 -0
- package/docs/worker-permissions.md +347 -0
- package/docs/workspace-contract.md +538 -0
- package/icon.svg +1 -0
- package/lib/client.d.ts +118 -0
- package/lib/client.js +3232 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +135 -4
- package/src/auth/fence.js +361 -0
- package/src/auth/grants.js +789 -0
- package/src/client/api.js +2322 -0
- package/src/client/index.jsx +2333 -0
- package/src/client/styles.js +251 -0
- package/src/codex/installer.js +3260 -0
- package/src/codex/seam.js +429 -0
- package/src/codex/toml.js +784 -0
- package/src/config/defaults.js +164 -0
- package/src/config/redact.js +184 -0
- package/src/config/settings.js +629 -0
- package/src/config/store.js +186 -0
- package/src/config/validate.js +763 -0
- package/src/credentials/seam.js +202 -0
- package/src/http/execution-plane.js +454 -0
- package/src/http/respond.js +175 -0
- package/src/http/user-plane.js +1122 -0
- package/src/index.d.ts +332 -0
- package/src/index.js +657 -0
- package/src/jobs/activity.js +1008 -0
- package/src/jobs/engine.js +3609 -0
- package/src/jobs/history.js +1467 -0
- package/src/mcp/server.js +1820 -0
- package/src/mcp/wait.js +536 -0
- package/src/model/connectivity.js +371 -0
- package/src/model/discovery.js +582 -0
- package/src/model/native-catalog.js +68 -0
- package/src/model/openai-adapter.js +671 -0
- package/src/model/probe.js +264 -0
- package/src/model/providers.js +756 -0
- package/src/model/routing.js +321 -0
- package/src/review/preset.js +868 -0
- package/src/review/prompts.js +126 -0
- package/src/review/reviewer.js +933 -0
- package/src/runtime/agent-runner.js +1738 -0
- package/src/runtime/endpoint-discovery.js +118 -0
- package/src/runtime/permissions.js +1429 -0
- package/src/runtime/sandbox.js +358 -0
- package/src/runtime/session-placement.js +1103 -0
- package/src/workspace/audit.js +775 -0
- package/src/workspace/locks.js +167 -0
- package/src/workspace/preflight.js +424 -0
- package/src/workspace/worktrees.js +613 -0
|
@@ -0,0 +1,922 @@
|
|
|
1
|
+
# Codex integration contract
|
|
2
|
+
|
|
3
|
+
Status: implemented in 1.3.1 (1.1.0 shipped the wait rules; 1.2.0 adds the installed-integration upgrade). Scope: Codex only. Claude Code and other hosts are
|
|
4
|
+
out of scope and no surface for them is provided.
|
|
5
|
+
|
|
6
|
+
This document is the contract between the plugin's settings page (browser half),
|
|
7
|
+
the host-side installer (`src/codex/installer.js`) and the two files it manages.
|
|
8
|
+
It is written so a reviewer can check the code against it without reading the
|
|
9
|
+
README.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. What is owned, and what is not
|
|
14
|
+
|
|
15
|
+
| Path | Owner | The plugin may | The plugin may never |
|
|
16
|
+
| --- | --- | --- | --- |
|
|
17
|
+
| `$CODEX_HOME/agents/dsh-delegate.toml` | managed copy of `codex/dsh-delegate.toml` | create it **exclusively** on explicit install when absent; refresh a byte-exact known build during plugin startup or explicit install; delete it on `remove` only after re-reading it and finding the same bytes it classified | overwrite or delete a file that is not that exact build — including a file with an old version line whose body was edited, and including a file that changed in the window between the status read and the write/removal |
|
|
18
|
+
| `$CODEX_HOME/config.toml`, table `mcp_servers.dsh-delegate` | operator, with one managed entry | add the entry when absent; update `command`/`args`/its own `env.DSH_DELEGATE_DISCOVERY_FILE` when the entry carries **the plugin marker** *and* is the exact shape this plugin writes; on an explicit `install`/`repair` only, adopt a recorded `args[0]` that is a PROVED real installation of this package (manifest `name` + `bin["dsh-delegate-mcp"]` mapping) | touch any other key, table, comment or ordering; adopt, update or delete an unmarked same-name entry, even one whose values coincide; adopt a differing script path from the automatic startup check |
|
|
19
|
+
| `$CODEX_HOME` and `$CODEX_HOME/agents` | Codex | read them (lstat **and** the Windows file attributes); create `agents` (`0700`) when both are real directories | create them relative to the process working directory; **follow a link at either level** (POSIX symlink, Windows junction/reparse point) for any read-through, write or delete |
|
|
20
|
+
| DSH local-call switch | operator | report it | change it |
|
|
21
|
+
|
|
22
|
+
`$CODEX_HOME` resolution: `CODEX_HOME` when set and absolute; otherwise
|
|
23
|
+
`~/.codex`. A relative override is refused (`CODEX_HOME_INVALID`), because
|
|
24
|
+
resolving it against the harness's cwd would report on, and write to, a directory
|
|
25
|
+
nobody named.
|
|
26
|
+
|
|
27
|
+
### 1.1 Link boundaries
|
|
28
|
+
|
|
29
|
+
`lstat` on the final file is not enough: if `$CODEX_HOME/agents` is a junction,
|
|
30
|
+
`mkdir -p` and the file create walk *through* it and write
|
|
31
|
+
`agents/dsh-delegate.toml` outside the Codex home entirely. Both directories are
|
|
32
|
+
therefore inspected as *boundaries*:
|
|
33
|
+
|
|
34
|
+
| `$CODEX_HOME` | `$CODEX_HOME/agents` | result |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| real directory | missing | normal: install creates `agents` (`0700`) |
|
|
37
|
+
| real directory | real directory | normal |
|
|
38
|
+
| real directory | link (symlink or junction) | `agent.state = conflict`, `reason = agents-dir-is-link`; install/repair/remove all refuse with `AGENT_PATH_CONFLICT` |
|
|
39
|
+
| link | not inspected (nothing below a link is examined) | `agent.state = conflict`, `reason = codex-home-is-link`; same refusal |
|
|
40
|
+
| could not be verified | — | `agent.state = conflict`, `reason = boundary-unverified`; same refusal |
|
|
41
|
+
|
|
42
|
+
A **junction** is the case `lstat` cannot see: Windows reports it as an ordinary
|
|
43
|
+
directory. On Windows the `ReparsePoint` file attribute is read through one
|
|
44
|
+
`powershell.exe` child (`-NoProfile -NonInteractive`, hidden, 15 s bound), with the
|
|
45
|
+
paths passed in an environment variable rather than interpolated into script text.
|
|
46
|
+
The child answers one comma-separated verdict per path — `dir/<bool>`, `other/<bool>`
|
|
47
|
+
or `missing` — and the boolean is PowerShell's `Boolean.ToString()` output, whose
|
|
48
|
+
spelling is **not** stable (`True`/`False` on Windows PowerShell 5.1, `true`/`false`
|
|
49
|
+
under other hosts/cultures). The verdict is therefore parsed case-insensitively
|
|
50
|
+
(`parseDirectoryVerdict`), the script emits lower case via `ToLowerInvariant()`, and
|
|
51
|
+
anything that is not a recognised `dir/`/`other/`/`missing` answer is treated as
|
|
52
|
+
`other` (a path this plugin will not write under), never as a missing answer.
|
|
53
|
+
A regular directory — `dir/false` in any spelling — is `directory`, so the ordinary
|
|
54
|
+
Windows layout is unaffected; only `dir/true` / `other/true` are reported as a link.
|
|
55
|
+
This is pinned by a real-directory probe test that runs the actual PowerShell child on
|
|
56
|
+
a temporary directory on Windows (and skips elsewhere), not only through the test
|
|
57
|
+
classifier hook.
|
|
58
|
+
|
|
59
|
+
The status document reports this as `boundary: { blocked, link, unknown, home,
|
|
60
|
+
agents }`. A **failed** verification is a refusal, not a pass: if the platform
|
|
61
|
+
answer cannot be obtained (no spawnable shell, no PowerShell), the boundary is
|
|
62
|
+
`unknown` and every action refuses, because "could not check" must never be read
|
|
63
|
+
as "safe". The check is re-done at the start of every writing action from the
|
|
64
|
+
freshly read status, so a link that replaced either directory after the operator
|
|
65
|
+
last looked is still refused.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 2. The MCP entry
|
|
71
|
+
|
|
72
|
+
The owned shape, written as a marked block:
|
|
73
|
+
|
|
74
|
+
```toml
|
|
75
|
+
# dsh-delegate: managed by the DSH Delegate plugin settings page
|
|
76
|
+
[mcp_servers.dsh-delegate]
|
|
77
|
+
command = "<a Node.js executable, resolved as described in 2.1>"
|
|
78
|
+
args = ["<installed package>/bin/dsh-delegate-mcp.js"]
|
|
79
|
+
tool_timeout_sec = 3660
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
* `command` is an **absolute path to a Node.js executable**, never a bare `node` and
|
|
83
|
+
never the desktop application. A GUI-launched Codex often has a narrower `PATH`
|
|
84
|
+
than the shell that started DSH, so a bare `node` fails at spawn time; and in the
|
|
85
|
+
DSH Desktop (Electron) host `process.execPath` is `DeepSeek Harness.exe`, which
|
|
86
|
+
would make Codex launch a second GUI instead of an MCP server. Section 2.1 states
|
|
87
|
+
how the executable is chosen and what happens when no candidate can be proved.
|
|
88
|
+
* `args[0]` is derived from `import.meta.url` of the running module, so it names
|
|
89
|
+
the *installed* package — never a repository checkout and never a path captured
|
|
90
|
+
when the tarball was built.
|
|
91
|
+
* `tool_timeout_sec = 3660` (1.1.0) is an **owned scalar on this entry only**. The
|
|
92
|
+
`delegate_wait` tool defaults to a 3600-second wait and caps it there, so a client that
|
|
93
|
+
honours this field is allowed to let one call run that long. The plugin cannot prove that
|
|
94
|
+
every client honours it: a client that applies its own default tool timeout may still end
|
|
95
|
+
the wait earlier (Codex's historical default is one minute). The managed entry therefore
|
|
96
|
+
*requests* 3660 s — the 3600-second wait plus one minute of slack, never a second wait
|
|
97
|
+
window — while a client-side cap that ignores the field remains a client limit the plugin
|
|
98
|
+
cannot lift. This is not a Codex-wide setting and the plugin writes it nowhere else.
|
|
99
|
+
* A managed entry written by an earlier release has no such field. It is classified
|
|
100
|
+
`outdated` and repaired **in place** (the line is inserted inside our table), so an
|
|
101
|
+
existing installation updates through the settings page instead of being reported as
|
|
102
|
+
somebody else's file.
|
|
103
|
+
* A managed entry with a different integer is likewise `outdated` and rewritten to
|
|
104
|
+
3660. A non-integer value is not a value this plugin writes, so the whole entry is
|
|
105
|
+
treated as operator-owned and left untouched (`timeout-not-an-integer`).
|
|
106
|
+
* An unmarked same-name entry stays a conflict regardless of its values: the marker
|
|
107
|
+
comment is the only authorship proof this format carries.
|
|
108
|
+
* `env.DSH_DELEGATE_DISCOVERY_FILE` is written only when DSH uses a non-default
|
|
109
|
+
discovery location (`DSH_HOME` set, or `DSH_DELEGATE_DISCOVERY_FILE` set). The
|
|
110
|
+
default stays implicit so a later `DSH_HOME` change is not silently overridden.
|
|
111
|
+
|
|
112
|
+
### 2.1 The `command` executable (`resolveNodeExecutable`)
|
|
113
|
+
|
|
114
|
+
The host is classified first (`hostRuntimeKind`): `process.versions.electron` makes
|
|
115
|
+
it an **electron** host; `process.resourcesPath` (set by Electron and by nothing in
|
|
116
|
+
plain Node.js) is an equivalent desktop signal; otherwise it is a **node** host.
|
|
117
|
+
|
|
118
|
+
| host | `process.execPath` | selected `command` |
|
|
119
|
+
| --- | --- | --- |
|
|
120
|
+
| plain Node.js | `node`/`node.exe` | that path, unchanged — it is the runtime that loaded this plugin |
|
|
121
|
+
| plain Node.js, `execPath` is not a Node binary | an embedded host binary | falls through to the desktop rules below, never `execPath` |
|
|
122
|
+
| DSH Desktop (Electron) | `DeepSeek Harness.exe` | the DSH **bundled runtime**, below |
|
|
123
|
+
|
|
124
|
+
The bundled runtime is
|
|
125
|
+
`<resources>/runtime/primary-runtime/dependencies/node/bin/node.exe` on Windows and
|
|
126
|
+
`…/bin/node` elsewhere (`packagedNodePath`). `<resources>` is `process.resourcesPath`
|
|
127
|
+
when the host exposes it; otherwise it is derived from the application executable as
|
|
128
|
+
`<dirname(execPath)>/resources` — the layout DSH Desktop installs into
|
|
129
|
+
(`…\DeepSeek Harness\resources\…` beside `…\DeepSeek Harness\DeepSeek Harness.exe`).
|
|
130
|
+
|
|
131
|
+
If the bundled runtime is not there, these environment variables are consulted **in
|
|
132
|
+
this order**, and the first usable one wins:
|
|
133
|
+
|
|
134
|
+
| variable | accepted when |
|
|
135
|
+
| --- | --- |
|
|
136
|
+
| `DSH_NODE_PATH` | an absolute path |
|
|
137
|
+
| `DSH_NODE_EXECUTABLE` | an absolute path |
|
|
138
|
+
| `CODEX_MCP_NODE_PATH` | an absolute path |
|
|
139
|
+
|
|
140
|
+
"Usable" is strict: the value must be **absolute**, its basename must be a Node
|
|
141
|
+
binary (`node`, `node.exe`, or a versioned `node-*.exe`), and `lstat` must report an
|
|
142
|
+
existing **regular file**. A relative path, a directory, a link and a missing file
|
|
143
|
+
are each rejected with a reason, and their rejection does not stop the next
|
|
144
|
+
candidate from being tried.
|
|
145
|
+
|
|
146
|
+
**Fail closed.** When no candidate is usable, `resolveNodeExecutable` throws
|
|
147
|
+
`CodexInstallError('MCP_EXECUTABLE_UNRESOLVED')`. The desktop application executable
|
|
148
|
+
and a bare `node` are never substituted. The status document reports this instead of
|
|
149
|
+
throwing: `mcp.node = null`, `mcp.nodeResolved = false`, `mcp.nodeError = { code,
|
|
150
|
+
message, details }`, `mcp.state = unreadable` (`reason: no-executable`), `ready =
|
|
151
|
+
false`, plus an `MCP_EXECUTABLE_UNRESOLVED` note. `install` and `repair` refuse the
|
|
152
|
+
MCP target with `MCP_EXECUTABLE_UNRESOLVED` and leave `config.toml` byte-identical;
|
|
153
|
+
the agent file is an independent target and is still installed.
|
|
154
|
+
|
|
155
|
+
### 2.1 Classification
|
|
156
|
+
|
|
157
|
+
`classifyMcpEntry` locates the definition (block or inline), then decides:
|
|
158
|
+
|
|
159
|
+
| state | meaning | install |
|
|
160
|
+
| --- | --- | --- |
|
|
161
|
+
| `not-configured` | no `mcp_servers.dsh-delegate` at all | writes the block |
|
|
162
|
+
| `configured` | the marker is present **and** the values are exactly the owned shape | no change |
|
|
163
|
+
| `outdated` | marked owned command, but stale `args`/discovery/`tool_timeout_sec`; or the narrowly recognised 0.1.6 Desktop command with the current package `args` and owned env shape | rewrites only those values in place |
|
|
164
|
+
| `conflict` | anything else (`unmanaged-entry`, `command-not-ours`, `legacy-command-shape`, `url`, `unknown-field`, `extra-env`, `args-not-an-array`, `command-not-a-string`, `not-a-table`, `array-table`, and the boundary reasons below) | **refuses** with `MCP_ENTRY_CONFLICT` and a note explaining why |
|
|
165
|
+
|
|
166
|
+
Every classification also reports **`drift`**: the list of owned facts that are stale
|
|
167
|
+
(`tool_timeout_sec`, `args`, `command`, `env`), or `null` when nothing is. The status
|
|
168
|
+
document publishes it as `mcp.drift`, and the note for an `outdated` entry names each
|
|
169
|
+
one, so neither the page nor a log line has to infer what a repair would change.
|
|
170
|
+
|
|
171
|
+
An `args[0]` that names `dsh-delegate-mcp.js` somewhere ELSE is a `conflict`
|
|
172
|
+
(`args-shape-not-ours`) in a bare status read: the synchronous classifier cannot prove that
|
|
173
|
+
a different path is this package, so it never labels one `outdated`. Only an explicit
|
|
174
|
+
`install`/`repair` may adopt it, after the asynchronous proof below — and only with the
|
|
175
|
+
config digest, the `$CODEX_HOME`/`agents` boundary and the current entry re-checked
|
|
176
|
+
immediately before the write. A different script name, a different command or an extra
|
|
177
|
+
argument stays `conflict` everywhere.
|
|
178
|
+
|
|
179
|
+
When `$CODEX_HOME` or `$CODEX_HOME/agents` is a link (or cannot be verified), the MCP
|
|
180
|
+
target is reported as `conflict` with `reason` `codex-home-is-link`,
|
|
181
|
+
`agents-dir-is-link` or `boundary-unverified` — the same verdict the agent target gets.
|
|
182
|
+
The entry is **not** read through the link, because a link bounds every write this
|
|
183
|
+
module makes, not only the agent file.
|
|
184
|
+
|
|
185
|
+
Two rules are deliberate:
|
|
186
|
+
|
|
187
|
+
* **`unmanaged-entry`.** Values alone never establish ownership. An entry without
|
|
188
|
+
the marker comment — even one whose `command`/`args` are byte-identical to what
|
|
189
|
+
the plugin would write — is the operator's. It is reported as a conflict, and
|
|
190
|
+
`install`, `repair` and `remove` all leave it byte-identical. The marker must be
|
|
191
|
+
the comment line directly above the definition (or above the `[mcp_servers]`
|
|
192
|
+
header when the definition is the inline `dsh-delegate = { … }` spelling); a
|
|
193
|
+
marker elsewhere in the file does not count.
|
|
194
|
+
* **`command-not-ours`.** A different command is a different program, so even
|
|
195
|
+
identical arguments do not make the entry ours. `extra-env` is symmetrical — an
|
|
196
|
+
`env` key the plugin did not write is the operator's data, and an entry carrying
|
|
197
|
+
one is reported as a conflict rather than pruned.
|
|
198
|
+
|
|
199
|
+
* **0.1.6 Desktop migration.** Version 0.1.6 could write the DSH Desktop GUI as
|
|
200
|
+
`command`. A marked entry is eligible for one automatic migration only when its
|
|
201
|
+
command has a path whose case-insensitive basename is exactly `DeepSeek Harness.exe`,
|
|
202
|
+
its `args` already name this installed package's `bin/dsh-delegate-mcp.js`, and its
|
|
203
|
+
env keys and values exactly match the currently owned shape. The installer then
|
|
204
|
+
reports `outdated` and replaces only the command with the proven Node runtime.
|
|
205
|
+
A bare GUI name, a similarly named executable, stale args, extra env or any other
|
|
206
|
+
command remains `conflict` and is left byte-identical.
|
|
207
|
+
|
|
208
|
+
### 2.2 Merge mechanics
|
|
209
|
+
|
|
210
|
+
`src/codex/toml.js` locates structure by line and column ranges and edits only
|
|
211
|
+
those ranges. It is a locator, not a validating TOML implementation, and it
|
|
212
|
+
refuses (`TomlSyntaxError`, carrying a line number) rather than guess:
|
|
213
|
+
|
|
214
|
+
* an unterminated single-line string, array or inline table;
|
|
215
|
+
* a table header with trailing text;
|
|
216
|
+
* a raw control character (0x00–0x08, 0x0A–0x1F except tab) **anywhere other than
|
|
217
|
+
as a line ending** — see below;
|
|
218
|
+
* text after a table header, an unbalanced bracket, a key without `=`.
|
|
219
|
+
|
|
220
|
+
**CRLF.** A Codex config touched by a Windows editor is normally CRLF. The locator
|
|
221
|
+
splits on `\n` only, treats a *terminal* `\r` as the second byte of a line ending
|
|
222
|
+
(it is skipped wherever whitespace would end a token), and every mutation re-joins
|
|
223
|
+
with the document's detected ending. Installing, updating and removing an entry in
|
|
224
|
+
a CRLF file therefore preserves CRLF and leaves every unrelated byte — comments,
|
|
225
|
+
settings, table order — exactly as it was. A `\r` **inside** a line (a broken or
|
|
226
|
+
mixed-ending file) is still a control character and still refuses the document as
|
|
227
|
+
a whole.
|
|
228
|
+
|
|
229
|
+
A refusal makes the whole action refuse (`CODEX_CONFIG_UNSUPPORTED`) and leaves
|
|
230
|
+
the file byte-identical. Nothing is ever written with a parsed-then-serialized
|
|
231
|
+
round trip, so comments and ordering cannot be lost.
|
|
232
|
+
|
|
233
|
+
Writes land through `writeFileAtomic` (temp file + rename), so a crash leaves the
|
|
234
|
+
previous or the new full document, never a partial one. A *first* agent file is
|
|
235
|
+
created with `link`, which fails when the target exists: a file that appears
|
|
236
|
+
between the status read and the write is reported (`AGENT_PATH_CONFLICT`,
|
|
237
|
+
`created-concurrently`) instead of being replaced.
|
|
238
|
+
|
|
239
|
+
### 2.3 Removal
|
|
240
|
+
|
|
241
|
+
`remove` deletes the `mcp_servers.dsh-delegate` table (header, assignments, child
|
|
242
|
+
tables and the plugin marker line) and the agent file when — and only when — that
|
|
243
|
+
file is the managed template or a byte-exact known prior build. Comments the
|
|
244
|
+
operator wrote *above* the marker stay; the marker itself is the plugin's line.
|
|
245
|
+
A `conflict` or `modified` target is reported and left untouched, including an
|
|
246
|
+
unmarked same-name entry. Removing twice is a no-op.
|
|
247
|
+
|
|
248
|
+
**The agent file is re-proved immediately before it is unlinked.** The status read
|
|
249
|
+
is stale by the time a removal runs: the operator, an editor or another tool may
|
|
250
|
+
have rewritten the file after the verdict. Deleting on the strength of that verdict
|
|
251
|
+
would destroy the new content, so `removeManagedAgentFile` reads the file again and
|
|
252
|
+
requires all of:
|
|
253
|
+
|
|
254
|
+
* it is still a **regular file** (not a link, not a directory) — otherwise
|
|
255
|
+
`AGENT_PATH_CONFLICT` (`reason: not-a-regular-file`);
|
|
256
|
+
* it still exists — otherwise `AGENT_PATH_CONFLICT`
|
|
257
|
+
(`reason: missing-before-removal`), reported as "no change", never as a deletion;
|
|
258
|
+
* its bytes are **exactly** the content the status derived its verdict from
|
|
259
|
+
(`agent.expect`) — otherwise `AGENT_USER_MODIFIED`
|
|
260
|
+
(`reason: modified-before-removal`) and the file is kept.
|
|
261
|
+
|
|
262
|
+
Only then is `unlink` called. A file that *looks* managed but differs by one
|
|
263
|
+
character is therefore refused, and an unlink the filesystem refuses (`EPERM`,
|
|
264
|
+
`EACCES`, `EBUSY`) is reported as `AGENT_PATH_CONFLICT` (`reason: unlink-refused`)
|
|
265
|
+
rather than thrown at the operator.
|
|
266
|
+
|
|
267
|
+
### 2.4 The startup upgrade of an installed integration (1.2.0)
|
|
268
|
+
|
|
269
|
+
`refreshKnownAgentTemplate({ refreshMcp: true })` — reached through the seam as
|
|
270
|
+
`refreshManagedIntegration({ startupTarget, backupDir })` and called once by plugin
|
|
271
|
+
activation — performs two independent upgrades:
|
|
272
|
+
|
|
273
|
+
| target | condition | write |
|
|
274
|
+
| --- | --- | --- |
|
|
275
|
+
| agent file | `outdated` (byte-exact published build) | replaced with this build's template |
|
|
276
|
+
| MCP entry | `outdated` **and** passing the write gate below | the owned values rewritten in place, in ONE atomic write |
|
|
277
|
+
|
|
278
|
+
The automatic check only ever accepts THIS installation's exact entry point. The
|
|
279
|
+
moved-install case (a recorded `args[0]` that is a different, provable installation of the
|
|
280
|
+
same package) is described below but is performed only by an explicit `install`/`repair`;
|
|
281
|
+
startup leaves it byte-identical and reports `conflict`.
|
|
282
|
+
|
|
283
|
+
#### The write gate (`isOwnedStaleEntry`)
|
|
284
|
+
|
|
285
|
+
"The classifier said `outdated`" is not permission to write. An automatic, unreviewed
|
|
286
|
+
write additionally requires that the entry is provably this plugin's in EVERY owned fact:
|
|
287
|
+
|
|
288
|
+
| fact | required |
|
|
289
|
+
| --- | --- |
|
|
290
|
+
| marker comment | present (authorship proof) |
|
|
291
|
+
| `command` | exactly this package's Node command (or the narrowed 0.1.6 Desktop command) |
|
|
292
|
+
| `args` length | exactly 1 — no wrapper flags, no extra arguments |
|
|
293
|
+
| `args[0]` | **provably** this package's entry point (see below) |
|
|
294
|
+
| `env` keys | none that this plugin did not write |
|
|
295
|
+
|
|
296
|
+
**`args[0]` must be PROVED, not pattern-matched** (`isOwnedEntryScript`, asynchronous
|
|
297
|
+
because the proof is a filesystem one). There are exactly two accepted proofs:
|
|
298
|
+
|
|
299
|
+
1. **This installation's own file** — an absolute path that is the same location as this
|
|
300
|
+
package's `bin/dsh-delegate-mcp.js`, compared under the PLATFORM's case rules
|
|
301
|
+
(`samePlatformPath`). Linux compares exactly: two case variants are different programs
|
|
302
|
+
there. Windows is case-insensitive; macOS is treated the same way because its default
|
|
303
|
+
volumes are, which is an assumption rather than a promise on a case-sensitive volume. A
|
|
304
|
+
RELATIVE path is never equivalent: `relative/bin/dsh-delegate-mcp.js` names no location.
|
|
305
|
+
2. **A different, real installation of this package** — an absolute path ending in
|
|
306
|
+
`<root>/bin/dsh-delegate-mcp.js` with ALL of:
|
|
307
|
+
* `<root>` and `<root>/bin` are real directories and not links (a junction is caught by
|
|
308
|
+
the same attribute read the boundary check uses);
|
|
309
|
+
* `<root>/bin/dsh-delegate-mcp.js` is a regular, non-link file that IS the candidate
|
|
310
|
+
(compared by `realpath`, so a link cannot smuggle in another program);
|
|
311
|
+
* `<root>/package.json` is a regular, non-link file that BOTH declares
|
|
312
|
+
`"name": "dsh-delegate"` AND maps `bin["dsh-delegate-mcp"]` to that very entry. A
|
|
313
|
+
`./` prefix is allowed; an absolute path, a `..` segment, a trailing slash, a wrong
|
|
314
|
+
mapping, a missing mapping or no `bin` object is refused.
|
|
315
|
+
|
|
316
|
+
The `<root>` is derived with the host's `dirname`/`basename` rules (`packageEntryRoot`), so
|
|
317
|
+
a POSIX leading `/` is preserved: splitting on `/` and rejoining would turn
|
|
318
|
+
`/opt/pkg/bin/dsh-delegate-mcp.js` into the relative `opt/pkg/...`, and no real Linux or
|
|
319
|
+
macOS installation could ever be proved.
|
|
320
|
+
|
|
321
|
+
Everything else — a wrapper that reuses the marker, the command or even the file name; a
|
|
322
|
+
same-layout script whose manifest maps its bin elsewhere; a missing path; a link; a
|
|
323
|
+
directory that declares another package — is **not** claimed. The synchronous classifier is
|
|
324
|
+
even stricter: only proof 1 can make an entry `outdated`, so a differing script is always a
|
|
325
|
+
`conflict` (`args-shape-not-ours`) and a bare status read can never authorize a write. Proof
|
|
326
|
+
2 is attempted **only by an explicit `install`/`repair`**, never by the unattended startup
|
|
327
|
+
check, and it is re-run immediately before the write together with the plan's config digest
|
|
328
|
+
and the boundary re-check; an edit in that window is refused (`config-changed`).
|
|
329
|
+
|
|
330
|
+
An unprovable path is therefore KEPT and reported, with a note pointing at the explicit
|
|
331
|
+
button: this is the intended outcome, not a gap. The core upgrade — an exact `args` match
|
|
332
|
+
with only `tool_timeout_sec` missing — always succeeds automatically.
|
|
333
|
+
|
|
334
|
+
#### No concurrent change (`config-changed`)
|
|
335
|
+
|
|
336
|
+
The plan records a SHA-256 of the WHOLE `config.toml` (`mcp.fingerprint`, stripped from the
|
|
337
|
+
public status by `publicCodexStatus`). Immediately before the write the file is re-read and
|
|
338
|
+
the digest must match. Re-classifying alone is not enough: an operator can change an owned
|
|
339
|
+
value and leave an entry that still looks stale and managed, which is exactly the overwrite
|
|
340
|
+
this refuses. The result is `MCP_ENTRY_CONFLICT` with `reason: config-changed` and the file
|
|
341
|
+
is kept byte-identical. This is covered by a deterministic test that changes the file
|
|
342
|
+
between the plan and the write.
|
|
343
|
+
|
|
344
|
+
#### The backup is a PRECONDITION (`MCP_ENTRY_BACKUP_UNAVAILABLE` / `_FAILED`)
|
|
345
|
+
|
|
346
|
+
Before any automatic MCP write the current document is copied to a protected location, and
|
|
347
|
+
that copy is **verified**. It is not best-effort:
|
|
348
|
+
|
|
349
|
+
* no destination supplied → `MCP_ENTRY_BACKUP_UNAVAILABLE`, nothing written; a RELATIVE
|
|
350
|
+
destination is refused as well, because it would be resolved against the harness cwd;
|
|
351
|
+
* EVERY ancestor of the destination is proved to be a real directory — a symbolic link, a
|
|
352
|
+
Windows junction/reparse point, a component the platform cannot verify, or a file in the
|
|
353
|
+
chain refuses the whole backup, so a complete `config.toml` is never written through a
|
|
354
|
+
linked parent (a leaf-only check is not enough: `/safe/backup` can be a plain directory
|
|
355
|
+
below a junction);
|
|
356
|
+
* missing levels are created ONE at a time and each is inspected immediately afterwards; a
|
|
357
|
+
recursive `mkdir` would follow a link that appeared at any depth in the window;
|
|
358
|
+
* the chain is re-checked immediately before the copy is written, then the copy is written
|
|
359
|
+
atomically with owner-only permissions and RE-READ; a mismatch or a write failure →
|
|
360
|
+
`MCP_ENTRY_BACKUP_FAILED`, nothing written;
|
|
361
|
+
* an existing destination that is a link, a non-file, or holds different bytes is refused
|
|
362
|
+
rather than overwritten.
|
|
363
|
+
|
|
364
|
+
The seam supplies `<plugin dataDir>/codex-config-backup` by default, so a caller that passes
|
|
365
|
+
no location still gets one; a direct `refreshMcp` call with no trusted location refuses
|
|
366
|
+
instead of writing. The original file is always left exactly as it was on any refusal.
|
|
367
|
+
|
|
368
|
+
#### The rest of the guarantees
|
|
369
|
+
|
|
370
|
+
* an absent entry stays absent — the plugin never creates `config.toml` or the table at
|
|
371
|
+
startup, so an upgrade can never turn a non-installation into an installation, and the
|
|
372
|
+
same is true of `agents/` and the agent file;
|
|
373
|
+
* an unmarked entry, an operator-edited shape and any `conflict` are refused and left
|
|
374
|
+
byte-identical (the outcome carries `MCP_ENTRY_CONFLICT` with the reason);
|
|
375
|
+
* a link or unverifiable directory at `$CODEX_HOME` / `agents` is re-inspected immediately
|
|
376
|
+
before the write and produces ONE `AGENT_PATH_CONFLICT` refusal for the whole check, even
|
|
377
|
+
when the visible state shows nothing stale: an upgrade that cannot be proved safe must not
|
|
378
|
+
look successful;
|
|
379
|
+
* the pre-write document is copied to `backupDir` (the plugin data directory) first — never
|
|
380
|
+
into the package, never into the Codex home, and never returned in a response;
|
|
381
|
+
* nothing else in `config.toml` is touched: comments, ordering, other MCP tables, CRLF
|
|
382
|
+
line endings and every unrelated setting survive byte for byte.
|
|
383
|
+
|
|
384
|
+
#### Which home is targeted — ONE precedence for every seam call
|
|
385
|
+
|
|
386
|
+
`resolveHomePreference` is the single implementation, and `status()`, the explicit actions
|
|
387
|
+
and the automatic check all use it. Before that, the check consulted the recorded directory
|
|
388
|
+
while `status()` and the buttons consulted only `CODEX_HOME`/default, so removing
|
|
389
|
+
`CODEX_HOME` made the page report — and the buttons write — a different tree than the one
|
|
390
|
+
startup had just upgraded. The order is:
|
|
391
|
+
|
|
392
|
+
| precedence | target |
|
|
393
|
+
| --- | --- |
|
|
394
|
+
| 1 | an explicit `CODEX_HOME` (or the seam's explicit `codexHome`) |
|
|
395
|
+
| 2 | the home a SUCCESSFUL explicit install recorded in `<dataDir>/codex-installation.json` |
|
|
396
|
+
| 3 | the default (`~/.codex`), only when it exists and is a real directory |
|
|
397
|
+
|
|
398
|
+
A successful `install` records the directory even when it wrote nothing because the
|
|
399
|
+
installation was already exactly right: `changed: []` is a success, not "nothing happened".
|
|
400
|
+
A REFUSED install records nothing, so a refusal cannot become the remembered target.
|
|
401
|
+
|
|
402
|
+
A default that is a link (or cannot be verified) is reported as `default-is-link` /
|
|
403
|
+
`default-unverified`; a home that does not exist is `no-codex-home`. When no supported
|
|
404
|
+
directory applies, `status()` and the actions REFUSE with `CODEX_HOME_INVALID` instead of
|
|
405
|
+
falling back, and so does `refreshManagedIntegration` when the caller passes a
|
|
406
|
+
`startupTarget` whose `home` is `null` — the plugin never walks a junction and never
|
|
407
|
+
substitutes a tree nobody named.
|
|
408
|
+
|
|
409
|
+
The explicit 安装 / 更新 Codex 集成 button (action `install`) is unchanged and remains
|
|
410
|
+
the way to *create* the two managed targets. `status` reports the drift (`mcp.drift`)
|
|
411
|
+
and, when an entry is `outdated`, a note naming exactly which owned facts are stale.
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## 3. Actions and their guarantees
|
|
416
|
+
|
|
417
|
+
Reachable only through the authenticated user plane (section 4) or the CLI
|
|
418
|
+
`bin/dsh-delegate-codex-agent.js`.
|
|
419
|
+
|
|
420
|
+
| action | writes | never writes |
|
|
421
|
+
| --- | --- | --- |
|
|
422
|
+
| `status` | nothing | anything |
|
|
423
|
+
| `install` | agent file (absent / older managed build) + MCP entry (absent / `outdated`) | a user's agent file, a conflicting MCP entry, the DSH switch |
|
|
424
|
+
| `repair` | the MCP entry only (absent / `outdated`), exactly as `install` would | the agent file: it is **not created, not refreshed and not deleted**, nor is `agents/` created |
|
|
425
|
+
| `remove` | deletes only owned targets | a user's agent file, a conflicting entry |
|
|
426
|
+
|
|
427
|
+
`install` is idempotent: a second run with nothing changed reports
|
|
428
|
+
`changed: []` and does not rewrite either file.
|
|
429
|
+
|
|
430
|
+
`install` reports the agent and MCP targets independently. One may succeed while
|
|
431
|
+
the other is refused (for example: no agent file yet, but a conflicting entry), and
|
|
432
|
+
the response says exactly which. The same holds for an unresolvable executable:
|
|
433
|
+
the agent file is still installed, and the MCP half is refused with
|
|
434
|
+
`MCP_EXECUTABLE_UNRESOLVED` (section 2.1).
|
|
435
|
+
|
|
436
|
+
**`repair` is MCP-only.** It is the action behind the settings page's
|
|
437
|
+
「仅修复 MCP 配置」 button and is the same code path `install` uses for its MCP half.
|
|
438
|
+
It never touches the agent file, so with a missing agent it reports
|
|
439
|
+
`agent.state = not-installed` and changes nothing, with an `outdated` agent it leaves
|
|
440
|
+
that file byte-identical (it stays `outdated`), and with a `modified`/`conflict` agent
|
|
441
|
+
it does not even report an agent refusal — the agent is simply out of this action's
|
|
442
|
+
scope. Concretely, `repair`:
|
|
443
|
+
|
|
444
|
+
* returns `changed` containing `mcp` (or nothing) and never `agent`;
|
|
445
|
+
* does not create `$CODEX_HOME/agents` when it is missing;
|
|
446
|
+
* still refuses a `conflict` MCP entry with `MCP_ENTRY_CONFLICT`, exactly like `install`.
|
|
447
|
+
|
|
448
|
+
Updating a stale agent is an explicit `install`, or the byte-exact startup refresh
|
|
449
|
+
described below.
|
|
450
|
+
|
|
451
|
+
**No action runs when the settings page opens, and package install writes nothing.**
|
|
452
|
+
The page's `init()` issues a `GET`; the three buttons are the only callers of the
|
|
453
|
+
`POST`.
|
|
454
|
+
|
|
455
|
+
**The single write at plugin load is the integration refresh.** `apply()` calls the
|
|
456
|
+
seam's `refreshManagedIntegration()` once — only when a Codex home directory exists — which
|
|
457
|
+
refreshes `agents/dsh-delegate.toml` when its complete bytes equal one of the enumerated
|
|
458
|
+
`KNOWN_AGENT_TEMPLATES` digests (section 5) **and** upgrades an already installed
|
|
459
|
+
`mcp_servers.dsh-delegate` entry that is provably this plugin's and merely stale
|
|
460
|
+
(section 2.4). It never creates a missing agent, never creates `agents/`, never creates
|
|
461
|
+
the MCP entry, and never touches a `modified`/`conflict` file: everything else stays an
|
|
462
|
+
explicit `install`. A refusal or failure is logged and startup continues, so a Codex
|
|
463
|
+
problem cannot stop the plugin from loading.
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
467
|
+
## 4. Routes
|
|
468
|
+
|
|
469
|
+
One exact path, two methods, registered on `ctx.connection.fetch` (the
|
|
470
|
+
authenticated operator channel):
|
|
471
|
+
|
|
472
|
+
| method | path | body | result |
|
|
473
|
+
| --- | --- | --- | --- |
|
|
474
|
+
| `GET` | `/api/dsh-delegate/codex` | — | `{ ok, action: 'status', changed: [], refused: [], codex, switch }` |
|
|
475
|
+
| `POST` | `/api/dsh-delegate/codex` | `{ "action": "install" \| "repair" \| "remove" }` | `{ ok, action, changed, refused, codex, switch }` |
|
|
476
|
+
|
|
477
|
+
Refusals use the standard envelope and these codes: `CODEX_ACTION_INVALID` (400),
|
|
478
|
+
`CODEX_HOME_INVALID` (400), `CODEX_CONFIG_UNSUPPORTED` (409),
|
|
479
|
+
`CODEX_CONFIG_UNREADABLE` (409), `CODEX_INTEGRATION_UNAVAILABLE` (503). A refusal
|
|
480
|
+
*per target* is not an HTTP error: it appears in `refused[]` with a stable `code`
|
|
481
|
+
(`AGENT_USER_MODIFIED`, `AGENT_PATH_CONFLICT`, `MCP_ENTRY_CONFLICT`,
|
|
482
|
+
`MCP_SCRIPT_MISSING`, `CODEX_CONFIG_UNSUPPORTED`) and the action still answers 200
|
|
483
|
+
with the fresh status, because "I did not touch your file, and here is why" is a
|
|
484
|
+
successful diagnosis.
|
|
485
|
+
|
|
486
|
+
`codex` (status document):
|
|
487
|
+
|
|
488
|
+
```jsonc
|
|
489
|
+
{
|
|
490
|
+
"codexHome": "…",
|
|
491
|
+
"packageVersion": "1.3.1",
|
|
492
|
+
"boundary": { "blocked": false, "link": null, "unknown": false, "home": "directory", "agents": "directory" },
|
|
493
|
+
"agent": {
|
|
494
|
+
"path": "…", "state": "installed", "installed": true, "managed": true,
|
|
495
|
+
"reason": null, "expect": "<the exact bytes a refresh may replace>"
|
|
496
|
+
},
|
|
497
|
+
"mcp": {
|
|
498
|
+
"path": "…", "exists": true, "serverName": "dsh-delegate",
|
|
499
|
+
"state": "configured", "configured": true,
|
|
500
|
+
"previous": { "command": "…", "args": ["…"], "envKeys": [] },
|
|
501
|
+
"reason": null,
|
|
502
|
+
"marked": true,
|
|
503
|
+
"desired": { "command": "…", "args": ["…"], "env": {} },
|
|
504
|
+
"node": "…", "nodeResolved": true, "nodeError": null,
|
|
505
|
+
"script": "…", "scriptExists": true,
|
|
506
|
+
"discoveryFile": "…", "discoveryPinned": false
|
|
507
|
+
},
|
|
508
|
+
"config": { "readable": true, "error": null },
|
|
509
|
+
"ready": true,
|
|
510
|
+
"notes": [{ "code": "…", "text": "…" }]
|
|
511
|
+
}
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
Agent states: `not-installed`, `installed`, `outdated`, `modified`, `conflict`.
|
|
515
|
+
MCP states: `not-configured`, `configured`, `outdated`, `conflict`, `unreadable`.
|
|
516
|
+
`unreadable` covers both "the config cannot be read safely" and — as of 0.1.7 —
|
|
517
|
+
"no Node.js executable could be proved" (`reason: no-executable`), in which case
|
|
518
|
+
`desired` is `null`, `node` is `null`, `nodeResolved` is `false` and `nodeError`
|
|
519
|
+
carries the `MCP_EXECUTABLE_UNRESOLVED` diagnosis (section 2.1).
|
|
520
|
+
Boundary kinds: `directory`, `missing`, `link`, `other`, `unchecked` (for the level
|
|
521
|
+
below a link, which is deliberately not inspected), and `unknown` when the platform
|
|
522
|
+
answer could not be obtained.
|
|
523
|
+
|
|
524
|
+
`boundary.blocked` is true when either directory is a link or could not be verified;
|
|
525
|
+
`boundary.link` names the level (`codex-home` or `agents`) and is `null` otherwise.
|
|
526
|
+
`agent.reason` carries `codex-home-is-link`, `agents-dir-is-link` or
|
|
527
|
+
`boundary-unverified` in that case, so the page can say which boundary it refused.
|
|
528
|
+
|
|
529
|
+
`agent.expect` and `mcp.marked` are the two ownership facts: `expect` is what a
|
|
530
|
+
refresh compares against immediately before its rename, and `marked` is true only
|
|
531
|
+
when the entry carries the plugin marker (i.e. when a `remove` may delete it).
|
|
532
|
+
|
|
533
|
+
`switch` reports the DSH posture and always carries
|
|
534
|
+
`changedByThisAction: false`: no Codex action can authorize dispatch.
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## 4.1 The preflight tool the agent depends on
|
|
539
|
+
|
|
540
|
+
`delegate_preflight` is the fifth MCP tool and the only one that is not an
|
|
541
|
+
authorization at all: it is a read-only measurement of one workspace, added so a
|
|
542
|
+
dispatcher learns *before* submitting that a checkout is dirty, is not a
|
|
543
|
+
repository, or needs an isolation decision — instead of learning it from a job that
|
|
544
|
+
failed after admission.
|
|
545
|
+
|
|
546
|
+
| property | value |
|
|
547
|
+
|---|---|
|
|
548
|
+
| tool | `delegate_preflight` |
|
|
549
|
+
| arguments | `workspacePath` (string, required, absolute), `allowShared` (boolean, optional) |
|
|
550
|
+
| schema | closed: `additionalProperties: false`; `allowShared` must be a real boolean (`MCP_ARGUMENT_TYPE` otherwise, and the plane is never reached) |
|
|
551
|
+
| execution-plane route | `POST /dsh-delegate/x/workspace/preflight` |
|
|
552
|
+
| writes | nothing: no commit, stash, branch, worktree, lock, task, grant or setting |
|
|
553
|
+
| gate | transport fence + connection identity only — **not** the switch, because it authorizes nothing |
|
|
554
|
+
|
|
555
|
+
The answer is `{ ok, readOnly, workspacePath, isolation, reason, sharedExplicit,
|
|
556
|
+
decisionRequired, facts, guidance, checkedAt }` with `isolation` one of
|
|
557
|
+
`worktree` / `shared` / `block` and `reason` a stable `PREFLIGHT_*` code. The full
|
|
558
|
+
shape, the decision table and the four git reads it is allowed to issue are stated
|
|
559
|
+
in `docs/workspace-contract.md` §3.5; this document only records the contract the
|
|
560
|
+
agent file depends on.
|
|
561
|
+
|
|
562
|
+
The one rule a reviewer should check: **a dirty repository is never downgraded
|
|
563
|
+
automatically.** Without `allowShared` the answer is `block` with
|
|
564
|
+
`decisionRequired: true`; with `allowShared: true` — a per-call decision record,
|
|
565
|
+
never a stored preference — it is `shared` with `sharedExplicit: true`. The Codex
|
|
566
|
+
coordinator evaluates the requested task and changed paths and may decide to use
|
|
567
|
+
shared isolation without asking on every dispatch; it pauses when ownership or risk
|
|
568
|
+
is unclear. To make the actual job match that decision, `delegate_submit` passes
|
|
569
|
+
only `{ isolation: "shared" }` as an override. Provider, model, effort and timeout
|
|
570
|
+
remain those selected in the plugin settings.
|
|
571
|
+
|
|
572
|
+
---
|
|
573
|
+
|
|
574
|
+
## 5. The agent file
|
|
575
|
+
|
|
576
|
+
```toml
|
|
577
|
+
version = "1.0.0" # stamped from package.json when written
|
|
578
|
+
name = "dsh-delegate"
|
|
579
|
+
description = "…"
|
|
580
|
+
developer_instructions = """…"""
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
The file is a custom-agent definition, not an MCP registration: it deliberately
|
|
584
|
+
contains no `[mcp_servers.*]` table, because the agent inherits the parent Codex
|
|
585
|
+
session's MCP tools, and a second definition would start a second server.
|
|
586
|
+
|
|
587
|
+
**Ownership is content identity, not a heuristic.** `readAgentState` reports:
|
|
588
|
+
|
|
589
|
+
* `installed` — byte-identical to the file this build would write;
|
|
590
|
+
* `outdated` — byte-identical to one of the enumerated `KNOWN_AGENT_TEMPLATES`
|
|
591
|
+
digests (published builds only: `0.1.6`, both `0.1.7` builds, `0.1.8`, `0.1.9`,
|
|
592
|
+
`0.1.10` in both its CRLF and LF byte forms, `0.1.11`, `0.1.12`, `0.1.13`, `0.1.14`,
|
|
593
|
+
`1.0.0` and `1.1.0` in both byte forms, plus any later build listed when it is packed
|
|
594
|
+
and verified);
|
|
595
|
+
* `modified`/`conflict` — everything else.
|
|
596
|
+
|
|
597
|
+
Every release from `0.1.10` through `0.1.13` changes only the version line in the
|
|
598
|
+
companion file, so those templates share one body and differ only in that stamped line.
|
|
599
|
+
`0.1.14` changes the body as well (the per-call decision rules below), which is why its
|
|
600
|
+
predecessor is enumerated as a pinned identity rather than rebuilt. The bytes are what
|
|
601
|
+
ownership is proved against, so every release is enumerated on its own:
|
|
602
|
+
|
|
603
|
+
| Release | Digest enumerated in `KNOWN_AGENT_TEMPLATES` |
|
|
604
|
+
| --- | --- |
|
|
605
|
+
| `0.1.10` | `fc7b27104dbb50f4e614cd4fd8df8db87fd8f59fcf2b3c27b412b49f8b89fbba` (packed CRLF) |
|
|
606
|
+
| `0.1.10` | `6583f08a3ec4912a875249e6b127357b41cc3f8bf388b8e5cadbbeff469349be` (same template, LF) |
|
|
607
|
+
| `0.1.11` | `b6ca7c3258fc00c1c1682abf099994b9f5abe650acc3ecf9635eec4a35520151` (packed) |
|
|
608
|
+
| `0.1.12` | `ff04a4bf2c09b97747f835770c837637869581bb13bad3b8a870a3e92218514f` (packed) |
|
|
609
|
+
| `0.1.13` | `b3a1d2f0520774c0066ea733f27fd47c67c5f5ac44394d0eec2564c7959700aa` (packed, 9191 bytes, CRLF) |
|
|
610
|
+
| `0.1.14` | `11379c0152f3fb2bd4da1170812e51fe68006d98f6378c720cbadcee9ee4750c` (packed) |
|
|
611
|
+
| `1.0.0` | `b1fd531598087564b26df14d3261515e961012f3fd010ea493f222da7bbaf415` (git release bytes, CRLF) |
|
|
612
|
+
| `1.0.0` | `0cce75574107049413f4ddbdf7d8e6cddea92d45a0c4e0fa41b169cb790e5e13` (same template, LF) |
|
|
613
|
+
| `1.0.0` | `a8c888afaa0a1a6a0abfcb56670ffbdb67697f07e54871ece78c8adffb15c149` (**legacy** pinned identity) |
|
|
614
|
+
| `1.0.0` | `f51831e2ff265c9ba63a4760e245787060de7bd91dcc9663a11729fb472e5f62` (**legacy** pinned identity) |
|
|
615
|
+
| `1.1.0` | `7d3ea5c54647a92cebaa0521741eb27f5141f7b2127b47009195fdb976dae4fb` (git release bytes, CRLF) |
|
|
616
|
+
| `1.1.0` | `93d580bd849bb6d2c30c2db6286695ef3e0356896a88e552abae5f03eafc7601` (same template, LF) |
|
|
617
|
+
|
|
618
|
+
The `1.0.0` and `1.1.0` **git-verified** identities come from the release commits
|
|
619
|
+
themselves — `git show 2750047:codex/dsh-delegate.toml` and
|
|
620
|
+
`git show 2d71708:codex/dsh-delegate.toml` — and are kept as fixtures
|
|
621
|
+
(`tests/fixtures/codex-agent-1.0.0.toml`, `…-1.1.0.toml`) that are never packed.
|
|
622
|
+
|
|
623
|
+
The two **legacy** `1.0.0` entries are NOT claimed to be the Git bytes: the fixture above
|
|
624
|
+
is what the release commit contains, and these digests do not match it. They are retained
|
|
625
|
+
because a released build enumerated them, so an installation created by that build stays
|
|
626
|
+
structurally refreshable instead of flipping to "somebody else's file". Labelling them
|
|
627
|
+
`legacy` is the point: keeping an old identity is conservative (an unrecognised file is
|
|
628
|
+
never adopted and never removable), while pretending it came from Git would be a false
|
|
629
|
+
claim.
|
|
630
|
+
|
|
631
|
+
`0.1.10` therefore carries **two** entries, because that release exists in two byte forms
|
|
632
|
+
and either one can be on disk: the CRLF file inside the packed
|
|
633
|
+
`dsh-delegate-0.1.10.tgz`, and the same template kept as LF text. Both are hashes of
|
|
634
|
+
actual published bytes — the LF digest is an exact identity, not a normalized comparison.
|
|
635
|
+
`0.1.11` was delivered as an uncommitted candidate plus a verified tarball (the last
|
|
636
|
+
commit, `a750c0b`, is `0.1.10`), so that digest is cited from the tarball and the saved
|
|
637
|
+
baseline rather than from a `0.1.11` commit. The `0.1.12` digest is likewise verified
|
|
638
|
+
against the `package/codex/dsh-delegate.toml` inside the packed
|
|
639
|
+
`dsh-delegate-0.1.12.tgz` and against the saved release baseline. No earlier digest was
|
|
640
|
+
removed or replaced when a later release was added, so a machine that skipped a release is
|
|
641
|
+
still migrated directly to this build.
|
|
642
|
+
|
|
643
|
+
`0.1.13` is the last release whose companion body is the older one: `0.1.14` added the
|
|
644
|
+
per-call permission decision rules, so the `0.1.13` bytes are **not** recoverable by
|
|
645
|
+
relabelling the current template and are enumerated as an exact identity instead. The
|
|
646
|
+
digest was verified against `package/codex/dsh-delegate.toml` inside the packed
|
|
647
|
+
`dsh-delegate-0.1.13.tgz` (9191 bytes, CRLF) and the file is kept as
|
|
648
|
+
`tests/fixtures/codex-agent-0.1.13.toml`, so the "unchanged `0.1.13` is refreshed" and
|
|
649
|
+
"edited `0.1.13` is preserved" cases are both driven by real published bytes.
|
|
650
|
+
|
|
651
|
+
**What the product does with line endings: nothing.** `readAgentState` and
|
|
652
|
+
`refreshKnownAgent` read the file and hash it as it is; they never normalize CRLF to LF or
|
|
653
|
+
the reverse, and never rewrite a file to change its endings. A digest taken over
|
|
654
|
+
normalized text would not be an identity at all — it would let an edited file match a
|
|
655
|
+
known build — so normalization is a defect, not a convenience. The earlier `0.1.10`
|
|
656
|
+
entry `6583f08a…` was reported as a normalized digest; it is in fact the digest of the
|
|
657
|
+
LF form of that release, which is why it is retained (not replaced) alongside the CRLF
|
|
658
|
+
value. `tests/codex-integration.test.js` constructs both forms explicitly, pins each
|
|
659
|
+
digest, and proves for each that a byte-exact file is refreshed while an edited one is
|
|
660
|
+
refused.
|
|
661
|
+
|
|
662
|
+
A digest is added only for a build that was actually packed and verified, and the
|
|
663
|
+
current template's digest is never in the list under an older label; the tests assert
|
|
664
|
+
both facts (`tests/codex-integration.test.js`, `tests/package.test.js`).
|
|
665
|
+
|
|
666
|
+
At plugin startup, an `outdated` agent is refreshed automatically only when its
|
|
667
|
+
bytes still match a known shipped build. This does not create a missing agent or
|
|
668
|
+
edit `config.toml`. A file with any other content is preserved, even when its
|
|
669
|
+
version line names an older release.
|
|
670
|
+
|
|
671
|
+
Since 1.2.0 the startup check has a second half: an **already installed** managed
|
|
672
|
+
`mcp_servers.dsh-delegate` entry that is merely `outdated` is upgraded in place (see
|
|
673
|
+
section 2.4). It is still not an install: no entry is created, and no entry the plugin
|
|
674
|
+
cannot prove it wrote is adopted or rewritten.
|
|
675
|
+
|
|
676
|
+
The version line is *never* the proof. A file that still starts with the managed
|
|
677
|
+
header, still contains the dispatch rules, but has an old or invented version line
|
|
678
|
+
and one edited body byte is the operator's: the digest no longer matches, so it is
|
|
679
|
+
`modified`, it is never refreshed, and it is never removed. Conversely a
|
|
680
|
+
byte-exact published build is refreshed and removable, as documented.
|
|
681
|
+
|
|
682
|
+
### 5.1 Required dispatch semantics
|
|
683
|
+
|
|
684
|
+
The instructions must state all of the following. They are asserted in
|
|
685
|
+
`tests/codex-integration.test.js` and `tests/package.test.js`, so an edit that drops
|
|
686
|
+
one fails the build:
|
|
687
|
+
|
|
688
|
+
1. **Explicit assignment only.** Dispatch only when the parent request explicitly
|
|
689
|
+
selects this agent (the exact mention `@dsh-delegate`, the agent picker, or an
|
|
690
|
+
explicit instruction to delegate this implementation task to DSH).
|
|
691
|
+
2. **Mention is not dispatch.** Text that merely mentions DSH, DeepSeek,
|
|
692
|
+
dsh-delegate, delegation or the agent while asking something else is not a
|
|
693
|
+
dispatch request, and neither is a question about the plugin, its settings or
|
|
694
|
+
its status.
|
|
695
|
+
3. **No dispatch for non-implementation work.** Explanation, planning,
|
|
696
|
+
review-only, summarising and status questions are answered in Codex.
|
|
697
|
+
4. **Ambiguity is a question.** If it is unclear whether the task was assigned, ask
|
|
698
|
+
once instead of dispatching.
|
|
699
|
+
5. **Switch first, facts second.** Call `delegate_status` first; then call
|
|
700
|
+
`delegate_preflight` with the exact authorized workspace path. If either fails,
|
|
701
|
+
the tool is missing, the switch is off, or the answer is ambiguous, stop and
|
|
702
|
+
report the bounded refusal. Never open the switch; never fall back to DSH Crew,
|
|
703
|
+
another endpoint, another provider or local execution.
|
|
704
|
+
6. **The isolation is decided from the measured facts, and never downgraded.**
|
|
705
|
+
`delegate_preflight` returns `isolation` (`worktree` / `shared` / `block`) and a
|
|
706
|
+
stable `reason` code:
|
|
707
|
+
* `worktree` (`PREFLIGHT_CLEAN_REPOSITORY`) — a clean repository; dispatch with
|
|
708
|
+
the worktree isolation selected in the plugin settings, unchanged.
|
|
709
|
+
* `block` + `decisionRequired: true` (`PREFLIGHT_DIRTY_NEEDS_DECISION`) — the
|
|
710
|
+
checkout is dirty, so a worktree cannot be prepared from a commit. The agent
|
|
711
|
+
must **not** silently downgrade and must **not** probe by submitting. As
|
|
712
|
+
coordinator, it inspects the changed-file count and bounded path list and
|
|
713
|
+
decides whether this authorized task can safely run in place while preserving
|
|
714
|
+
the existing changes. It need not ask the operator to choose on every dispatch:
|
|
715
|
+
it states a safe shared decision and its reason before dispatch, re-runs the
|
|
716
|
+
preflight with `allowShared: true`, and proceeds only if the answer is `shared`
|
|
717
|
+
(`PREFLIGHT_DIRTY_SHARED_EXPLICIT`). If ownership, overlap or risk is unclear,
|
|
718
|
+
it pauses for one focused question.
|
|
719
|
+
* `block` for any other reason (`PREFLIGHT_GIT_UNAVAILABLE`,
|
|
720
|
+
`PREFLIGHT_NOT_A_REPOSITORY`, `PREFLIGHT_NO_COMMITS`, `PREFLIGHT_GIT_FAILED`,
|
|
721
|
+
`PREFLIGHT_WORKSPACE_INVALID`, `PREFLIGHT_NOT_A_DIRECTORY`) — stop and report
|
|
722
|
+
the code; no fallback exists.
|
|
723
|
+
7. **The dispatch text carries the workspace facts and the isolation reason.** A
|
|
724
|
+
shared run is named as such, because the worker writes into a checkout that
|
|
725
|
+
already has uncommitted work.
|
|
726
|
+
8. **Route settings stay in the plugin.** For `worktree`, call `delegate_submit`
|
|
727
|
+
without `overrides` so the configured isolation applies. For an explicitly chosen
|
|
728
|
+
`shared` run, pass only `{ isolation: "shared" }` as the per-task override because
|
|
729
|
+
the plugin may still be configured for `worktree`. Never override provider,
|
|
730
|
+
model, effort or timeout, and never encode a route in the prompt. `allowShared`
|
|
731
|
+
on preflight records the decision but does not change the submitted job's
|
|
732
|
+
isolation by itself.
|
|
733
|
+
9. **One task, WAITED — not polled (1.1.0).** Keep the returned `taskId` and call
|
|
734
|
+
`delegate_wait` on that same task, repeating it until it returns an actionable
|
|
735
|
+
reason. `delegate_result` is **not** a polling loop: one `delegate_wait` blocks
|
|
736
|
+
internally for up to about 25 seconds and re-issues itself, which is the polling
|
|
737
|
+
loop. Never submit a duplicate because a task is still running; `delegate_cancel`
|
|
738
|
+
stops it. The wait defaults to 3600 seconds and the tool caps it there.
|
|
739
|
+
`heartbeat` means "nothing to report" and is internal: the tool re-waits rather than
|
|
740
|
+
handing it to the model, so normal progress never wakes Codex.
|
|
741
|
+
10. **Each wait reason has a stated policy (1.1.0).**
|
|
742
|
+
- `attention` — the run has been completely silent past the configured attention
|
|
743
|
+
interval. It is a QUESTION, not a verdict: read the compact diagnostic (phase,
|
|
744
|
+
last activity, current tool and its elapsed time, self-check verdict) and
|
|
745
|
+
**default to waiting again** on the same task. Never cancel, never mark failed,
|
|
746
|
+
and never resubmit merely because a task is quiet or one tool or test is slow.
|
|
747
|
+
Only a concrete, stated error justifies anything else, and then it is reported
|
|
748
|
+
rather than silently restarted.
|
|
749
|
+
- `permission` — a per-call decision is outstanding; see item 12. After deciding,
|
|
750
|
+
wait the SAME task again.
|
|
751
|
+
- `ready` — execution finished and the task awaits **host review**; that is not
|
|
752
|
+
acceptance. Read `delegate_result` **once** for full evidence and review it in
|
|
753
|
+
Codex. A large diff is inspected file by relevant file, once each, not re-read.
|
|
754
|
+
- `failed` / `cancelled` — read `delegate_result` once for the recorded reason and
|
|
755
|
+
report it; do not resubmit identical work hoping for a different outcome.
|
|
756
|
+
- `wait-limit` (the client's own wait budget ran out) — the task is still running:
|
|
757
|
+
immediately `delegate_wait` the same task. It is not a failure, a stall, or a reason
|
|
758
|
+
to submit anything new or to check the implementation locally.
|
|
759
|
+
- `interrupted` — **the wait was cut off; that is not by itself a finished
|
|
760
|
+
execution.** One call answers it at once (it does not loop), so the answer's own
|
|
761
|
+
fields decide the response (1.2.0):
|
|
762
|
+
* `terminal: false` with a live `state` (`running`/`pending`): the task is running.
|
|
763
|
+
`delegate_wait` the same task; never resubmit, never implement locally, never
|
|
764
|
+
cancel for this reason.
|
|
765
|
+
* `terminal: true` and `state: "interrupted"`: the TASK record itself is a restart
|
|
766
|
+
history and will not resume. Read `delegate_result` once and report; do not keep
|
|
767
|
+
calling `delegate_wait` on it.
|
|
768
|
+
* `terminal: false` with no state, an unrecognized state, or a state that
|
|
769
|
+
contradicts the record (for example `running` with an end time): neither
|
|
770
|
+
"running" nor "stopped" may be assumed. Keep the task id and check one fact with
|
|
771
|
+
`delegate_result` before deciding — and do not re-wait indefinitely on a task the
|
|
772
|
+
host cannot classify.
|
|
773
|
+
A settled state carried by an `interrupted` observation is reported as that real
|
|
774
|
+
outcome (`awaiting-host-review` → `ready`), so a completed run always reaches review.
|
|
775
|
+
10b. **When the host blocks the connection, the control channel is separate (1.2.0).**
|
|
776
|
+
Some hosts forward one tool call at a time, so a long `delegate_wait` blocks
|
|
777
|
+
`delegate_status`/`delegate_cancel` on that same MCP connection. When — and only
|
|
778
|
+
when — the operator asks to stop or inspect that task in that situation, the agent
|
|
779
|
+
may run `dsh-delegate-control status <taskId>` or
|
|
780
|
+
`dsh-delegate-control cancel <taskId>` from the SAME package directory as the
|
|
781
|
+
configured MCP script (derived from this plugin's own MCP `args[0]`, never another
|
|
782
|
+
script), using the same `node` executable. It cannot submit, change a setting or
|
|
783
|
+
the switch, act on another task, resubmit the work or switch models, and during a
|
|
784
|
+
normal wait it stays silent instead of polling that binary.
|
|
785
|
+
|
|
786
|
+
What the command guarantees, so the expected output is never mistaken for a hang:
|
|
787
|
+
`status` reads the task's CURRENT compact state through ONE observation with the
|
|
788
|
+
smallest positive wait (`waitMs: 1`) — not `waitMs: 0`, which the engine reads as
|
|
789
|
+
"no bound requested" and replaces with a 25-second long poll. The commands answer
|
|
790
|
+
inside a single budget (10 s by default; `DSH_DELEGATE_CONTROL_TIMEOUT_MS` may only
|
|
791
|
+
lower it), enforced through one caller `AbortSignal` with the observation retry
|
|
792
|
+
disabled for that call, so a dead endpoint cannot spend a backoff schedule after
|
|
793
|
+
the answer. A failure — including an exhausted budget, `CONTROL_TIMEOUT` — is one
|
|
794
|
+
bounded JSON document on stdout plus a non-zero exit code, never a stack trace.
|
|
795
|
+
11. **Evidence, not approval.** Return state, the actual provider/model/effort,
|
|
796
|
+
changed-file summary, verification evidence, limitations, and the preflight
|
|
797
|
+
facts with the isolation reason actually used. Executing is not accepting:
|
|
798
|
+
Codex remains responsible for review. Do not claim a check passed without
|
|
799
|
+
evidence, and never commit or push.
|
|
800
|
+
12. **The workspace is not tidied up to pass a check.** No commit, stash, branch,
|
|
801
|
+
worktree creation, `clean`, `reset` or revert on the operator's behalf. A dirty
|
|
802
|
+
workspace is an isolation decision for the coordinator; pause only when the
|
|
803
|
+
existing edits' ownership or risk is unclear.
|
|
804
|
+
13. **A task awaiting a permission decision is still running, and the coordinating
|
|
805
|
+
Codex decides it.** A wait reporting `permission` (with the full redacted request
|
|
806
|
+
at the top level) is the worker paused on one native tool call, not a
|
|
807
|
+
stall: never submit a duplicate, mark it failed, or cancel it merely because it
|
|
808
|
+
waits, and keep waiting the SAME task. The agent does **not** invoke a second
|
|
809
|
+
approval/review model, does **not** ask the operator to choose routine within-task
|
|
810
|
+
decisions, and does **not** delegate the decision to the worker. The worker's own
|
|
811
|
+
`reason` is a claim, never authority. It checks the actual tool, redacted
|
|
812
|
+
arguments, call identity, session and repository against the authorized task,
|
|
813
|
+
reading local evidence when it needs to understand an executable script or target,
|
|
814
|
+
and approves only the specific operation the task needs — refusing anything
|
|
815
|
+
unrelated, destructive or exfiltrating, any credential or configuration change, and
|
|
816
|
+
any request whose evidence is unknown or materially incomplete. An allow requires
|
|
817
|
+
`argumentsComplete: true`, `completeness: complete`, `allowBlocked: null`, no
|
|
818
|
+
transport truncation affecting the pending operation, a still-pending request and
|
|
819
|
+
its exact `fingerprint`, passed to `delegate_permission_decide` with the `taskId`,
|
|
820
|
+
`requestId`, `decision` (`allow-once`/`reject`) and a bounded `reason`. An invalid or
|
|
821
|
+
stale allow grants nothing: re-read the current request and decide safely, and never
|
|
822
|
+
retry under broader settings. Waiting the SAME task continues after the decision, a
|
|
823
|
+
later request needs a fresh check, and an approval is one call only — never host
|
|
824
|
+
acceptance and never a standing sandbox grant. When dispatching on behalf of a
|
|
825
|
+
parent commander, the complete request evidence is preserved for that commander
|
|
826
|
+
rather than involving a separate review model.
|
|
827
|
+
14. **No local implementation while a delegated worker runs (1.1.0).** Neither the
|
|
828
|
+
dispatch companion nor the parent commander writes, patches or "just fixes" the
|
|
829
|
+
implementation while a delegated task is running, waiting, or awaiting review: that
|
|
830
|
+
would make the reviewer a second implementer of the same change, produce conflicting
|
|
831
|
+
edits in one workspace, and break the single-writer property the isolation mode
|
|
832
|
+
provides. The only exception is an explicit, user-authorized takeover — the operator
|
|
833
|
+
saying to take over and implement it here. A long silence, a permission refusal, a
|
|
834
|
+
failed run, a wait-limit or the commander's own opinion of the plan is **not** that
|
|
835
|
+
authorization. Permitted local actions while a task runs are: reading status and
|
|
836
|
+
diagnostics, waiting, reading evidence, deciding a pending permission, cancelling,
|
|
837
|
+
and writing the follow-up prompt. A believed-wrong result is reported and proposed
|
|
838
|
+
as a follow-up in the same chain, never applied locally.
|
|
839
|
+
15. **No secrets.** Never read, request, store or relay provider credentials or
|
|
840
|
+
connection tokens.
|
|
841
|
+
16. **Task threads are explicit.** A submission starts a NEW DSH task conversation
|
|
842
|
+
by default; a directory-level reuse setting no longer exists. `continueFromTaskId`
|
|
843
|
+
is passed **only** for a follow-up change, correction or retry that belongs to one
|
|
844
|
+
earlier delegated task, and its value is the latest prior task id of that chain.
|
|
845
|
+
An unrelated task, a new topic or a different workspace omits the field entirely:
|
|
846
|
+
an id is never reused "to keep context" and never guessed. A follow-up to a
|
|
847
|
+
`worktree` task keeps its original source `workspacePath` for preflight and
|
|
848
|
+
submit; the plugin resolves the same internal tree and continues its earlier
|
|
849
|
+
uncommitted changes there. Never send the tree's internal execution path as the
|
|
850
|
+
authorization path or choose a new isolation override. A refusal naming an
|
|
851
|
+
unavailable or mismatched tree is reported and escalated, never worked around
|
|
852
|
+
by re-submitting as a new task. The run's report states which of the two happened.
|
|
853
|
+
Corrections are consolidated into one follow-up submission rather than a scatter of
|
|
854
|
+
new tasks.
|
|
855
|
+
|
|
856
|
+
### 5.2 What the file cannot guarantee: `@` selection
|
|
857
|
+
|
|
858
|
+
**This plugin does not claim that any Codex surface supports selecting the agent by
|
|
859
|
+
typing `@dsh-delegate`.** Only verified facts are stated:
|
|
860
|
+
|
|
861
|
+
* A custom-agent file at `$CODEX_HOME/agents/<name>.toml` is a Codex-recognised
|
|
862
|
+
definition, and the parent session's MCP tools are inherited by it — this is what
|
|
863
|
+
the installation relies on.
|
|
864
|
+
* Whether the *current* Codex Desktop / CLI input box offers an `@`-mention picker
|
|
865
|
+
for that file is a property of the Codex build, not of this plugin. No official
|
|
866
|
+
documentation or runtime evidence in this repository establishes it for the
|
|
867
|
+
versions under test, so the wording here (and in the settings page) says the
|
|
868
|
+
mention *may* select the agent, and claims no more.
|
|
869
|
+
|
|
870
|
+
Consequently the agent's own instructions treat `@dsh-delegate` as **one example**
|
|
871
|
+
of an explicit selection, alongside the agent picker and an explicit instruction to
|
|
872
|
+
delegate. If a Codex build does not offer `@` selection, the agent still works when
|
|
873
|
+
chosen through whatever selection mechanism that build does provide. A new Codex
|
|
874
|
+
session (or a restart) is required to load the new file and the new MCP entry.
|
|
875
|
+
|
|
876
|
+
---
|
|
877
|
+
|
|
878
|
+
## 6. Failure modes a reviewer should check
|
|
879
|
+
|
|
880
|
+
| Situation | Expected |
|
|
881
|
+
| --- | --- |
|
|
882
|
+
| `CODEX_HOME` relative | 400 `CODEX_HOME_INVALID`; nothing read or written |
|
|
883
|
+
| `CODEX_HOME` unset | diagnosed against `~/.codex` |
|
|
884
|
+
| `$CODEX_HOME` is a symlink or a Windows junction | `conflict` (`codex-home-is-link`); nothing below it is inspected, written or deleted |
|
|
885
|
+
| `$CODEX_HOME/agents` is a symlink or a Windows junction | `conflict` (`agents-dir-is-link`); install/repair/remove refuse with `AGENT_PATH_CONFLICT` and no file is created outside the home |
|
|
886
|
+
| an ordinary real Windows directory | `directory` in every spelling of the helper's boolean (`dir/False`, `dir/false`); never reported as a link |
|
|
887
|
+
| `repair` with the agent file missing or `outdated` | `changed: ["mcp"]` or `[]`; the agent file is not created and not refreshed, and `agents/` is not created |
|
|
888
|
+
| the boundary cannot be verified (no spawnable shell / no PowerShell) | `conflict` (`boundary-unverified`); everything refused, nothing assumed safe |
|
|
889
|
+
| agents dir missing | created on install (`0700`) when the boundary is clean |
|
|
890
|
+
| `agents/dsh-delegate.toml` is a symlink or a directory | `conflict`; untouched |
|
|
891
|
+
| a different agent file appears between status and install | `modified`; untouched (first install is exclusive) |
|
|
892
|
+
| an agent file is rewritten between the status read and `remove` | `AGENT_USER_MODIFIED` (`modified-before-removal`); the new bytes are kept |
|
|
893
|
+
| the agent path is replaced by a directory / a link before `remove` | `AGENT_PATH_CONFLICT`; the entry is left in place |
|
|
894
|
+
| an edited agent file with an old version line | `modified`; never refreshed, never removed |
|
|
895
|
+
| a byte-exact previously published agent file | `outdated`; refreshed on install, removed on remove |
|
|
896
|
+
| `config.toml` is a symlink | `unreadable`; refused |
|
|
897
|
+
| `config.toml` > 1 MiB | refused (`other`), untouched |
|
|
898
|
+
| `config.toml` contains a NUL / control character | `CODEX_CONFIG_UNSUPPORTED`, untouched |
|
|
899
|
+
| `config.toml` uses CRLF | edited in place; CRLF and every unrelated byte preserved |
|
|
900
|
+
| an unmarked same-name `mcp_servers.dsh-delegate` entry | `conflict` (`unmanaged-entry`); byte-identical after install/repair/remove |
|
|
901
|
+
| entry added between the read and the write | re-classified; refused if it stopped being ours |
|
|
902
|
+
| package `bin/dsh-delegate-mcp.js` missing | MCP refused (`MCP_SCRIPT_MISSING`), agent still installed |
|
|
903
|
+
| plain Node.js host (`process.execPath` is a Node binary) | `command` is that path; no override is consulted |
|
|
904
|
+
| DSH Desktop host (`process.versions.electron` set) | `command` is the bundled runtime, **never** `DeepSeek Harness.exe` |
|
|
905
|
+
| desktop host that exposes no `resourcesPath` | `<dirname(execPath)>/resources` is derived and the bundled runtime is used |
|
|
906
|
+
| bundled runtime missing, `DSH_NODE_PATH` set to an absolute existing file | that file is written as `command` |
|
|
907
|
+
| an override that is relative / a directory / a link / missing | ignored; the next candidate is tried, and the reason is kept in `nodeError.details.rejected` |
|
|
908
|
+
| no candidate can be proved | status: `mcp.node = null`, `nodeResolved: false`, `ready: false`; install/repair refuse `MCP_EXECUTABLE_UNRESOLVED`; `config.toml` byte-identical; agent file still installed |
|
|
909
|
+
| no candidate can be proved, an owned entry already points at a stale command | left as written (nothing is guessed); the note names the environment variable to set |
|
|
910
|
+
| DSH has no execution plane (public bind) | unchanged by this feature; delegation still refuses |
|
|
911
|
+
| the agent is asked to dispatch into a dirty repository | `delegate_preflight` answers `block` / `PREFLIGHT_DIRTY_NEEDS_DECISION`; the coordinator evaluates the listed paths and task, then either reports and dispatches with an isolation-only `shared` override or pauses when risk/ownership is unclear |
|
|
912
|
+
| the agent is asked to dispatch into a non-repository or commit-less directory | `block` with the matching `PREFLIGHT_*` code; the agent stops and reports it rather than submitting |
|
|
913
|
+
| the workspace path is relative, missing or a file | `block` / `PREFLIGHT_WORKSPACE_INVALID` or `PREFLIGHT_NOT_A_DIRECTORY`; nothing is resolved against the process cwd |
|
|
914
|
+
| `delegate_preflight` is called while the switch is off | answered normally: it authorizes nothing, and that is when a coordinator needs it most |
|
|
915
|
+
| `delegate_preflight` is sent `allowShared: "true"` | `MCP_ARGUMENT_TYPE`; the plane is not called |
|
|
916
|
+
| `delegate_submit` is called twice for one directory | two Sessions in one Workspace: a new submission never continues a previous one |
|
|
917
|
+
| `delegate_submit` sends `continueFromTaskId` for an unknown, pruned or live parent | the run fails with `JOB_CONTINUATION_REFUSED` and `error.details.session` = `SESSION_CONTINUATION_UNKNOWN` / `SESSION_CONTINUATION_STATE`; no conversation is started |
|
|
918
|
+
| a follow-up names a parent that ran elsewhere (another directory, another worktree, another repository) | `JOB_CONTINUATION_REFUSED` with `SESSION_CONTINUATION_PATH_MISMATCH` / `SESSION_CONTINUATION_WORKSPACE_MISMATCH`; nothing runs |
|
|
919
|
+
| a follow-up to a `worktree` task is submitted with the source checkout | accepted: the source path remains the authorization/preflight path, and the engine restores the parent's exact managed tree internally |
|
|
920
|
+
| a follow-up's recorded tree was removed or belongs to another run | `SESSION_CONTINUATION_UNAVAILABLE` with the stated reason; no fresh tree is prepared |
|
|
921
|
+
| `continueFromTaskId` is not a string | refused at the MCP schema (`MCP_ARGUMENT_TYPE`) and again by the engine (`JOB_CONTINUATION_REFUSED`) |
|
|
922
|
+
| the settings page is asked to save a conversation mode | `setConversation` refuses with `CONVERSATION_MODE_REMOVED`; the stored legacy value is untouched and still inert |
|