code60-transmission-server 0.1.0-staging.12 → 0.1.0-staging.16

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.
Files changed (104) hide show
  1. package/INTENT.md +47 -0
  2. package/README.md +36 -345
  3. package/dist/src/acp.js +115 -0
  4. package/dist/src/contract.js +60 -0
  5. package/dist/src/engine.js +481 -0
  6. package/dist/src/main.js +70 -25
  7. package/dist/src/repository.js +94 -0
  8. package/dist/src/service.js +184 -0
  9. package/package.json +16 -35
  10. package/reference/openapi.json +423 -0
  11. package/README.engine.md +0 -463
  12. package/dist/src/broker/filesystem.js +0 -385
  13. package/dist/src/broker/index.js +0 -734
  14. package/dist/src/broker/native/README.md +0 -207
  15. package/dist/src/broker/native/build.js +0 -46
  16. package/dist/src/broker/native/command-helper.c +0 -93
  17. package/dist/src/broker/native/fs-helper.c +0 -529
  18. package/dist/src/broker/native/git-helper.c +0 -205
  19. package/dist/src/broker/policy.js +0 -149
  20. package/dist/src/broker/startup-lock.js +0 -14
  21. package/dist/src/broker/types.js +0 -11
  22. package/dist/src/cli/configure.js +0 -208
  23. package/dist/src/cli/daemon.js +0 -369
  24. package/dist/src/cli/helpers.js +0 -112
  25. package/dist/src/cli/main.js +0 -189
  26. package/dist/src/cli/runtime-build.js +0 -38
  27. package/dist/src/config/coding-policy.js +0 -4
  28. package/dist/src/config/deployment.js +0 -183
  29. package/dist/src/config/documents.js +0 -29
  30. package/dist/src/config/profile-validation.js +0 -129
  31. package/dist/src/config/schema-graph.js +0 -237
  32. package/dist/src/config/schema-loader.js +0 -185
  33. package/dist/src/config/validation-pool.js +0 -105
  34. package/dist/src/config/validation-protocol.js +0 -1
  35. package/dist/src/config/validation-worker.js +0 -106
  36. package/dist/src/config/workflow-language.js +0 -9
  37. package/dist/src/config/workflow-schema.json +0 -545
  38. package/dist/src/config/workflow-types.js +0 -1
  39. package/dist/src/config/workflow-validation.js +0 -95
  40. package/dist/src/engine/budgets.js +0 -50
  41. package/dist/src/engine/clocks.js +0 -27
  42. package/dist/src/engine/commands.js +0 -477
  43. package/dist/src/engine/contracts.js +0 -11
  44. package/dist/src/engine/drain-state.js +0 -31
  45. package/dist/src/engine/effective-permissions.js +0 -120
  46. package/dist/src/engine/instruction-pins.js +0 -205
  47. package/dist/src/engine/retries.js +0 -50
  48. package/dist/src/engine/state.js +0 -1
  49. package/dist/src/engine/timing.js +0 -23
  50. package/dist/src/engine/tool-observations.js +0 -87
  51. package/dist/src/engine/workflow-engine.js +0 -1862
  52. package/dist/src/mcp/catalog.js +0 -71
  53. package/dist/src/mcp/main.js +0 -26
  54. package/dist/src/mcp/server.js +0 -177
  55. package/dist/src/runtime/codex-app-server.js +0 -91
  56. package/dist/src/runtime/codex-executable.js +0 -50
  57. package/dist/src/runtime/containment.js +0 -82
  58. package/dist/src/runtime/engine-driver.js +0 -221
  59. package/dist/src/runtime/json-line-writer.js +0 -192
  60. package/dist/src/runtime/pinned-instruction-sources.js +0 -24
  61. package/dist/src/runtime/protocol-client.js +0 -264
  62. package/dist/src/runtime/protocol-pool.js +0 -183
  63. package/dist/src/runtime/protocol-projection.js +0 -393
  64. package/dist/src/runtime/protocol-types.js +0 -1
  65. package/dist/src/runtime/protocol-worker.js +0 -18
  66. package/dist/src/runtime/provider-bridge.js +0 -290
  67. package/dist/src/runtime/provider-credentials.js +0 -41
  68. package/dist/src/runtime/provider-transport.js +0 -406
  69. package/dist/src/runtime/runtime-broker.js +0 -213
  70. package/dist/src/runtime/workspace-instructions.js +0 -120
  71. package/dist/src/runtime/workspace-view.js +0 -74
  72. package/dist/src/server/api-contract.json +0 -11629
  73. package/dist/src/server/api-types.js +0 -1
  74. package/dist/src/server/application.js +0 -44
  75. package/dist/src/server/auth.js +0 -67
  76. package/dist/src/server/broker-handlers.js +0 -242
  77. package/dist/src/server/coding.js +0 -281
  78. package/dist/src/server/control-plane.js +0 -50
  79. package/dist/src/server/deployment.js +0 -249
  80. package/dist/src/server/errors.js +0 -22
  81. package/dist/src/server/history-handlers.js +0 -127
  82. package/dist/src/server/http.js +0 -124
  83. package/dist/src/server/paging.js +0 -56
  84. package/dist/src/server/publication.js +0 -119
  85. package/dist/src/server/tool-event-handler.js +0 -77
  86. package/dist/src/server/workspace-handlers.js +0 -34
  87. package/dist/src/storage/coordinator.js +0 -224
  88. package/dist/src/storage/startup-lock.js +0 -71
  89. package/dist/src/storage/store.js +0 -167
  90. package/dist/src/tools/check-worker.js +0 -81
  91. package/dist/src/tools/checks.js +0 -117
  92. package/dist/src/tools/command-check.js +0 -34
  93. package/dist/src/tools/commands.js +0 -312
  94. package/dist/src/tools/developer.js +0 -353
  95. package/dist/src/tools/dns.js +0 -248
  96. package/dist/src/tools/http-contract.js +0 -38
  97. package/dist/src/tools/http.js +0 -358
  98. package/dist/src/tools/index.js +0 -194
  99. package/dist/src/tools/worker-check.js +0 -73
  100. package/dist/src/workspaces/git.js +0 -227
  101. package/dist/src/workspaces/index.js +0 -937
  102. package/dist/src/workspaces/source.js +0 -295
  103. package/examples/deployment.local.json +0 -22
  104. package/scripts/postinstall.mjs +0 -26
