dsh-log-contract 0.3.21 → 0.3.22
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 +32 -0
- package/README.zh.md +22 -0
- package/adapters/dsh/archive.js +135 -0
- package/adapters/dsh/event-shapes.js +639 -0
- package/adapters/dsh/format-versions.js +743 -0
- package/adapters/dsh/frames.js +331 -0
- package/adapters/dsh/host-probes.js +212 -0
- package/adapters/dsh/index.js +35 -0
- package/adapters/dsh/rules.js +560 -0
- package/adapters/dsh/surface.js +792 -0
- package/adapters/dsh/vocab.js +66 -0
- package/bin/dsh-log-contract.mjs +4 -4
- package/contract/index.js +17 -0
- package/contract/invariants.js +478 -0
- package/contract/registry.js +77 -0
- package/contract/rules.js +70 -0
- package/contract/verdict.js +52 -0
- package/docs/ARCHITECTURE.md +46 -0
- package/docs/CONTRACTS.md +34 -34
- package/lib/archive.js +14 -304
- package/lib/checks.js +64 -1332
- package/lib/compat.js +7 -278
- package/lib/contracts.js +8 -522
- package/lib/host-probes.js +4 -178
- package/lib/legacy-fold.js +4 -174
- package/lib/log-reader.js +3 -295
- package/lib/prewrite.js +4 -4
- package/lib/repair.js +11 -11
- package/lib/validate.js +49 -320
- package/lib/version-support.js +4 -146
- package/lib/vocab.js +4 -227
- package/package.json +15 -5
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-log-contract · adapters/dsh/event-shapes.js
|
|
3
|
+
*
|
|
4
|
+
* DSH 专属:事件形状判定(信封 / 消息 / 存储行 / 工具配对 / 可忽略标记 / 来源引用)。
|
|
5
|
+
*
|
|
6
|
+
* 平台无关的不变量在 contract/invariants.js;本文件负责把 DSH 记录**规范化**成
|
|
7
|
+
* 契约层认识的记录视图,再交给不变量判定(序号存在性、负载无损、物理序单调等)。
|
|
8
|
+
*/
|
|
9
|
+
import { violation } from '../../contract/verdict.js';
|
|
10
|
+
import {
|
|
11
|
+
isSafeInt,
|
|
12
|
+
isPlainRecord,
|
|
13
|
+
ordinalViolations,
|
|
14
|
+
payloadLosslessViolations,
|
|
15
|
+
physicalOrderViolations as physicalOrderInvariant,
|
|
16
|
+
} from '../../contract/invariants.js';
|
|
17
|
+
import { ENVELOPE_ALLOWED_KEYS, CHUNK_ROW_TYPES } from './vocab.js';
|
|
18
|
+
import { currentVocabulary } from './format-versions.js';
|
|
19
|
+
|
|
20
|
+
/** 事件信封 shape:seq/type/time/data(E1/E3/E4/E5/E6)。version = 被检文件版本。 */
|
|
21
|
+
export function envelopeViolations(event, loc, version) {
|
|
22
|
+
const out = [];
|
|
23
|
+
out.push(...ordinalViolations([{ seq: event.seq, lineNo: loc.lineNo, eventType: loc.eventType }]));
|
|
24
|
+
if (typeof event.type !== 'string') {
|
|
25
|
+
out.push(violation('E3', loc, `事件缺少 type 字符串(${String(event.type)})`));
|
|
26
|
+
} else if (!currentVocabulary(version).has(event.type) && event.ignorable !== true) {
|
|
27
|
+
out.push(violation('E3', loc, `type "${event.type}" 不在已知词汇表内且未带 ignorable 标记(可能由更新版本的 harness 写入)`));
|
|
28
|
+
}
|
|
29
|
+
out.push(...payloadLosslessViolations(event, loc, {
|
|
30
|
+
required: ['data'],
|
|
31
|
+
optional: ['surfaceOp', 'sourceEventSeqs'],
|
|
32
|
+
}));
|
|
33
|
+
if (event.type === 'request/header-delta') {
|
|
34
|
+
out.push(violation('E5', loc, '使用已删除的遗留格式 request/header-delta——写入会成功(宿主 append 不看 type)、下一次读取才炸;请改用当前格式'));
|
|
35
|
+
}
|
|
36
|
+
if (event.type === 'request/header' && event.data?.reason === 'fallback') {
|
|
37
|
+
out.push(violation('E5', loc, 'request/header 使用已删除的遗留 reason "fallback"'));
|
|
38
|
+
}
|
|
39
|
+
// ── 确证漏检形状补成候选规则 ───────────────────────────────────────
|
|
40
|
+
// E8 信封键白名单:宿主 `assertSessionEventEnvelope`(@deepseek-ai/dsh-session@0.1.5-rc.1
|
|
41
|
+
// lib/index.js:852-861)逐键 switch,只认 7 个键,其余一律 `invalid event envelope`。
|
|
42
|
+
// 反例形状:宿主拒、旧契约漏检。
|
|
43
|
+
if (typeof event === 'object' && event !== null) {
|
|
44
|
+
const extra = Object.keys(event).filter((k) => !ENVELOPE_ALLOWED_KEYS.has(k));
|
|
45
|
+
if (extra.length > 0) {
|
|
46
|
+
out.push(violation('E8', loc, `事件信封含多余键 ${extra.join(', ')}——宿主只认 {${[...ENVELOPE_ALLOWED_KEYS].join(',')}}(dsh-session@0.1.5-rc.1 lib/index.js:852-861)`));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// E10 request/header 的 data 字段约束:宿主 `validateSessionEventData`
|
|
50
|
+
// (dsh-session@0.1.5-rc.1 lib/index.js:231-248)——`header.system` 必须省略、
|
|
51
|
+
// 空 tools / 空 adapterDefaults 必须省略。反例:宿主拒、旧契约漏检。
|
|
52
|
+
if (event.type === 'request/header') {
|
|
53
|
+
const header = event.data?.header;
|
|
54
|
+
if (typeof header !== 'object' || header === null || Array.isArray(header)) {
|
|
55
|
+
out.push(violation('E10', loc, 'request/header 的 data.header 必须是对象'));
|
|
56
|
+
} else {
|
|
57
|
+
if (Object.hasOwn(header, 'system')) out.push(violation('E10', loc, 'request/header 必须省略 header.system(系统提示改走 system/message)——宿主 lib/index.js:237'));
|
|
58
|
+
if (Array.isArray(header.tools) && header.tools.length === 0) out.push(violation('E10', loc, 'request/header 必须省略空 tools——宿主 lib/index.js:238'));
|
|
59
|
+
const defaults = header.adapterDefaults;
|
|
60
|
+
if (typeof defaults === 'object' && defaults !== null && !Array.isArray(defaults) && Object.keys(defaults).length === 0) {
|
|
61
|
+
out.push(violation('E10', loc, 'request/header 必须省略空 adapterDefaults——宿主 lib/index.js:239-240'));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
out.push(...messageShapeViolations(event, loc, version));
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
/** v4 消息类事件 → 期望 role(dsh-session@0.2.0-rc.2 `MESSAGE_ROLE_BY_TYPE`,`src/index.ts:323-329`)。 */
|
|
71
|
+
const V4_MESSAGE_ROLE_BY_TYPE = {
|
|
72
|
+
'system/message': 'system',
|
|
73
|
+
'developer/message': 'developer',
|
|
74
|
+
'user/message': 'user',
|
|
75
|
+
'assistant/message': 'assistant',
|
|
76
|
+
'tool/result': 'tool',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 镜像官方 assertMessageEventShape(lib/index.js:1242-1266)。**按被检文件版本**择路:
|
|
81
|
+
* v0–v3 → 旧形状(下方原逻辑);v4 → `v4MessageShapeViolations`。
|
|
82
|
+
*/
|
|
83
|
+
export function messageShapeViolations(event, loc, version) {
|
|
84
|
+
if (version >= 4) return v4MessageShapeViolations(event, loc);
|
|
85
|
+
const type = event.type;
|
|
86
|
+
// 把 v3 新增的 `system/message` 纳入形状检查(MESSAGE_ROLE_BY_TYPE:system/message → system,
|
|
87
|
+
// dsh-session@0.1.5-rc.1 lib/index.js:917-926;source 要求 :942-944)。旧实现只查 user/assistant/tool
|
|
88
|
+
// ⇒ 反例(system/message 的 source.kind='user')宿主拒、旧契约漏检。
|
|
89
|
+
if (type !== 'user/message' && type !== 'assistant/message' && type !== 'tool/result' && type !== 'system/message') return [];
|
|
90
|
+
const out = [];
|
|
91
|
+
const data = event.data;
|
|
92
|
+
const record = typeof data === 'object' && data !== null ? data : undefined;
|
|
93
|
+
const message = type === 'user/message' ? record : record?.message;
|
|
94
|
+
const shape = () => `(seq ${event.seq})消息形状`;
|
|
95
|
+
if (typeof message !== 'object' || message === null) {
|
|
96
|
+
out.push(violation('E6', loc, `${shape()}:缺少 message 对象`));
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
if (typeof message.id !== 'string' || message.id === '') {
|
|
100
|
+
out.push(violation('E6', loc, `${shape()}:id 必须为非空字符串`));
|
|
101
|
+
}
|
|
102
|
+
const expectedRole = type === 'assistant/message' ? 'assistant' : (type === 'system/message' ? 'system' : 'user');
|
|
103
|
+
if (message.role !== expectedRole) {
|
|
104
|
+
out.push(violation('E6', loc, `${shape()}:role 必须为 "${expectedRole}",实际 ${String(message.role)}`));
|
|
105
|
+
}
|
|
106
|
+
const source = message.source;
|
|
107
|
+
if (typeof source !== 'object' || source === null || typeof source.kind !== 'string' || source.kind === '') {
|
|
108
|
+
out.push(violation('E6', loc, `${shape()}:source.kind 缺失或非法`));
|
|
109
|
+
}
|
|
110
|
+
if (!Array.isArray(message.content)) {
|
|
111
|
+
out.push(violation('E6', loc, `${shape()}:content 必须为数组`));
|
|
112
|
+
}
|
|
113
|
+
if (type === 'assistant/message') {
|
|
114
|
+
if (source?.kind !== 'model' || typeof source.provider !== 'string' || source.provider === '' || typeof source.model !== 'string' || source.model === '') {
|
|
115
|
+
out.push(violation('E6', loc, `${shape()}:assistant/message 必须带 model source(provider/model 非空)`));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (type === 'system/message') {
|
|
119
|
+
// E9(候选规则):system/message 必须 plugin source(kind==='plugin' + plugin 非空)。
|
|
120
|
+
// 宿主依据:dsh-session@0.1.5-rc.1 lib/index.js:942-944("must have plugin source")。
|
|
121
|
+
if (source?.kind !== 'plugin' || typeof source.plugin !== 'string' || source.plugin === '') {
|
|
122
|
+
out.push(violation('E9', loc, `${shape()}:system/message 必须带 plugin source(kind==='plugin' 且 plugin 非空)——宿主 lib/index.js:942-944`));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (type === 'tool/result') {
|
|
126
|
+
if (source?.kind !== 'tool' || typeof source.callId !== 'string' || source.callId === '') {
|
|
127
|
+
out.push(violation('E6', loc, `${shape()}:tool/result 必须带 tool source(callId 非空)`));
|
|
128
|
+
}
|
|
129
|
+
const content = message.content;
|
|
130
|
+
const block = Array.isArray(content) ? content[0] : undefined;
|
|
131
|
+
if (content?.length !== 1 || typeof block !== 'object' || block === null || block.type !== 'tool-result' || !Array.isArray(block.content)) {
|
|
132
|
+
out.push(violation('E6', loc, `${shape()}:必须恰含一个 tool-result block`));
|
|
133
|
+
} else if (block.toolCallId !== source?.callId) {
|
|
134
|
+
out.push(violation('E6', loc, `${shape()}:block.toolCallId 与 source.callId 不匹配`));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* v4 消息形状。两层一手依据:
|
|
142
|
+
* - 运行时 load 路径:dsh-session@0.2.0-rc.2 `assertMessageEventShape`(`src/index.ts:331-381`)——
|
|
143
|
+
* role 表、system-prompt source、model source、tool source + `toolCallId` 匹配;
|
|
144
|
+
* - 文件读取路径:`dsh-session-format-v3-to-v4` 原生 v4 准入(`src/tool-role.ts:89-109`、
|
|
145
|
+
* `src/message-sources.ts:9`)——残留 `tool-result` 包装块、非布尔 `isError`、`data.error` 而
|
|
146
|
+
* `isError !== true`、`source.kind === 'plugin'` 一律 SessionFormatError ⇒ 会话从盘上读不回来。
|
|
147
|
+
* `adoptSessionEvent` 不查这几条,所以只看运行时会漏掉"写得进、读不回"的形状。
|
|
148
|
+
*
|
|
149
|
+
* 与 v3 的差异(v3→v4 迁移 `tool-role.ts` / `sources.ts` 的逐项改写):
|
|
150
|
+
* - 新增 `developer/message`(role `developer`);
|
|
151
|
+
* - `tool/result`:role `tool`;去掉 `tool-result` 包装块,content 直接是结果数组;
|
|
152
|
+
* `message.toolCallId` 必须等于 `source.callId`;`isError` 若存在必须为布尔;
|
|
153
|
+
* - `system/message`:source.kind 必须为 `system-prompt`(v3 是 plugin 包装);
|
|
154
|
+
* - 任何消息的 source.kind 都不得为 `plugin`(v4 把插件包装改写成生产者自有 kind)。
|
|
155
|
+
*/
|
|
156
|
+
function v4MessageShapeViolations(event, loc) {
|
|
157
|
+
const type = event.type;
|
|
158
|
+
const expectedRole = V4_MESSAGE_ROLE_BY_TYPE[type];
|
|
159
|
+
if (expectedRole === undefined) return [];
|
|
160
|
+
const out = [];
|
|
161
|
+
const data = event.data;
|
|
162
|
+
const record = typeof data === 'object' && data !== null ? data : undefined;
|
|
163
|
+
const message = type === 'user/message' ? record : record?.message;
|
|
164
|
+
const shape = () => `(seq ${event.seq})消息形状`;
|
|
165
|
+
if (typeof message !== 'object' || message === null) {
|
|
166
|
+
out.push(violation('E6', loc, `${shape()}:缺少 message 对象`));
|
|
167
|
+
return out;
|
|
168
|
+
}
|
|
169
|
+
if (typeof message.id !== 'string' || message.id === '') {
|
|
170
|
+
out.push(violation('E6', loc, `${shape()}:id 必须为非空字符串`));
|
|
171
|
+
}
|
|
172
|
+
if (message.role !== expectedRole) {
|
|
173
|
+
out.push(violation('E6', loc, `${shape()}:role 必须为 "${expectedRole}",实际 ${String(message.role)}`));
|
|
174
|
+
}
|
|
175
|
+
const source = message.source;
|
|
176
|
+
if (typeof source !== 'object' || source === null || typeof source.kind !== 'string' || source.kind === '') {
|
|
177
|
+
out.push(violation('E6', loc, `${shape()}:source.kind 缺失或非法`));
|
|
178
|
+
} else if (source.kind === 'plugin') {
|
|
179
|
+
out.push(violation('E6', loc, `${shape()}:v4 不再接受 plugin source(kind==='plugin')——v3→v4 迁移把它改写为生产者自有 kind`));
|
|
180
|
+
}
|
|
181
|
+
if (!Array.isArray(message.content)) {
|
|
182
|
+
out.push(violation('E6', loc, `${shape()}:content 必须为数组`));
|
|
183
|
+
}
|
|
184
|
+
if (type === 'assistant/message') {
|
|
185
|
+
if (source?.kind !== 'model' || typeof source.provider !== 'string' || source.provider === '' || typeof source.model !== 'string' || source.model === '') {
|
|
186
|
+
out.push(violation('E6', loc, `${shape()}:assistant/message 必须带 model source(provider/model 非空)`));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (type === 'system/message' && source?.kind !== 'system-prompt') {
|
|
190
|
+
out.push(violation('E9', loc, `${shape()}:system/message 必须带 system-prompt source(kind==='system-prompt')——dsh-session@0.2.0-rc.2 src/index.ts:360-364`));
|
|
191
|
+
}
|
|
192
|
+
if (type === 'tool/result') {
|
|
193
|
+
if (source?.kind !== 'tool' || typeof source.callId !== 'string' || source.callId === '') {
|
|
194
|
+
out.push(violation('E6', loc, `${shape()}:tool/result 必须带 tool source(callId 非空)`));
|
|
195
|
+
} else if (message.toolCallId !== source.callId) {
|
|
196
|
+
out.push(violation('E6', loc, `${shape()}:message.toolCallId 与 source.callId 不匹配`));
|
|
197
|
+
}
|
|
198
|
+
if (Array.isArray(message.content) && message.content.some((b) => typeof b === 'object' && b !== null && b.type === 'tool-result')) {
|
|
199
|
+
out.push(violation('E6', loc, `${shape()}:v4 tool/result 不得再含 tool-result 包装块(content 直接是结果数组)`));
|
|
200
|
+
}
|
|
201
|
+
if (message.isError !== undefined && typeof message.isError !== 'boolean') {
|
|
202
|
+
out.push(violation('E6', loc, `${shape()}:isError 若存在必须为布尔`));
|
|
203
|
+
}
|
|
204
|
+
if (record?.error !== undefined && message.isError !== true) {
|
|
205
|
+
out.push(violation('E6', loc, `${shape()}:带 data.error 时 message.isError 必须为 true`));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return out;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* P3 —— tool/call ↔ tool/result 配对完整性(考古 B1)。
|
|
214
|
+
* 每个 tool/call 的 `data.callId` 必须能在 tool/result 的
|
|
215
|
+
* `data.message.source.callId` 中找到配对;孤儿 call(无 result)告警——
|
|
216
|
+
* 中断/失败轮次可能产生孤儿(合法但要审计)。warning 级:不破坏日志。
|
|
217
|
+
*/
|
|
218
|
+
export function toolPairingViolations(events) {
|
|
219
|
+
const out = [];
|
|
220
|
+
const calls = new Map(); // callId → { command, loc }
|
|
221
|
+
const results = new Map(); // callId → loc(双向:孤儿 result 也要指认)
|
|
222
|
+
for (const { event, lineNo } of events) {
|
|
223
|
+
if (event.type === 'tool/call') {
|
|
224
|
+
const callId = event.data?.callId;
|
|
225
|
+
if (typeof callId === 'string' && callId !== '') {
|
|
226
|
+
let command = '';
|
|
227
|
+
try {
|
|
228
|
+
const args = typeof event.data?.arguments === 'string' ? JSON.parse(event.data.arguments) : event.data?.arguments;
|
|
229
|
+
command = typeof args?.command === 'string' ? args.command.slice(0, 120) : '';
|
|
230
|
+
} catch { /* 参数解析失败不阻断配对检查 */ }
|
|
231
|
+
calls.set(callId, { command, loc: { seq: event.seq, lineNo, eventType: event.type } });
|
|
232
|
+
}
|
|
233
|
+
} else if (event.type === 'tool/result') {
|
|
234
|
+
const callId = event.data?.message?.source?.callId;
|
|
235
|
+
if (typeof callId === 'string' && callId !== '') results.set(callId, { seq: event.seq, lineNo, eventType: event.type });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
for (const [callId, { command, loc }] of calls) {
|
|
239
|
+
if (!results.has(callId)) {
|
|
240
|
+
out.push(violation('P3', loc, `tool/call ${callId}(命令 ${command || '(未知)'})没有配对的 tool/result——孤儿调用(中断/失败未落结果),考古提取将缺该输出`));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// 双向:孤儿 result = result 无对应 tool/call。
|
|
244
|
+
// 折叠后 wire 流中无主 tool 消息 = provider 拒绝风险(W1/W2 同族、不同层);
|
|
245
|
+
// 与孤儿 call 同为 warning 级——合法场景(中断/修复产物)不破坏日志。
|
|
246
|
+
for (const [callId, loc] of results) {
|
|
247
|
+
if (!calls.has(callId)) {
|
|
248
|
+
out.push(violation('P3', loc, `tool/result ${callId} 没有配对的 tool/call——孤儿结果(无主 tool 消息,wire 流 provider 拒绝风险;中断/修复产物合法但要审计),考古配对将无法归属`));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 递归检查 content 的可提取性:任意标量(string/number/boolean/null)都是合法
|
|
257
|
+
* 元数据(如 isError、toolCallId)——只有 "text 字段存在但值非 string" 才是
|
|
258
|
+
* 考古提取会漏数据的结构异常(extractText 依赖 text 为 string)。
|
|
259
|
+
*/
|
|
260
|
+
function findUnparsableContent(node, path) {
|
|
261
|
+
if (typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean' || node === null) return null;
|
|
262
|
+
if (Array.isArray(node)) {
|
|
263
|
+
for (let i = 0; i < node.length; i++) {
|
|
264
|
+
const r = findUnparsableContent(node[i], `${path}[${i}]`);
|
|
265
|
+
if (r !== null) return r;
|
|
266
|
+
}
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
if (typeof node === 'object') {
|
|
270
|
+
if (Object.prototype.hasOwnProperty.call(node, 'text') && typeof node.text !== 'string') {
|
|
271
|
+
return `${path}.text(${String(node.text)},非 string)`;
|
|
272
|
+
}
|
|
273
|
+
for (const key of Object.keys(node)) {
|
|
274
|
+
if (key === 'text') continue;
|
|
275
|
+
const r = findUnparsableContent(node[key], `${path}.${key}`);
|
|
276
|
+
if (r !== null) return r;
|
|
277
|
+
}
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
return `${path}(${String(node)})`;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* P4 —— tool/result 输出结构契约(考古 B2)。
|
|
285
|
+
* `data.message.content` 必须可递归解析(list[dict{type:text,text}] 或等价);
|
|
286
|
+
* 不可解析片段 = 考古提取将漏数据。空 content(失败/无输出)合法。warning 级。
|
|
287
|
+
*/
|
|
288
|
+
export function toolResultStructureViolations(events) {
|
|
289
|
+
const out = [];
|
|
290
|
+
for (const { event, lineNo } of events) {
|
|
291
|
+
if (event.type !== 'tool/result') continue;
|
|
292
|
+
const content = event.data?.message?.content;
|
|
293
|
+
if (!Array.isArray(content) || content.length === 0) continue;
|
|
294
|
+
const callId = event.data?.message?.source?.callId;
|
|
295
|
+
const loc = { seq: event.seq, lineNo, eventType: event.type };
|
|
296
|
+
const bad = findUnparsableContent(content, 'content');
|
|
297
|
+
if (bad !== null) {
|
|
298
|
+
out.push(violation('P4', loc, `tool/result ${callId ?? '?'} 的 content 含不可解析片段(${bad})——考古提取将漏数据`));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return out;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* E7 —— ignorable 未知 type 合法性。
|
|
307
|
+
*
|
|
308
|
+
* 盲区:E3 对"未知 type + ignorable:true"直接放行(容忍更新版本 harness 写入),
|
|
309
|
+
* 但 ignorable 标记无合法性校验 = 后门——被读路径接纳却无人消费的未知事件 =
|
|
310
|
+
* 静默垃圾(违 R3 精神)。补:未知 type + ignorable + **不在已知消费者白名单** →
|
|
311
|
+
* warning"有被忽略的未知事件"。
|
|
312
|
+
*
|
|
313
|
+
* 已知消费者(不算垃圾,排除):retrace 家族 marker(retrace/marker、retrace/goal-marker,
|
|
314
|
+
* neutralize/插件产物,retrace 客户端识别消费)与旧前缀 message-editor。
|
|
315
|
+
* 判定:type ∉ KNOWN && ignorable && 非已知插件前缀 → warning。
|
|
316
|
+
*/
|
|
317
|
+
const KNOWN_IGNORABLE_CONSUMERS = new Set(['retrace/marker', 'retrace/goal-marker'])
|
|
318
|
+
function isKnownIgnorableType(type) {
|
|
319
|
+
if (typeof type !== 'string') return false
|
|
320
|
+
if (KNOWN_IGNORABLE_CONSUMERS.has(type)) return true
|
|
321
|
+
return type.startsWith('message-editor/') || type.startsWith('retrace/')
|
|
322
|
+
}
|
|
323
|
+
export function ignorableTypeViolations(events, version) {
|
|
324
|
+
const out = []
|
|
325
|
+
for (const { event, lineNo } of events) {
|
|
326
|
+
if (typeof event?.type !== 'string' || event.ignorable !== true) continue
|
|
327
|
+
if (currentVocabulary(version).has(event.type)) continue
|
|
328
|
+
if (isKnownIgnorableType(event.type)) continue
|
|
329
|
+
out.push(violation('E7', { seq: event.seq, lineNo, eventType: event.type }, `type "${event.type}" 不在已知词汇表且带 ignorable 标记、无已知消费者——被读路径接纳但无人消费 = 静默垃圾(ignorable 后门;若你的插件消费它,登记到 KNOWN_IGNORABLE_CONSUMERS)`))
|
|
330
|
+
}
|
|
331
|
+
return out
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* S10 —— `sourceEventSeqs` 元素类型硬断言。
|
|
337
|
+
*
|
|
338
|
+
* 嵌套 `[a,b]` 会被投影层/`restore` **静默放过** ⇒ 契约层必须判红。但 `[a,b]` 本身是
|
|
339
|
+
* v3+ 的**官方存储形态**(`encodeSeqRanges` 把连续 ≥3 的 run 压成闭区间对,可被官方
|
|
340
|
+
* `decodeSeqRanges` 展开)⇒ 不能把合法的区间对当违规。判红点收严为两层:
|
|
341
|
+
* ① **存储形态**(`rawSourceEventSeqViolations`,看 `log.rows[].value`):元素只能是
|
|
342
|
+
* 非负安全整数或 `[start,end]`(start ≤ end),且必须能被官方 `decodeSeqRanges`
|
|
343
|
+
* 解出且严格递增;否则 S10 error(解码层失败 = 投影/restore 会把它当 seq)。
|
|
344
|
+
* ② **解码形态**(`sourceEventSeqElementViolations`,看已归一事件):解码后仍出现
|
|
345
|
+
* 数组/非整数 = S10 error。
|
|
346
|
+
* 覆盖面比 S6 宽:**所有事件**(含非 surface 类型与 `ignorable` 未知插件事件)都判——
|
|
347
|
+
* 旧实现里非 surface 事件的 `sourceEventSeqs` 只在 S2 里被顺带提一句,`ignorable` 未知
|
|
348
|
+
* 事件连 S2 都豁免 ⇒ 这类事件上的坏 provenance 是真空区。
|
|
349
|
+
*
|
|
350
|
+
* @param {Array<{event:object,lineNo?:number}>} events 已归一(区间已展开)的事件
|
|
351
|
+
* @returns S10 违规列表
|
|
352
|
+
*/
|
|
353
|
+
export function sourceEventSeqElementViolations(events) {
|
|
354
|
+
const out = [];
|
|
355
|
+
for (const { event, lineNo } of events ?? []) {
|
|
356
|
+
if (!event || typeof event !== 'object') continue;
|
|
357
|
+
const src = event.sourceEventSeqs;
|
|
358
|
+
if (src === undefined) continue;
|
|
359
|
+
const loc = { seq: event.seq, lineNo, eventType: event.type };
|
|
360
|
+
if (!Array.isArray(src)) {
|
|
361
|
+
out.push(violation('S10', loc, `sourceEventSeqs 必须是数组(实际 ${typeof src})——元素必须是非负整数`));
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
for (let i = 0; i < src.length; i++) {
|
|
365
|
+
const v = src[i];
|
|
366
|
+
if (isSafeInt(v)) continue;
|
|
367
|
+
if (Array.isArray(v)) {
|
|
368
|
+
out.push(violation('S10', loc, `sourceEventSeqs[${i}] 解码后仍是嵌套数组 ${JSON.stringify(v).slice(0, 80)}——元素必须是非负整数(投影/restore/重写路径会把它静默当成 seq)`));
|
|
369
|
+
} else {
|
|
370
|
+
out.push(violation('S10', loc, `sourceEventSeqs[${i}] 不是非负安全整数(${String(v)},${typeof v})——元素必须是非负整数`));
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return out;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** 单个元素是否为官方区间对 `[start,end]`(`decodeSeqRanges` 的存储形态,start ≤ end)。 */
|
|
378
|
+
export function isSeqRangePair(value) {
|
|
379
|
+
return Array.isArray(value) && value.length === 2 && isSafeInt(value[0]) && isSafeInt(value[1]) && value[0] <= value[1];
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* S10 · 存储形态层(见上)。只读 `loadSessionLog()` 的 `rows`(`value` = JSON.parse 原文)。
|
|
384
|
+
* @param {Array<{lineNo:number,value:object|null}>} rows
|
|
385
|
+
* @returns S10 违规列表
|
|
386
|
+
*/
|
|
387
|
+
export function rawSourceEventSeqViolations(rows) {
|
|
388
|
+
const out = [];
|
|
389
|
+
for (const row of rows ?? []) {
|
|
390
|
+
const value = row?.value;
|
|
391
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) continue;
|
|
392
|
+
const src = value.sourceEventSeqs;
|
|
393
|
+
if (src === undefined) continue;
|
|
394
|
+
const loc = { seq: Number.isSafeInteger(value.seq) ? value.seq : null, lineNo: row.lineNo, eventType: value.type };
|
|
395
|
+
if (!Array.isArray(src)) {
|
|
396
|
+
out.push(violation('S10', loc, `sourceEventSeqs 必须是数组(实际 ${typeof src})`));
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
let bad = null;
|
|
400
|
+
for (let i = 0; i < src.length; i++) {
|
|
401
|
+
const v = src[i];
|
|
402
|
+
if (isSafeInt(v) || isSeqRangePair(v)) continue;
|
|
403
|
+
bad = { i, v };
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
if (bad !== null) {
|
|
407
|
+
const shape = Array.isArray(bad.v) ? `嵌套数组 ${JSON.stringify(bad.v).slice(0, 80)}` : `${String(bad.v)}(${typeof bad.v})`;
|
|
408
|
+
out.push(violation('S10', loc, `sourceEventSeqs[${bad.i}] 存储形态非法:${shape}——只允许非负安全整数或官方区间对 [start,end](start ≤ end)`));
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
// 形态合法但官方解码器解不出(区间对逆序 / 越界 / 非严格递增)⇒ 同样是契约违规。
|
|
412
|
+
try {
|
|
413
|
+
decodeSeqRanges(src);
|
|
414
|
+
} catch (err) {
|
|
415
|
+
out.push(violation('S10', loc, `sourceEventSeqs 无法按官方区间编码解码:${err.message}——投影/restore 会把它静默当成 seq`));
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return out;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
/** Whether a value is a JSON-visible record (object, not null, not array)(rc.7 `isRecord`)。 */
|
|
423
|
+
function isRecord(value) {
|
|
424
|
+
return typeof value === 'object' && value !== null;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** Exact-key check: `value` has every key in `keys` and nothing else(rc.7 `hasExactKeys`)。 */
|
|
428
|
+
function hasExactKeys(value, keys) {
|
|
429
|
+
return Object.keys(value).length === keys.length && keys.every((k) => Object.hasOwn(value, k));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
//#region decodeStorageRecord —— rc.7 validateRow/expandRow 的移植
|
|
434
|
+
/** Throw the uniform malformed-row diagnostic(rc.7 `malformed`)。 */
|
|
435
|
+
function malformed(tag, why) {
|
|
436
|
+
throw new Error(`malformed ${tag} storage row: ${why}`);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/** Validate the shared run-data fields and the payload/dt arity; returns the member payload(rc.7 `validateRunData`)。 */
|
|
440
|
+
function validateRunData(tag, data, payloadKey) {
|
|
441
|
+
if (typeof data.turn !== 'number' || typeof data.step !== 'number' || typeof data.index !== 'number') malformed(tag, 'turn/step/index must be numbers');
|
|
442
|
+
const payload = data[payloadKey];
|
|
443
|
+
if (!Array.isArray(payload) || payload.length === 0 || payload.some((entry) => typeof entry !== 'string')) malformed(tag, `${payloadKey} must be a non-empty string array`);
|
|
444
|
+
const dt = data.dt;
|
|
445
|
+
if (!Array.isArray(dt) || dt.some((gap) => !Number.isSafeInteger(gap))) malformed(tag, 'dt must be an array of safe integers');
|
|
446
|
+
if (dt.length !== payload.length - 1) malformed(tag, `dt length ${dt.length} does not match ${payload.length} members`);
|
|
447
|
+
return payload;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** Validate a row-tagged parsed value's envelope and data, throwing on any malformation(rc.7 `validateRow`)。 */
|
|
451
|
+
function validateRow(value, tag) {
|
|
452
|
+
if (!hasExactKeys(value, ['type', 'seq0', 'time0', 'data'])) malformed(tag, 'envelope must be exactly {type, seq0, time0, data}');
|
|
453
|
+
if (!Number.isSafeInteger(value.seq0) || value.seq0 < 0) malformed(tag, 'seq0 must be a non-negative safe integer');
|
|
454
|
+
if (!Number.isSafeInteger(value.time0)) malformed(tag, 'time0 must be a safe integer');
|
|
455
|
+
const data = value.data;
|
|
456
|
+
if (!isRecord(data)) malformed(tag, 'data must be an object');
|
|
457
|
+
let payload;
|
|
458
|
+
if (tag === 'tool-call-chunks') {
|
|
459
|
+
const withName = hasExactKeys(data, ['turn', 'step', 'index', 'id', 'name', 'dt', 'args']);
|
|
460
|
+
if (!withName && !hasExactKeys(data, ['turn', 'step', 'index', 'id', 'dt', 'args'])) malformed(tag, 'data must be exactly {turn, step, index, id, name?, dt, args}');
|
|
461
|
+
if (typeof data.id !== 'string' || (withName && typeof data.name !== 'string')) malformed(tag, 'id (and name when present) must be strings');
|
|
462
|
+
payload = validateRunData(tag, data, 'args');
|
|
463
|
+
} else {
|
|
464
|
+
if (!hasExactKeys(data, ['turn', 'step', 'index', 'dt', 'texts'])) malformed(tag, 'data must be exactly {turn, step, index, dt, texts}');
|
|
465
|
+
payload = validateRunData(tag, data, 'texts');
|
|
466
|
+
}
|
|
467
|
+
if (!Number.isSafeInteger(value.seq0 + payload.length - 1)) malformed(tag, 'member seqs must stay safe integers');
|
|
468
|
+
let time = value.time0;
|
|
469
|
+
for (const gap of data.dt) {
|
|
470
|
+
time += gap;
|
|
471
|
+
if (!Number.isSafeInteger(time)) malformed(tag, 'member times must stay safe integers');
|
|
472
|
+
}
|
|
473
|
+
return value;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** Expand a validated row back into its exact original events, in order(rc.7 `expandRow`)。 */
|
|
477
|
+
function expandRow(row) {
|
|
478
|
+
const members = row.type === 'tool-call-chunks' ? row.data.args : row.data.texts;
|
|
479
|
+
const events = [];
|
|
480
|
+
let time = row.time0;
|
|
481
|
+
for (let k = 0; k < members.length; k++) {
|
|
482
|
+
if (k > 0) time += row.data.dt[k - 1];
|
|
483
|
+
let chunk;
|
|
484
|
+
switch (row.type) {
|
|
485
|
+
case 'text-chunks':
|
|
486
|
+
chunk = { type: 'text-delta', index: row.data.index, text: members[k] };
|
|
487
|
+
break;
|
|
488
|
+
case 'reasoning-chunks':
|
|
489
|
+
chunk = { type: 'reasoning-delta', index: row.data.index, text: members[k] };
|
|
490
|
+
break;
|
|
491
|
+
case 'tool-call-chunks':
|
|
492
|
+
chunk = {
|
|
493
|
+
type: 'tool-call-delta',
|
|
494
|
+
index: row.data.index,
|
|
495
|
+
id: row.data.id,
|
|
496
|
+
...Object.hasOwn(row.data, 'name') ? { name: row.data.name } : {},
|
|
497
|
+
argumentsDelta: members[k],
|
|
498
|
+
};
|
|
499
|
+
break;
|
|
500
|
+
/* v8 ignore next 4 -- validateRow only returns the three row tags */
|
|
501
|
+
default:
|
|
502
|
+
throw new Error(`chunk-rows received unsupported row ${String(row)}`);
|
|
503
|
+
}
|
|
504
|
+
events.push({ type: 'assistant/chunk', seq: row.seq0 + k, time, data: { turn: row.data.turn, step: row.data.step, chunk } });
|
|
505
|
+
}
|
|
506
|
+
return events;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* 存储行解码:chunk 行校验后展开为完整事件序列,其他行原样返回(rc.7 `decodeStorageRecord`)。
|
|
511
|
+
* 损坏的 chunk 行**抛错**(fail-loud)——调用方(log-reader)据此落 `row.error` → R2。
|
|
512
|
+
* @param {unknown} value 已 JSON.parse 的一行
|
|
513
|
+
* @returns {unknown[]} 事件数组
|
|
514
|
+
*/
|
|
515
|
+
export function decodeStorageRecord(value) {
|
|
516
|
+
if (!isRecord(value)) return [value];
|
|
517
|
+
const tag = value.type;
|
|
518
|
+
if (tag !== 'text-chunks' && tag !== 'reasoning-chunks' && tag !== 'tool-call-chunks') return [value];
|
|
519
|
+
return expandRow(validateRow(value, tag));
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
//#region decodeSeqRanges —— v3 storage-form 区间编码解码(0.1.5 `lib/types/seq-ranges.js` 逐条移植)
|
|
523
|
+
// 为什么本地化:`decodeSeqRanges` 只在 0.1.5+ 从包根导出;`0.1.0-rc.7` 上为 `undefined`
|
|
524
|
+
// (见 vocab.js 的双宿主声明)。本包 peer 允许两个版本 ⇒ 必须在两种宿主上都能解码。
|
|
525
|
+
//
|
|
526
|
+
// 语义(官方 `seq-ranges.js:34-73`):`sourceEventSeqs` 的 JSON 存储形态是"数字 + 闭区间对"
|
|
527
|
+
// 混合数组,例 `[3, [174,176], 180, …]` ⇒ 内存形态 `[3,174,175,176,180,…]`。
|
|
528
|
+
// v3 持久化层对连续段用区间对压缩(真实 v3 会话中 1 个 `user/message` replace
|
|
529
|
+
// 的 `sourceEventSeqs` 可由区间对展开为稠密序列)。**不解码 = 拿物理未展开的序列
|
|
530
|
+
// 喂 S5/S6 与官方 foldSurface ⇒ 真实健康会话被误判 S5/S6/S8 + `--resume` broken。**
|
|
531
|
+
|
|
532
|
+
/** 非负安全整数(rc.7/0.1.5 `assertSeq`)。 */
|
|
533
|
+
function assertSeq(value) {
|
|
534
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new TypeError('sourceEventSeqs must contain non-negative safe integers');
|
|
535
|
+
}
|
|
536
|
+
/** 带 Session 序号 brand 的断言(官方 `SessionSeq`;额外拒绝 `-0`)。 */
|
|
537
|
+
function sessionSeq(value) {
|
|
538
|
+
if (!Number.isSafeInteger(value) || value < 0 || Object.is(value, -0)) {
|
|
539
|
+
throw new TypeError(`SessionSeq must be a non-negative safe integer, got ${String(value)}`);
|
|
540
|
+
}
|
|
541
|
+
return value;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* 展开 JSON 存储形态的 `sourceEventSeqs`(官方 `decodeSeqRanges` 逐条移植)。
|
|
546
|
+
* 任一形态非法即抛 `TypeError`(fail-loud:调用方据此报 S6/E4,不静默当稠密序列)。
|
|
547
|
+
* @param {unknown} value 已 JSON.parse 的 `sourceEventSeqs`
|
|
548
|
+
* @param {number} [maxEntries] 该事件允许的最大成员数
|
|
549
|
+
* @returns {number[]} 内存稠密序列
|
|
550
|
+
*/
|
|
551
|
+
export function decodeSeqRanges(value, maxEntries = Number.MAX_SAFE_INTEGER) {
|
|
552
|
+
if (!Array.isArray(value)) throw new TypeError('sourceEventSeqs must be an array');
|
|
553
|
+
const decoded = [];
|
|
554
|
+
let hasRange = false;
|
|
555
|
+
for (const entry of value) {
|
|
556
|
+
if (typeof entry === 'number') {
|
|
557
|
+
assertSeq(entry);
|
|
558
|
+
if (decoded.length >= maxEntries) throw new TypeError('sourceEventSeqs exceeds its event sequence');
|
|
559
|
+
decoded.push(sessionSeq(entry));
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
if (!Array.isArray(entry) || entry.length !== 2) {
|
|
563
|
+
throw new TypeError('sourceEventSeqs range entries must be [start, end] pairs');
|
|
564
|
+
}
|
|
565
|
+
const start = entry[0];
|
|
566
|
+
const end = entry[1];
|
|
567
|
+
assertSeq(start);
|
|
568
|
+
assertSeq(end);
|
|
569
|
+
if (end < start) throw new TypeError('sourceEventSeqs ranges require start <= end');
|
|
570
|
+
if (end - start + 1 > maxEntries - decoded.length) {
|
|
571
|
+
throw new TypeError('sourceEventSeqs range exceeds its event sequence');
|
|
572
|
+
}
|
|
573
|
+
for (let seq = start; seq <= end; seq += 1) decoded.push(sessionSeq(seq));
|
|
574
|
+
hasRange = true;
|
|
575
|
+
}
|
|
576
|
+
if (hasRange && !decoded.every((v, i) => i === 0 || v > decoded[i - 1])) {
|
|
577
|
+
throw new TypeError('sourceEventSeqs ranges must be strictly increasing');
|
|
578
|
+
}
|
|
579
|
+
return decoded;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* 把一个已解码事件的 storage-form `sourceEventSeqs` 归一成内存稠密序列。
|
|
584
|
+
* - 无 `sourceEventSeqs` / 非对象 → 原样返回(同一引用);
|
|
585
|
+
* - 解码成功 → 返回**新对象**(不修改入参;调用方须使用返回值);
|
|
586
|
+
* - 解码失败 → 原样返回,保留存储形态交由 S6/E4 报违规(读取层不崩、不吞错)。
|
|
587
|
+
*/
|
|
588
|
+
export function normalizeEventSeqRanges(event) {
|
|
589
|
+
if (!isRecord(event) || event.sourceEventSeqs === undefined) return event;
|
|
590
|
+
let expanded;
|
|
591
|
+
try {
|
|
592
|
+
expanded = decodeSeqRanges(event.sourceEventSeqs);
|
|
593
|
+
} catch {
|
|
594
|
+
return event;
|
|
595
|
+
}
|
|
596
|
+
return { ...event, sourceEventSeqs: expanded };
|
|
597
|
+
}
|
|
598
|
+
//#endregion
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* R2 —— 存储行损坏(聚合行展开失败 = 整段 run 丢失且加载失败)。
|
|
603
|
+
* @param {Array<{lineNo:number, value:object|null, error:Error|null}>} rows
|
|
604
|
+
* @returns {Array<object>} R2 判定
|
|
605
|
+
*/
|
|
606
|
+
export function chunkRowMalformationViolations(rows) {
|
|
607
|
+
const out = [];
|
|
608
|
+
for (const row of rows ?? []) {
|
|
609
|
+
if (!row?.error || row.value === null) continue;
|
|
610
|
+
if (!CHUNK_ROW_TYPES.has(row.value?.type)) continue;
|
|
611
|
+
out.push(violation('R2', { lineNo: row.lineNo }, `chunk 行 "${row.value.type}" 损坏:${row.error.message} —— 整段 run 丢失且加载失败(fail-loud,无跳过逃生舱)`));
|
|
612
|
+
}
|
|
613
|
+
return out;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* 把物理存储行展开成**物理顺序**的规范化记录视图(供物理序不变量判定)。
|
|
618
|
+
* @param {Array<{lineNo:number, decoded: object[]|null}>} rows
|
|
619
|
+
* @returns {Array<{seq:unknown, lineNo:number, eventType:unknown}>}
|
|
620
|
+
*/
|
|
621
|
+
export function physicalSequence(rows) {
|
|
622
|
+
const entries = [];
|
|
623
|
+
for (const row of rows ?? []) {
|
|
624
|
+
if (!Array.isArray(row?.decoded) || row.decoded.length === 0) continue;
|
|
625
|
+
for (const event of row.decoded) {
|
|
626
|
+
entries.push({ seq: event.seq, lineNo: row.lineNo, eventType: event.type });
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return entries;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* S9 —— 文件物理序序号单调(适配器包装:物理行 → 规范化记录视图)。
|
|
634
|
+
* @param {Array<{lineNo:number, decoded: object[]|null}>} rows
|
|
635
|
+
* @returns {Array<object>} S9 判定
|
|
636
|
+
*/
|
|
637
|
+
export function physicalOrderViolations(rows) {
|
|
638
|
+
return physicalOrderInvariant(physicalSequence(rows));
|
|
639
|
+
}
|