DeeSeek Harness Postmortems and Engineering Culture
The dsh repo writes every bug that 'appeared when it shouldn't have' into a postmortem, leaving safeguards at the testing, documentation and rules levels.
Understand this postmortem culture and testing discipline and you can apply it in the runoob project: not just using dsh, but thinking like a maintainer.
In short: the value of a bug is not the fix line, but why the process let it through and what safeguards were added so the same class of problem fails explicitly next time.
Postmortem culture: four questions
A postmortem records a bug appearing where it shouldn't (real users, a merged PR, a released version).
What matters is why our process let it through, not just that one fix line.
It is a retrospective failure record answering four questions:
| Four Questions | What to Answer |
|---|---|
| What broke | Use a short paragraph so busy readers grasp the key points in thirty seconds |
| What was the mechanism | Explain the root cause in plain words without blaming individuals |
| Why every safety net failed to catch it | Find gaps in tests, tools and conventions, not a one-off typo |
| What safeguards were added | Tests, AGENTS.md rules, ADRs, so the same bug fails explicitly next time |
Not every bug deserves a postmortem.
Write one only when a bug meets three conditions at once: subtle (the mechanism isn't obvious, even a careful engineer must re-derive it with effort), systemic (the escape cause is a gap in tests, tools or conventions), and costly to rediscover (it consumed real debugging time and will again).
Four real cases
The repo currently has four postmortems, each corresponding to a class of engineering mistakes prone to recurrence.
Below we introduce each, focusing on 'why it escaped' and 'what safeguards were added'.
Postmortem 0001
ACP server crashes on connection: export default drops the plugin's inject.
What broke: as soon as the editor (Zed) connected, the first
session/newreportedcannot get property "agents" without inject。Mechanism: the plugin wrote an extra
export default apply, and the Loader'sunwrapExportspicked up the bare function, thereby dropping everything on the namespaceinjectentirely.Why safety nets failed: 178 green unit tests + 100% line coverage were all there, but every test used manual
ctx.plugin(...)mounting, bypassing the real Loader's load path.New safeguards: remove the default export; add a keyless real-Loader smoke test; rule 'test the real entry path, line coverage is not behavior coverage'.
Postmortem 0002
The filesystem snapshot tool was permanently disabled by a literal !!js object.
What broke: seven filesystem scenarios called tools that don't exist in the registry, returning
UNKNOWN_TOOL。Mechanism: the author used
disabled: !!js ...to conditionally enable the filesystem plugin, but Cordis only inside the pluginconfiginternally evaluates JS expressions; when reading thedisabledconfig item directly, it sees a truthy object.Why the safety net didn't catch it: the snapshot refresh treated 'deterministic replay' as 'correct behavior'—it proved the regression was reproduced stably, but not that the filesystem tools were actually registered.
New safeguards: switched to an explicit filesystem overlay; a static config guard rejects expression nodes in Loader config item metadata; the snapshot framework rejects structured
UNKNOWN_TOOLresults.
Postmortem 0003
The Web agent validated a substitute server instead of the GUI hosting its session.
What broke: the agent modified the GUI source but didn't know which URL the current session corresponded to or which process hosted it.
Mechanism: it treated the HTTP 200 returned by bare Vite as success (actually a blank screen), then went on to validate the substitute
dsh webserver on another port, never probing port 3081.Why the safety net didn't catch it: the Web composition didn't provide the model with the identity of the current GUI, canonical URL, or run mode; the first regression test also passed off 'process timeout' as 'fail fast', producing a false positive.
New safeguards: the launcher publishes the canonical loopback URL and the actual production/development mode (env vars + prompt sections); standalone Vite service mode refuses to start at the config stage; layered real-path tests cover the CLI, prompt, runtime facts, and browser HMR.
Postmortem 0004
A partial Landlock enforcement notice caused a subprocess failure to be misclassified.
What broke: on kernels with an older Landlock ABI, ripgrep exits normally with code 1 when there are no matches, but this was presented as a
SANDBOX_UNAVAILABLEsandbox failure.Mechanism: the launcher prints a harmless
landlock-run: partial enforcement (older Landlock ABI)notice; the harness uses a case-insensitivelandlock-run:substring to combine the notice with any nonzero exit, misjudging it as a runner failure.Why the safety net didn't catch it: the sandbox result type can only express a set of substrings, not 'a Landlock failure must exit with code 125 + a one-line fatal diagnostic'; the test matrix never constructed the combination of 'notice followed by a nonzero subprocess exit'.
New safeguards:
RunnerFailureRulean informational line carrying allowed exit codes, per-line fatal signatures, and exact exclusions; filesystem search switched to usingctx.subprocessrunning the bundled ripgrep, no longer going through sandboxed bash.
Taken together, the four cases yield one common lesson: tests must go through the real entry path.
Manual mounting, mocking everything, treating snapshot refresh as acceptance—all make it possible for 'all unit tests green but the product broken'.
Four Layers of Testing
The repo's testing strategy is layered, with each layer covering blind spots the previous layer can't catch.
| Level | Command | What It Catches |
|---|---|---|
| Unit testing | pnpm run test |
vitest runs in-package tests, prioritizing boundaries, error paths, event order, and concurrency races |
| Coverage Gate | pnpm run test:coverage |
100% coverage per file; uncovered lines are often dead code that should be deleted |
| Real API e2e | pnpm run test:e2e |
calls real provider APIs with a key; auto-skips when the key is missing, keeping keyless CI green |
| snapshot | pnpm run test:snapshot / test:web |
keyless expected outputs cover external behavior; browser snapshots are compared via Chromium replay |
The repo is DeepSeek's own, so there's a special principle: inference is cheap here, don't skimp on real API tests.
Keyless tests can only prove the underlying path; only runs with a key prove the agent works correctly with a real model.
The most valuable are smoke tests: start a real example, send a prompt, and check the outside world.
They can catch the class of problems mocks can't find, such as 'all unit tests green but the product broken'.
Line coverage is a necessary condition, never a sufficient one.
It proves lines were executed, not that the feature works as delivered.
The 0001 case, where 100% coverage still let two integration bugs through, is the best illustration.
Another principle is to verify the outside world, not self-reports.
e2e assertions should re-run commands or re-read files from outside; keyword probing of the agent's own output lets a cheating agent pass.
Assertions on unmodified files should be byte-for-byte identical.
Documentation Discipline: One Fact, One Home
The repo's docs aren't done once written; there are mechanisms to prevent 'docs drifting from source'.
verify-type-equiv is a gate: it uses the TypeScript parser to extract the symbols of type declarations and their accompanying JSDoc from the source, asserting that doc code blocks match both.
When you change a documented type declaration or its JSDoc, the gate fails until you update the pasted content.
This guarantees the type definitions in the docs always match the source, avoiding 'docs copied from an old version'.
Another discipline is one fact, one home: each fact is maintained in only one file, and other files reference it.
For example, the 'source of truth' for the tool schema is in adding-a-tool.md, with other pages referencing rather than copying it.
Chinese and English docs are maintained via bilingual pairs; when updating, first run pnpm run gen-doc-graphs to update English, then update Chinese and verify the pair.
The same applies to your own projects: put the 'single fact' in one place, don't let the same config scatter across three docs.
Hands-on Example: Write a Thirty-Second Executive Summary
Each postmortem opens with an executive summary so busy readers can absorb the key points in thirty seconds.
Try doing a postmortem of an Agent failure you encountered in the runoob project, using the template below:
# Review 0005: The tool blacklist in the runoob demo environment did not take effect
## 摘要
demo 环境里模型仍能调用被禁用的 fs_write,直接写入了工作区。
根因是黑名单插件用 `tools/pre-execute` 返回了 `next()`,
而真正负责拦截的守卫注册在插件卸载之后——加载顺序错了。
逃逸原因是加载顺序没有测试覆盖,`cordis.yml` 只测了「能起来」。
新增防护:给黑名单插件补一条「顺序敏感」的装配测试,
并在 AGENTS.md 记录「pre-execute 与 guard 的注册顺序」规则。
Formula for the thirty-second summary: what broke -> the root cause in plain words -> why it escaped -> the long-lasting lesson.
Series Conclusion
At this point, all 28 parts of the DeepSeek Harness getting-started tutorial are complete.
Looking back: from Part 1 meeting the four guardrails of dsh, to learning installation, using the Web UI, and using the Python SDK; from writing your first plugin to understanding plugin lifecycle, services and scopes, and the event system; from designing capabilities with the three-role pattern and integrating any LLM, to packaging and release; and finally these last five parts, which fill in the last piece of the puzzle—security and engineering culture.
What you truly take away isn't just API usage, but a way of thinking:
The model is responsible for being smart; Harness is responsible for being reliable. Constraints aren't limitations, but the foundation that makes the Agent predictable, auditable, and replayable.
Everything is a plugin. Put policies at extension points, not baked into the loop, so the system can evolve without losing control.
The real entry path beats all mocks. Coverage, snapshots, and smoke tests each play their part, jointly preventing 'all green but broken'.
Failures aren't scary; not knowing why is. A postmortem culture turns an incident into a set of safeguards.