diff --git a/scripts/agents-index-contract.ps1 b/scripts/agents-index-contract.ps1 index afdb175cf..4052af722 100644 --- a/scripts/agents-index-contract.ps1 +++ b/scripts/agents-index-contract.ps1 @@ -28,6 +28,13 @@ function Assert-Contains([string]$text, [string]$needle, [string]$scope) { } } +function Assert-Matches([string]$text, [string]$pattern, [string]$scope) { + $script:checked++ + if ($text -notmatch $pattern) { + Add-Failure "$scope 未匹配合同: $pattern" + } +} + function Assert-Path([string]$relativePath) { $script:checked++ $absolutePath = Join-Path $workspaceRoot $relativePath @@ -108,6 +115,33 @@ foreach ($pdaApplication in $pdaApplications) { } } +# 文档声明为正式开放的 Client 海外仓页面必须仍是 active 路由。 +$clientOverseasRoutesPath = Join-Path $workspaceRoot 'apps/client-web/src/modules/overseas-warehouse/routes.ts' +$clientOverseasRoutes = Read-RequiredText $clientOverseasRoutesPath +foreach ($route in @( + 'overseas-warehouse/labeling', + 'overseas-warehouse/storage-transfer', + 'overseas-warehouse/cargo-disposal', + 'overseas-warehouse/return-relabel' +)) { + $routePattern = "(?s)path:\s*'$([regex]::Escape($route))'.{0,500}?release:\s*'active'" + Assert-Matches $clientOverseasRoutes $routePattern "Client 正式路由 $route" +} + +# 根索引中的海外浏览器 API 必须被海外 Gateway 显式覆盖。 +$overseasGatewayConfigPath = Join-Path $backendRoot 'gateway-overseas/src/main/resources/application-overseas.yml' +$overseasGatewayConfig = Read-RequiredText $overseasGatewayConfigPath +foreach ($gatewayPath in @( + '/api/merchant/v1/last-leg/**', + '/api/platform/v1/last-leg/**', + '/api/merchant/v1/warehouses/**', + '/api/platform/v1/warehouse-admin/**' +)) { + Assert-Contains $overseasGatewayConfig $gatewayPath 'Overseas Gateway 路由' +} +Assert-Contains $overseasGatewayConfig 'uri: lb://lastleg-service' 'Overseas Gateway Lastleg 路由' +Assert-Contains $overseasGatewayConfig 'uri: lb://warehouse-overseas-service' 'Overseas Gateway Warehouse 路由' + # Maven 聚合声明的全部历史/当前模块必须在后端根指引中可定位。 [xml]$pom = Get-Content -LiteralPath (Join-Path $backendRoot 'pom.xml') -Raw foreach ($module in $pom.project.modules.module) { @@ -163,6 +197,12 @@ $criticalPaths = @( 'baiyue-firstleg/gateway-overseas/src/test/java/com/baiyue/gateway/config/OverseasLastlegRouteContractTest.java', 'baiyue-firstleg/event-bridge-service/src/main/java/com/baiyue/eventbridge/service/FirstlegEventClient.java', 'baiyue-firstleg/common-event-contract/src/main/java/com/baiyue/common/event/FirstLegLoadingPlanCompletedV2.java', + 'baiyue-firstleg/firstleg/src/test/java/com/baiyue/firstleg/service/TaillegRealProducerAcceptanceTest.java', + 'baiyue-firstleg/lastleg-service/src/main/java/com/baiyue/lastleg/entity/LastlegInboundOrder.java', + 'baiyue-firstleg/lastleg-service/src/main/java/com/baiyue/lastleg/mapper/LastlegInboundOrderMapper.java', + 'baiyue-firstleg/lastleg-service/src/test/java/com/baiyue/lastleg/service/TaillegRealConsumerAcceptanceTest.java', + 'baiyue-firstleg/deploy/scripts/deploy-built-service.sh', + 'baiyue-firstleg/scripts/deploy-built-service-rollback.test.mjs', 'docs/四期/船节点标准化契约.md' ) $criticalPaths | ForEach-Object { Assert-Path $_ } @@ -182,11 +222,12 @@ $indexedAgentFiles = @( (Join-Path $backendRoot 'file/AGENTS.md'), (Join-Path $backendRoot 'common-event-contract/AGENTS.md') ) -$excludedTargetPattern = '(?i)`(?:[^`]*/)?(node_modules|node_modules\.broken-by-path|dist|target|reports|output|outputs|uni_modules|\.git|\.codex[^/`]*)(?:/|`)' +$excludedTargetPattern = '(?i)`(?:[^`]*/)?(node_modules|node_modules\.broken-by-path|dist|target|reports|output|outputs|uni_modules|\.git|\.codex[^/`]*|\.runtime[^/`]*)(?:/|`)' $excludedPatternSamples = @( '| 错误入口 | `node_modules/pkg/` |', '| 错误入口 | `src/target/classes/` |', - '| 错误入口 | `.codex-temp/task/` |' + '| 错误入口 | `.codex-temp/task/` |', + '| 错误入口 | `.runtime-tailleg/DbQuery.java` |' ) foreach ($sample in $excludedPatternSamples) { $script:checked++ @@ -215,5 +256,5 @@ if ($failures.Count -gt 0) { exit 1 } -Write-Host "AGENTS 索引合同通过:$checked 项检查,覆盖快速表唯一性、部署单元、前端模块、PDA 注册页面、Maven 模块、关键入口和排除目录。" -ForegroundColor Green +Write-Host "AGENTS 索引合同通过:$checked 项检查,覆盖快速表唯一性、部署单元、前端模块、Client active 路由、Gateway 覆盖、PDA 注册页面、Maven 模块、关键入口和排除目录。" -ForegroundColor Green exit 0