maintain | 2026-08-07 机制固化(frontmatter 字段审计强制 + 月度回顾归档提醒)+ 18 页补 last_updated

This commit is contained in:
AAsige
2026-08-07 17:35:48 +08:00
parent 87f8143db0
commit f1c7036c33
21 changed files with 56 additions and 1 deletions
+29
View File
@@ -69,6 +69,28 @@ foreach ($page in $pages) {
}
$text = [IO.File]::ReadAllText($page.FullName)
# frontmatter 必填字段(schema 第 3 节:title/type/last_updated/tags/confidence
# 导航页整体豁免(走导航 frontmatter 约定),raw_sources 另对 query 页豁免)
$fmMatch = [regex]::Match($text, '(?s)^---\r?\n(.*?)\r?\n---')
if ($fmMatch.Success) {
$fmText = $fmMatch.Groups[1].Value
$isNavPage = $page.Name -in @('INDEX.md', 'Glossary.md', 'sources.md', '期货研究资料目录.md', '期货资料来源与证据边界.md')
if (-not $isNavPage) {
foreach ($field in @('title', 'type', 'last_updated', 'tags', 'confidence')) {
if (-not [regex]::IsMatch($fmText, "(?m)^$field\s*:")) {
Add-Warning "missing frontmatter field '$field' in $($page.FullName)"
}
}
}
$isQueryPage = [regex]::IsMatch($fmText, '(?m)^type:\s*query')
if (-not $isQueryPage -and -not $isNavPage) {
if (-not [regex]::IsMatch($fmText, '(?m)^raw_sources\s*:')) {
Add-Warning "missing raw_sources field in $($page.FullName)"
}
}
}
foreach ($match in [regex]::Matches($text, '\[\[([^\]|#]+)(?:#[^\]|]+)?(?:\|[^\]]+)?\]\]')) {
$target = $match.Groups[1].Value.Trim()
if (-not $byBaseName.ContainsKey($target)) {
@@ -137,6 +159,13 @@ if (Test-Path -LiteralPath $State -PathType Leaf) {
Add-Error "compile-results.tsv does not exist: $State"
}
# 月度回顾页积累提醒(schema 第 7 节时序内容约定:满 3 页应归档最早为历史层)
$reviewPages = @($pages | Where-Object { $_.BaseName -match '20\d{2}年\d{1,2}月市场回顾$' })
if ($reviewPages.Count -ge 3) {
$reviewNames = ($reviewPages | Sort-Object Name | ForEach-Object { $_.BaseName }) -join '、'
Add-Warning "月度回顾页已积累 $($reviewPages.Count) 页($reviewNames);按 schema 时序内容约定应归档最早页面为历史层(status: historical)并由季度/年度综述承接"
}
$allTextFiles = @(Get-ChildItem -LiteralPath $Root -Recurse -File -Include '*.md', '*.tsv', '*.log' -ErrorAction SilentlyContinue)
$deletedSourceRefs = @()
foreach ($file in $allTextFiles) {