teamsmith 0.4.6 → 0.4.7
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 +6 -6
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +24 -0
- package/skills/teamsmith/SKILL.md +32 -23
- package/skills/teamsmith/extension/team-bg.ts +5 -3
- package/skills/teamsmith/extension/team-inbox-watch.ts +14 -3
- package/skills/teamsmith/extension/team-notify.ts +20 -13
- package/skills/teamsmith/extension/team-remind.ts +189 -0
- package/skills/teamsmith/extension/team-reply.ts +4 -7
- package/skills/teamsmith/references/migration.md +101 -0
- package/skills/teamsmith/references/openspec.md +43 -27
- package/skills/teamsmith/references/protocol.md +26 -15
- package/skills/teamsmith/references/reminders.md +153 -161
- package/skills/teamsmith/references/troubleshooting.md +12 -7
- package/skills/teamsmith/references/workflows.md +84 -31
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +10 -4
- package/skills/teamsmith/scripts/lib/cmd-project.sh +88 -6
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +88 -2
- package/skills/teamsmith/scripts/lib/cmd-review.sh +42 -4
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +48 -11
- package/skills/teamsmith/scripts/lib/common.sh +83 -13
- package/skills/teamsmith/scripts/panel/panel.js +179 -179
- package/skills/teamsmith/scripts/panel/src/data.ts +71 -15
- package/skills/teamsmith/scripts/panel/src/layout.ts +20 -8
- package/skills/teamsmith/scripts/panel/src/main.tsx +83 -21
- package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
- package/skills/teamsmith/scripts/remind-store.mjs +55 -24
- package/skills/teamsmith/scripts/remind-tick.mjs +5 -2
- package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
- package/skills/teamsmith/scripts/state-authority.mjs +72 -6
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +11 -8
- package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
- package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +31 -19
- package/skills/teamsmith/templates/report.md.tmpl +33 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
- package/skills/teamsmith/tests/bg-ledger.sh +24 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
- package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
- package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
- package/skills/teamsmith/tests/help-surface.sh +3 -5
- package/skills/teamsmith/tests/isolation-ledger.sh +6 -2
- package/skills/teamsmith/tests/key-replies-ui.sh +53 -0
- package/skills/teamsmith/tests/key-replies.sh +307 -106
- package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +1 -0
- package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
- package/skills/teamsmith/tests/remind-adversarial-faults.mjs +163 -0
- package/skills/teamsmith/tests/remind-adversarial-faults.sh +26 -0
- package/skills/teamsmith/tests/remind-adversarial-real.sh +27 -0
- package/skills/teamsmith/tests/remind-cli.sh +108 -3
- package/skills/teamsmith/tests/remind-delivery-node.mjs +13 -0
- package/skills/teamsmith/tests/remind-delivery.sh +123 -35
- package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
- package/skills/teamsmith/tests/remind-pulse.sh +199 -0
- package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
- package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
- package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
- package/skills/teamsmith/tests/remind-tool-real.mjs +754 -0
- package/skills/teamsmith/tests/remind-tool-real.sh +5 -0
- package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
- package/skills/teamsmith/tests/routes.sh +213 -293
- package/skills/teamsmith/tests/section-paths.tsv +10 -8
- package/skills/teamsmith/tests/smoke.sh +484 -28
- package/skills/teamsmith/tests/state-authority.sh +152 -8
- package/skills/teamsmith-init/SKILL.md +5 -5
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
|
@@ -36,7 +36,7 @@ for arg in "$@"; do
|
|
|
36
36
|
case "$arg" in
|
|
37
37
|
--flip=*)
|
|
38
38
|
case "${arg#--flip=}" in
|
|
39
|
-
view-stored|no-prune|highwater-lax|past-time|key-conflict-gone) FLIPS+=("${arg#--flip=}") ;;
|
|
39
|
+
view-stored|no-prune|highwater-lax|past-time|key-conflict-gone|key-not-released|no-key-dedup|json-refusal) FLIPS+=("${arg#--flip=}") ;;
|
|
40
40
|
*) printf 'remind-cli:不认识的 --flip 值 [%s]\n' "${arg#--flip=}" >&2; exit 2 ;;
|
|
41
41
|
esac ;;
|
|
42
42
|
-h|--help) sed -n '2,26p' "$0"; exit 0 ;;
|
|
@@ -187,6 +187,11 @@ printf 'first line — 中文 100%%\nsecond line\n\n' > "$ROOT/msg/full.txt"
|
|
|
187
187
|
FULL_BYTES="$(wc -c < "$ROOT/msg/full.txt" | tr -d ' ')"
|
|
188
188
|
printf 'line one\nline two\n' > "$ROOT/msg/two.txt"
|
|
189
189
|
printf 'probe text\n' > "$ROOT/msg/x.txt"
|
|
190
|
+
python3 - "$ROOT/msg/large.txt" <<'PY'
|
|
191
|
+
import sys
|
|
192
|
+
with open(sys.argv[1], 'wb') as f:
|
|
193
|
+
f.write(b'x' * (64 * 1024) + b'\n')
|
|
194
|
+
PY
|
|
190
195
|
: > "$ROOT/msg/empty.txt"
|
|
191
196
|
: > "$ROOT/msg/none"
|
|
192
197
|
printf 'a\000b' > "$ROOT/msg/nul.bin"
|
|
@@ -252,6 +257,42 @@ assert_has "A list:取消后计数跟着变(cancelled=1,只剩 2099 那条
|
|
|
252
257
|
"视图 scheduled=1 derived-due=0 queued=0 intent=0 observed=0 unknown=0 cancelled=1 resolved=0"
|
|
253
258
|
assert_has "A list:取消的那条仍在保留的终结历史里" "$(cat "$ROOT/out/a7.txt")" "另有 1 条已终结"
|
|
254
259
|
|
|
260
|
+
# 无额度:100 条活跃记录 + 最近一分钟 20 次创建之后,1 秒延迟与 64 KiB 全文仍然合法。
|
|
261
|
+
Q="$(new_repo Q)" || { bad "夹具建不出仓库 Q"; result; exit 1; }
|
|
262
|
+
run_team "$Q" "$ROOT/msg/none" "$ROOT/out/q0.txt" remind add --after 2h --message seed
|
|
263
|
+
[ "$RC" = "0" ] || bad "Q 夹具:种子提醒没建成($(head -1 "$ROOT/out/q0.txt"))"
|
|
264
|
+
cat > "$ROOT/script/q-fill.mjs" <<'JS'
|
|
265
|
+
snap.reminders = Array.from({ length: 100 }, (_, index) => ({
|
|
266
|
+
id: 'rem-' + snap.project.id + '-' + (index + 1), seq: index + 1, owner: 'pm', source: 'cli', task: null, key: null,
|
|
267
|
+
phase: 'scheduled', createdAt: new Date().toISOString(), request: { form: 'after', value: '2h' },
|
|
268
|
+
dueAt: new Date(Date.now() + 7200000).toISOString(), message: 'active ' + (index + 1), endedAt: null,
|
|
269
|
+
}));
|
|
270
|
+
snap.sequences.reminder = 101;
|
|
271
|
+
snap.audit = Array.from({ length: 20 }, () => ({ at: new Date().toISOString(), op: 'remind-add', ids: ['recent'], source: 'cli' }));
|
|
272
|
+
JS
|
|
273
|
+
edit_snapshot "$Q" "$ROOT/script/q-fill.mjs"
|
|
274
|
+
run_team "$Q" "$ROOT/msg/large.txt" "$ROOT/out/q1.txt" remind add --after 1s --message-file "$ROOT/msg/large.txt"
|
|
275
|
+
assert_eq "Q 100 条活跃 + 20 次近期创建后,1s/64KiB 请求仍建成" "$RC" "0"
|
|
276
|
+
Q_ID="$(sed -n 's/^已创建 \(rem-[^ ]*\) · .*/\1/p' "$ROOT/out/q1.txt")"
|
|
277
|
+
assert_has "Q 新记录使用第 101 个单调 ID" "$Q_ID" '-101'
|
|
278
|
+
run_team "$Q" "$ROOT/msg/none" "$ROOT/out/q2.txt" remind show "$Q_ID" --json
|
|
279
|
+
if jdump "$ROOT/out/q2.txt" reminder.message "$ROOT/out/q-show-message.txt" \
|
|
280
|
+
&& cmp -s "$ROOT/msg/large.txt" "$ROOT/out/q-show-message.txt"; then
|
|
281
|
+
ok "Q show 保留 64 KiB + 末尾换行(65537 字节)"
|
|
282
|
+
else
|
|
283
|
+
bad "Q show 的正文被截断或改写字节"
|
|
284
|
+
fi
|
|
285
|
+
run_team "$Q" "$ROOT/msg/none" "$ROOT/out/q3.txt" remind list --json
|
|
286
|
+
"$RUNNER" -e '
|
|
287
|
+
import fs from "node:fs";
|
|
288
|
+
const result = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
|
|
289
|
+
const record = result.active.find(item => item.id === process.argv[2]);
|
|
290
|
+
if (!record) process.exit(3);
|
|
291
|
+
fs.writeFileSync(process.argv[3], record.message);
|
|
292
|
+
' "$ROOT/out/q3.txt" "$Q_ID" "$ROOT/out/q-list-message.txt"
|
|
293
|
+
cmp -s "$ROOT/msg/large.txt" "$ROOT/out/q-list-message.txt" \
|
|
294
|
+
&& ok "Q list 保留同一份全文与末尾换行" || bad "Q list 的正文与原文不同"
|
|
295
|
+
|
|
255
296
|
# ---------------------------------------------------------------- B. refusals (each names its reason, writes nothing)
|
|
256
297
|
B="$(new_repo B)" || { bad "夹具建不出仓库 B"; result; exit 1; }
|
|
257
298
|
run_team "$B" "$ROOT/msg/none" "$ROOT/out/b0.txt" remind add --after 2h --message seed
|
|
@@ -283,6 +324,15 @@ refuse "NUL 正文" "NUL byte" --after 2h --message-file "$ROOT/msg/nul.bin"
|
|
|
283
324
|
refuse "非 UTF-8 正文" "not valid UTF-8" --after 2h --message-file "$ROOT/msg/bad.bin"
|
|
284
325
|
refuse "key 用了非 ASCII" "outside printable ASCII" --after 2h --message-file "$ROOT/msg/x.txt" --key 有中文
|
|
285
326
|
|
|
327
|
+
# V150:机器调用方带 --json 时,stdin 解码/NUL 拒绝也必须是结构化结果,不能退回人读行。
|
|
328
|
+
for kind in nul bad; do
|
|
329
|
+
run_team "$B" "$ROOT/msg/none" "$ROOT/out/b-json-$kind.txt" remind add --after 2h --message-file "$ROOT/msg/$kind.bin" --json
|
|
330
|
+
assert_eq "B $kind 的 --json 拒绝:rc=1" "$RC" "1"
|
|
331
|
+
assert_eq "B $kind 的 --json 拒绝:refusal 字段" "$(jfield "$ROOT/out/b-json-$kind.txt" refusal)" "bad-message"
|
|
332
|
+
"$RUNNER" -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$ROOT/out/b-json-$kind.txt" \
|
|
333
|
+
&& ok "B $kind 的 --json 拒绝:stdout 是可解析 JSON" || bad "B $kind 的 --json 拒绝混入了人读行"
|
|
334
|
+
done
|
|
335
|
+
|
|
286
336
|
run_team "$B" "$ROOT/msg/none" "$ROOT/out/b-flag.txt" remind add --after 2h --message x --frobnicate
|
|
287
337
|
assert_eq "B 未知参数:rc(用法错误)" "$RC" "2"
|
|
288
338
|
assert_has "B 未知参数:点名该参数" "$(cat "$ROOT/out/b-flag.txt")" "--frobnicate"
|
|
@@ -320,6 +370,30 @@ else
|
|
|
320
370
|
bad "C 终结后复用 key:没有新建(拿到 [$C_NEW])"
|
|
321
371
|
fi
|
|
322
372
|
|
|
373
|
+
run_team "$C" "$ROOT/msg/none" "$ROOT/out/c6.txt" remind add --after 2h --message "identical without key"
|
|
374
|
+
C_NK1="$(sed -n 's/^已创建 \(rem-[^ ]*\) · .*/\1/p' "$ROOT/out/c6.txt")"
|
|
375
|
+
run_team "$C" "$ROOT/msg/none" "$ROOT/out/c7.txt" remind add --after 2h --message "identical without key"
|
|
376
|
+
C_NK2="$(sed -n 's/^已创建 \(rem-[^ ]*\) · .*/\1/p' "$ROOT/out/c7.txt")"
|
|
377
|
+
if [ -n "$C_NK1" ] && [ -n "$C_NK2" ] && [ "$C_NK1" != "$C_NK2" ]; then
|
|
378
|
+
ok "C 无 key 的相同正文与时长是两个独立 ID($C_NK1 / $C_NK2)"
|
|
379
|
+
else
|
|
380
|
+
bad "C 无 key 相同请求被错误去重([$C_NK1] / [$C_NK2])"
|
|
381
|
+
fi
|
|
382
|
+
|
|
383
|
+
# observed 也释放 key:下一次同 key 请求是新的单调一次性提醒,而不是全局幂等。
|
|
384
|
+
R="$(new_repo R)" || { bad "夹具建不出仓库 R"; result; exit 1; }
|
|
385
|
+
run_team "$R" "$ROOT/msg/none" "$ROOT/out/r1.txt" remind add --after 2h --message "cycle text" --key cycle
|
|
386
|
+
R_ID="$(sed -n 's/^已创建 \(rem-[^ ]*\) · .*/\1/p' "$ROOT/out/r1.txt")"
|
|
387
|
+
printf "const r = snap.reminders.find(item => item.id === '%s'); r.phase = 'observed'; r.endedAt = new Date().toISOString();\n" "$R_ID" > "$ROOT/script/r-observed.mjs"
|
|
388
|
+
edit_snapshot "$R" "$ROOT/script/r-observed.mjs"
|
|
389
|
+
run_team "$R" "$ROOT/msg/none" "$ROOT/out/r2.txt" remind add --after 2h --message "cycle text" --key cycle
|
|
390
|
+
R_NEW="$(sed -n 's/^已创建 \(rem-[^ ]*\) · .*/\1/p' "$ROOT/out/r2.txt")"
|
|
391
|
+
if [ -n "$R_NEW" ] && [ "$R_NEW" != "$R_ID" ]; then
|
|
392
|
+
ok "C observed 后同 key 新建:新单调 ID($R_ID → $R_NEW)"
|
|
393
|
+
else
|
|
394
|
+
bad "C observed 后同 key 没有新建([$R_ID] / [$R_NEW])"
|
|
395
|
+
fi
|
|
396
|
+
|
|
323
397
|
# ---------------------------------------------------------------- D. views are derived, never stored
|
|
324
398
|
V="$(new_repo V)" || { bad "夹具建不出仓库 V"; result; exit 1; }
|
|
325
399
|
run_team "$V" "$ROOT/msg/none" "$ROOT/out/d1.txt" remind add --after 2h --message "queued one"
|
|
@@ -478,13 +552,18 @@ flip_prepare() { # <id> <helper>
|
|
|
478
552
|
mutate "$store" " if (parsed.seq >= highWater) bad(" " if (false) bad(" ;;
|
|
479
553
|
past-time) mutate "$store" " if (dueMs <= nowMs) {" " if (false) {" ;;
|
|
480
554
|
key-conflict-gone) mutate "$store" " if (!sameRequest(active, candidate)) {" " if (false) {" ;;
|
|
555
|
+
key-not-released) mutate "$store" "const KEY_HOLDING = new Set(['scheduled', 'queued', 'intent', 'unknown']);" \
|
|
556
|
+
"const KEY_HOLDING = new Set(['scheduled', 'queued', 'intent', 'unknown', 'observed']);" ;;
|
|
557
|
+
no-key-dedup) mutate "$store" " if (key.key) {" " if (true) {" ;;
|
|
558
|
+
json-refusal) mutate "$2" "process.stdout.write(json ? JSON.stringify(refusal, null, 2) + '\\n' : renderRemind(requestData.op, refusal));" \
|
|
559
|
+
"process.stdout.write(renderRemind(requestData.op, refusal));" ;;
|
|
481
560
|
*) return 1 ;;
|
|
482
561
|
esac
|
|
483
562
|
}
|
|
484
563
|
flip_probe() { # <id> <helper>
|
|
485
564
|
local id="$1" helper="$2" repo rid out
|
|
486
565
|
case "$id" in
|
|
487
|
-
view-stored|no-prune|highwater-lax|past-time|key-conflict-gone) repo="$(new_repo "flip-$id")" ;;
|
|
566
|
+
view-stored|no-prune|highwater-lax|past-time|key-conflict-gone|key-not-released|no-key-dedup|json-refusal) repo="$(new_repo "flip-$id")" ;;
|
|
488
567
|
*) return 1 ;;
|
|
489
568
|
esac
|
|
490
569
|
case "$id" in
|
|
@@ -545,10 +624,36 @@ JS
|
|
|
545
624
|
else
|
|
546
625
|
bad "flip(活跃 key 的不同请求照旧返回):仍然拒绝了(rc=$RC),这条红侧是橡皮章"
|
|
547
626
|
fi ;;
|
|
627
|
+
key-not-released)
|
|
628
|
+
run_helper "$helper" "$repo" "$ROOT/msg/x.txt" "$ROOT/out/p.txt" remind-add --after 2h --key cycle
|
|
629
|
+
rid="$(sed -n 's/^已创建 \(rem-[^ ]*\) · .*/\1/p' "$ROOT/out/p.txt")"
|
|
630
|
+
printf "const r = snap.reminders.find(item => item.id === '%s'); r.phase = 'observed'; r.endedAt = new Date().toISOString();\n" "$rid" > "$ROOT/script/p-cycle.mjs"
|
|
631
|
+
edit_snapshot "$repo" "$ROOT/script/p-cycle.mjs"
|
|
632
|
+
run_helper "$helper" "$repo" "$ROOT/msg/x.txt" "$ROOT/out/p2.txt" remind-add --after 2h --key cycle --json
|
|
633
|
+
if [ "$(jfield "$ROOT/out/p2.txt" 'reminder.id')" = "$rid" ]; then
|
|
634
|
+
ok "flip(observed 不释放 key):同 key 续建返回旧 ID —— C 的「观察后新 ID」会红"
|
|
635
|
+
else
|
|
636
|
+
bad "flip(observed 不释放 key):仍分配了新 ID,这条红侧是橡皮章"
|
|
637
|
+
fi ;;
|
|
638
|
+
no-key-dedup)
|
|
639
|
+
run_helper "$helper" "$repo" "$ROOT/msg/x.txt" "$ROOT/out/p.txt" remind-add --after 2h
|
|
640
|
+
run_helper "$helper" "$repo" "$ROOT/msg/x.txt" "$ROOT/out/p2.txt" remind-add --after 2h --json
|
|
641
|
+
if [ "$(jfield "$ROOT/out/p2.txt" 'duplicate')" = "true" ]; then
|
|
642
|
+
ok "flip(无 key 也去重):相同正文被合并 —— C 的「两个独立 ID」会红"
|
|
643
|
+
else
|
|
644
|
+
bad "flip(无 key 也去重):仍分配了两个 ID,这条红侧是橡皮章"
|
|
645
|
+
fi ;;
|
|
646
|
+
json-refusal)
|
|
647
|
+
run_helper "$helper" "$repo" "$ROOT/msg/nul.bin" "$ROOT/out/p.txt" remind-add --after 2h --json
|
|
648
|
+
if ! "$RUNNER" -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$ROOT/out/p.txt" 2>/dev/null; then
|
|
649
|
+
ok "flip(--json 拒绝退回人读行):JSON.parse 失败 —— B 的结构化拒绝断言会红"
|
|
650
|
+
else
|
|
651
|
+
bad "flip(--json 拒绝退回人读行):输出仍是 JSON,这条红侧是橡皮章"
|
|
652
|
+
fi ;;
|
|
548
653
|
esac
|
|
549
654
|
}
|
|
550
655
|
|
|
551
|
-
for flip_id in view-stored no-prune highwater-lax past-time key-conflict-gone; do
|
|
656
|
+
for flip_id in view-stored no-prune highwater-lax past-time key-conflict-gone key-not-released no-key-dedup json-refusal; do
|
|
552
657
|
arm_selected "$flip_id" || continue
|
|
553
658
|
FLIPS_RUN="${FLIPS_RUN:+$FLIPS_RUN,}$flip_id"
|
|
554
659
|
if ! helper="$(helper_copy "$flip_id")"; then
|
|
@@ -74,6 +74,10 @@ if (group === 'content') {
|
|
|
74
74
|
check('content 标出补发与来源/任务/key', text.includes('overdue: the patrol queued it late') &&
|
|
75
75
|
text.includes('source cli') && text.includes('task P423') && text.includes('key check'))
|
|
76
76
|
check('content 不截断:整条正文长度原样留在消息里', (text.match(new RegExp(MESSAGE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g')) ?? []).length === 1)
|
|
77
|
+
const large = `${'x'.repeat(64 * 1024)}\n`
|
|
78
|
+
const largeText = MOD.reminderContent(batchFixture({ members: [{ ...batch.members[0], message: large }] }))
|
|
79
|
+
check('content 64 KiB + 末尾换行逐字进入投递消息', Buffer.byteLength(large, 'utf8') === 65537 &&
|
|
80
|
+
largeText.includes(`${large}\n\n---\n`))
|
|
77
81
|
const details = MOD.reminderDetails(batch)
|
|
78
82
|
check('details 带批次身份与成员(模型看不见的那一半)', details.batchId === batch.id && details.nonce === 'nonce-abc' &&
|
|
79
83
|
details.members.join(',') === 'rem-x-1,rem-x-2')
|
|
@@ -148,6 +152,15 @@ check('watcher 先写 intent 再发(快照里已有该批次)', (() => {
|
|
|
148
152
|
const intentBatch = snapshot().batches.find(b => b.id === first?.message?.details?.batchId)
|
|
149
153
|
check('watcher 的意图绑定了当前待命代次', intentBatch?.generation === 1, `generation=${intentBatch?.generation}`)
|
|
150
154
|
|
|
155
|
+
// A real event with the batch id and nonce but a different frozen member set is not this message.
|
|
156
|
+
// It must not spend the right or clear Standby before the genuine observation arrives.
|
|
157
|
+
await handlers.message_start[0]({ message: { role: 'custom', customType: first.message.customType,
|
|
158
|
+
details: { ...first.message.details, members: [] } } })
|
|
159
|
+
const mismatched = snapshot()
|
|
160
|
+
check('watcher 批次和 nonce 相同但成员集不同 → 拒绝,权利与待命都不动',
|
|
161
|
+
mismatched.batches.find(b => b.id === first.message.details.batchId)?.phase === 'intent' &&
|
|
162
|
+
mismatched.batches.find(b => b.id === first.message.details.batchId)?.right === 'unspent' && mismatched.standby.on === true)
|
|
163
|
+
|
|
151
164
|
// the observation: Pi's own message_start for that very message
|
|
152
165
|
await handlers.message_start[0]({ message: { role: 'custom', customType: first.message.customType, details: first.message.details } })
|
|
153
166
|
const after = snapshot()
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
#
|
|
8
8
|
# A 到期入队 不到点不入队;到点的只入一次(重复巡检不加第二条);取消的项不入队;
|
|
9
9
|
# overdue 的两种形状(到期早于本巡检实例 / 入队滞后超 30s),正常轮询延迟不标 overdue
|
|
10
|
-
# B 冻结批次
|
|
11
|
-
#
|
|
10
|
+
# B 冻结批次 按入队顺序把当前成员全部冻结成一批;已有一批在飞时拒绝再冻(不重复送);
|
|
11
|
+
# 观察后下一批立即可发;成员记录带批次 id
|
|
12
12
|
# C 观察与待命 匹配的回执 → observed + 花掉唯一 right + 自动退当前代次 + 一条点名全部 id/来源的审计;
|
|
13
13
|
# 手动已 off → already-off;更新的代次 → 保留并报 ambiguous;重复事件不产生第二次 off;
|
|
14
|
-
# nonce
|
|
14
|
+
# nonce/会话/成员不符(含同长度乱序)→ 拒绝且不消耗 right
|
|
15
15
|
# D 未送达 queued / intent / failed-unknown 都不清待命;只有真回执才清
|
|
16
16
|
# E 失败与确认 API 拒绝 → unknown(可见、不重发、attempts 记账);unknown 挡住下一批;
|
|
17
17
|
# resolve 必须显式 --ack-unknown;确认后成员 resolved、right 烧掉、下一批可以再冻
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
# --flip=admit-any 入队不看到期时间 → A 的「不到点不入队」必须红
|
|
26
26
|
# --flip=intent-multi 不看已有一批在飞 → B 的「拒绝再冻」必须红
|
|
27
27
|
# --flip=observe-nogen 观察不再核对待命代次 → C 的「更新代次必须保留」必须红
|
|
28
|
+
# --flip=members-length 成员只比长度不比顺序 → C 的「同长度乱序必须拒绝」必须红
|
|
28
29
|
# --flip=off-on-queue 入队就把待命关掉 → D 的「未送达不得清待命」必须红
|
|
29
30
|
# --flip=unknown-resend unknown 不再挡住下一批 → E 的「unknown 挡住下一批」必须红
|
|
30
31
|
# 红侧跑在 scratch 副本上(只复制 state-authority.mjs + remind-store.mjs,import 关系与产品相同),
|
|
@@ -43,7 +44,7 @@ for arg in "$@"; do
|
|
|
43
44
|
case "$arg" in
|
|
44
45
|
--flip=*)
|
|
45
46
|
case "${arg#--flip=}" in
|
|
46
|
-
admit-any|intent-multi|observe-nogen|off-on-queue|unknown-resend) FLIPS+=("${arg#--flip=}") ;;
|
|
47
|
+
admit-any|intent-multi|observe-nogen|members-length|off-on-queue|unknown-resend|batch-cap|batch-spacing) FLIPS+=("${arg#--flip=}") ;;
|
|
47
48
|
*) printf 'remind-delivery:不认识的 --flip 值 [%s]\n' "${arg#--flip=}" >&2; exit 2 ;;
|
|
48
49
|
esac ;;
|
|
49
50
|
-h|--help) sed -n '2,33p' "$0"; exit 0 ;;
|
|
@@ -119,6 +120,9 @@ fs.writeFileSync(file + '.edit', JSON.stringify(snap) + '\n');
|
|
|
119
120
|
fs.renameSync(file + '.edit', file);
|
|
120
121
|
JS
|
|
121
122
|
jfield() { "$RUNNER" "$ROOT/json-get.mjs" "$1" "$2"; }
|
|
123
|
+
reversed_members() { # <intent.json> → 同长度、逆序的成员 id JSON(不改写持久快照)
|
|
124
|
+
"$RUNNER" -e 'const fs=require("fs");const r=JSON.parse(fs.readFileSync(process.argv[1],"utf8"));process.stdout.write(JSON.stringify(r.batch.members.map(m=>m.id).reverse()))' "$1"
|
|
125
|
+
}
|
|
122
126
|
snapshot_of() { printf '%s/.pi/team/state/reminders/state.json\n' "$1"; }
|
|
123
127
|
edit_snapshot() { # <repo> <script-file>
|
|
124
128
|
"$RUNNER" "$ROOT/snapshot-edit.mjs" "$(snapshot_of "$1")" "$2"
|
|
@@ -292,42 +296,58 @@ assert_eq "B 批次绑定了当时的待命状态(off)" "$(jfield "$ROOT/out
|
|
|
292
296
|
authority "$D" "$ROOT/out/intent2.txt" remind-intent --session sess-D --pid 111
|
|
293
297
|
assert_eq "B 已有一批在飞:第二次冻结被拒(wait,不产生第二批)" "$(jfield "$ROOT/out/intent2.txt" 'action')" "wait"
|
|
294
298
|
assert_eq "B 快照里只有一批" "$(jfield "$SD" 'batches.length')" "1"
|
|
295
|
-
#
|
|
299
|
+
# 九条同批:没有成员数上限;观察结束后新成员立即进入下一批,不等批次间隔。
|
|
296
300
|
E="$(new_repo E)"; SE="$(snapshot_of "$E")"
|
|
297
|
-
for i in 1 2 3 4 5 6 7 8 9; do add_due "$E" "
|
|
301
|
+
for i in 1 2 3 4 5 6 7 8 9; do add_due "$E" "uncapped member $i" "uncapped$i" >/dev/null; done
|
|
298
302
|
tick "$E" "$(iso_shift -10)" "$ROOT/out/tick.txt"
|
|
299
303
|
authority "$E" "$ROOT/out/intent.txt" remind-intent --session sess-E --pid 222
|
|
300
|
-
assert_eq "B
|
|
301
|
-
assert_eq "B
|
|
302
|
-
# 5 秒间隔:刚冻结完立刻再冻(先确认上一批已离开 outstanding)
|
|
304
|
+
assert_eq "B 九条全部进入同一批" "$(jfield "$ROOT/out/intent.txt" 'batch.members.length')" "9"
|
|
305
|
+
assert_eq "B 第九条不再滞留 queued" "$(jfield "$SE" 'reminders.8.phase')" "intent"
|
|
303
306
|
authority "$E" "$ROOT/out/obs.txt" remind-observe --id "$(jfield "$ROOT/out/intent.txt" 'batch.id')" \
|
|
304
|
-
--nonce "$(jfield "$ROOT/out/intent.txt" 'batch.nonce')" --session sess-E
|
|
307
|
+
--nonce "$(jfield "$ROOT/out/intent.txt" 'batch.nonce')" --session sess-E \
|
|
308
|
+
--members "$(jfield "$ROOT/out/intent.txt" 'batch.members')"
|
|
309
|
+
add_due "$E" 'immediately eligible after observation' >/dev/null
|
|
310
|
+
tick "$E" "$(iso_shift -10)" "$ROOT/out/tick.txt"
|
|
305
311
|
authority "$E" "$ROOT/out/intent2.txt" remind-intent --session sess-E --pid 222
|
|
306
|
-
assert_eq "B
|
|
312
|
+
assert_eq "B 观察后下一批立即可发(无 spacing)" "$(jfield "$ROOT/out/intent2.txt" 'action')" "send"
|
|
313
|
+
assert_eq "B 新批次就是刚入队的那一条" "$(jfield "$ROOT/out/intent2.txt" 'batch.members.0.message')" 'immediately eligible after observation'
|
|
307
314
|
|
|
308
315
|
# ---------------------------------------------------------------- C. 观察与待命
|
|
309
316
|
F="$(new_repo F)"; SF="$(snapshot_of "$F")"
|
|
310
317
|
add_due "$F" 'standby wake' wake >/dev/null
|
|
318
|
+
add_due "$F" 'standby wake two' wake-two >/dev/null
|
|
311
319
|
authority "$F" "$ROOT/out/sb.txt" standby-on --reason "user away" --json
|
|
312
320
|
assert_eq "C 待命开了(代次 1)" "$(jfield "$ROOT/out/sb.txt" 'generation')" "1"
|
|
313
321
|
tick "$F" "$(iso_shift -10)" "$ROOT/out/tick.txt"
|
|
314
322
|
authority "$F" "$ROOT/out/intent.txt" remind-intent --session sess-F --pid 333
|
|
315
323
|
FB="$(jfield "$ROOT/out/intent.txt" 'batch.id')"; FN="$(jfield "$ROOT/out/intent.txt" 'batch.nonce')"
|
|
316
324
|
assert_eq "C 意图绑定当前代次 1" "$(jfield "$ROOT/out/intent.txt" 'batch.generation')" "1"
|
|
317
|
-
authority "$F" "$ROOT/out/bad.txt" remind-observe --id "$FB" --nonce "wrong" --session sess-F
|
|
325
|
+
authority "$F" "$ROOT/out/bad.txt" remind-observe --id "$FB" --nonce "wrong" --session sess-F \
|
|
326
|
+
--members "$(jfield "$ROOT/out/intent.txt" 'batch.members')"
|
|
318
327
|
assert_eq "C nonce 不符:拒绝且不消耗 right" "$(jfield "$ROOT/out/bad.txt" 'refusal')" "nonce-mismatch"
|
|
319
328
|
assert_eq "C nonce 不符后 right 仍未花" "$(jfield "$SF" 'batches.0.right')" "unspent"
|
|
320
|
-
authority "$F" "$ROOT/out/bad.txt" remind-observe --id "$FB" --nonce "$FN" --session other
|
|
329
|
+
authority "$F" "$ROOT/out/bad.txt" remind-observe --id "$FB" --nonce "$FN" --session other \
|
|
330
|
+
--members "$(jfield "$ROOT/out/intent.txt" 'batch.members')"
|
|
321
331
|
assert_eq "C 会话不符:拒绝" "$(jfield "$ROOT/out/bad.txt" 'refusal')" "session-mismatch"
|
|
322
|
-
authority "$F" "$ROOT/out/
|
|
332
|
+
authority "$F" "$ROOT/out/bad.txt" remind-observe --id "$FB" --nonce "$FN" --session sess-F --members '[]'
|
|
333
|
+
assert_eq "C 成员集不符:拒绝且不消耗 right" "$(jfield "$ROOT/out/bad.txt" 'refusal')" "member-mismatch"
|
|
334
|
+
assert_eq "C 成员集不符后 right 仍未花" "$(jfield "$SF" 'batches.0.right')" "unspent"
|
|
335
|
+
authority "$F" "$ROOT/out/bad.txt" remind-observe --id "$FB" --nonce "$FN" --session sess-F \
|
|
336
|
+
--members "$(reversed_members "$ROOT/out/intent.txt")"
|
|
337
|
+
assert_eq "C 同长度乱序成员:拒绝" "$(jfield "$ROOT/out/bad.txt" 'refusal')" "member-mismatch"
|
|
338
|
+
assert_eq "C 同长度乱序成员:right 仍未花" "$(jfield "$SF" 'batches.0.right')" "unspent"
|
|
339
|
+
assert_eq "C 同长度乱序成员:Standby 仍开" "$(jfield "$SF" 'standby.on')" "true"
|
|
340
|
+
authority "$F" "$ROOT/out/obs.txt" remind-observe --id "$FB" --nonce "$FN" --session sess-F \
|
|
341
|
+
--members "$(jfield "$ROOT/out/intent.txt" 'batch.members')"
|
|
323
342
|
assert_has "C 匹配事件 → observed" "$(cat "$ROOT/out/obs.txt")" '"outcome":"observed"'
|
|
324
343
|
assert_has "C 观察原子地自动退代次 1" "$(cat "$ROOT/out/obs.txt")" '"standby":"auto-off"'
|
|
325
344
|
assert_eq "C 待命已关" "$(jfield "$SF" 'standby.on')" "false"
|
|
326
345
|
assert_eq "C right 已花(wake)" "$(jfield "$SF" 'batches.0.rightSpentBy')" "wake"
|
|
327
346
|
assert_eq "C 审计一条、点名批次" "$(jfield "$SF" 'audit.-1.batch')" "$FB"
|
|
328
|
-
assert_eq "C 审计带每个提醒 id" "$(jfield "$SF" 'audit.-1.ids.length')" "
|
|
347
|
+
assert_eq "C 审计带每个提醒 id" "$(jfield "$SF" 'audit.-1.ids.length')" "2"
|
|
329
348
|
assert_eq "C 审计带来源" "$(jfield "$SF" 'audit.-1.sources.0')" "cli"
|
|
330
|
-
authority "$F" "$ROOT/out/obs.txt" remind-observe --id "$FB" --nonce "$FN" --session sess-F
|
|
349
|
+
authority "$F" "$ROOT/out/obs.txt" remind-observe --id "$FB" --nonce "$FN" --session sess-F \
|
|
350
|
+
--members "$(jfield "$ROOT/out/intent.txt" 'batch.members')"
|
|
331
351
|
assert_has "C 重复事件 → duplicate(不再退待命)" "$(cat "$ROOT/out/obs.txt")" '"outcome":"duplicate"'
|
|
332
352
|
assert_eq "C 重复事件不产生第二条观察审计" \
|
|
333
353
|
"$(node -e 'const s=require("'"$SF"'");console.log(s.audit.filter(a=>a.op==="remind-observed").length)')" "1"
|
|
@@ -340,7 +360,8 @@ tick "$G" "$(iso_shift -10)" "$ROOT/out/tick.txt"
|
|
|
340
360
|
authority "$G" "$ROOT/out/intent.txt" remind-intent --session sess-G --pid 444
|
|
341
361
|
authority "$G" "$ROOT/out/sb.txt" standby-off >/dev/null
|
|
342
362
|
authority "$G" "$ROOT/out/obs.txt" remind-observe --id "$(jfield "$ROOT/out/intent.txt" 'batch.id')" \
|
|
343
|
-
--nonce "$(jfield "$ROOT/out/intent.txt" 'batch.nonce')" --session sess-G
|
|
363
|
+
--nonce "$(jfield "$ROOT/out/intent.txt" 'batch.nonce')" --session sess-G \
|
|
364
|
+
--members "$(jfield "$ROOT/out/intent.txt" 'batch.members')"
|
|
344
365
|
assert_has "C 手动已关 → already-off(不虚构自动退出)" "$(cat "$ROOT/out/obs.txt")" '"standby":"already-off"'
|
|
345
366
|
|
|
346
367
|
# 更新的代次:保留,报 ambiguous
|
|
@@ -353,7 +374,8 @@ authority "$H" "$ROOT/out/sb.txt" standby-off >/dev/null
|
|
|
353
374
|
authority "$H" "$ROOT/out/sb.txt" standby-on --reason "g2" --json >/dev/null
|
|
354
375
|
assert_eq "C 现在的代次是 2" "$(jfield "$ROOT/out/sb.txt" 'generation')" "2"
|
|
355
376
|
authority "$H" "$ROOT/out/obs.txt" remind-observe --id "$(jfield "$ROOT/out/intent.txt" 'batch.id')" \
|
|
356
|
-
--nonce "$(jfield "$ROOT/out/intent.txt" 'batch.nonce')" --session sess-H
|
|
377
|
+
--nonce "$(jfield "$ROOT/out/intent.txt" 'batch.nonce')" --session sess-H \
|
|
378
|
+
--members "$(jfield "$ROOT/out/intent.txt" 'batch.members')"
|
|
357
379
|
assert_has "C 更新代次 → 保留并报 generation-ambiguous" "$(cat "$ROOT/out/obs.txt")" '"standby":"generation-ambiguous"'
|
|
358
380
|
assert_eq "C 更新代次没有被清掉" "$(jfield "$SH" 'standby.on')" "true"
|
|
359
381
|
assert_eq "C 更新代次仍是 2" "$(jfield "$SH" 'standby.generation')" "2"
|
|
@@ -387,11 +409,7 @@ assert_eq "E 成员一起关闭" "$(jfield "$SI" 'reminders.0.phase')" "resolved
|
|
|
387
409
|
assert_eq "E right 由确认烧掉" "$(jfield "$SI" 'batches.0.rightSpentBy')" "resolve"
|
|
388
410
|
assert_eq "E 确认不声称送达(没有 remind-observed)" \
|
|
389
411
|
"$(node -e 'const s=require("'"$SI"'");console.log(s.audit.filter(a=>a.op==="remind-observed").length)')" "0"
|
|
390
|
-
#
|
|
391
|
-
cat > "$ROOT/script/space.js" <<'JS'
|
|
392
|
-
for (const batch of snap.batches) batch.intentAt = iso(Date.now() - 10000);
|
|
393
|
-
JS
|
|
394
|
-
edit_snapshot "$I" "$ROOT/script/space.js"
|
|
412
|
+
# 确认后下一批可以再冻结,不需要等待或改写上一批的时间。
|
|
395
413
|
add_due "$I" 'after resolve' >/dev/null
|
|
396
414
|
tick "$I" "$(iso_shift -10)" "$ROOT/out/tick.txt"
|
|
397
415
|
authority "$I" "$ROOT/out/intent3.txt" remind-intent --session sess-I --pid 666
|
|
@@ -408,7 +426,8 @@ authority "$J" "$ROOT/out/intent.txt" remind-intent --session sess-J --pid 777
|
|
|
408
426
|
assert_eq "F 重启后 queued 被冻结成批次" "$(jfield "$ROOT/out/intent.txt" 'action')" "send"
|
|
409
427
|
assert_has "F 正文仍是原文" "$(cat "$ROOT/out/intent.txt")" 'restart catch-up'
|
|
410
428
|
authority "$J" "$ROOT/out/obs.txt" remind-observe --id "$(jfield "$ROOT/out/intent.txt" 'batch.id')" \
|
|
411
|
-
--nonce "$(jfield "$ROOT/out/intent.txt" 'batch.nonce')" --session sess-J
|
|
429
|
+
--nonce "$(jfield "$ROOT/out/intent.txt" 'batch.nonce')" --session sess-J \
|
|
430
|
+
--members "$(jfield "$ROOT/out/intent.txt" 'batch.members')"
|
|
412
431
|
tick "$J" "$(iso_shift -10)" "$ROOT/out/tick.txt"
|
|
413
432
|
assert_eq "F 已送达的不再入队(admitted 为空)" "$(jfield "$ROOT/out/tick.txt" 'admitted.length')" "0"
|
|
414
433
|
assert_eq "F 已送达记录仍是 observed" "$(jfield "$SJ" 'reminders.0.phase')" "observed"
|
|
@@ -523,12 +542,8 @@ JS
|
|
|
523
542
|
for i in 1 2 3 4 5 6 7 8 9; do add_due "$repo" "flip member $i" "fm$i" >/dev/null; done
|
|
524
543
|
run_helper "$helper" "$repo" "$ROOT/out/flip.txt" remind-admit --pulse-started "$(iso_shift -10)"
|
|
525
544
|
run_helper "$helper" "$repo" "$ROOT/out/f1.txt" remind-intent --session s --pid 1
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
cat > "$ROOT/script/space3.js" <<'JS'
|
|
529
|
-
for (const batch of snap.batches) batch.intentAt = iso(Date.now() - 10000);
|
|
530
|
-
JS
|
|
531
|
-
edit_snapshot "$repo" "$ROOT/script/space3.js"
|
|
545
|
+
add_due "$repo" 'queued while another batch is in flight' >/dev/null
|
|
546
|
+
run_helper "$helper" "$repo" "$ROOT/out/flip.txt" remind-admit --pulse-started "$(iso_shift -10)"
|
|
532
547
|
run_helper "$helper" "$repo" "$ROOT/out/f2.txt" remind-intent --session s --pid 1
|
|
533
548
|
if [ "$(jfield "$ROOT/out/f2.txt" 'action')" = "send" ]; then
|
|
534
549
|
ok "flip(不看已有一批在飞):同一批被冻了两次 —— B 的「拒绝再冻」会红"
|
|
@@ -552,7 +567,8 @@ JS
|
|
|
552
567
|
run_helper "$helper" "$repo" "$ROOT/out/f.txt" standby-off
|
|
553
568
|
run_helper "$helper" "$repo" "$ROOT/out/f.txt" standby-on --reason g2
|
|
554
569
|
run_helper "$helper" "$repo" "$ROOT/out/f2.txt" remind-observe --id "$(jfield "$ROOT/out/f1.txt" 'batch.id')" \
|
|
555
|
-
--nonce "$(jfield "$ROOT/out/f1.txt" 'batch.nonce')" --session s
|
|
570
|
+
--nonce "$(jfield "$ROOT/out/f1.txt" 'batch.nonce')" --session s \
|
|
571
|
+
--members "$(jfield "$ROOT/out/f1.txt" 'batch.members')"
|
|
556
572
|
if [ "$(jfield "$ROOT/out/f2.txt" 'standby')" = "auto-off" ]; then
|
|
557
573
|
ok "flip(观察不核对代次):新代次被清掉 —— C 的「更新代次必须保留」会红"
|
|
558
574
|
else
|
|
@@ -560,6 +576,35 @@ JS
|
|
|
560
576
|
fi
|
|
561
577
|
fi
|
|
562
578
|
|
|
579
|
+
if arm_selected members-length; then
|
|
580
|
+
helper="$(helper_copy members-length)"
|
|
581
|
+
if mutate "$(dirname "$helper")/remind-store.mjs" \
|
|
582
|
+
"request.members.length !== batch.members.length ||
|
|
583
|
+
request.members.some((id, index) => id !== batch.members[index])" \
|
|
584
|
+
"request.members.length !== batch.members.length"; then
|
|
585
|
+
ok "红侧 members-length:变异已落地(成员只比长度,不再逐项比身份与顺序)"
|
|
586
|
+
else
|
|
587
|
+
bad "红侧 members-length:变异锚点没落地"
|
|
588
|
+
fi
|
|
589
|
+
FLIPS_RUN="${FLIPS_RUN:+$FLIPS_RUN,}members-length"
|
|
590
|
+
repo="$(new_repo FLIP_MEMBERS)"
|
|
591
|
+
add_due "$repo" 'member order one' order-one >/dev/null
|
|
592
|
+
add_due "$repo" 'member order two' order-two >/dev/null
|
|
593
|
+
run_helper "$helper" "$repo" "$ROOT/out/f.txt" standby-on --reason g1
|
|
594
|
+
run_helper "$helper" "$repo" "$ROOT/out/flip.txt" remind-admit --pulse-started "$(iso_shift -10)"
|
|
595
|
+
run_helper "$helper" "$repo" "$ROOT/out/f1.txt" remind-intent --session s --pid 1
|
|
596
|
+
run_helper "$helper" "$repo" "$ROOT/out/f2.txt" remind-observe --id "$(jfield "$ROOT/out/f1.txt" 'batch.id')" \
|
|
597
|
+
--nonce "$(jfield "$ROOT/out/f1.txt" 'batch.nonce')" --session s \
|
|
598
|
+
--members "$(reversed_members "$ROOT/out/f1.txt")"
|
|
599
|
+
if [ "$(jfield "$ROOT/out/f2.txt" 'outcome')" = "observed" ] && \
|
|
600
|
+
[ "$(jfield "$ROOT/out/f2.txt" 'standby')" = "auto-off" ] && \
|
|
601
|
+
[ "$(jfield "$(snapshot_of "$repo")" 'standby.on')" = "false" ]; then
|
|
602
|
+
ok "flip(成员只比长度):同长度乱序被误收并清了 Standby —— C 的乱序拒绝会红;完整比较恢复后拒绝"
|
|
603
|
+
else
|
|
604
|
+
bad "flip(成员只比长度):变异没有误收同长度乱序(红侧无效)"
|
|
605
|
+
fi
|
|
606
|
+
fi
|
|
607
|
+
|
|
563
608
|
if arm_selected off-on-queue; then
|
|
564
609
|
helper="$(helper_copy off-on-queue)"
|
|
565
610
|
mutate "$(dirname "$helper")/remind-store.mjs" \
|
|
@@ -592,10 +637,6 @@ JS
|
|
|
592
637
|
run_helper "$helper" "$repo" "$ROOT/out/f1.txt" remind-intent --session s --pid 1
|
|
593
638
|
run_helper "$helper" "$repo" "$ROOT/out/f.txt" remind-fail --id "$(jfield "$ROOT/out/f1.txt" 'batch.id')" \
|
|
594
639
|
--nonce "$(jfield "$ROOT/out/f1.txt" 'batch.nonce')" --reason "refused"
|
|
595
|
-
cat > "$ROOT/script/space2.js" <<'JS'
|
|
596
|
-
for (const batch of snap.batches) batch.intentAt = iso(Date.now() - 10000);
|
|
597
|
-
JS
|
|
598
|
-
edit_snapshot "$repo" "$ROOT/script/space2.js"
|
|
599
640
|
add_due "$repo" 'flip next batch' >/dev/null
|
|
600
641
|
run_helper "$helper" "$repo" "$ROOT/out/f.txt" remind-admit --pulse-started "$(iso_shift -10)"
|
|
601
642
|
run_helper "$helper" "$repo" "$ROOT/out/f2.txt" remind-intent --session s --pid 1
|
|
@@ -605,6 +646,53 @@ JS
|
|
|
605
646
|
bad "flip(unknown 不再挡住下一批):变异没有改变答案(红侧无效)"
|
|
606
647
|
fi
|
|
607
648
|
fi
|
|
649
|
+
|
|
650
|
+
if arm_selected batch-cap; then
|
|
651
|
+
helper="$(helper_copy batch-cap)"
|
|
652
|
+
mutate "$(dirname "$helper")/remind-store.mjs" \
|
|
653
|
+
" .sort((a, b) => ((a.queueSeq ?? 0) - (b.queueSeq ?? 0)) || (a.seq - b.seq));" \
|
|
654
|
+
" .sort((a, b) => ((a.queueSeq ?? 0) - (b.queueSeq ?? 0)) || (a.seq - b.seq))
|
|
655
|
+
.slice(0, 8);"
|
|
656
|
+
ok "红侧 batch-cap:变异已落地(恢复单批 8 条上限)"
|
|
657
|
+
FLIPS_RUN="${FLIPS_RUN:+$FLIPS_RUN,}batch-cap"
|
|
658
|
+
repo="$(new_repo FLIP6)"
|
|
659
|
+
for i in 1 2 3 4 5 6 7 8 9; do add_due "$repo" "flip cap $i" "fc$i" >/dev/null; done
|
|
660
|
+
run_helper "$helper" "$repo" "$ROOT/out/flip.txt" remind-admit --pulse-started "$(iso_shift -10)"
|
|
661
|
+
run_helper "$helper" "$repo" "$ROOT/out/f1.txt" remind-intent --session s --pid 1
|
|
662
|
+
if [ "$(jfield "$ROOT/out/f1.txt" 'batch.members.length')" = "8" ]; then
|
|
663
|
+
ok "flip(恢复单批 8 条上限):第九条被留下 —— B 的「九条同批」会红"
|
|
664
|
+
else
|
|
665
|
+
bad "flip(恢复单批 8 条上限):第九条仍同批,这条红侧是橡皮章"
|
|
666
|
+
fi
|
|
667
|
+
fi
|
|
668
|
+
|
|
669
|
+
if arm_selected batch-spacing; then
|
|
670
|
+
helper="$(helper_copy batch-spacing)"
|
|
671
|
+
mutate "$(dirname "$helper")/remind-store.mjs" \
|
|
672
|
+
" const queued = snapshot.reminders" \
|
|
673
|
+
" const last = snapshot.batches[snapshot.batches.length - 1];
|
|
674
|
+
if (last && Number.isFinite(msOf(last.intentAt)) && nowMs - msOf(last.intentAt) < 5000) {
|
|
675
|
+
return { ok: true, action: 'spacing', now: iso(nowMs), swept };
|
|
676
|
+
}
|
|
677
|
+
const queued = snapshot.reminders"
|
|
678
|
+
ok "红侧 batch-spacing:变异已落地(恢复五秒批次间隔)"
|
|
679
|
+
FLIPS_RUN="${FLIPS_RUN:+$FLIPS_RUN,}batch-spacing"
|
|
680
|
+
repo="$(new_repo FLIP7)"
|
|
681
|
+
add_due "$repo" 'flip spacing first' >/dev/null
|
|
682
|
+
run_helper "$helper" "$repo" "$ROOT/out/flip.txt" remind-admit --pulse-started "$(iso_shift -10)"
|
|
683
|
+
run_helper "$helper" "$repo" "$ROOT/out/f1.txt" remind-intent --session s --pid 1
|
|
684
|
+
run_helper "$helper" "$repo" "$ROOT/out/obs.txt" remind-observe --id "$(jfield "$ROOT/out/f1.txt" 'batch.id')" \
|
|
685
|
+
--nonce "$(jfield "$ROOT/out/f1.txt" 'batch.nonce')" --session s \
|
|
686
|
+
--members "$(jfield "$ROOT/out/f1.txt" 'batch.members')"
|
|
687
|
+
add_due "$repo" 'flip spacing second' >/dev/null
|
|
688
|
+
run_helper "$helper" "$repo" "$ROOT/out/flip.txt" remind-admit --pulse-started "$(iso_shift -10)"
|
|
689
|
+
run_helper "$helper" "$repo" "$ROOT/out/f2.txt" remind-intent --session s --pid 1
|
|
690
|
+
if [ "$(jfield "$ROOT/out/f2.txt" 'action')" = "spacing" ]; then
|
|
691
|
+
ok "flip(恢复五秒批次间隔):下一批被推迟 —— B 的「立即可发」会红"
|
|
692
|
+
else
|
|
693
|
+
bad "flip(恢复五秒批次间隔):下一批仍立即可发,这条红侧是橡皮章"
|
|
694
|
+
fi
|
|
695
|
+
fi
|
|
608
696
|
}
|
|
609
697
|
run_flips
|
|
610
698
|
|