Commit Graph

1326 Commits

Author SHA1 Message Date
Tianyi Cui
3263dab822 fix(core): enforce agent-scoped ownership boundaries 2026-07-11 22:55:26 +08:00
Tianyi Cui
850796bb35 fix(tools): reserve the Code Mode transport 2026-07-11 20:47:45 +08:00
Tianyi Cui
fc0357a100 Merge remote-tracking branch 'origin/master' into codex/pr224-rfc-rewrite
# Conflicts:
#	docs/architecture.md
#	docs/event-producer-consumer.md
#	docs/module-graph.md
#	scripts/doc-budgets.manifest.json
#	scripts/gen-doc-graphs.ts
2026-07-11 20:38:25 +08:00
Tianyi Cui
6091c0a3dc docs: rewrite the agent-scope RFC 2026-07-11 14:01:49 +08:00
Tianyi Cui
ee3e4ea8f9 Merge pull request #245 from deepseek-harness/fix/subagent-acp-onerror-containment
fix(subagent-acp): contain onError sink exceptions to keep result from rejecting
2026-07-10 23:33:03 +08:00
Tianyi Cui
a8b68e1303 Merge branch 'master' into fix/subagent-acp-onerror-containment 2026-07-10 23:31:17 +08:00
Tianyi Cui
ee15a01f61 Merge pull request #252 from deepseek-harness/eslint-project-service
chore(lint): one shared project service; ignore harness-local .claude state
2026-07-10 22:52:21 +08:00
Tianyi Cui
dce2945211 Merge branch 'master' into eslint-project-service 2026-07-10 22:50:28 +08:00
Tianyi Cui
feb457d425 Merge pull request #236 from deepseek-harness/codex/mock-snapshot-rerecord
Add keyless snapshot refresh mode
2026-07-10 22:36:48 +08:00
Tianyi Cui
65587c6091 Merge remote-tracking branch 'origin/master' into codex/mock-snapshot-rerecord
# Conflicts:
#	packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts
2026-07-10 22:19:18 +08:00
kingwl
53f6a959e2 chore(lint): one shared project service; ignore harness-local .claude state
Two independent multipliers were pushing bare `pnpm run lint` past node's
default heap:

1. parserOptions.project expanded to every package tsconfig plus the root
   one — each matched config built its OWN ts.Program, and the dev paths
   map pulls sibling package SOURCES (plus the vendored Cordis stack) into
   every such program, so resident memory grew as sum-of-closures, not
   repo size: ~4.6 GB peak for 425 repo files. projectService shares one
   tsserver-style graph: ~2.0 GB peak, ~28 s → ~14 s wall.

2. `eslint .` traversed .claude/ harness-local state — stale worktree
   checkouts there carry tens of thousands of additional .ts files
   (whole-repo copies), roughly tripling the work again even under the
   project service. Other checkouts are not this one's sources; ignore
   them like node_modules. (#169 carries the identical ignore line inside
   its chain; the hunks dedupe on its next rebase.)

Type-aware rules verified live under the service: a floating-promise
probe still trips no-floating-promises.
2026-07-10 22:13:40 +08:00
Tianyi Cui
afb0a2b5cd Merge pull request #246 from deepseek-harness/fix/workflow-workerthread-waitfor
test(workflow-workerthread): flake-proof the lifecycle spec's waits under CI load
2026-07-10 21:05:58 +08:00
pku-xht
dd2f37b80f fix(workflow-workerthread): tighten post-result promptness waits back down
Review follow-up: the blanket 10s default correctly targets worker-thread
cold-start races (starting, first-script-line, async child-registration
messages — genuinely CPU-bound under CI contention), but four waits assert
something different — that the HOST reacted PROMPTLY to an event that
already happened (a settled result, an observed worker death). Those had no
cold-start left to wait on, so the generous default just widened the window
a real regression could hide in.

