Skip to content

v1.3.2 — Stricter card anchors, drift downgrade, run-all · 卡片锚点收紧、漂移降级、测试聚合

Choose a tag to compare

@TheLiudawei TheLiudawei released this 02 Nov 12:02
· 6 commits to main since this release

English · 中文

English

Card identity got stricter, and two long-standing defects the CI matrix caught are fixed.

Only path-shaped tokens become source anchors

A card's identity is task:<type>:<source anchor>. The old rule took any fragment containing a dot, so v1.2.3, 3.5, https://example.com/x.md and e.g. all became anchors. Two consequences: two unrelated cards could pair up, or the same card could stop pairing after a re-import — and silently lose its run state.

A token now qualifies when it contains a path separator, or ends in a known source extension (SOURCE_EXTENSIONS, ~90 entries: code, config, docs, stylesheets, markup). Explicitly rejected: scheme URLs (https://, file://, vscode://), version patterns (v1.2.3, 2.0), bare numbers (3.5), abbreviations (e.g., i.e.) and timestamps. Line suffixes (path:12) still work, Windows separators are normalised, and a URL followed by a real path picks the path.

Five counterexamples and seven positive cases are in tests/cards.mjs — all of them reproduce on the previous rule.

Drifted cards drop back to pending

When the scanned source changed since the last import (paramsDrift), the old "done" is no longer evidence about the current state. Such cards now:

  • return to pending — the same rule as "not executed means failed": never let a stale result pose as the current state;
  • keep a note 源码已变,需重跑 in detail;
  • show an amber 源码已变,需重跑 badge (distinct from the grey dashed "no longer in source" badge), which disappears as soon as the card runs again.

No drift, no change — re-importing an unchanged project leaves statuses untouched.

npm test is one aggregator

tests/run-all.mjs spawns all sixteen suites in order, collects every exit code, and prints one summary table with per-suite timing. It is aligned with CI's if: always(): a failing suite never hides the ones after it. Exit code is 0 only when all sixteen pass.

Two defects found by the CI matrix

  • Undo reported same-size edits as unchanged. files.modified was derived from size plus a 1 ms mtime tolerance; a same-size edit (print("v1") → print("v2")) written within the same millisecond on a high-resolution filesystem was silently dropped, so the restore report came back empty on Linux. dryRun and restore now compare contents when size matches and the timestamps are within 1 ms.
  • Fixture cleanup raced the plugin. rm(recursive) occasionally threw ENOTEMPTY on macOS because the plugin's debounced persistence can drop a file back into the directory while it is being deleted. Recursive removals in validate now retry with a short backoff instead of failing the run.

Full changelog: v1.3.1...v1.3.2


中文

English

卡片身份更严格了,另外修掉两个由 CI 矩阵抓出来的既有缺陷。

只有「像路径」的 token 才能成为源锚点

卡片身份是 task:<类型>:<源锚点>。旧规则把任何含小数点的片段都当路径,于是 v1.2.3、3.5、https://example.com/x.md、e.g. 都会变成锚点。后果有两个:两张无关的卡片可能配到一起;或者同一张卡片换个导入就配不上了——运行状态悄悄丢失。

现在 token 要么含路径分隔符,要么命中已知源码扩展名(SOURCE_EXTENSIONS,约 90 项,覆盖代码、配置、文档、样式、标记语言)。显式排除:带 scheme 的 URL(https://、file://、vscode://)、版本号(v1.2.3、2.0)、纯数字(3.5)、缩写(e.g.、i.e.)、时间戳。行号后缀(path:12)仍然有效,Windows 分隔符照常归一,URL 后面跟着真路径时取那个路径。

五条反例与七条正例都在 tests/cards.mjs——它们在旧规则下全部可复现。

漂移的卡片退回 pending

当扫描到的源码相对上次导入发生变化(paramsDrift)时,旧的「完成」就不再是当前状态的证据。这类卡片现在:

  • 退回 pending——与「未执行即失败」同一口径:绝不让过期结果冒充当前状态;
  • 在 detail 里记一条「源码已变,需重跑」;
  • 画布上挂琥珀色「源码已变,需重跑」徽章(与灰虚线「源码中已不存在」区分),重跑后自动消失。

没有漂移则什么都不动——重新导入未变更的项目不会改动任何状态。

npm test 合并成一个聚合器

tests/run-all.mjs 顺序启动全部 16 个套件、收集每个退出码、末尾打印一张带耗时的汇总表。与 CI 的 if: always() 对齐:失败的套件不再掩盖它之后的套件。只有 16 个全过,退出码才是 0。

CI 矩阵揪出的两个缺陷

  • 撤销把同尺寸修改判成未修改。 files.modified 原先按 size 加 1ms 的 mtime 容差推导;同尺寸改动(print("v1") → print("v2"))若落在同一毫秒内,在高分辨率文件系统上会被静默丢弃,于是 Linux 上恢复报告是空的。dryRun 与 restore 现在在「尺寸相同且时间差 ≤1ms」时按内容比对。
  • 临时目录清理与插件抢跑。 rm(recursive) 在 macOS 上偶尔抛 ENOTEMPTY——插件去抖落盘可能在删除过程中把文件放回去。validate 里的递归删除改为短退避重试,不再因竞态整轮标红。

完整变更:v1.3.1...v1.3.2