refactor(phase-3): 3A 拆薄第五笔——外观专利 LLM 批管线出件,服务 3135→2801

B 聚类(候选收集、批调度、轮次判死、结果行合并、批计数)原样搬进
service/support/AppearancePatentLlmBatchPipeline;读分片、分片合并、
心跳、封口判定仍留在服务侧,以回调交入。四枚同名入口保留为测试
按名反射的接缝;SourceScanTest 面数 31→32、support 8→9 并逐枚点名新件。
This commit is contained in:
2026-10-20 14:03:18 +08:00
parent 3ac859e05f
commit 4bcce9d534
4 changed files with 537 additions and 371 deletions
@@ -10,6 +10,7 @@ import com.nanri.aiimage.config.InstanceMetadata;
import com.nanri.aiimage.config.StorageProperties;
import com.nanri.aiimage.modules.appearancepatent.client.AppearancePatentLlmClient;
import com.nanri.aiimage.modules.appearancepatent.model.dto.AppearancePatentResultRowDto;
import com.nanri.aiimage.modules.appearancepatent.service.support.AppearancePatentLlmBatchPipeline;
import com.nanri.aiimage.modules.file.service.LocalFileStorageService;
import com.nanri.aiimage.modules.file.service.oss.OssStorageService;
import com.nanri.aiimage.modules.task.mapper.FileResultMapper;
@@ -137,7 +138,7 @@ class AppearancePatentRowMarkTimingTest {
when(taskCacheService.beginRowInspection(eq(TASK_ID), anyString())).thenReturn(true);
List<AppearancePatentResultRowDto> candidates = (List<AppearancePatentResultRowDto>) ReflectionTestUtils
.invokeMethod(service, "collectPendingLlmCandidates", List.of(chunk()), new AppearancePatentTaskService.ChunkRowKeyIndex());
.invokeMethod(service, "collectPendingLlmCandidates", List.of(chunk()), new AppearancePatentLlmBatchPipeline.ChunkRowKeyIndex());
assertEquals(2, candidates.size());
verify(taskCacheService).beginRowInspection(TASK_ID, "r1");
@@ -153,7 +154,7 @@ class AppearancePatentRowMarkTimingTest {
when(taskCacheService.beginRowInspection(eq(TASK_ID), eq("r2"))).thenReturn(false);
List<AppearancePatentResultRowDto> candidates = (List<AppearancePatentResultRowDto>) ReflectionTestUtils
.invokeMethod(service, "collectPendingLlmCandidates", List.of(chunk()), new AppearancePatentTaskService.ChunkRowKeyIndex());
.invokeMethod(service, "collectPendingLlmCandidates", List.of(chunk()), new AppearancePatentLlmBatchPipeline.ChunkRowKeyIndex());
assertEquals(1, candidates.size());
assertEquals("r1", candidates.get(0).getRowToken());
@@ -362,7 +363,7 @@ class AppearancePatentRowMarkTimingTest {
when(taskCacheService.beginRowInspection(eq(TASK_ID), anyString())).thenReturn(true);
List<AppearancePatentResultRowDto> candidates = (List<AppearancePatentResultRowDto>) ReflectionTestUtils
.invokeMethod(service, "collectPendingLlmCandidates", List.of(chunk()), new AppearancePatentTaskService.ChunkRowKeyIndex());
.invokeMethod(service, "collectPendingLlmCandidates", List.of(chunk()), new AppearancePatentLlmBatchPipeline.ChunkRowKeyIndex());
assertEquals(1, candidates.size());
assertEquals("r3", candidates.get(0).getRowToken());
@@ -387,7 +388,7 @@ class AppearancePatentRowMarkTimingTest {
List<AppearancePatentResultRowDto> candidates = (List<AppearancePatentResultRowDto>) ReflectionTestUtils
.invokeMethod(service, "collectPendingLlmCandidates", List.of(chunk()),
new AppearancePatentTaskService.ChunkRowKeyIndex());
new AppearancePatentLlmBatchPipeline.ChunkRowKeyIndex());
assertEquals(3, candidates.size(), "同父号三行必须都进候选,不能只检一行");
verify(taskCacheService).beginRowInspection(TASK_ID, "r21");
@@ -409,7 +410,7 @@ class AppearancePatentRowMarkTimingTest {
List<AppearancePatentResultRowDto> candidates = (List<AppearancePatentResultRowDto>) ReflectionTestUtils
.invokeMethod(service, "collectPendingLlmCandidates", List.of(chunk()),
new AppearancePatentTaskService.ChunkRowKeyIndex());
new AppearancePatentLlmBatchPipeline.ChunkRowKeyIndex());
assertEquals(1, candidates.size());
assertEquals("r22", candidates.get(0).getRowToken(), "该检的是没结论的那一行,不是已经检过的");
@@ -435,7 +436,7 @@ class AppearancePatentRowMarkTimingTest {
landed.setConclusion("无侵权");
ReflectionTestUtils.invokeMethod(service, "mergeLlmRowsIntoChunks",
task(), List.of(landed), List.of(landed), new AppearancePatentTaskService.ChunkRowKeyIndex());
task(), List.of(landed), List.of(landed), new AppearancePatentLlmBatchPipeline.ChunkRowKeyIndex());
ArgumentCaptor<String> written = ArgumentCaptor.forClass(String.class);
verify(transientPayloadStorageService, org.mockito.Mockito.atLeastOnce()).storeChunkPayloadVersioned(
@@ -266,13 +266,13 @@ class SourceScanTest {
// ---------------------------------------------------------------- N6 moduleSources
@Test
void moduleSources_appearancepatent返回31支含拆分后的support件() {
void moduleSources_appearancepatent返回32支含拆分后的support件() {
List<Path> files = SourceScan.moduleSources("modules/appearancepatent");
assertThat(files)
.as("真实集成:对真仓目录求值。31 支=1 controller+1 client+1 service 主件+3 spi/cache+"
+ "8 service/support+16 model(dto7/vo9),与 find 实测同号")
.hasSize(31);
.as("真实集成:对真仓目录求值。32 支=1 controller+1 client+1 service 主件+3 spi/cache+"
+ "9 service/support+16 model(dto7/vo9),与 find 实测同号")
.hasSize(32);
assertThat(files.stream().map(p -> p.toString().replace('\\', '/')).toList())
.as("support 目录里的既有件必须在面里——聚合入口存在的理由就是拆分后的新文件要自动被看到")
.anyMatch(rel -> rel.endsWith("service/support/AppearancePatentRowNormalizer.java"));
@@ -366,22 +366,23 @@ class SourceScanTest {
}
@Test
void recursive_包含service_support下的既有8件() {
void recursive_包含service_support下的既有9件() {
List<String> support = SourceScan.moduleSources("modules/appearancepatent").stream()
.map(p -> p.toString().replace('\\', '/'))
.filter(rel -> rel.contains("/service/support/"))
.toList();
assertThat(support)
.as("真实集成:对真仓 modules/appearancepatent/service/support 求值,实测 8 支(3A 拆薄把归属谓词、陈旧扫描、结果打包抽成三枚 support 件,5→8)。"
.as("真实集成:对真仓 modules/appearancepatent/service/support 求值,实测 9 支(3A 拆薄把归属谓词、陈旧扫描、结果打包、LLM 批管线抽成四枚 support 件,5→9)。"
+ "这一格就是聚合入口存在的理由——拆分出去的新文件必须自动进面")
.hasSize(8);
.hasSize(9);
assertThat(support)
.as("3A 拆出去的三枚新件必须被逐枚点名扫到:只把分母数字改大,下一回拆件又只剩「数不对」"
.as("3A 拆出去的四枚新件必须被逐枚点名扫到:只把分母数字改大,下一回拆件又只剩「数不对」"
+ "一记红,证不了「扫得到」这件事")
.anyMatch(rel -> rel.endsWith("service/support/AppearancePatentTaskOwnership.java"))
.anyMatch(rel -> rel.endsWith("service/support/AppearancePatentStaleTaskScanner.java"))
.anyMatch(rel -> rel.endsWith("service/support/AppearancePatentResultPackager.java"));
.anyMatch(rel -> rel.endsWith("service/support/AppearancePatentResultPackager.java"))
.anyMatch(rel -> rel.endsWith("service/support/AppearancePatentLlmBatchPipeline.java"));
}
@Test