refactor(session): centralize surface provenance validation

This commit is contained in:
Hypatia May
2026-07-13 14:46:43 +08:00
parent 7351f07995
commit 75de01f06d
10 changed files with 171 additions and 131 deletions

View File

@@ -359,7 +359,7 @@ export interface Config {
}
```
Source: [`packages/support/invariants/src/index.ts:45`](../packages/support/invariants/src/index.ts)
Source: [`packages/support/invariants/src/index.ts:52`](../packages/support/invariants/src/index.ts)
## `@deepseek-ai/dsh-llm-deepseek`

View File

@@ -16,7 +16,7 @@ Session relationships are encoded across immutable headers, positional surface o
## Validation boundary
Event tracing checks target existence before surface analysis. Before returning a trace it validates the whole loaded log: only surface event types carry provenance, present arrays are nonempty and duplicate-free, every source is a known earlier seq, and every positional replacement names all surface nodes it removed. Provenance failures use `SESSION_QUERY_INVALID_PROVENANCE`; positional fold failures keep `SESSION_QUERY_INVALID_SURFACE`. `listEvents()` remains a surface-classification operation and does not acquire trace-specific provenance rejection.
Event tracing checks target existence before surface analysis. Before returning a trace it validates the whole loaded log through `dsh-session`'s shared provenance checker: only surface event types carry provenance, present arrays are nonempty and duplicate-free, every source is a known earlier seq, and every positional replacement names all surface nodes it removed. Provenance failures use `SESSION_QUERY_INVALID_PROVENANCE`; positional fold failures keep `SESSION_QUERY_INVALID_SURFACE`. `listEvents()` remains a surface-classification operation and does not acquire trace-specific provenance rejection.
All returned records and arrays are detached. A known live event trace never consults persistence; persisted event traces preserve the exact-read list/load consistency check. Session lineage is necessarily a cross-corpus operation and therefore preserves cross-corpus persistence failure semantics.