dsh-log-contract 0.3.26 → 0.3.28
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.
- package/README.md +126 -44
- package/README.zh.md +105 -44
- package/bin/dsh-log-contract.mjs +13 -13
- package/docs/CONTRACTS.md +83 -55
- package/lib/archaeology.js +38 -22
- package/lib/archive.js +21 -21
- package/lib/checks.js +64 -64
- package/lib/compat.js +7 -7
- package/lib/contracts.js +88 -56
- package/lib/host-probes.js +4 -4
- package/lib/legacy-fold.js +5 -5
- package/lib/log-reader.js +82 -17
- package/lib/prewrite.js +23 -7
- package/lib/repair.js +34 -34
- package/lib/validate.js +39 -11
- package/lib/version-support.js +2 -2
- package/lib/vocab.js +8 -8
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -25,12 +25,21 @@ plugin marker semantics).
|
|
|
25
25
|
|
|
26
26
|
- **`check <session-log>`** — offline health check: official decoder full decode +
|
|
27
27
|
per-rule contract validation + foldSurface final verification, with a violation
|
|
28
|
-
report.
|
|
28
|
+
report and a machine-readable **tail-completeness** field (`tailStatus`).
|
|
29
29
|
- **`prewrite <edit-file> --log <session-log>`** — ★ pre-write validation: any
|
|
30
30
|
write (append / frame-level surgery) passes the three-layer contract before it
|
|
31
|
-
lands; violations are blocked.
|
|
31
|
+
lands; violations are blocked (including self-invented `seq` values).
|
|
32
32
|
- **`contracts`** — list the built-in contract rule catalog (each with its
|
|
33
33
|
official source reference).
|
|
34
|
+
- **`check --resume`** — three-tier verdict (`loadable` / `resumable` /
|
|
35
|
+
`compactable`, plus `not-assessable` when the host cannot judge the file).
|
|
36
|
+
- **`fix` / `extract` / `audit-report`** — repair primitives and read-only
|
|
37
|
+
session archaeology.
|
|
38
|
+
|
|
39
|
+
**Capabilities at a glance**: session formats **v0–v4** · 55 contract rules ·
|
|
40
|
+
exit-code contract `0/1/3/4` · three-tier verdicts · pre-write validation ·
|
|
41
|
+
per-rule negative-control tests + rules self-test · tolerant reading (a single
|
|
42
|
+
damaged file degrades to structured results and is counted, never thrown).
|
|
34
43
|
|
|
35
44
|
---
|
|
36
45
|
|
|
@@ -67,7 +76,7 @@ line-by-line verification against the official Host source (each rule carries it
|
|
|
67
76
|
---
|
|
68
77
|
|
|
69
78
|
## Three-layer contract (the model)
|
|
70
|
-
>
|
|
79
|
+
> 55 rules across the layers below (`contracts` lists them all, each with its
|
|
71
80
|
> official source reference).
|
|
72
81
|
|
|
73
82
|
| Layer | Rules | What it guards |
|
|
@@ -76,6 +85,8 @@ line-by-line verification against the official Host source (each rule carries it
|
|
|
76
85
|
| **Client engine** | **M1** + **T1 / T2 / I1** | turn-null markers only as replace; token-meter pairing; cross-step source refs; inbox seed-relative replay |
|
|
77
86
|
| **Wire message flow** | **W1 / W2** | tool messages follow an assistant with tool_calls; no user text between tool_calls and results |
|
|
78
87
|
| **Plugin semantics** | P1/P2 | marker id prefixes recognizable; a marker's seq not in its own shadowed set |
|
|
88
|
+
| **Framing** | Z1–Z6 | zstd frame shape (header own first frame; no single-frame re-compression), empty-shell sessions, **tail completeness (`tailStatus`)** |
|
|
89
|
+
| **Reader / aggregation** | **R4 / R5** | a single damaged file must degrade to a structured, countable result (never throw, never abort enumeration); aggregation APIs isolate failures per item |
|
|
79
90
|
|
|
80
91
|
> Philosophy: first an incremental replay with official-equivalent semantics for
|
|
81
92
|
> **per-event attribution** (pinpoint seq/line), then the official `foldSurface` as
|
|
@@ -88,18 +99,18 @@ line-by-line verification against the official Host source (each rule carries it
|
|
|
88
99
|
|
|
89
100
|
| Item | Baseline | Note |
|
|
90
101
|
|---|---|---|
|
|
91
|
-
| Host package | `@deepseek-ai/dsh-session@0.
|
|
92
|
-
| Session format | **
|
|
93
|
-
| Declared range | `peerDependencies: ^0.1.0-rc.7 || ^0.1.5-rc.1` | installable — a declared range is **not** a per-version verification |
|
|
94
|
-
| Known formats | 0 / 1 / 2 / 3 | 0–2 are supported by this package's **vendored** vocabulary + local equivalent fold (`legacyFoldSurface`), independent of the host |
|
|
102
|
+
| Host package | `@deepseek-ai/dsh-session@0.2.0-rc.2` | the version this rule set is developed and CI-tested against (CI runs `pnpm check` + `pnpm test`; the four `prepublishOnly` steps are green locally on it) |
|
|
103
|
+
| Session format | **v4** (`SESSION_FORMAT_VERSION = 4`) | v4 uses the runtime vocabulary + official `foldSurface` final check |
|
|
104
|
+
| Declared range | `peerDependencies: ^0.1.0-rc.7 || ^0.1.5-rc.1 || ^0.2.0-rc.1` | installable — a declared range is **not** a per-version verification |
|
|
105
|
+
| Known formats | 0 / 1 / 2 / 3 / 4 | 0–2 are supported by this package's **vendored** vocabulary + local equivalent fold (`legacyFoldSurface`), independent of the host |
|
|
95
106
|
|
|
96
107
|
**What happens on unverified versions (detected and reported at runtime — never silently judged by stale rules)**:
|
|
97
108
|
|
|
98
109
|
| Case | Behaviour |
|
|
99
110
|
|---|---|
|
|
100
111
|
| Host **newer than the baseline** | explicit **warning** (`host … is newer than the tested baseline …`); the verdict is still produced but flagged as possibly not applicable |
|
|
101
|
-
| Host older than the baseline (still in peer range) | notice + the host-capability gate decides whether
|
|
102
|
-
| **Unknown** session format (not in 0/1/2/3) | reported as **unverified format** and handled **read-only**: `check` runs structure rules only; `prewrite` / `fix` **refuse** (exit 3) |
|
|
112
|
+
| Host older than the baseline (still in peer range) | notice + the host-capability gate decides whether the file's format is assessable (`SESSION_FORMAT_VERSION` too low ⇒ `not-assessable`, exit 3) |
|
|
113
|
+
| **Unknown** session format (not in 0/1/2/3/4) | reported as **unverified format** and handled **read-only**: `check` runs structure rules only; `prewrite` / `fix` **refuse** (exit 3) |
|
|
103
114
|
| Format **unrecognisable** (no `header.version` and no distinguishing event shapes) | same: "unverified format" + read-only |
|
|
104
115
|
| File version above the host's supported maximum | `not-assessable` (**not** broken), exit 3; skipped/executed rules are listed |
|
|
105
116
|
|
|
@@ -107,19 +118,50 @@ Implementation: `lib/version-support.js` (`TESTED_BASELINE` / `detectSupport()`,
|
|
|
107
118
|
Both the human-readable `check` output and the `--json` `support` field carry the baseline summary and the warnings, e.g.:
|
|
108
119
|
|
|
109
120
|
```
|
|
110
|
-
version support: host @deepseek-ai/dsh-session@0.
|
|
121
|
+
version support: host @deepseek-ai/dsh-session@0.2.0-rc.2 (baseline 0.2.0-rc.2) | file format v4 (header, baseline)
|
|
111
122
|
```
|
|
112
123
|
|
|
124
|
+
## 🆕 0.3.28 · Reader tolerance, tail completeness, seq provenance
|
|
125
|
+
Four rules distilled from recent production failures (each pinned by a
|
|
126
|
+
negative-control test — a violating sample must turn red, a compliant one green):
|
|
127
|
+
|
|
128
|
+
| Rule | Checks | Severity |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| `R4` | read/parse tolerance: a single damaged file (torn zstd frame, corrupt line, bad chunk row, empty file) must degrade to a **structured, countable** result (`null` / per-row `error` markers / `frameInfo` facts) — never throw and never abort an enumeration/summary run | error |
|
|
131
|
+
| `R5` | aggregation/summary APIs isolate failures **per item** (per-item `try/catch` + a `skipped` counter); one bad item must not sink the batch | error |
|
|
132
|
+
| `E11` | `seq` is assigned by the log layer's continuous cursor only: a pre-write candidate must omit `seq` (auto-assigned) or carry exactly `nextSeq`; producer-side `seq` invention / delete-without-renumber shows up as gaps ⇒ `E2`/`S9` | error |
|
|
133
|
+
| `Z6` | tail completeness must be declared: `tailStatus: complete \| interrupted \| truncated \| unknown` (see the known boundary below) | warning |
|
|
134
|
+
|
|
135
|
+
Also in 0.3.28: **rules self-test** — the registry, the tests and the generated
|
|
136
|
+
docs are cross-checked (`test/rules-self-test.test.js`): every rule must be
|
|
137
|
+
referenced by a control or a binding assertion in the tests (or carry an
|
|
138
|
+
explicit, justified delegation entry; the red/green strength of each control is
|
|
139
|
+
owned by that rule's own negative-control cases); every emitted violation id
|
|
140
|
+
must be registered. `summary.unreadableRows` and
|
|
141
|
+
`summary.tailStatus` are new machine-readable fields.
|
|
142
|
+
|
|
143
|
+
**Known boundary (stated honestly)**: `check` / `check --json` guarantee that
|
|
144
|
+
**the events actually read** are self-consistent — they do **not** guarantee the
|
|
145
|
+
file tail is intact. A file whose last frame was cut mid-write can still come
|
|
146
|
+
back `ok=true`; read `summary.tailStatus` (`--json`) to know the tail state.
|
|
147
|
+
`tailStatus` values: `complete` (tail intact) · `interrupted` (torn zstd tail —
|
|
148
|
+
in-flight/interrupted write; the host reader keeps complete records and drops
|
|
149
|
+
the unfinished tail, so it is recoverable) · `truncated` (the tail record itself
|
|
150
|
+
is cut — data is missing) · `unknown` (undecidable: unreadable/empty file).
|
|
151
|
+
`Z6` reports the non-`complete` states as a warning and deliberately does not
|
|
152
|
+
flip `ok`.
|
|
153
|
+
|
|
113
154
|
## 🆕 0.3.18 – 0.3.24 · DSH 0.2.x (session format v4) support
|
|
114
155
|
**Session format v4** (`@deepseek-ai/dsh-session` 0.2.x) is now validated by format-version dispatch
|
|
115
156
|
rather than by relaxing the format gate:
|
|
116
157
|
|
|
117
158
|
- `tool/result` is validated with the v4 shape (`role: 'tool'`, no `tool-result` wrapper block)
|
|
118
159
|
- `system/message` accepts v4's `source.kind: 'system-prompt'`
|
|
119
|
-
- validation for v3 and earlier is **unchanged** (identical verdicts on
|
|
160
|
+
- validation for v3 and earlier is **unchanged** (identical verdicts on [n] real v3 sessions before/after)
|
|
120
161
|
- the format gate still rejects **unknown** future versions (`readOnly`); v5+ remains unassessable by design
|
|
121
162
|
|
|
122
|
-
**
|
|
163
|
+
**Rules (55 total as of 0.3.28):** the five rules below were added in the
|
|
164
|
+
0.3.18 – 0.3.24 window (see above for the 0.3.28 additions):
|
|
123
165
|
|
|
124
166
|
| Rule | Checks |
|
|
125
167
|
|---|---|
|
|
@@ -129,7 +171,7 @@ rather than by relaxing the format gate:
|
|
|
129
171
|
| `P5` | two-segment carrier pairing: 2nd segment's first seq == 1st segment seq (read side accepts the legacy order) |
|
|
130
172
|
| `A1` | "in-place restorable" is judged from structured fields only (`archiveRef` / `archive` / `externalized.*`) — never from free text |
|
|
131
173
|
|
|
132
|
-
**Large sessions:** reading is line-wise (no whole-file stringification ⇒ no `ERR_STRING_TOO_LONG` above ~
|
|
174
|
+
**Large sessions:** reading is line-wise (no whole-file stringification ⇒ no `ERR_STRING_TOO_LONG` above ~[size]),
|
|
133
175
|
and repair rebuilds `.jsonl.zstd` with streaming frames (header frame + chunked body frames, per-frame checksum + round-trip).
|
|
134
176
|
|
|
135
177
|
**Windows:** the `header.cwd` absolute-path check in `H2` is platform-aware (`win32` and `posix` both accepted).
|
|
@@ -143,20 +185,23 @@ omitted.
|
|
|
143
185
|
|
|
144
186
|
| # | Date | What happened | The rule / fix it produced |
|
|
145
187
|
| --- | --- | --- | --- |
|
|
146
|
-
| 1 |
|
|
147
|
-
| 2 |
|
|
148
|
-
| 3 |
|
|
149
|
-
| 4 |
|
|
150
|
-
| 5 |
|
|
151
|
-
| 6 |
|
|
152
|
-
| 7 |
|
|
153
|
-
| 8 |
|
|
154
|
-
| 9 |
|
|
155
|
-
| 10 |
|
|
156
|
-
| 11 |
|
|
157
|
-
| 12 |
|
|
158
|
-
| 13 |
|
|
159
|
-
| 14 |
|
|
188
|
+
| 1 | [n]-08-25 | A "restore hidden content" repair wrote a replace marker with **emptied `sourceEventSeqs`** → the session refused to load (`SessionPersistenceCorruptionError`); a second attempt changed the marker to **append** → the client engine crashed. Both were **violating writes that nothing caught**. | **S5** (sourceEventSeqs must cover shadowed nodes), **M1** (turn-null assistant/message can only be replace), pre-write validation |
|
|
189
|
+
| 2 | [n]-08-27~28 | Interrupted/restarted turns replayed with a **stale in-memory cursor**, re-appending old seqs to the file tail (tail regression, duplicate batches); two writers interleaved → **file-physical order non-monotonic** (`[n] → [n] → [n]`). Sessions failed to load with `seq gap`. | **S9** (physical-order monotonic), fix `--tail-renumber` |
|
|
190
|
+
| 3 | [n]-08-27~28 | **Fork-boundary orphan splice**: the fork's "remove parent's pending prompt" splice assumed the parent's inbox; the child's seed-relative replay has an empty inbox → `resume failed: invalid persisted inbox splice`. | **I1** (inbox seed-relative replay), fix `--neutralize-orphan` |
|
|
191
|
+
| 4 | [n]-08-28 | An oversized session (**[n] tokens** vs the 1M window) could neither continue nor `/compact`; the trim budget estimator underpriced CJK by ~3.7×. | T1 (token-meter pairing) for compactability, `fix --trim-budget` guidance |
|
|
192
|
+
| 5 | [n]-08-29 | **W1/W2 wire violations**: markers shadowed an assistant with tool_calls but left the tool results dangling → strict endpoints (`INVALID_REQUEST`) reject the session's request stream. | **W1 / W2** (wire message flow) |
|
|
193
|
+
| 6 | [n]-08-30 | A single **turn-null marker** made the token-meter listener throw on **every** appended event (`consumedEvents` never advanced → full-prefix re-fold per event) → **30s / [n] log lines**, host event loop crushed, all sessions locked. Same session also had a **cross-step sourceEventSeqs** (steps 7/8/9 mixed in one assistant message) — offline checks were green, the live meter crashed. | **T1** (turn/step pairing), **T2** (cross-step source refs), `fix --neutralize`, `fix --clip-crossstep` |
|
|
194
|
+
| 7 | [n]-08-31 | A log was compressed as a **single zstd frame** (or the header did not form its own frame) → different readers disagreed on record boundaries ⇒ **Z4/Z5** frame-shape rules (first frame = exactly one header line; body framed) | |
|
|
195
|
+
| 8 | [n]-08-31 | A log whose **last zstd frame was torn** mid-write could not be loaded at all, with no diagnosis ⇒ **Z1** + explicit "torn tail / in-flight write" reporting | |
|
|
196
|
+
| 9 | [n]-09-09 | On **session format v4**, `tool/result` uses `role: 'tool'` and `system/message` carries a `system-prompt` source → v3-shaped checks produced **thousands of false errors on healthy v4 logs** ⇒ version dispatch + **E6/E9** v4 semantics | |
|
|
197
|
+
| 10 | [n]-09-17 | On **Windows**, `header.cwd` was judged with POSIX-only rules → **every** session flagged by **H2** ⇒ platform-aware absolute-path check | |
|
|
198
|
+
| 11 | [n]-10-20 | A **> [size] session** crashed the reader (`ERR_STRING_TOO_LONG`) and repair built the whole text in memory ⇒ line-wise decode + streaming frame rebuild | |
|
|
199
|
+
| 12 | [n]-10-20 | Two-segment carrier references were written with the audit segment first while an earlier convention started at the range start → readers reported hundreds of **false orphan carriers** ⇒ **P5** write-side pairing + tolerant read-side | |
|
|
200
|
+
| 13 | [n]-10-20 | `seedLength` was read as a **byte size** by some consumers (it is the number of inherited events), and `parentSession` with missing/0 was treated as corruption ⇒ **I2** semantics pinned | |
|
|
201
|
+
| 14 | [n]-10-20 | An **unknown but explicitly ignorable** event type blocked an entire migration ⇒ **G4** declarative skip + allow-list | |
|
|
202
|
+
| 15 | [n]-10-26 | A **truncated zstd frame** made the session-header reader throw `ERR_OUT_OF_RANGE`, and because there was no per-item isolation the whole enumeration/summary run failed (hundreds of failures over 33 days) — **one damaged file sank the whole batch** | **R4** (read/parse tolerance: degrade to a structured, countable result), **R5** (per-item isolation + failure counting in aggregation APIs) |
|
|
203
|
+
| 16 | [n]-10-26 | A file whose **last frame was cut mid-write** still reported `ok=true` — the check certifies only the events it actually read | **Z6** (`tailStatus: complete/interrupted/truncated/unknown`) + the documented tail-completeness boundary |
|
|
204
|
+
| 17 | [n]-10-26 | Producers **inventing `seq` on the write side**, and **deleting rows without renumbering** | **E11** (`seq` assigned by the log layer only; pre-write rejects self-invented `seq`), gap traces pinned to `E2`/`S9` |
|
|
160
205
|
|
|
161
206
|
> **Takeaway**: these rules are not synthetic theory — each one is pinned by a
|
|
162
207
|
> regression test that reproduces the corrupt shape it guards against. That is what
|
|
@@ -188,41 +233,56 @@ with the Harness read path).
|
|
|
188
233
|
### 1. Offline health check
|
|
189
234
|
|
|
190
235
|
```bash
|
|
191
|
-
dsh-log-contract check
|
|
192
|
-
dsh-log-contract check
|
|
236
|
+
dsh-log-contract check [path]<id>.jsonl.zstd
|
|
237
|
+
dsh-log-contract check [path]<id>.jsonl.zstd --json # machine-readable
|
|
193
238
|
```
|
|
194
239
|
|
|
195
240
|
Sample output (the CLI reports in Chinese — it is the tool's UI language):
|
|
196
241
|
|
|
197
242
|
```
|
|
198
243
|
📋 dsh-log-contract check —— backup-session-xxxx.jsonl.zstd
|
|
199
|
-
事件
|
|
244
|
+
事件 [n] | surface 节点 16 | replace 代数 5 | 帧 [n]([n].5KiB → [n].3KiB)
|
|
200
245
|
违规 1(error 1 / warning 0)
|
|
201
246
|
|
|
202
247
|
[error] S5 @ seq <seq> / line <line> (assistant/message)
|
|
203
|
-
surface replace: sourceEventSeqs 必须覆盖每个被替换节点;缺失
|
|
248
|
+
surface replace: sourceEventSeqs 必须覆盖每个被替换节点;缺失 [n] [n](共 2 个)
|
|
204
249
|
|
|
205
250
|
❌ 未通过:见上方违规明细(error 级 = 会话不可读/不可写)
|
|
206
251
|
```
|
|
207
252
|
|
|
208
|
-
Exit
|
|
209
|
-
|
|
253
|
+
**Exit-code contract** (there is no exit code `2`):
|
|
254
|
+
|
|
255
|
+
| Code | Meaning |
|
|
256
|
+
|---|---|
|
|
257
|
+
| `0` | pass — no error-level violations (and the migration pre-check is not blocked) |
|
|
258
|
+
| `1` | error-level violations exist (session unreadable/unwritable under this rule set) |
|
|
259
|
+
| `3` | not assessable on this host (file format newer than the host supports) — **not** "broken" |
|
|
260
|
+
| `4` | the migration pre-check is blocked (the official upgrade chain will refuse the file) |
|
|
261
|
+
|
|
262
|
+
**Three-tier verdict** (`check --resume`, also in `--json` as `resume`):
|
|
263
|
+
`loadable` (structure green) ⊂ `resumable` (+ `I1` inbox replay green) ⊂
|
|
264
|
+
`compactable` (+ `T1`/`T2` token-meter pairing green); a file failing the first
|
|
265
|
+
tier is reported as `broken`, and `not-assessable` is a separate fourth state
|
|
266
|
+
when the host cannot judge the file.
|
|
267
|
+
|
|
268
|
+
**Tail-completeness boundary**: `ok=true` only certifies that *the events actually
|
|
269
|
+
read* are self-consistent — see the `tailStatus` note in the 0.3.28 section above.
|
|
210
270
|
|
|
211
271
|
`check` adds **W1/W2 wire-level checks** since 0.2.0: expand the model request
|
|
212
272
|
stream in surface order and catch "dangling tool messages" (a tool result with no
|
|
213
273
|
preceding assistant tool_calls) and "user text between tool_calls and their
|
|
214
274
|
results" — tolerated by some endpoints, `INVALID_REQUEST` on strict ones
|
|
215
|
-
(MiMo, verified
|
|
275
|
+
(MiMo, verified [n]-08-27).
|
|
216
276
|
|
|
217
277
|
### 2. Repair (`fix`)
|
|
218
278
|
|
|
219
279
|
```bash
|
|
220
280
|
# Dry run (report only): strict seq scan + full contract check + removable-marker count
|
|
221
|
-
dsh-log-contract fix
|
|
281
|
+
dsh-log-contract fix [path]<id>.jsonl.zstd --remove-markers
|
|
222
282
|
|
|
223
283
|
# Apply: backup first, then write (.zstd rebuilt in official frame format: frame1=header,
|
|
224
284
|
# frame2=rest, checksum, single trailing newline)
|
|
225
|
-
dsh-log-contract fix
|
|
285
|
+
dsh-log-contract fix [path]<id>.jsonl.zstd --remove-markers --apply
|
|
226
286
|
```
|
|
227
287
|
|
|
228
288
|
- `--remove-markers`: remove retrace/message-editor markers and renumber everything
|
|
@@ -245,7 +305,7 @@ dsh-log-contract fix ~/.dsh/sessions/<id>.jsonl.zstd --remove-markers --apply
|
|
|
245
305
|
|
|
246
306
|
```jsonc
|
|
247
307
|
// Append one event to the log tail (seq omitted = auto-assigned as nextSeq)
|
|
248
|
-
{ "append": { "type": "assistant/message", "surfaceOp": { "op": "replace", "start":
|
|
308
|
+
{ "append": { "type": "assistant/message", "surfaceOp": { "op": "replace", "start": [n] "end": [n] }, "sourceEventSeqs": [[n] [n] "…"], "data": { "turn": null, "step": null, "message": { "…": "…" }, "editor": { "targetSeq": [n] "text": "…" } } } }
|
|
249
309
|
|
|
250
310
|
// Frame-level surgery: the complete event list after the edit (both baseline and
|
|
251
311
|
// result must be green before it may land)
|
|
@@ -253,11 +313,14 @@ dsh-log-contract fix ~/.dsh/sessions/<id>.jsonl.zstd --remove-markers --apply
|
|
|
253
313
|
```
|
|
254
314
|
|
|
255
315
|
```bash
|
|
256
|
-
dsh-log-contract prewrite marker-write.json --log
|
|
316
|
+
dsh-log-contract prewrite marker-write.json --log [path]<id>.jsonl.zstd
|
|
257
317
|
```
|
|
258
318
|
|
|
259
319
|
- A baseline with error-level violations is rejected outright (safety protocol
|
|
260
320
|
step 2: **the pre-surgery baseline must be green**).
|
|
321
|
+
- `seq` must be **omitted** (auto-assigned as `nextSeq`) or exactly `nextSeq` —
|
|
322
|
+
a self-invented `seq` is rejected (`E11`); on the file side, delete-without-
|
|
323
|
+
renumber and invented `seq` show up as gaps and are caught by `E2`/`S9`.
|
|
261
324
|
- Only a pass may land — **validate first, commit later** (same idea as the
|
|
262
325
|
official `SurfaceManager.validateNext`).
|
|
263
326
|
|
|
@@ -301,8 +364,8 @@ if (!baseline.ok) throw new Error('baseline is broken; repair it first');
|
|
|
301
364
|
const prewriter = createPreWriter({ events: log.events.map((e) => e.event) });
|
|
302
365
|
const verdict = prewriter.validateAppend({
|
|
303
366
|
type: 'assistant/message',
|
|
304
|
-
surfaceOp: { op: 'replace', start:
|
|
305
|
-
sourceEventSeqs: [
|
|
367
|
+
surfaceOp: { op: 'replace', start: [n] end: [n] },
|
|
368
|
+
sourceEventSeqs: [[n] [n] /* …must fully cover shadowed nodes… */],
|
|
306
369
|
data: { turn: null, step: null, message: { /* … */ } },
|
|
307
370
|
});
|
|
308
371
|
if (!verdict.ok) {
|
|
@@ -322,6 +385,14 @@ pnpm check && pnpm test # syntax check + contract-doc drift gate + all unit t
|
|
|
322
385
|
- **Synthetic fixtures** (in-repo): legal session / seq gap / empty sourceEventSeqs
|
|
323
386
|
/ turn-null append / unknown type / bad chunk row / torn tail frame / unknown
|
|
324
387
|
marker prefix / self-shadowing etc.
|
|
388
|
+
- **Negative controls are mandatory**: every rule must have a violating sample
|
|
389
|
+
that turns red and a compliant sample that stays green (the incident-derived
|
|
390
|
+
fixtures above double as those controls).
|
|
391
|
+
- **Rules self-test** (`test/rules-self-test.test.js`): registry completeness,
|
|
392
|
+
`violation(id)` binding, test coverage per rule (or an explicit justified
|
|
393
|
+
delegation), and "every emitted id is registered" — so a rule cannot exist
|
|
394
|
+
without a control, and a control cannot reference a rule that was never
|
|
395
|
+
registered.
|
|
325
396
|
|
|
326
397
|
> **Scope of the published package**: it contains the runtime code and documentation only.
|
|
327
398
|
> Local maintainer tooling is not part of the public repository, so `pnpm check` and `pnpm test`
|
|
@@ -359,19 +430,30 @@ boundary note in [docs/CONTRACTS.md](docs/CONTRACTS.md).
|
|
|
359
430
|
|
|
360
431
|
---
|
|
361
432
|
|
|
362
|
-
## ⚠️ Upgrading — behaviour notes (0.3.12 → 0.3.
|
|
433
|
+
## ⚠️ Upgrading — behaviour notes (0.3.12 → 0.3.28)
|
|
434
|
+
|
|
435
|
+
### 0.3.24 → 0.3.28 in one paragraph
|
|
436
|
+
|
|
437
|
+
Four rules were added (`R4`/`R5` read tolerance and aggregation isolation,
|
|
438
|
+
`E11` seq provenance on the write side, `Z6` tail completeness) and three
|
|
439
|
+
machine-readable fields appeared in `--json` (`summary.tailStatus`,
|
|
440
|
+
`summary.tailStatusReason`, `summary.unreadableRows`). Behaviour changes are narrow: `check` now emits a
|
|
441
|
+
`Z6` **warning** when the tail is not `complete` (verdicts and exit codes are
|
|
442
|
+
unchanged — a torn tail is recoverable under the host reader semantics), and
|
|
443
|
+
`prewrite` rejects a candidate that carries a self-invented `seq` (`E11`, error).
|
|
444
|
+
Rule count: 51 → 55.
|
|
363
445
|
|
|
364
446
|
### 0.3.18 → 0.3.24 in one paragraph
|
|
365
447
|
|
|
366
448
|
Session format **v4** (host `dsh-session` 0.2.x) is supported by version dispatch (`tool/result` role,
|
|
367
449
|
`system/message` source); five rules were added (`G4` unknown-but-ignorable events, `S10` reference element
|
|
368
450
|
types, `I2` `seedLength` semantics, `P5` carrier pairing, `A1` structured-only in-place restorability);
|
|
369
|
-
large sessions (>
|
|
451
|
+
large sessions (> [size]) are read line-wise and repaired with streaming frames; the Windows absolute-path
|
|
370
452
|
check for `H2` is platform-aware. still **partial** — see the changelog's known-gap list). Verdicts, exit codes and `--json` fields are unchanged.
|
|
371
453
|
|
|
372
454
|
> **0.3.17 changes no behaviour.** It only adjusts the wording of comments, test titles, a few
|
|
373
455
|
> diagnostic strings and the README. Every verdict, exit code and `--json`
|
|
374
|
-
> field is unchanged from 0.3.
|
|
456
|
+
> field is unchanged from 0.3.[n] so everything below applies unchanged when going from 0.3.12 to 0.3.17.
|
|
375
457
|
>
|
|
376
458
|
> 0.3.15 was a documentation-only release as well.
|
|
377
459
|
|
|
@@ -408,7 +490,7 @@ Read `coverage.uncovered` for the known gaps.
|
|
|
408
490
|
- [x] **Phase 1.5 (0.2.0)**: `fix` subcommand (strict seq scan + W1/W2 wire checks +
|
|
409
491
|
marker removal with renumbering + official frame rebuild); CI integration
|
|
410
492
|
(`dsh-log-contract check` as a scheduled guard over the Harness session dir)
|
|
411
|
-
- [x] **0.3.x (
|
|
493
|
+
- [x] **0.3.x ([n]-08-30 case hardening)**: T1 token-meter pairing → 0.3.1 W1/W2
|
|
412
494
|
fold-position fix → 0.3.2 `tailSeq` → 0.3.3 `fix --neutralize` (in-place
|
|
413
495
|
turn-null neutralization) → 0.3.4 `fix --clip-crossstep` (cross-step clipping) →
|
|
414
496
|
0.3.5 **T2/S9/I1 rules** (cross-step source refs / physical order / inbox replay)
|