docs: localize phase 13 legal materials
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
param(
|
||||
param(
|
||||
[string]$ArtifactRoot = "",
|
||||
[string]$LibraryRoot = "",
|
||||
[int]$MinLegalSources = 20,
|
||||
@@ -70,6 +70,62 @@ function Add-Check {
|
||||
}) | Out-Null
|
||||
}
|
||||
|
||||
function Convert-GateStatusText {
|
||||
param([string]$Status)
|
||||
switch ($Status) {
|
||||
"PASS" { return "通过" }
|
||||
"WARN" { return "通过但有警告" }
|
||||
"FAIL" { return "未通过" }
|
||||
"PASS_WITH_LEGAL_REVIEW_REQUIRED" { return "通过但仍需法务复核" }
|
||||
default { return $Status }
|
||||
}
|
||||
}
|
||||
|
||||
function Convert-AlertSeverityText {
|
||||
param([string]$Severity)
|
||||
switch ($Severity) {
|
||||
"critical" { return "严重" }
|
||||
"review_required" { return "需法务复核" }
|
||||
"warning" { return "警告" }
|
||||
"none" { return "无" }
|
||||
default { return $Severity }
|
||||
}
|
||||
}
|
||||
|
||||
function Convert-CheckStatusText {
|
||||
param([string]$Status)
|
||||
switch ($Status) {
|
||||
"pass" { return "通过" }
|
||||
"fail" { return "失败" }
|
||||
"warn" { return "警告" }
|
||||
"skip" { return "跳过" }
|
||||
"blocked" { return "阻塞" }
|
||||
default { return $Status }
|
||||
}
|
||||
}
|
||||
|
||||
function Convert-BoolText {
|
||||
param([bool]$Value)
|
||||
if ($Value) {
|
||||
return "是"
|
||||
}
|
||||
return "否"
|
||||
}
|
||||
|
||||
function Convert-KnowledgeDomainText {
|
||||
param([string]$Domain)
|
||||
switch ($Domain) {
|
||||
"civil-code" { return "民法典与合同通用" }
|
||||
"judicial-interpretations" { return "司法解释" }
|
||||
"company-commercial" { return "公司与商事" }
|
||||
"labor-employment" { return "劳动与用工" }
|
||||
"data-privacy" { return "数据与个人信息保护" }
|
||||
"intellectual-property" { return "知识产权" }
|
||||
"procurement-tendering" { return "采购与招投标" }
|
||||
default { return $Domain }
|
||||
}
|
||||
}
|
||||
|
||||
function Save-Json {
|
||||
param([string]$Path, [object]$Value)
|
||||
$Value | ConvertTo-Json -Depth 20 | Set-Content -Encoding UTF8 -Path $Path
|
||||
@@ -139,7 +195,7 @@ function Add-RequiredFileCheck {
|
||||
)
|
||||
$path = Join-Path $repoRoot $RelativePath
|
||||
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
|
||||
Add-Check -Key $Key -Label $Label -Status "fail" -Detail "Missing file: $RelativePath" -Meta @{ path = $path }
|
||||
Add-Check -Key $Key -Label $Label -Status "fail" -Detail "缺少文件:$RelativePath" -Meta @{ path = $path }
|
||||
$inventoryReport.Add([pscustomobject][ordered]@{
|
||||
key = $Key
|
||||
label = $Label
|
||||
@@ -165,9 +221,9 @@ function Add-RequiredFileCheck {
|
||||
}) | Out-Null
|
||||
|
||||
if ($schema.ok) {
|
||||
Add-Check -Key $Key -Label $Label -Status "pass" -Detail "Schema OK, rows=$($rows.Count)" -Meta @{ path = $path }
|
||||
Add-Check -Key $Key -Label $Label -Status "pass" -Detail "字段结构通过,行数=$($rows.Count)" -Meta @{ path = $path }
|
||||
} else {
|
||||
Add-Check -Key $Key -Label $Label -Status "fail" -Detail "Missing columns: $($schema.missing -join ',')" -Meta @{ path = $path; missing = $schema.missing }
|
||||
Add-Check -Key $Key -Label $Label -Status "fail" -Detail "缺少字段:$($schema.missing -join ',')" -Meta @{ path = $path; missing = $schema.missing }
|
||||
}
|
||||
return $rows
|
||||
}
|
||||
@@ -191,9 +247,9 @@ function Test-SecretLeak {
|
||||
}
|
||||
|
||||
if (-not (Test-Path "$HOME\.Codex\skills\gstack\bin")) {
|
||||
Add-Check -Key "gstack" -Label "gstack preflight" -Status "fail" -Detail "gstack is missing"
|
||||
Add-Check -Key "gstack" -Label "gstack 前置检查" -Status "fail" -Detail "gstack 缺失"
|
||||
} else {
|
||||
Add-Check -Key "gstack" -Label "gstack preflight" -Status "pass" -Detail "GSTACK_OK"
|
||||
Add-Check -Key "gstack" -Label "gstack 前置检查" -Status "pass" -Detail "GSTACK_OK"
|
||||
}
|
||||
|
||||
$branch = (git -C $repoRoot rev-parse --abbrev-ref HEAD).Trim()
|
||||
@@ -203,21 +259,21 @@ $gitStatus = git -C $repoRoot status --short
|
||||
($gitStatus -join [Environment]::NewLine) | Set-Content -Encoding UTF8 -Path $gitStatusPath
|
||||
|
||||
if ($remoteUrl -match "192\.168\.3\.90") {
|
||||
Add-Check -Key "origin_remote" -Label "origin remote" -Status "pass" -Detail "origin points to 192.168.3.90" -Meta @{ branch = $branch; commit = $commit; remote = $remoteUrl }
|
||||
Add-Check -Key "origin_remote" -Label "origin 远端仓库" -Status "pass" -Detail "origin 指向 192.168.3.90" -Meta @{ branch = $branch; commit = $commit; remote = $remoteUrl }
|
||||
} else {
|
||||
Add-Check -Key "origin_remote" -Label "origin remote" -Status "fail" -Detail "origin does not point to 192.168.3.90" -Meta @{ branch = $branch; commit = $commit; remote = $remoteUrl }
|
||||
Add-Check -Key "origin_remote" -Label "origin 远端仓库" -Status "fail" -Detail "origin 未指向 192.168.3.90" -Meta @{ branch = $branch; commit = $commit; remote = $remoteUrl }
|
||||
}
|
||||
|
||||
if ($gitStatus) {
|
||||
Add-Check -Key "working_tree" -Label "working tree" -Status "warn" -Required $false -Detail "Working tree has uncommitted changes; gate is advisory" -Meta @{ artifact = $gitStatusPath }
|
||||
Add-Check -Key "working_tree" -Label "工作区状态" -Status "warn" -Required $false -Detail "工作区存在未提交改动;本次门禁按提示性结果记录" -Meta @{ artifact = $gitStatusPath }
|
||||
} else {
|
||||
Add-Check -Key "working_tree" -Label "working tree" -Status "pass" -Detail "Working tree is clean" -Meta @{ artifact = $gitStatusPath }
|
||||
Add-Check -Key "working_tree" -Label "工作区状态" -Status "pass" -Detail "工作区干净" -Meta @{ artifact = $gitStatusPath }
|
||||
}
|
||||
|
||||
if (Test-Path -LiteralPath $LibraryRoot -PathType Container) {
|
||||
Add-Check -Key "library_root" -Label "phase13 library root" -Status "pass" -Detail "Library root exists" -Meta @{ root = $LibraryRoot }
|
||||
Add-Check -Key "library_root" -Label "阶段 13 资料包根目录" -Status "pass" -Detail "资料包根目录存在" -Meta @{ root = $LibraryRoot }
|
||||
} else {
|
||||
Add-Check -Key "library_root" -Label "phase13 library root" -Status "fail" -Detail "Library root is missing" -Meta @{ root = $LibraryRoot }
|
||||
Add-Check -Key "library_root" -Label "阶段 13 资料包根目录" -Status "fail" -Detail "资料包根目录缺失" -Meta @{ root = $LibraryRoot }
|
||||
}
|
||||
|
||||
$requiredDirs = @(
|
||||
@@ -237,9 +293,9 @@ $requiredDirs = @(
|
||||
|
||||
$missingDirs = @($requiredDirs | Where-Object { -not (Test-Path -LiteralPath (Join-Path $repoRoot $_) -PathType Container) })
|
||||
if ($missingDirs.Count -eq 0) {
|
||||
Add-Check -Key "directory_structure" -Label "directory structure" -Status "pass" -Detail "Required directories exist"
|
||||
Add-Check -Key "directory_structure" -Label "目录结构" -Status "pass" -Detail "必需目录均已存在"
|
||||
} else {
|
||||
Add-Check -Key "directory_structure" -Label "directory structure" -Status "fail" -Detail "Missing directories: $($missingDirs -join ',')" -Meta @{ missing = $missingDirs }
|
||||
Add-Check -Key "directory_structure" -Label "目录结构" -Status "fail" -Detail "缺少目录:$($missingDirs -join ',')" -Meta @{ missing = $missingDirs }
|
||||
}
|
||||
|
||||
$commonDocFiles = @(
|
||||
@@ -251,9 +307,9 @@ foreach ($docPath in $commonDocFiles) {
|
||||
$absoluteDocPath = Join-Path $repoRoot $docPath
|
||||
$key = "doc_" + ([System.IO.Path]::GetFileNameWithoutExtension($docPath) -replace "[^A-Za-z0-9]+", "_")
|
||||
if (Test-Path -LiteralPath $absoluteDocPath -PathType Leaf) {
|
||||
Add-Check -Key $key -Label $docPath -Status "pass" -Detail "Document exists" -Meta @{ path = $absoluteDocPath }
|
||||
Add-Check -Key $key -Label $docPath -Status "pass" -Detail "文档存在" -Meta @{ path = $absoluteDocPath }
|
||||
} else {
|
||||
Add-Check -Key $key -Label $docPath -Status "fail" -Detail "Document missing" -Meta @{ path = $absoluteDocPath }
|
||||
Add-Check -Key $key -Label $docPath -Status "fail" -Detail "文档缺失" -Meta @{ path = $absoluteDocPath }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,27 +323,27 @@ $generationSampleColumns = @("sample_id", "template_id", "contract_type", "varia
|
||||
$kbQaSampleColumns = @("sample_id", "question", "expected_answer_boundary", "expected_source_ids", "expected_citation_required", "expected_refusal_required", "status", "owner", "legal_reviewer", "review_required", "production_ready", "notes")
|
||||
$expertReviewColumns = @("review_id", "asset_type", "asset_id", "reviewer", "reviewer_role", "review_date", "review_result", "required_changes", "follow_up_owner", "evidence_path", "status", "notes")
|
||||
|
||||
$legalSourceRows = Add-RequiredFileCheck -Key "inventory_legal_sources" -Label "legal source inventory" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\legal-source-inventory.csv" -Columns $legalSourceColumns
|
||||
Add-RequiredFileCheck -Key "inventory_knowledge_cards" -Label "legal knowledge card inventory" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\legal-knowledge-card-inventory.csv" -Columns $knowledgeCardColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_risk_rules" -Label "review risk rule inventory" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\review-risk-rule-inventory.csv" -Columns $riskRuleColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_clauses" -Label "clause library inventory" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\clause-library-inventory.csv" -Columns $clauseColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_templates" -Label "contract template inventory" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\contract-template-inventory.csv" -Columns $templateColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_review_samples" -Label "review golden sample inventory" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\review-golden-sample-inventory.csv" -Columns $reviewSampleColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_generation_samples" -Label "generation golden sample inventory" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\generation-golden-sample-inventory.csv" -Columns $generationSampleColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_kb_qa_samples" -Label "KB QA golden sample inventory" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\kb-qa-golden-sample-inventory.csv" -Columns $kbQaSampleColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_expert_reviews" -Label "expert review register" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\expert-review-register.csv" -Columns $expertReviewColumns | Out-Null
|
||||
$legalSourceRows = Add-RequiredFileCheck -Key "inventory_legal_sources" -Label "法源清单" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\legal-source-inventory.csv" -Columns $legalSourceColumns
|
||||
Add-RequiredFileCheck -Key "inventory_knowledge_cards" -Label "法律知识卡清单" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\legal-knowledge-card-inventory.csv" -Columns $knowledgeCardColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_risk_rules" -Label "审核风险规则清单" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\review-risk-rule-inventory.csv" -Columns $riskRuleColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_clauses" -Label "标准条款库清单" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\clause-library-inventory.csv" -Columns $clauseColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_templates" -Label "合同模板清单" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\contract-template-inventory.csv" -Columns $templateColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_review_samples" -Label "合同审核黄金样本清单" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\review-golden-sample-inventory.csv" -Columns $reviewSampleColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_generation_samples" -Label "合同生成黄金样本清单" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\generation-golden-sample-inventory.csv" -Columns $generationSampleColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_kb_qa_samples" -Label "知识库问答黄金样本清单" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\kb-qa-golden-sample-inventory.csv" -Columns $kbQaSampleColumns | Out-Null
|
||||
Add-RequiredFileCheck -Key "inventory_expert_reviews" -Label "专家复核登记表" -RelativePath "project-docs\phase13-legal-knowledge-template-library\inventories\expert-review-register.csv" -Columns $expertReviewColumns | Out-Null
|
||||
|
||||
if ($legalSourceRows.Count -ge $MinLegalSources) {
|
||||
Add-Check -Key "legal_source_minimum" -Label "legal source minimum" -Status "pass" -Detail "Legal sources=$($legalSourceRows.Count), minimum=$MinLegalSources"
|
||||
Add-Check -Key "legal_source_minimum" -Label "法源数量下限" -Status "pass" -Detail "法源数量=$($legalSourceRows.Count),最低要求=$MinLegalSources"
|
||||
} else {
|
||||
Add-Check -Key "legal_source_minimum" -Label "legal source minimum" -Status "fail" -Detail "Legal sources=$($legalSourceRows.Count), minimum=$MinLegalSources"
|
||||
Add-Check -Key "legal_source_minimum" -Label "法源数量下限" -Status "fail" -Detail "法源数量=$($legalSourceRows.Count),最低要求=$MinLegalSources"
|
||||
}
|
||||
|
||||
$duplicateSourceIds = @($legalSourceRows | Group-Object source_id | Where-Object { $_.Count -gt 1 } | Select-Object -ExpandProperty Name)
|
||||
if ($duplicateSourceIds.Count -eq 0) {
|
||||
Add-Check -Key "legal_source_ids_unique" -Label "legal source IDs unique" -Status "pass" -Detail "No duplicate legal source IDs"
|
||||
Add-Check -Key "legal_source_ids_unique" -Label "法源编号唯一性" -Status "pass" -Detail "未发现重复法源编号"
|
||||
} else {
|
||||
Add-Check -Key "legal_source_ids_unique" -Label "legal source IDs unique" -Status "fail" -Detail "Duplicate IDs: $($duplicateSourceIds -join ',')" -Meta @{ duplicates = $duplicateSourceIds }
|
||||
Add-Check -Key "legal_source_ids_unique" -Label "法源编号唯一性" -Status "fail" -Detail "重复编号:$($duplicateSourceIds -join ',')" -Meta @{ duplicates = $duplicateSourceIds }
|
||||
}
|
||||
|
||||
$missingRequiredFields = @($legalSourceRows | Where-Object {
|
||||
@@ -300,57 +356,59 @@ $missingRequiredFields = @($legalSourceRows | Where-Object {
|
||||
[string]::IsNullOrWhiteSpace($_.owner)
|
||||
} | Select-Object -ExpandProperty source_id)
|
||||
if ($missingRequiredFields.Count -eq 0) {
|
||||
Add-Check -Key "legal_source_required_fields" -Label "legal source required fields" -Status "pass" -Detail "Required fields are populated"
|
||||
Add-Check -Key "legal_source_required_fields" -Label "法源必填字段" -Status "pass" -Detail "必填字段均已填写"
|
||||
} else {
|
||||
Add-Check -Key "legal_source_required_fields" -Label "legal source required fields" -Status "fail" -Detail "Rows missing required fields: $($missingRequiredFields -join ',')" -Meta @{ rows = $missingRequiredFields }
|
||||
Add-Check -Key "legal_source_required_fields" -Label "法源必填字段" -Status "fail" -Detail "以下行缺少必填字段:$($missingRequiredFields -join ',')" -Meta @{ rows = $missingRequiredFields }
|
||||
}
|
||||
|
||||
$nonOfficialUrls = @($legalSourceRows | Where-Object { -not (Test-AllowedOfficialUrl -Url $_.source_url) } | Select-Object -ExpandProperty source_id)
|
||||
if ($nonOfficialUrls.Count -eq 0) {
|
||||
Add-Check -Key "official_source_urls" -Label "official source URLs" -Status "pass" -Detail "All legal source URLs use official allowlisted domains"
|
||||
Add-Check -Key "official_source_urls" -Label "官方来源地址" -Status "pass" -Detail "所有法源地址均使用白名单官方域名"
|
||||
} else {
|
||||
Add-Check -Key "official_source_urls" -Label "official source URLs" -Status "fail" -Detail "Non-allowlisted source URLs: $($nonOfficialUrls -join ',')" -Meta @{ rows = $nonOfficialUrls; allowed_domains = $allowedDomains }
|
||||
Add-Check -Key "official_source_urls" -Label "官方来源地址" -Status "fail" -Detail "以下法源地址不在官方域名白名单内:$($nonOfficialUrls -join ',')" -Meta @{ rows = $nonOfficialUrls; allowed_domains = $allowedDomains }
|
||||
}
|
||||
|
||||
$unknownValidityRows = @($legalSourceRows | Where-Object { $_.validity_status -eq "VERIFY_REQUIRED" -or $_.effective_date -eq "VERIFY_REQUIRED" } | Select-Object -ExpandProperty source_id)
|
||||
if ($unknownValidityRows.Count -gt 0) {
|
||||
Add-Check -Key "legal_review_required" -Label "legal review required" -Status "warn" -Required $false -Detail "Legal source validity still requires legal review: $($unknownValidityRows.Count) rows" -Meta @{ rows = $unknownValidityRows }
|
||||
Add-Check -Key "legal_review_required" -Label "法务复核要求" -Status "warn" -Required $false -Detail "仍有 $($unknownValidityRows.Count) 条法源需要法务确认有效状态或施行日期" -Meta @{ rows = $unknownValidityRows }
|
||||
} else {
|
||||
Add-Check -Key "legal_review_required" -Label "legal review required" -Status "pass" -Detail "Legal source validity is verified"
|
||||
Add-Check -Key "legal_review_required" -Label "法务复核要求" -Status "pass" -Detail "法源有效状态已确认"
|
||||
}
|
||||
|
||||
$publishedWithoutReview = @($legalSourceRows | Where-Object {
|
||||
@("APPROVED", "PUBLISHED") -contains $_.status -and
|
||||
([string]::IsNullOrWhiteSpace($_.legal_reviewer) -or $_.legal_reviewer -eq "pending" -or $_.validity_status -eq "VERIFY_REQUIRED")
|
||||
([string]::IsNullOrWhiteSpace($_.legal_reviewer) -or @("pending", "待法务复核", "待复核") -contains $_.legal_reviewer -or $_.validity_status -eq "VERIFY_REQUIRED")
|
||||
} | Select-Object -ExpandProperty source_id)
|
||||
if ($publishedWithoutReview.Count -eq 0) {
|
||||
Add-Check -Key "no_unreviewed_publication" -Label "no unreviewed publication" -Status "pass" -Detail "No legal source is published without review"
|
||||
Add-Check -Key "no_unreviewed_publication" -Label "未复核资料禁止发布" -Status "pass" -Detail "未发现未经复核即发布的法源"
|
||||
} else {
|
||||
Add-Check -Key "no_unreviewed_publication" -Label "no unreviewed publication" -Status "fail" -Detail "Published/approved rows missing review: $($publishedWithoutReview -join ',')" -Meta @{ rows = $publishedWithoutReview }
|
||||
Add-Check -Key "no_unreviewed_publication" -Label "未复核资料禁止发布" -Status "fail" -Detail "以下已批准或已发布法源缺少复核记录:$($publishedWithoutReview -join ',')" -Meta @{ rows = $publishedWithoutReview }
|
||||
}
|
||||
|
||||
$statusValues = @("DRAFT", "LEGAL_REVIEW", "BUSINESS_REVIEW", "APPROVED", "PUBLISHED", "DEPRECATED")
|
||||
$invalidStatuses = @($legalSourceRows | Where-Object { $statusValues -notcontains $_.status } | Select-Object -ExpandProperty source_id)
|
||||
if ($invalidStatuses.Count -eq 0) {
|
||||
Add-Check -Key "legal_source_status_values" -Label "legal source status values" -Status "pass" -Detail "Legal source statuses are allowed"
|
||||
Add-Check -Key "legal_source_status_values" -Label "法源状态值" -Status "pass" -Detail "法源状态均在允许范围内"
|
||||
} else {
|
||||
Add-Check -Key "legal_source_status_values" -Label "legal source status values" -Status "fail" -Detail "Invalid statuses: $($invalidStatuses -join ',')" -Meta @{ rows = $invalidStatuses; allowed = $statusValues }
|
||||
Add-Check -Key "legal_source_status_values" -Label "法源状态值" -Status "fail" -Detail "以下法源状态无效:$($invalidStatuses -join ',')" -Meta @{ rows = $invalidStatuses; allowed = $statusValues }
|
||||
}
|
||||
|
||||
$domainsCovered = @($legalSourceRows | Select-Object -ExpandProperty knowledge_domain -Unique)
|
||||
$requiredDomains = @("civil-code", "judicial-interpretations", "company-commercial", "labor-employment", "data-privacy", "intellectual-property", "procurement-tendering")
|
||||
$missingKnowledgeDomains = @($requiredDomains | Where-Object { $domainsCovered -notcontains $_ })
|
||||
$domainsCoveredText = (@($domainsCovered | ForEach-Object { Convert-KnowledgeDomainText -Domain $_ }) -join "、")
|
||||
$missingKnowledgeDomainsText = (@($missingKnowledgeDomains | ForEach-Object { Convert-KnowledgeDomainText -Domain $_ }) -join "、")
|
||||
if ($missingKnowledgeDomains.Count -eq 0) {
|
||||
Add-Check -Key "knowledge_domain_coverage" -Label "knowledge domain coverage" -Status "pass" -Detail "Domains covered: $($domainsCovered -join ',')"
|
||||
Add-Check -Key "knowledge_domain_coverage" -Label "知识领域覆盖" -Status "pass" -Detail "已覆盖领域:$domainsCoveredText"
|
||||
} else {
|
||||
Add-Check -Key "knowledge_domain_coverage" -Label "knowledge domain coverage" -Status "fail" -Detail "Missing knowledge domains: $($missingKnowledgeDomains -join ',')" -Meta @{ missing = $missingKnowledgeDomains }
|
||||
Add-Check -Key "knowledge_domain_coverage" -Label "知识领域覆盖" -Status "fail" -Detail "缺少知识领域:$missingKnowledgeDomainsText" -Meta @{ missing = $missingKnowledgeDomains }
|
||||
}
|
||||
|
||||
$secretHits = Test-SecretLeak -Root $LibraryRoot
|
||||
if ($secretHits.Count -eq 0) {
|
||||
Add-Check -Key "secret_scan" -Label "secret scan" -Status "pass" -Detail "No administrator password literal found in Phase 13 package or gate script"
|
||||
Add-Check -Key "secret_scan" -Label "敏感信息扫描" -Status "pass" -Detail "阶段 13 资料包和门禁脚本中未发现管理员密码明文"
|
||||
} else {
|
||||
Add-Check -Key "secret_scan" -Label "secret scan" -Status "fail" -Detail "Sensitive literal found" -Meta @{ hits = $secretHits }
|
||||
Add-Check -Key "secret_scan" -Label "敏感信息扫描" -Status "fail" -Detail "发现敏感明文" -Meta @{ hits = $secretHits }
|
||||
}
|
||||
|
||||
$legalSourceRows |
|
||||
@@ -412,37 +470,41 @@ $summary = [ordered]@{
|
||||
}
|
||||
Save-Json -Path $summaryJson -Value $summary
|
||||
|
||||
$overallStatusText = Convert-GateStatusText -Status $overallStatus
|
||||
$alertSeverityText = Convert-AlertSeverityText -Severity $alertSeverity
|
||||
$md = New-Object System.Collections.Generic.List[string]
|
||||
$md.Add("# Phase 13 Legal Knowledge Library Gate") | Out-Null
|
||||
$md.Add("# 阶段 13 法律知识库资料门禁") | Out-Null
|
||||
$md.Add("") | Out-Null
|
||||
$md.Add("- Status: $overallStatus") | Out-Null
|
||||
$md.Add("- Alert severity: $alertSeverity") | Out-Null
|
||||
$md.Add("- Generated at: $($summary.generated_at)") | Out-Null
|
||||
$md.Add("- Branch: $branch") | Out-Null
|
||||
$md.Add("- Commit: $commit") | Out-Null
|
||||
$md.Add("- Artifact dir: $artifactDir") | Out-Null
|
||||
$md.Add("- Library root: $LibraryRoot") | Out-Null
|
||||
$md.Add("- 门禁状态:$overallStatusText($overallStatus)") | Out-Null
|
||||
$md.Add("- 告警级别:$alertSeverityText($alertSeverity)") | Out-Null
|
||||
$md.Add("- 生成时间:$($summary.generated_at)") | Out-Null
|
||||
$md.Add("- 分支:$branch") | Out-Null
|
||||
$md.Add("- 提交:$commit") | Out-Null
|
||||
$md.Add("- 产物目录:$artifactDir") | Out-Null
|
||||
$md.Add("- 资料包根目录:$LibraryRoot") | Out-Null
|
||||
$md.Add("") | Out-Null
|
||||
$md.Add("## Metrics") | Out-Null
|
||||
$md.Add("## 指标") | Out-Null
|
||||
$md.Add("") | Out-Null
|
||||
$md.Add("| Metric | Count |") | Out-Null
|
||||
$md.Add("| 指标 | 数量 |") | Out-Null
|
||||
$md.Add("|---|---:|") | Out-Null
|
||||
$md.Add("| Legal sources | $($legalSourceRows.Count) |") | Out-Null
|
||||
$md.Add("| Allowed official domains | $($allowedDomains.Count) |") | Out-Null
|
||||
$md.Add("| Knowledge domains | $($domainsCovered.Count) |") | Out-Null
|
||||
$md.Add("| Inventory files | $($inventoryReport.Count) |") | Out-Null
|
||||
$md.Add("| Legal review required rows | $legalReviewRequired |") | Out-Null
|
||||
$md.Add("| 官方法源 | $($legalSourceRows.Count) |") | Out-Null
|
||||
$md.Add("| 允许的官方域名 | $($allowedDomains.Count) |") | Out-Null
|
||||
$md.Add("| 知识领域 | $($domainsCovered.Count) |") | Out-Null
|
||||
$md.Add("| 清单文件 | $($inventoryReport.Count) |") | Out-Null
|
||||
$md.Add("| 仍需法务复核的法源 | $legalReviewRequired |") | Out-Null
|
||||
$md.Add("") | Out-Null
|
||||
$md.Add("## Checks") | Out-Null
|
||||
$md.Add("## 检查项") | Out-Null
|
||||
$md.Add("") | Out-Null
|
||||
$md.Add("| Check | Required | Status | Detail |") | Out-Null
|
||||
$md.Add("| 检查项 | 必需 | 状态 | 说明 |") | Out-Null
|
||||
$md.Add("|---|---:|---|---|") | Out-Null
|
||||
foreach ($check in $checks) {
|
||||
$detail = ([string]$check.detail).Replace("|", "/")
|
||||
$md.Add("| $($check.label) | $($check.required) | $($check.status.ToUpperInvariant()) | $detail |") | Out-Null
|
||||
$requiredText = Convert-BoolText -Value $check.required
|
||||
$statusText = Convert-CheckStatusText -Status $check.status
|
||||
$md.Add("| $($check.label) | $requiredText | $statusText($($check.status.ToUpperInvariant())) | $detail |") | Out-Null
|
||||
}
|
||||
$md.Add("") | Out-Null
|
||||
$md.Add("Local artifacts:") | Out-Null
|
||||
$md.Add("本地产物:") | Out-Null
|
||||
$md.Add("") | Out-Null
|
||||
$md.Add('- `legal-knowledge-library-gate-summary.json`') | Out-Null
|
||||
$md.Add('- `legal-knowledge-library-gate-summary.md`') | Out-Null
|
||||
@@ -452,15 +514,15 @@ $md | Set-Content -Encoding UTF8 -Path $summaryMd
|
||||
|
||||
if ($overallStatus -eq "FAIL") {
|
||||
Write-Host "PHASE13_LEGAL_KNOWLEDGE_LIBRARY_GATE_FAIL $artifactDir"
|
||||
throw "Phase 13 legal knowledge library gate failed. See $summaryMd"
|
||||
throw "阶段 13 法律知识库资料门禁未通过。查看:$summaryMd"
|
||||
}
|
||||
if ($overallStatus -eq "WARN" -and $FailOnWarn) {
|
||||
Write-Host "PHASE13_LEGAL_KNOWLEDGE_LIBRARY_GATE_WARN $artifactDir"
|
||||
throw "Phase 13 legal knowledge library gate has warnings. See $summaryMd"
|
||||
throw "阶段 13 法律知识库资料门禁存在警告。查看:$summaryMd"
|
||||
}
|
||||
if ($overallStatus -eq "PASS_WITH_LEGAL_REVIEW_REQUIRED" -and $FailOnLegalReviewRequired) {
|
||||
Write-Host "PHASE13_LEGAL_KNOWLEDGE_LIBRARY_GATE_PASS_WITH_LEGAL_REVIEW_REQUIRED $artifactDir"
|
||||
throw "Phase 13 legal knowledge library gate requires legal review. See $summaryMd"
|
||||
throw "阶段 13 法律知识库资料门禁仍需法务复核。查看:$summaryMd"
|
||||
}
|
||||
|
||||
Write-Host "PHASE13_LEGAL_KNOWLEDGE_LIBRARY_GATE_$overallStatus $artifactDir"
|
||||
|
||||
Reference in New Issue
Block a user