package/README.engine.md DELETED
@@ -1,463 +0,0 @@
1
- # Workflow engine
2
-
3
- The server runs sequential agent steps in Git workspaces, stores durable state
4
- in SQLite, and brokers tool access through engine-owned permissions and approvals.
5
-
6
- For first setup, see [README.md](README.md) and the loadable
7
- [local deployment example](examples/deployment.local.json).
8
- For a complete live-model run, use the
9
- [hello-world example](examples/hello-world/README.md): `npm run example:hello-world`.
10
-
11
- ## Normal entry point
12
-
13
- The emitted server entry point is `dist/src/main.js`, also available through
14
- `npm start -- <arguments>`. It does not build anything automatically. It requires all five arguments, with absolute paths:
15
-
16
- ```text
17
- --state-directory /private/owned/engine-state
18
- --fs-helper /absolute/owned/fs-helper
19
- --git-helper /absolute/owned/git-helper
20
- --configuration /private/owned/configuration.json
21
- --operator-token-file /private/owned/operator.token
22
- ```
23
-
24
- Use the supported Node 24 version declared in `package.json`. `npm run build`,
25
- `npm test` and `npm run test:pilot` invoke the native build; they are not
26
- TypeScript-only validation shortcuts. The build compiles both C helpers. Keep
27
- native runs serial and do not rebuild images used by a preserved-image run.
28
-
29
- The state directory must already exist, be owned by the current user, and have
30
- mode `0700`. Configuration and token files must be owned regular files with no
31
- group/other access, symlinks or hardlinks. The token file contains a randomly
32
- generated URL-safe token of 32 through 512 characters, optionally with surrounding
33
- whitespace. Never put a token in a command argument or configuration JSON.
34
-
35
- There is no home/environment configuration or login discovery. The API listens
36
- only on `127.0.0.1`. A deployment wishing to expose it remotely must separately
37
- provide an authenticated, appropriately secured ingress.
38
-
39
- Use [examples/deployment.local.json](examples/deployment.local.json) as the strict
40
- JSON starting point. Install a private `0600` copy, replace uppercase placeholders,
41
- and choose unused ports. Its focused test copies the exact checked-in bytes for
42
- real-loader validation without relaxing private-file rules or launching the
43
- placeholder executable.
44
-
45
- A minimal disabled configuration has this shape. Replace its deployment paths,
46
- ports and model selection with values advertised by your installation:
47
-
48
- ```json
49
- {
50
- "listenPort": 31260,
51
- "operator": { "id": "local-operator", "workspaceIds": ["*"] },
52
- "runtime": {
53
- "enabled": false,
54
- "executable": "/absolute/owned/codex",
55
- "modelPort": 31261,
56
- "models": [{ "id": "deployment-configured-local-model", "effortLevels": [] }]
57
- },
58
- "deploymentPolicy": { "defaultEffect": "deny", "rules": [] },
59
- "agentHttp": {},
60
- "schemaHttp": { "networkPolicy": { "defaultEffect": "deny", "rules": [] } },
61
- "checks": [],
62
- "deploymentRoots": []
63
- }
64
- ```
65
-
66
- `"*"` explicitly authorizes this operator for every registered workspace.
67
- Otherwise list exact workspace IDs. Startup rotates this configured operator's
68
- token and revokes previously configured operator identities.
69
-
70
- `enabled: false` advertises the runtime as unavailable/requiring configuration.
71
- Enable it only after selecting the actual executable/model and providing an
72
- owned loopback Responses-compatible provider. Runtime `codex-local` retains the explicit
73
- local provider `code60-local`, using the configured loopback model port and model
74
- IDs. Advertise only effort
75
- levels actually supported by that model (`none`, `minimal`, `low`, `medium`,
76
- `high`, `xhigh` are the representable protocol values).
77
-
78
- The only runtime option is `artifactFormat: "json" | "yaml"`. Additional HTTPS
79
- Responses providers use the optional configuration below. Arbitrary runtime
80
- options, ambient credentials and implicit login discovery remain unsupported.
81
- The generic publication service is not narrowed to local providers.
82
-
83
- ## Operator API walkthrough
84
-
85
- This request sequence uses the normal deployment's HTTP API. The base URL is
86
- `http://127.0.0.1:<listenPort>/api/v1`. Every request needs the configured operator
87
- Bearer token. Use a client that reads that private token without printing it,
88
- embedding it in a URL, or exposing it in process arguments or saved request logs.
89
- There is no browser login, token-discovery endpoint or unauthenticated health
90
- route.
91
-
92
- 1. **Discover actual deployment support.** GET `/runtimes`, then
93
- `/runtimes/<runtimeId>/configuration`, and GET `/checks`. An unavailable
94
- runtime is not made usable by publishing a profile. Choose only the returned
95
- provider/model/effort, tool configurations and named checks. The reference
96
- examples' `runtime_001` is not the normal deployment's `codex-local`.
97
- 2. **Register an explicitly authorized, existing disposable Git worktree.**
98
- POST `/workspaces` with a body such as
99
- `{"name":"first-workspace","repositoryPath":"/absolute/owned/disposable-worktree","scratchPaths":[]}`.
100
- Registration requires an unrestricted operator, returns `201` with a
101
- workspace `id`, `Location` and `ETag`, and does not clone or clean a repository.
102
- Never attach a user repository merely to test setup.
103
- 3. **Publish a complete worker profile.** POST `/agent-profiles` with the
104
- following shape, replacing the model with an actually advertised selection.
105
- This minimal profile deliberately enables no tools. Real tools also require
106
- matching profile and outer deployment permissions; approval cannot override
107
- a hard denial.
108
-
109
- ```json
110
- {
111
- "name": "first-worker",
112
- "initialVersion": {
113
- "definition": {
114
- "role": "worker",
115
- "runtime": {
116
- "runtimeId": "codex-local",
117
- "provider": "code60-local",
118
- "model": "deployment-configured-local-model",
119
- "options": {},
120
- "credentialRefs": {}
121
- },
122
- "tools": [],
123
- "permissions": { "defaultEffect": "deny", "rules": [] },
124
- "instructions": [{ "kind": "inline", "text": "Return the assigned JSON artifact without Markdown." }]
125
- },
126
- "resources": []
127
- }
128
- }
129
- ```
130
-
131
- Record the returned profile's **`latestVersionId`**, not its profile `id`.
132
- Optional preflight POST `/agent-profile-validations` takes the `initialVersion`
133
- object itself and returns a validation report, not a published version.
134
- HTTPS selections additionally need the configured credential reference below;
135
- never substitute credential bytes.
136
- 4. **Publish an immutable workflow package.** For example, use this YAML as the
137
- source content, replacing the worker version ID with the preceding response:
138
-
139
- ```yaml
140
- kind: Workflow
141
- version: "1"
142
- metadata:
143
- name: first-workflow
144
- config:
145
- agent-profiles:
146
- worker: worker_profile_version_from_response
147
- steps:
148
- - id: first-step
149
- execution:
150
- max-session-resets: 1
151
- max-attempts-per-session: 2
152
- exitArtifact:
153
- schema:
154
- type: object
155
- required: [answer]
156
- properties:
157
- answer: { type: string }
158
- additionalProperties: false
159
- exitCriteria:
160
- semantic:
161
- criteria: []
162
- verifier:
163
- session: ephemeral
164
- max-attempts: 1
165
- ```
166
-
167
- POST `/workflows` with
168
- `{"name":"first-workflow","initialVersion":{"source":{"format":"yaml","content":"<the complete YAML source>"}}}`.
169
- Use a JSON serializer for the source string. Optional preflight
170
- `/workflow-validations` takes the `initialVersion` object, not the create
171
- wrapper. An empty semantic criterion list needs no verifier session/profile;
172
- enabling criteria requires an explicit complete verifier profile and finite
173
- role bounds. Record the returned workflow's **`latestVersionId`**.
174
- 5. **Admit and observe a run.** POST `/runs` with
175
- `{"workspaceId":"<workspace id>","workflowVersionId":"<workflow version id>"}`.
176
- `202` means admitted, not completed. Follow its run `Location`; inspect the
177
- run's state and independent `executionControl`, `approvalWait` and pending
178
- blocks. Under `/runs/<id>`, GET the `/steps`, `/sessions`, `/submissions`,
179
- `/artifacts`, `/blocks`, `/baselines` and `/instruction-snapshots` collections.
180
- GET `/runs/<id>/events?waitSeconds=30` supports bounded long-polling.
181
- Follow each `nextCursor` until `null`, keeping the same collection and
182
- authenticated scope.
183
- 6. **Use explicit, conditional controls.** Fetch the target run, block, action
184
- or approval's current `ETag` before its conditional POST and send it as
185
- `If-Match`. Pause/resume bodies are `{"reason":"..."}`. Their `202` response is
186
- an operation: follow its `Location` until success, failure or a required
187
- decision. An accepted pause is still draining until genuinely quiescent;
188
- resuming never clears a separate approval, budget or external-change hold.
189
- Missing conversations require explicit recovery, not an implicit resume.
190
-
191
- All POSTs require `Content-Type: application/json` and a nonempty
192
- `Idempotency-Key` (at most 200 characters). Preserve a request's exact body and
193
- key to retrieve its original receipt after a lost response; a changed body under
194
- that key is `409`, not a new command. Conditional POSTs require `If-Match`:
195
- missing is `428`, stale is `412`. Obtain a fresh ETag and make a new deliberate
196
- request instead of blindly retrying a state conflict. Adapter routes use
197
- engine-issued session credentials plus `X-Session-Epoch`; an operator token is
198
- not adapter authority, and fenced adapters cannot resurrect old receipts.
199
-
200
- The complete request bodies and response/Problem shapes are in
201
- [the OpenAPI contract](reference/workflow-engine/api/openapi.yaml).
202
- The API is not permission to start a model or mutate a repository without
203
- the operator's explicit selection and authorization.
204
-
205
- ## Configured HTTPS providers
206
-
207
- Add explicit `providers` and `providerCredentials` arrays to the configuration.
208
- For example, replacing the documentation-only hosts, addresses and file path:
209
-
210
- ```json
211
- {
212
- "providers": [{
213
- "id": "configured-provider",
214
- "endpoint": "https://model.example/v1/responses",
215
- "models": [{ "id": "configured-model", "effortLevels": ["low", "high"], "defaultEffort": "high" }],
216
- "maxRequestBytes": 67108864,
217
- "timeoutMs": 30000,
218
- "maxConcurrent": 2,
219
- "dnsResolvers": [{ "address": "192.0.2.53", "port": 53 }],
220
- "networkPolicy": {
221
- "defaultEffect": "deny",
222
- "rules": [
223
- { "kind": "network", "protocol": "https", "host": "model.example", "port": 443, "effect": "allow" },
224
- { "kind": "network", "protocol": "https", "host": "198.51.100.20", "port": 443, "effect": "allow" },
225
- { "kind": "network", "protocol": "udp", "host": "192.0.2.53", "port": 53, "effect": "allow" },
226
- { "kind": "network", "protocol": "tcp", "host": "192.0.2.53", "port": 53, "effect": "allow" }
227
- ]
228
- }
229
- }],
230
- "providerCredentials": [{
231
- "referenceId": "configured-provider-reference",
232
- "version": "deployment-v1",
233
- "providerId": "configured-provider",
234
- "origin": "https://model.example",
235
- "file": "/private/owned/provider.token"
236
- }]
237
- }
238
- ```
239
-
240
- The endpoint is a complete fixed HTTPS URL ending in `/responses`, without user
241
- information, query or fragment. Model requests cannot change its method, path,
242
- origin or headers. Every resolved IP needs its own network authority, including
243
- unused answers. Zero or one explicit numeric resolver is supported. Hostnames
244
- require that resolver plus both UDP and TCP permission; numeric HTTPS endpoints
245
- need no DNS. There is no address/server fallback, ambient DNS, proxy, redirect or
246
- transport retry.
247
-
248
- Credential files follow the configuration/token file's private ownership and
249
- no-alias rules. They contain 1–8192 printable ASCII token bytes, optionally
250
- followed by one newline. The engine preloads them once. Only reference IDs,
251
- versions, provider grants and origins enter descriptions; raw secrets never
252
- enter configuration JSON, profiles, history, process arguments or diagnostics.
253
- Credential lookup happens only after exact TLS identity and peer verification.
254
- Do not use the legacy local-model port as an unauthenticated billable relay.
255
-
256
- A profile selects `runtimeId: "codex-local"`, the configured provider/model,
257
- optional supported `effort`, and
258
- `credentialRefs: { "provider": "configured-provider-reference" }`. The runtime
259
- advertises the `provider` slot, not an invented `apiKey` slot. Omitted effort uses
260
- that model's explicit administrative `defaultEffort`. Provider/origin/version
261
- mismatches fail before launching a process.
262
-
263
- Each session gets a separate ephemeral loopback listener and random capability.
264
- The contained process may contact only that port. The bridge also requires a
265
- currently active generation and the actual Core admission predicate, including
266
- session/epoch, pause, approval holds, assignment, deadlines and remaining role
267
- allowance. Containment and knowledge of a local port are not model authority.
268
-
269
- Requests spool into a private engine-only sibling directory, outside the
270
- contained process's writable state. Bounded pure workers strictly validate the
271
- original JSON bytes and pinned model/effort before provider contact.
272
- `maxRequestBytes` is an explicit finite provider-input policy, not an artifact
273
- schema size cap or truncation rule. Resource exhaustion fails visibly; it does
274
- not manufacture a successful shortened artifact.
275
-
276
- The engine records each request's scoped metadata and exact-byte digest before
277
- contact, then records its terminal outcome after physical settlement. No request
278
- body, provider error, capability or secret enters that ledger. Unfinished markers
279
- become uncertain on recovery; old requests are never silently resent. Codex's
280
- request and stream retries are disabled. Explicit engine retries still use the
281
- existing shared durable retry allowance and execution clocks. Ordinary provider
282
- round trips are not artifact submissions, and repeated admission checks neither
283
- charge nor refill any allowance.
284
-
285
- Response streaming preserves bytes and backpressure. Only successful JSON/SSE
286
- content types and safe headers pass through; a literal credential echo is fatal.
287
- Shutdown counts spool I/O, validation workers, request/response callbacks and
288
- physical socket close before releasing ownership. Failed settlement bookkeeping
289
- retains a barrier rather than declaring the run quiet.
290
-
291
- Filesystem tool configuration comes from the actual tool registry. Deployment
292
- roots, when needed, are explicitly registered as `{ "id": "...", "path": "..." }`
293
- directory entries. Outer deployment policy defaults to deny. Agent HTTP and
294
- administrative schema fetching use separate network policies, with explicit
295
- numeric DNS settings and all-destination authorization, never ambient DNS.
296
- Administrative transport does not silently impose a shorter default timeout than
297
- the workflow's schema-fetch deadline. An explicitly configured `schemaHttp`
298
- `timeoutMs` is a deployment transport bound and must cover permitted fetch times.
299
-
300
- Named checks are deployment registrations with `id`, `description`, `version`
301
- and either a fixed artifact `predicate` or a `command` with optional `cwd`, `env`
302
- and `timeoutMs`. Command checks execute through the broker-owned command runner,
303
- with source read-only. Declared generated/cache paths require profile and
304
- deployment write authority; a read-only profile does not gain cache write access.
305
- Passing evidence is pinned to the exact source revision and command definition. Changing source
306
- requires fresh checks. Model-authored commands do not become acceptance checks.
307
-
308
- ## Coding tasks
309
-
310
- `POST /coding-tasks` accepts `task`, `repositoryPath` or `workspaceId`, optional
311
- immutable `inputs`/`inputArtifacts`, a profile version, and command-check overrides.
312
- The caller's idempotency key covers workspace/profile/workflow/run setup, including
313
- reconnects. The default preset detects package-manager scripts named `typecheck`,
314
- `lint`, `test`, and `build` and runs them with `CI=1`. Supply explicit commands for
315
- other ecosystems or scripts that need noninteractive flags. Dependencies can be
316
- installed by the worker; ignored dependency trees are not source checkpoints.
317
-
318
- `GET /readiness` reports local setup, an actual contained app-server handshake,
319
- command capabilities, quotas, and separately unverified provider authentication.
320
- Use `code60 configure` and `code60 doctor` for setup. `commands.enabled` is false
321
- for existing deployments unless configured. New coding configurations enable
322
- general outbound access; `commands.network: none` selects offline execution.
323
-
324
- `GET /runs/{runId}/result` returns the run-only diff, changed files, command logs,
325
- check evidence, diagnostics, and `verified`, `pending_or_failed`, or `unverified`
326
- status. Patch/output cursors count bytes and support bounded reads. Command output
327
- also includes Base64 bytes for exact reconstruction across UTF-8 boundaries.
328
- To inspect a command log, call `get_coding_task_result` with `runId`, `commandId`,
329
- `stream`, `outputCursor`, and `outputLimit`; the HTTP result endpoint accepts
330
- the same query parameters. Pending questions survive daemon shutdown; answer
331
- them before recovering the interrupted conversation. Answers remain available
332
- to the replacement worker through its context manifest.
333
- `sourceQuotas`, command deadlines/output limits, and `contextBytes` are explicit
334
- deployment settings. Supplemental model context defaults to 64 KiB; retrieval
335
- tools expose pinned artifacts, schemas, history, messages, and immutable inputs.
336
-
337
- New HTTP workspace registrations use Git-aware manifests by default. Linked
338
- worktrees and binary/symlink source entries are supported. Historical checkpoints
339
- remain readable. Starting a coding task upgrades an
340
- existing idle registration to Git-aware tracking without changing working files;
341
- active leases cannot be upgraded. Declared generated paths exclude untracked
342
- output even when the project has no matching ignore rule; tracked files always
343
- remain source. `sourceTracking: false` explicitly selects the legacy native format.
344
- An existing commit is required. Submodules and unsupported entry types fail
345
- preflight rather than being silently omitted.
346
-
347
- `POST /runs/{runId}/messages` queues steering before acceptance. Worker questions
348
- appear in `/runs/{runId}/questions` and the run's `inputWait`; answer through
349
- `POST /questions/{questionId}/answers`. Questions retain the conversation and
350
- freeze execution accounting without consuming submissions. Absolute authored
351
- deadlines remain hard bounds. Restarted conversations require explicit recovery.
352
-
353
- Coding tasks default to `resultMode: working_tree`, preserving HEAD and the
354
- index. The starting dirty source state is the rollback baseline; ignored caches
355
- are retained. Explicit `resultMode: commit` requires a clean source baseline.
356
- Legacy commit-based workflows keep their original default.
357
-
358
- If command settlement is uncertain, inspect the result's recovery preview and
359
- provide `commandResolution: { sourceDigest, action }` to `recover_run` (or the
360
- HTTP recovery endpoint). `action` is `preserve_changes` or `rollback`. The engine
361
- requires stopped processes, the exact current preview digest, and unchanged Git
362
- metadata before adopting or restoring command changes. It never resends the old
363
- command automatically. Concurrent external edits during writing commands cannot
364
- be reliably attributed; pause/stop commands before editing the project elsewhere.
365
-
366
- ## Ownership and recovery
367
-
368
- Startup acquires the inherited writer lock **before opening SQLite**, applying
369
- migrations or constructing/recovering workspace and broker owners. Every service
370
- shares one SQL coordinator. Existing sessions are fenced and runs are marked
371
- interrupted, preserving explicit pause state and authored downtime accounting.
372
- No provider conversation is reconnected. Resumption after process loss requires
373
- the explicit recovery protocol.
374
-
375
- All API operations use `createApplication`. New tool admission delegates
376
- to the actual engine's read-only predicate. Trusted tool history commits inside
377
- the broker completion transaction before effect work drains. Driver observations
378
- deduplicate that record and cannot clear uncertain effects.
379
-
380
- Workspace instruction bytes come from the owner's immutable active-lease
381
- snapshot, before any session exists. `AGENTS.md`/`AGENTS.override.md` remain scoped USER
382
- guidance, never system/developer instructions. Recovery reuses the original pins.
383
-
384
- Shutdown stops the engine and awaits physical work before closing the broker,
385
- workspace descriptors, database and inherited lock, in that order. An uncertain
386
- journal prevents optimistic owner/barrier release and requires reconciliation.
387
-
388
- ## Runtime containment
389
-
390
- The installed Codex CLI runs as an app-server under a default-deny macOS Seatbelt
391
- policy and an isolated runtime directory. HOME, CODEX_HOME and XDG locations
392
- point into that directory; ambient credentials, proxies and user configuration
393
- are not inherited. The process may execute only the selected runtime executable
394
- and contact only its assigned loopback model port. Managed workspace access goes
395
- through brokered tools, rather than direct runtime filesystem access.
396
-
397
- The `/etc` and `/private/etc` compatibility exception permits metadata/existence
398
- queries only. It grants neither file contents nor directory listing and does not
399
- authorize broker/model access. Workspace `AGENTS.md` and `AGENTS.override.md`
400
- content is discovered and pinned by the engine as scoped USER guidance.
401
-
402
- Builds require Node 24.22.x, npm and the macOS command-line C toolchain. Packaging
403
- emits TypeScript and builds both helpers under `dist/src/broker/native/.build`.
404
- Pass trusted absolute helper paths to the server; runtime requests cannot select
405
- source-tree fallback binaries or trigger compilation.
406
-
407
- ## Validation
408
-
409
- TypeScript checks and the focused example-loader check:
410
-
411
- ```sh
412
- npm run typecheck
413
- node ./node_modules/typescript/bin/tsc -p tsconfig.build.json
414
- node ./node_modules/vitest/vitest.mjs run tests/server/example-configuration.test.ts --maxWorkers=1
415
- ```
416
-
417
- The example test uses the actual private-file loader and emitted pure validation
418
- workers; it does not launch a helper, sandbox, Codex or network listener.
419
- Additional controlled provider checks:
420
-
421
- ```sh
422
- node ./node_modules/vitest/vitest.mjs run tests/server/deployment.test.ts tests/runtime/provider-bridge.test.ts tests/runtime/provider-credentials.test.ts tests/runtime/provider-driver.test.ts
423
- ```
424
-
425
- These explicit tests use controlled native/process ports and owned in-process
426
- loopback TLS fixtures, not a live provider.
427
-
428
- Build and full-tree test entry points, on macOS with the native prerequisites:
429
-
430
- ```sh
431
- npm run build
432
- npm test
433
- npm run test:pilot
434
- ```
435
-
436
- Both test scripts rebuild native helpers. Default native fixtures select those
437
- built helpers; sanitizer variants compile separately. Normal-entrypoint and
438
- restart suites run in this default mode without preserved-image prerequisites.
439
- Installed-Codex fixtures resolve the explicit absolute `CODE60_CODEX_EXECUTABLE`
440
- override first, otherwise `codex` on `PATH`, and fail clearly when it is missing.
441
- Lookup does not launch Codex or read its configuration/credentials. Use
442
- `--maxWorkers=1` to run native suites serially.
443
-
444
- Packaged fixture mode remains optional for independently preserved images, not a
445
- fresh-clone prerequisite. Do not enable it against newly compiled images.
446
-
447
- To run suites that require existing preserved helper images:
448
-
449
- ```sh
450
- CODE60_NATIVE_FIXTURE_MODE=packaged node ./node_modules/vitest/vitest.mjs run tests \
451
- --exclude=tests/workspaces/writer-barrier.test.ts \
452
- --exclude=tests/pilot/broker-fs.test.ts \
453
- --maxWorkers=1
454
- ```
455
-
456
- The exclusions are C-compiling fixtures. Packaged mode checks fixed existing
457
- assets and skips unavailable sanitizer variants; it does not rebuild them.
458
- Run clean-build and sanitizer suites separately with their required toolchain.
459
-
460
- Fresh-process component measurements use emitted code, synthetic inputs and owned
461
- TLS only: `node scripts/measure-provider-bridge.mjs plain-50m` (also
462
- `search-escape`, `unicode`, `two-slots`). They do not prove installed Codex
463
- compatibility or a global memory bound.