fix(cr-01/02/03/08/09/10/11/13): 会话世代、损耗共享基线、任务活性与工作台包

- CR-01:users.session_epoch(V172)+ JWT sessionEpoch;登录/登出原子推进,
  check_login/requireUser 先比世代再做设备比对;登出不再依赖 machine CAS
- CR-02/09:cost-guard 基线落 Redis(CostGuardBaselineStore),按 elapsed 归一化;
  非持锁实例刷新共享密钥快照;pause() 返回写成功,失败不通知且不推进基线
- CR-03:stuck_requeue_count(V173,上限 20)与 retry_count 分账;终态父任务心跳
  停止 touchRunning 并 markFailedPermanent;良性停续期 markLost=false
- CR-08:工作台包对象 key 加 UUID、0 字节拒绝、同 objectKey 幂等、同版本重复拒绝、
  前端 confirm 超时抬到 10 分钟
- CR-10:Excel onSheetTotal 统一在 onHeader 之后回调(xlsx/xls)
- CR-13/11:迁移头/文件名一致断言(V170 唯一豁免);V167 前置由 CompanyService 同事务
  复制菜单树,已应用迁移未回改
This commit is contained in:
2026-10-25 03:40:15 +08:00
parent 112c61afa8
commit c2f429f112
43 changed files with 1003 additions and 95 deletions
@@ -11,6 +11,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -91,6 +92,14 @@ class MigrationInventoryTest {
*/
private static final Set<Integer> RETIRED_HOLES = Set.of(132, 133, 148, 168, 169);
/**
* 文件名版本与头注释版本不一致的历史件。V170 的头注释误写成 V168;它已应用到生产,
* 按 AGENTS.md「已发布迁移一个字节都不许改」不能回改(CR-13)。文件名才是 Flyway
* 认的号,这里把它显式登记成唯一豁免;新增任何不一致都会判红。
*/
private static final Map<String, String> KNOWN_HEADER_VERSION_MISMATCH =
Map.of("V170__user_task_guard.sql", "V168");
@Test
void integerVersionsSequentialFromOne() throws IOException {
List<Migration> all = parseAll(versionFiles());
@@ -144,6 +153,24 @@ class MigrationInventoryTest {
@Test
void headerVersionMatchesFileNameExceptKnownImmutableMismatch() throws IOException {
Map<String, String> mismatches = new LinkedHashMap<>();
Pattern fileNameVersion = Pattern.compile("^V(\\d+)");
Pattern headerVersion = Pattern.compile("(?m)^--\\s*迁移\\s+V(\\d+)");
for (Path file : versionFiles()) {
String name = file.getFileName().toString();
Matcher fileMatcher = fileNameVersion.matcher(name);
Matcher headerMatcher = headerVersion.matcher(Files.readString(file));
if (fileMatcher.find() && headerMatcher.find()
&& !fileMatcher.group(1).equals(headerMatcher.group(1))) {
mismatches.put(name, "V" + headerMatcher.group(1));
}
}
assertEquals(KNOWN_HEADER_VERSION_MISMATCH, mismatches,
"迁移头注释的版本号必须与文件名一致;V170 是已应用件,只能登记为豁免,不能回改");
}
@Test
void checksumStableAcrossReads() throws IOException {
Map<String, String> first = sha256All(versionFiles());