Verified by injecting a 6s delay into the settle-reap's abort call: the
un-overridden helper's test still passed in ~6s. The same mutation now fails
in ~1s with the explicit 1000ms override restored on all four sites (the
abort-on-settle test's own assertion, the two worker-death cancel/dispose
reap checks, and the dispose-ack-race check). The other 12 waits keep the
10s default — they run BEFORE a result is awaited, waiting on the worker to
actually start rather than on a host reaction. Doc comment corrected to
describe the split instead of claiming every wait is a cold-start race.
2026-07-10 20:48:14 +08:00
pku-xht
64b4e2ed2d test(workflow-workerthread): flake-proof the lifecycle spec's waits under CI load
The spec's 16 vi.waitFor sites used the 1s default timeout to wait for
worker-thread startup and child registration — CPU-bound work that blows
past 1s on a contended runner. The CI coverage lane (4 vitest workers plus
suites that spawn real subprocesses) hit this 3 times across 4 recent PR
runs, each a different subset of the cancellation/worker-death tests, each
green on rerun.

Every wait now goes through a shared helper with a 10s bound, and the file
sets a 30s test timeout to make room for it. The one deliberately tight
wait keeps its 800ms bound through the helper's override — it proves the
host (not the wedged worker's later loop turn) delivered the cancel, so a
generous bound would erase what it tests. No behavior under test changed.
2026-07-10 16:43:41 +08:00
pku-xht
62627d7625 fix(subagent-acp): contain onError sink exceptions to keep result from rejecting
spec.onError is a caller-supplied callback boundary, but the flattening
catch invoked it unguarded: a throwing sink rejected the whole async result,
breaking the seam's "result never rejects on a child-level failure"
contract (and docs/defensive-patterns.md's contain-callback-exceptions
rule). The sink's own throw is now swallowed — named as such — while the
original child failure still settles as stopReason 'error'. Regression test
drives a spawn failure through a throwing sink and asserts result resolves.

Same defect as the codex backend's, fixed there on PR #240; this is the
symmetric fix for the already-merged ACP backend.
2026-07-10 16:42:20 +08:00
Tianyi Cui
42ebbfdf8f Merge pull request #217 from deepseek-harness/feat/subagent-process
feat(subagent): extract dsh-subagent-process shared out-of-process machinery
2026-07-10 10:15:52 +08:00
pku-xht
3eea868a1b Merge branch 'master' into feat/subagent-process 2026-07-10 10:05:01 +08:00
Tianyi Cui
af242dbae5 Preserve snapshot refresh seed boundaries 2026-07-10 01:04:06 +08:00
Tianyi Cui
5f7177a0a9 Stabilize workflow worker coverage wait 2026-07-10 00:55:47 +08:00
Tianyi Cui
9d2cf8ce82 Add keyless snapshot refresh mode 2026-07-10 00:48:27 +08:00
Tianyi Cui
a5c972b7a4 Merge pull request #233 from deepseek-harness/workflow-vm-to-workerthread
workflow: script-driven multi-agent orchestration (workflow seam + node:worker_threads engine + tool)
2026-07-10 00:41:48 +08:00
imccyu
3d141eea57 Merge remote-tracking branch 'origin/master' into workflow-vm-to-workerthread 2026-07-10 00:35:16 +08:00
Tianyi Cui
0cfb657f98 Merge pull request #234 from deepseek-harness/turtle/docs-human
docs: a human touch
2026-07-10 00:31:54 +08:00
imccyu
a53be53d64 workflow: forward TSX_TSCONFIG_PATH through the worker env scrub
The empty-env hardening wiped the one variable the UNBUILT worker's
loader depends on: tsx finds a tsconfig by searching up from the
worker's cwd, and a parent running outside the repo (the ACP snapshot
harness pins the repo tsconfig through TSX_TSCONFIG_PATH exactly
because its child cwd is a temp dir) lost the dsh-* paths map - the
worker then resolved workspace imports to unbuilt lib/ bundles and died
on CI with ERR_MODULE_NOT_FOUND (green locally only because stale built
lib/ masked the wrong resolution).

