feat(invariants): dev-mode event-contract assertions + session-log freeze (RFC 005 pt 3, RFC 008)

New @deepseek-ai/dsh-invariants plugin (pure listeners, off in prod) asserts
the event taxonomy at runtime — seq monotonicity, turn/step nesting, a
tool/result needs a prior tool/call (NOT the converse), legal agent/status
transitions — and deep-freezes logged event data so mutating history throws.
Seeded sessions are checked + frozen on session/created.

The real RFC 008 fix is always-on: deriveMessages now structured-clones the
content it emits, so the loop's sanctioned request/adapter mutation can no
longer reach back and rewrite the append-only log. The pervasive
DeepReadonly<T> type flip is rejected (compile-only, high-noise, castable) —
recorded in ADR 0012, which folds in RFC 008. Wired into both demos.
This commit is contained in:
Tianyi Cui
2026-06-13 23:25:12 +08:00
parent 11f85b4f88
commit 11a29fdefe
19 changed files with 626 additions and 11 deletions

View File

@@ -611,6 +611,21 @@ __metadata:
languageName: unknown
linkType: soft
"@deepseek-ai/dsh-invariants@workspace:packages/invariants":
version: 0.0.0-use.local
resolution: "@deepseek-ai/dsh-invariants@workspace:packages/invariants"
dependencies:
"@deepseek-ai/dsh-agent": "npm:^0.0.1"
"@deepseek-ai/dsh-llm": "npm:^0.0.1"
"@deepseek-ai/dsh-session": "npm:^0.0.1"
cordis: "npm:^4.0.0-rc.6"
peerDependencies:
"@deepseek-ai/dsh-agent": ^0.0.1
"@deepseek-ai/dsh-session": ^0.0.1
cordis: ^4.0.0-rc.6
languageName: unknown
linkType: soft
"@deepseek-ai/dsh-llm-deepseek@npm:^0.0.1, @deepseek-ai/dsh-llm-deepseek@workspace:packages/llm-deepseek":
version: 0.0.0-use.local
resolution: "@deepseek-ai/dsh-llm-deepseek@workspace:packages/llm-deepseek"