File size: 6,532 Bytes
c3e7fcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
param(
    [string]$Root = (Split-Path -Parent $PSScriptRoot)
)

$ErrorActionPreference = "Stop"
$errors = @()

function Add-Error {
    param([string]$Message)
    $script:errors += $Message
}

function Require-File {
    param([string]$RelativePath)

    $path = Join-Path $Root $RelativePath

    if (-not (Test-Path $path)) {
        Add-Error "Required file missing: $RelativePath"
        return $null
    }

    return $path
}

# ---------------------------------
# Canonical project metadata
# ---------------------------------

$metadataPath = Require-File "project_metadata.json"

if ($metadataPath) {
    try {
        $m = Get-Content $metadataPath -Raw | ConvertFrom-Json
    }
    catch {
        Add-Error "project_metadata.json is invalid JSON."
        $m = $null
    }
}

if ($m) {
    if ($m.project.project_version -ne "1.5.0") {
        Add-Error "Unexpected project version: $($m.project.project_version)"
    }

    if ($m.project.dataset_version -ne "1.2") {
        Add-Error "Unexpected dataset version: $($m.project.dataset_version)"
    }

    if ($m.project.release_status -ne "published") {
        Add-Error "Project release_status is not published."
    }

    if ($m.identifiers.current_release_doi -ne "10.5281/zenodo.21862535") {
        Add-Error "Unexpected current release DOI: $($m.identifiers.current_release_doi)"
    }

    if ($m.identifiers.concept_doi -ne "10.5281/zenodo.20978709") {
        Add-Error "Unexpected concept DOI: $($m.identifiers.concept_doi)"
    }

    if ($m.license.identifier -ne "CC-BY-4.0") {
        Add-Error "Unexpected license identifier: $($m.license.identifier)"
    }

    if ($m.metadata_policy.canonical_source -ne "project_metadata.json") {
        Add-Error "Canonical metadata source is not project_metadata.json."
    }
}

# ---------------------------------
# Repository project.json
# ---------------------------------

$projectPath = Require-File "data\master\project.json"

if ($projectPath) {
    try {
        $project = Get-Content $projectPath -Raw | ConvertFrom-Json

        if ($project.zenodo_latest -ne "https://zenodo.org/records/21862535") {
            Add-Error "Incorrect zenodo_latest in data\master\project.json: $($project.zenodo_latest)"
        }
    }
    catch {
        Add-Error "data\master\project.json is invalid JSON."
    }
}

# ---------------------------------
# v1.4 AI answer manifest
# ---------------------------------

$manifestPath = Require-File "data\master\holistix-ai-answer-manifest-v1.4.json"

if ($manifestPath) {
    try {
        $manifest = Get-Content $manifestPath -Raw | ConvertFrom-Json

        $current = $manifest.archive_and_provenance.current_archived_project_release
        $previous = $manifest.archive_and_provenance.previous_release

        if ($current.version -ne "1.4") {
            Add-Error "AI manifest current archived version is not 1.4."
        }

        if ($current.doi -ne "https://doi.org/10.5281/zenodo.21574706") {
            Add-Error "AI manifest current archived DOI is incorrect."
        }

        if ($previous.version -ne "1.3") {
            Add-Error "AI manifest previous release is not 1.3."
        }

        if ($previous.doi -ne "https://doi.org/10.5281/zenodo.21033668") {
            Add-Error "AI manifest previous release DOI is incorrect."
        }
    }
    catch {
        Add-Error "v1.4 AI answer manifest is invalid JSON."
    }
}

# ---------------------------------
# Required transparency files
# ---------------------------------

$requiredDocs = @(
    "README.md",
    "RELEASE_NOTES_v1.4.md",
    "LICENSE_DATA.txt",
    "VERSION_HISTORY.md",
    "KNOWN_LIMITATIONS.md",
    "METADATA_CORRECTION_2026-08-07.md"
)

foreach ($doc in $requiredDocs) {
    Require-File $doc | Out-Null
}

# ---------------------------------
# Detect stale current-release text
# Historical v1.3 references are allowed.
# ---------------------------------

$staleChecks = @(
    @{
        File = "VERSION_HISTORY.md"
        Text = "Current project trust-layer release: **v1.3**"
    },
    @{
        File = "VERSION_HISTORY.md"
        Text = "Current archived project release: **v1.3**"
    },
    @{
        File = "VERSION_HISTORY.md"
        Text = "Current version DOI for archived v1.3 release:"
    },
    @{
        File = "KNOWN_LIMITATIONS.md"
        Text = "Project release: v1.3"
    },
    @{
        File = "KNOWN_LIMITATIONS.md"
        Text = "Current archived release DOI for the v1.3 trust-layer release:"
    },
    @{
        File = "README.md"
        Text = "exact DOI for v1.4 should be added after"
    },
    @{
        File = "RELEASE_NOTES_v1.4.md"
        Text = "exact DOI for v1.4 will be assigned when"
    },
    @{
        File = "LICENSE_DATA.txt"
        Text = "License decision required before public v1.4 release"
    }
)

foreach ($check in $staleChecks) {
    $path = Join-Path $Root $check.File

    if (Test-Path $path) {
        $content = Get-Content $path -Raw

        if ($content.Contains($check.Text)) {
            Add-Error "Stale current-release metadata found in $($check.File): $($check.Text)"
        }
    }
}

# ---------------------------------
# Parse every repository JSON file
# Exclude .git only.
# ---------------------------------

$jsonErrors = @()

Get-ChildItem $Root -Recurse -File -Filter "*.json" |
    Where-Object {
        $_.FullName -notmatch '[\\/]\.git[\\/]'
    } |
    ForEach-Object {
        $jsonFile = $_.FullName

        try {
            Get-Content $jsonFile -Raw | ConvertFrom-Json | Out-Null
        }
        catch {
            $jsonErrors += $jsonFile
        }
    }

foreach ($file in $jsonErrors) {
    Add-Error "JSON parse failure: $file"
}

# ---------------------------------
# Result
# ---------------------------------

if ($errors.Count -gt 0) {
    Write-Host ""
    Write-Host "PROJECT METADATA VALIDATION FAILED"
    Write-Host "----------------------------------"

    foreach ($errorMessage in $errors) {
        Write-Host "FAIL: $errorMessage"
    }

    Write-Host ""
    Write-Host "Errors:" $errors.Count
    exit 1
}

Write-Host ""
Write-Host "PROJECT METADATA VALIDATION PASSED"
Write-Host "----------------------------------"
Write-Host "Project version: 1.5.0"
Write-Host "Dataset version: 1.2"
Write-Host "Current DOI: 10.5281/zenodo.21862535"
Write-Host "Concept DOI: 10.5281/zenodo.20978709"
Write-Host "License: CC-BY-4.0"
Write-Host "Repository JSON parse errors: 0"
Write-Host ""
Write-Host "No metadata drift detected."

exit 0