Forward exactly that variable when the parent carries it - loader
plumbing, not a secret; the built shape stays fully empty - and pin the
whole contract with an escape-based test: the worker env is exactly
{TSX_TSCONFIG_PATH}, the credential canary still never crosses.
2026-07-10 00:23:11 +08:00
Turtle
c60eb87860 make wordcount budget guidance clearer and dedup docs 2026-07-10 00:20:35 +08:00
imccyu
aff657cc28 fix: ci run without build lib for snapshot 2026-07-10 00:16:29 +08:00
Turtle
f77174f13a make it clearer 2026-07-10 00:13:06 +08:00
Tianyi Cui
4751a7be0b Merge origin/master: Code Mode composed with agent scopes
Master advanced 11 commits mid-merge (the Code Mode registry integration:
mode config, run_code, the tools:sdk section, the ACP run_code cards and
unified demos). The fusion makes Code Mode scope-aware end to end:

- wireSchemas(scope): the mode-aware wire contribution is computed from the
  CALLING SCOPE's visible set (scoped tools join, shadowing and restrictions
  apply) and feeds the {schemas, knownNames} provider protocol.
- knownNames under the mode collapse: a per-scope RESTRICTION is runtime
  state, so the universe stays pre-restriction (a restricted-away tool in
  toolOrder is a normal absence) — but the MODE collapse is deployment
  config, so under mode 'code' the universe is [run_code] and a toolOrder
  naming a native tool fails every assembly loud (master's tested decision,
  kept).
- The tools:sdk section renders per assembly CONTEXT: the SDK declares
  exactly the calling agent's callable set, using the section-text provider
  signature this branch already had.
- run_code bindings enumerate schemas(exec.agent) — a program can bind
  exactly what its prompt promised; sub-dispatches already threaded
  exec.agent through registry.execute, so scoped resolution and carriers
  flow unchanged.
- dsh-tools declares both sides' new deps (dsh-scope + dsh-session);
  lockfile and all generated catalogs/graphs/api-catalog regenerated.

Gates green on the merged tree: typecheck, lint, per-file 100% coverage
(2710 tests), snapshots (41), doc-sync, module graph, build, hygiene, demo
smoke.
2026-07-09 23:57:50 +08:00
imccyu
d12cb45838 workflow: spawn the worker with an empty environment
The documented vm escape reaches process, and the worker inherited the
harness's env - so a buggy or prompt-injected script could read and
exfiltrate ambient credentials (DEEPSEEK_API_KEY et al.) without
touching a single file (ds-review-bot finding on #233).

Spawn with env: {} and a hermetic execArgv on both runtime shapes, the
same stance as dsh-code-runtime-worker and stronger than the scrubbed
env the defensive-patterns rule requires for spawned commands (a shell
needs PATH; this worker needs nothing). Ambient-channel hardening only:
an escapee keeps the process-wide privileges the trust premise already
admits - the genuine sandbox remains an engine swap.
2026-07-09 23:57:43 +08:00
Turtle
bf1ab14b78 a human touch
get some headroom
2026-07-09 23:48:29 +08:00
Tianyi Cui
58a5088feb Merge remote-tracking branch 'origin/master' into workflow-vm-to-workerthread
# Conflicts:
#	docs/config-catalog.md
#	docs/event-producer-consumer.md
#	packages/core/tools/tests/gen-tool-catalog.spec.ts
2026-07-09 23:48:17 +08:00
Tianyi Cui
2489402610 Merge origin/master: scope-aware fusion of the tools/execute seam, session-prefix, and tool-cordis
Master brought 50 commits (the tool-cordis group, dsh-code-runtime + worker,
the tools/execute around-dispatch seam + timeout-policy, repeat-tool-guard,
agent/session-prefix, the ui reorganization). Beyond the ten textual
conflicts, the merge reconciles master's new seams with this branch's
scoped-registration world:

- tools/execute (new waterfall around core dispatch): dispatched with the
  SAME exec.agent carrier as the pre/post waterfalls — an agent.ctx wrapper
  times/retries only its own agent's calls — and its base thunk resolves the
  tool through the caller's visible view (get(exec.name, exec.agent)), so a
  scoped/shadowed tool dispatches and a restricted-away global stays
  UNKNOWN_TOOL. Declared this: Scoped<ToolRegistry> with the scope-filtered
  doc sentence; invariants table + verify-scoped-dispatch pin it (21 events).
- agent/session-prefix (new waterfall, once per loop instance): composed via
  the fused agentEvents dispatcher (scope-filtered like every agent-subject
  event), declared this: Scoped<Agent>, table-pinned. agent/pre-step keeps
  master's new sessionPrefix parameter with this branch's Scoped this.
- timeout-policy reads the budget through the caller's visible view
  (get(exec.name, exec.agent)): a scoped tool's own timeoutMs governs its
  calls; a global name-twin's budget is never misapplied to a shadowing
  per-agent variant.
- tool-cordis: cordis_inspect's tools section lists the CALLING agent's view
  (its description promises "what you can call"); the sandbox tool façade's
  reads resolve through the mount's own scope, mirroring where its register
  lands writes; sandboxRegisterTool's return type carries the exact-disposer
  union honestly. dsh-scope declared as peer+dev with the project reference.
- doc-sync chain unions master's verify-cordis-api with this branch's
  verify-scoped-dispatch; the generated catalogs, event matrix (the
  zero-dispatcher guard passes over master's new events), module graph, and
  the cordis api-catalog are regenerated on the merged surface.

Full gate sequence green on the merged tree: typecheck, lint, per-file 100%
coverage (2668 tests), snapshots (38), doc-sync, module graph, build,
hygiene, demo smoke.
2026-07-09 23:24:42 +08:00
Tianyi Cui
a205dd9a46 Merge pull request #211 from deepseek-harness/code-mode-tools
feat: Code Mode — the model drives the tool registry by writing TypeScript
2026-07-09 23:24:12 +08:00
imccyu
7d3b16c184 docs: update budget / catalog 2026-07-09 23:10:28 +08:00
imccyu
64d0703c40 workflow: host-guarantee the agent-start/agent-end pairing on every stop path
agent-end was worker-authored only, so a start already forwarded to
observers lost its paired end whenever the worker could no longer speak
- the grace force-settle terminating a wedged script, or an unexpected
worker death - stranding progress consumers with agents that never
finish (ds-review-bot finding on #233).

The host now keeps a ledger of forwarded starts and funnels every
agent-end through one gate: worker-reported ends pair (and clear) their
entry, and both termination paths drain the remainder as synthesized
'cancelled' ends BEFORE the run settles, so ends always precede
workflow/end. A real settlement racing the force-settle loses to the
synthesized cancellation - the same first-wins override onResult applies
to the run's own result.
2026-07-09 23:05:43 +08:00
Tianyi Cui
2da28e89eb Merge remote-tracking branch 'origin/master' into code-mode-tools
# Conflicts:
#	examples/AGENTS.md
#	examples/README.md
#	package.json
#	packages/core/tools/tests/gen-tool-catalog.spec.ts
2026-07-09 22:58:58 +08:00
imccyu
053a2b9403 Merge remote-tracking branch 'origin/master' into workflow-vm-to-workerthread 2026-07-09 22:54:19 +08:00
Tianyi Cui
d58a55ad59 Merge pull request #201 from deepseek-harness/agent-request-messages
feat(agent): the agent/session-prefix seam — a compose-once, header-logged session prefix
2026-07-09 22:46:06 +08:00
Tianyi Cui
c39fe5cd30 Merge remote-tracking branch 'origin/master' into agent-request-messages
# Conflicts:
#	docs/cordis-catalog/services.md
2026-07-09 22:43:26 +08:00
Tianyi Cui
30bc7f6a1d fix: the run_code program IS the execute-card title (root cause: Zed shows nothing else)
Systematic trace through Zed (crates/agent_ui thread_view.rs +
crates/acp_thread): kind:execute routes a tool call onto the
terminal-card layout, whose header (render_collapsible_command) has NO
disclosure toggle, whose body content renders only when is_open — a
flag only a real terminal entity can ever set — and which suppresses
the Raw Input view outright. Every prior attempt (rawInput, pending
content, completed content) targeted slots that layout structurally
never renders; the one slot it always shows is the TITLE, which said
"Run code". codex-acp confirms the idiom: execute cards are titled
with the command itself.

presentCall now titles the card with the program (rawInput kept as the
canonical input slot); presentResult omits the title — an update
replaces only provided fields, so the program header persists — and
carries the captured output as content. Goldens re-recorded; the unit
test pins title-carries-program on both frames.
2026-07-09 22:41:57 +08:00
imccyu
2c812fb84a Merge remote-tracking branch 'origin/master' into workflow-vm-to-workerthread 2026-07-09 22:36:52 +08:00
Tianyi Cui
b472dbcfb1 Merge pull request #225 from deepseek-harness/recall-renderer-shared
refactor(compact): extract the shared transcript renderer into dsh-compact
2026-07-09 22:36:25 +08:00
Tianyi Cui
d976767fa6 Merge branch 'master' into recall-renderer-shared 2026-07-09 22:34:56 +08:00
Tianyi Cui
868b33b8b1 Merge pull request #220 from deepseek-harness/tool-cordis
feat: add the self-referential cordis toolset (@deepseek-ai/dsh-tool-cordis)
2026-07-09 22:32:43 +08:00
Tianyi Cui
88ab5ce0bc Merge branch 'master' into feat/subagent-process 2026-07-09 22:19:30 +08:00
imccyu
fe4da9244f fix(tool-cordis): validate a dynamic tool's execute return shape after the realm round-trip
The sandbox execute wrapper JSON round-tripped the return and blindly cast it
to ToolExecuteReturn. A JSON-valid but wrong-shape return — a bare string,
{ content: 'ok' }, blocks without a type tag — sailed through: the registry
spreads result.content, so { content: 'ok' } became ['o','k'], passed the
session log's isJsonValue gate, and the DeepSeek serializer then flattened it
to '(no output)' — silent corruption of the next model request and every
replay, instead of a contained tool error.

The round-tripped value is now shape-checked against the two ToolExecuteReturn
forms (array of content blocks, or { content: blocks, meta? }); block checks
are structural only (plain object + string type tag) because the ContentBlock
union is merge-extensible. A wrong shape — and the formerly cryptic
forgot-return/bare-string cases — fails that one call with a teaching error
echoing a truncated preview of what was returned and the two valid forms.
New specs pin the object-form pass-through (meta included), six rejection
shapes, and the preview truncation; per-file 100% coverage holds.
2026-07-09 22:12:30 +08:00
Tianyi Cui
f505776eee fix: keep the program on the COMPLETED run_code card (agent review follow-up)
The previous commit put the fenced program only on the pending card —
but an ACP tool_call_update's content REPLACES the card content (Zed
truncates to the new list, crates/acp_thread update_fields), so the
code vanished the moment the run completed and was effectively never
visible. presentResult now re-carries the fenced program before the
captured output via a shared fencedProgram helper; the completed card
body is program + output, rendered by Zed as syntax-highlighted
markdown behind the card disclosure. Goldens re-recorded (filtered
this time: DSH_SNAPSHOT=record vitest -u -t mode-turn); unit test pins
the two-block result content.
2026-07-09 22:04:52 +08:00
imccyu
fda5784e16 Merge remote-tracking branch 'origin/master' into tool-cordis
# Conflicts:
#	docs/capability-seams.md
#	packages/core/tools/tests/gen-tool-catalog.spec.ts
#	scripts/gen-doc-graphs.ts
2026-07-09 22:02:06 +08:00
imccyu
27f9c45e6a docs: update budget 2026-07-09 21:38:49 +08:00
imccyu
7f5b990aa1 Merge remote-tracking branch 'origin/master' into workflow-vm-to-workerthread 2026-07-09 21:34:52 +08:00