Build vault, memory, and Quartz operating surfaces
This commit is contained in:
parent
36783c14be
commit
6b62f17ccf
28 changed files with 1383 additions and 0 deletions
69
scripts/lore/check-publication-boundary.ps1
Normal file
69
scripts/lore/check-publication-boundary.ps1
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
param(
|
||||
[string]$RepositoryRoot,
|
||||
[string]$ContentRoot,
|
||||
[switch]$SkipEntrypointCheck
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
if (-not $RepositoryRoot) {
|
||||
$RepositoryRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
}
|
||||
$repoFull = [System.IO.Path]::GetFullPath($RepositoryRoot).TrimEnd('\', '/')
|
||||
if (-not $ContentRoot) {
|
||||
$ContentRoot = Join-Path $repoFull "Kalsa"
|
||||
}
|
||||
$contentFull = [System.IO.Path]::GetFullPath($ContentRoot).TrimEnd('\', '/')
|
||||
|
||||
if (-not (Test-Path -LiteralPath $repoFull -PathType Container)) {
|
||||
throw "Repository root not found: $repoFull"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $contentFull -PathType Container)) {
|
||||
throw "Canonical publication root not found: $contentFull"
|
||||
}
|
||||
if (-not $contentFull.StartsWith($repoFull + [System.IO.Path]::DirectorySeparatorChar, [System.StringComparison]::OrdinalIgnoreCase)) {
|
||||
throw "Publication root must remain inside the repository root"
|
||||
}
|
||||
|
||||
$errors = @()
|
||||
$reserved = @('seed', 'workshop', '.epiphany', '.voidbot', 'site', '.github', 'scripts', 'quartz-site', '.quartz-build')
|
||||
foreach ($directory in Get-ChildItem -LiteralPath $contentFull -Recurse -Directory -Force) {
|
||||
if ($directory.Name.ToLowerInvariant() -in $reserved) {
|
||||
$errors += "reserved project directory nested in publication root: $($directory.FullName)"
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($item in Get-ChildItem -LiteralPath $contentFull -Recurse -Force) {
|
||||
if (($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint) -ne 0) {
|
||||
$errors += "reparse point may escape publication ownership: $($item.FullName)"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $SkipEntrypointCheck) {
|
||||
$launcher = Join-Path $repoFull "scripts\quartz\quartz.ps1"
|
||||
$workflow = Join-Path $repoFull ".github\workflows\deploy-quartz.yml"
|
||||
if (-not (Test-Path -LiteralPath $launcher -PathType Leaf)) {
|
||||
$errors += "Quartz launcher missing: $launcher"
|
||||
}
|
||||
else {
|
||||
$launcherText = Get-Content -Raw -LiteralPath $launcher -Encoding utf8
|
||||
if ($launcherText -notmatch '(?s)--contentDir.{0,80}["'']Kalsa["'']') {
|
||||
$errors += "Quartz launcher does not bind --contentDir to Kalsa"
|
||||
}
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $workflow -PathType Leaf)) {
|
||||
$errors += "Quartz deployment workflow missing: $workflow"
|
||||
}
|
||||
else {
|
||||
$workflowText = Get-Content -Raw -LiteralPath $workflow -Encoding utf8
|
||||
if ($workflowText -notmatch '(?m)^\s*content-dir:\s*Kalsa\s*$') {
|
||||
$errors += "Quartz deployment workflow does not bind content-dir to Kalsa"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors.Count -gt 0) {
|
||||
throw "Publication-boundary verification failed:`n- $($errors -join "`n- ")"
|
||||
}
|
||||
|
||||
Write-Output "Publication boundary passed: only $contentFull is admitted as canonical site input."
|
||||
81
scripts/lore/check-wikilinks.ps1
Normal file
81
scripts/lore/check-wikilinks.ps1
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
param(
|
||||
[string]$ContentRoot
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
if (-not $ContentRoot) {
|
||||
$ContentRoot = Join-Path $repoRoot "Kalsa"
|
||||
}
|
||||
$contentFull = [System.IO.Path]::GetFullPath($ContentRoot)
|
||||
if (-not (Test-Path -LiteralPath $contentFull -PathType Container)) {
|
||||
throw "Canonical content root not found: $contentFull"
|
||||
}
|
||||
|
||||
$notes = @(Get-ChildItem -LiteralPath $contentFull -Recurse -File -Filter '*.md')
|
||||
$allFiles = @(Get-ChildItem -LiteralPath $contentFull -Recurse -File)
|
||||
$noteByStem = @{}
|
||||
$noteByRelative = @{}
|
||||
$fileByName = @{}
|
||||
|
||||
foreach ($note in $notes) {
|
||||
$stem = [System.IO.Path]::GetFileNameWithoutExtension($note.Name).ToLowerInvariant()
|
||||
if (-not $noteByStem.ContainsKey($stem)) { $noteByStem[$stem] = @() }
|
||||
$noteByStem[$stem] += $note.FullName
|
||||
$relative = $note.FullName.Substring($contentFull.Length).TrimStart('\', '/') -replace '\\', '/'
|
||||
$noteByRelative[([System.IO.Path]::ChangeExtension($relative, $null).TrimEnd('.').ToLowerInvariant())] = $note.FullName
|
||||
}
|
||||
foreach ($file in $allFiles) {
|
||||
$key = $file.Name.ToLowerInvariant()
|
||||
if (-not $fileByName.ContainsKey($key)) { $fileByName[$key] = @() }
|
||||
$fileByName[$key] += $file.FullName
|
||||
}
|
||||
|
||||
$errors = @()
|
||||
$linkCount = 0
|
||||
foreach ($note in $notes) {
|
||||
$text = Get-Content -Raw -LiteralPath $note.FullName -Encoding utf8
|
||||
foreach ($match in [regex]::Matches($text, '!??\[\[(?<target>[^\]]+)\]\]')) {
|
||||
$linkCount += 1
|
||||
$target = ($match.Groups['target'].Value -split '\|', 2)[0]
|
||||
$target = ($target -split '#', 2)[0].Trim()
|
||||
if (-not $target) { continue }
|
||||
$target = $target -replace '\\', '/'
|
||||
$resolved = @()
|
||||
$extension = [System.IO.Path]::GetExtension($target)
|
||||
if ($extension -and $extension.ToLowerInvariant() -ne '.md') {
|
||||
$relativeAsset = [System.IO.Path]::GetFullPath((Join-Path $note.DirectoryName $target))
|
||||
$rootAsset = [System.IO.Path]::GetFullPath((Join-Path $contentFull $target))
|
||||
if (Test-Path -LiteralPath $relativeAsset -PathType Leaf) { $resolved += $relativeAsset }
|
||||
if (Test-Path -LiteralPath $rootAsset -PathType Leaf) { $resolved += $rootAsset }
|
||||
$assetName = [System.IO.Path]::GetFileName($target).ToLowerInvariant()
|
||||
if ($fileByName.ContainsKey($assetName)) { $resolved += $fileByName[$assetName] }
|
||||
}
|
||||
else {
|
||||
$noteTarget = if ($extension) { [System.IO.Path]::ChangeExtension($target, $null).TrimEnd('.') } else { $target }
|
||||
$relativeKey = $noteTarget.TrimStart('/')
|
||||
if ($noteByRelative.ContainsKey($relativeKey.ToLowerInvariant())) {
|
||||
$resolved += $noteByRelative[$relativeKey.ToLowerInvariant()]
|
||||
}
|
||||
$relativeCandidate = [System.IO.Path]::GetFullPath((Join-Path $note.DirectoryName ($noteTarget + '.md')))
|
||||
if (Test-Path -LiteralPath $relativeCandidate -PathType Leaf) { $resolved += $relativeCandidate }
|
||||
$stem = [System.IO.Path]::GetFileName($noteTarget).ToLowerInvariant()
|
||||
if ($noteByStem.ContainsKey($stem)) { $resolved += $noteByStem[$stem] }
|
||||
}
|
||||
$resolved = @($resolved | Sort-Object -Unique)
|
||||
$sourceRelative = $note.FullName.Substring($contentFull.Length).TrimStart('\', '/')
|
||||
if ($resolved.Count -eq 0) {
|
||||
$errors += "$sourceRelative -> [[$($match.Groups['target'].Value)]] is unresolved"
|
||||
}
|
||||
elseif ($resolved.Count -gt 1 -and $target -notmatch '[/\\]') {
|
||||
$errors += "$sourceRelative -> [[$($match.Groups['target'].Value)]] is ambiguous across $($resolved.Count) files"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors.Count -gt 0) {
|
||||
throw "Wikilink verification failed:`n- $($errors -join "`n- ")"
|
||||
}
|
||||
|
||||
Write-Output "Wikilink verification passed: $linkCount links across $($notes.Count) canonical notes."
|
||||
72
scripts/lore/measure-depth.ps1
Normal file
72
scripts/lore/measure-depth.ps1
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
param(
|
||||
[string]$ContentRoot,
|
||||
[string]$CompareRoot = "F:\Projects\AetheriaLore\Aetheria\Worldbuilding"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
if (-not $ContentRoot) {
|
||||
$ContentRoot = Join-Path $repoRoot "Kalsa"
|
||||
}
|
||||
|
||||
function Measure-Branch {
|
||||
param(
|
||||
[string]$Root,
|
||||
[string]$Label
|
||||
)
|
||||
|
||||
$full = [System.IO.Path]::GetFullPath($Root)
|
||||
if (-not (Test-Path -LiteralPath $full -PathType Container)) {
|
||||
throw "Depth input root not found: $full"
|
||||
}
|
||||
$rows = @()
|
||||
foreach ($file in Get-ChildItem -LiteralPath $full -Recurse -File -Filter '*.md') {
|
||||
$text = Get-Content -Raw -LiteralPath $file.FullName -Encoding utf8
|
||||
$relative = $file.FullName.Substring($full.Length).TrimStart('\', '/')
|
||||
$rows += [pscustomobject]@{
|
||||
Path = $relative
|
||||
IsIndex = $file.Name -ieq 'index.md'
|
||||
Words = ([regex]::Matches($text, "\b[\p{L}\p{N}'-]+\b")).Count
|
||||
Wikilinks = ([regex]::Matches($text, '\[\[')).Count
|
||||
Headings = ([regex]::Matches($text, '(?m)^#{1,6}\s')).Count
|
||||
}
|
||||
}
|
||||
|
||||
$nonIndex = @($rows | Where-Object { -not $_.IsIndex })
|
||||
$wordValues = @($nonIndex.Words | Sort-Object)
|
||||
$median = if ($wordValues.Count -eq 0) { 0 } else { $wordValues[[math]::Floor($wordValues.Count / 2)] }
|
||||
$summary = [pscustomobject]@{
|
||||
Branch = $Label
|
||||
Notes = $rows.Count
|
||||
NonIndexNotes = $nonIndex.Count
|
||||
Words = ($rows | Measure-Object Words -Sum).Sum
|
||||
Wikilinks = ($rows | Measure-Object Wikilinks -Sum).Sum
|
||||
Headings = ($rows | Measure-Object Headings -Sum).Sum
|
||||
MedianNonIndexWords = $median
|
||||
NotesWithoutWikilinks = @($nonIndex | Where-Object { $_.Wikilinks -eq 0 }).Count
|
||||
}
|
||||
return [pscustomobject]@{ Summary = $summary; Rows = $rows }
|
||||
}
|
||||
|
||||
$kalsa = Measure-Branch -Root $ContentRoot -Label "Kalsa canonical"
|
||||
$summaries = @($kalsa.Summary)
|
||||
if (Test-Path -LiteralPath $CompareRoot -PathType Container) {
|
||||
$comparison = Measure-Branch -Root $CompareRoot -Label "Aetheria worldbuilding"
|
||||
$summaries += $comparison.Summary
|
||||
}
|
||||
else {
|
||||
Write-Warning "Comparison root not available: $CompareRoot"
|
||||
}
|
||||
|
||||
Write-Output "Structural diagnostics (counts are pressure signals, not a depth verdict):"
|
||||
$summaries | Format-Table -AutoSize
|
||||
|
||||
Write-Output "Kalsa notes with the least connective structure:"
|
||||
$kalsa.Rows |
|
||||
Where-Object { -not $_.IsIndex } |
|
||||
Sort-Object @{ Expression = 'Wikilinks'; Ascending = $true }, @{ Expression = 'Words'; Ascending = $true } |
|
||||
Select-Object -First 20 Path, Words, Wikilinks, Headings |
|
||||
Format-Table -AutoSize
|
||||
|
||||
Write-Output "Qualitative parity still requires the review in workshop/deepening/benchmark.md."
|
||||
59
scripts/lore/test-lore-tools.ps1
Normal file
59
scripts/lore/test-lore-tools.ps1
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$tempBase = [System.IO.Path]::GetFullPath([System.IO.Path]::GetTempPath()).TrimEnd('\', '/')
|
||||
$fixture = Join-Path $tempBase ("kalsa-lore-tools-" + [guid]::NewGuid().ToString())
|
||||
New-Item -ItemType Directory -Path $fixture | Out-Null
|
||||
$fixtureFull = [System.IO.Path]::GetFullPath($fixture)
|
||||
if (-not $fixtureFull.StartsWith($tempBase + [System.IO.Path]::DirectorySeparatorChar, [System.StringComparison]::OrdinalIgnoreCase)) {
|
||||
throw "Refusing to create test fixture outside the system temporary directory"
|
||||
}
|
||||
|
||||
try {
|
||||
$content = Join-Path $fixtureFull "Kalsa"
|
||||
New-Item -ItemType Directory -Path $content | Out-Null
|
||||
Set-Content -LiteralPath (Join-Path $content "index.md") -Encoding utf8 -Value "# Fixture`n`nSee [[Institution]]."
|
||||
Set-Content -LiteralPath (Join-Path $content "Institution.md") -Encoding utf8 -Value "# Institution`n`nA bounded test note."
|
||||
|
||||
& (Join-Path $PSScriptRoot "verify-seed.ps1")
|
||||
& (Join-Path $PSScriptRoot "check-wikilinks.ps1") -ContentRoot $content
|
||||
& (Join-Path $PSScriptRoot "check-publication-boundary.ps1") -RepositoryRoot $fixtureFull -ContentRoot $content -SkipEntrypointCheck
|
||||
& (Join-Path $PSScriptRoot "measure-depth.ps1") -ContentRoot $content -CompareRoot (Join-Path $fixtureFull "missing-comparison") | Out-Null
|
||||
|
||||
$broken = Join-Path $content "Broken.md"
|
||||
Set-Content -LiteralPath $broken -Encoding utf8 -Value "# Broken`n`nSee [[No Such Note]]."
|
||||
$caughtBrokenLink = $false
|
||||
try {
|
||||
& (Join-Path $PSScriptRoot "check-wikilinks.ps1") -ContentRoot $content | Out-Null
|
||||
}
|
||||
catch {
|
||||
$caughtBrokenLink = $true
|
||||
}
|
||||
if (-not $caughtBrokenLink) {
|
||||
throw "Wikilink checker failed to reject an unresolved link"
|
||||
}
|
||||
Remove-Item -LiteralPath $broken -Force
|
||||
|
||||
$forbidden = Join-Path $content "workshop"
|
||||
New-Item -ItemType Directory -Path $forbidden | Out-Null
|
||||
$caughtBoundary = $false
|
||||
try {
|
||||
& (Join-Path $PSScriptRoot "check-publication-boundary.ps1") -RepositoryRoot $fixtureFull -ContentRoot $content -SkipEntrypointCheck | Out-Null
|
||||
}
|
||||
catch {
|
||||
$caughtBoundary = $true
|
||||
}
|
||||
if (-not $caughtBoundary) {
|
||||
throw "Publication checker failed to reject a nested workshop directory"
|
||||
}
|
||||
|
||||
Write-Output "Lore tool tests passed, including broken-link and publication-boundary negative checks."
|
||||
}
|
||||
finally {
|
||||
$resolvedFixture = [System.IO.Path]::GetFullPath($fixtureFull)
|
||||
if ($resolvedFixture.StartsWith($tempBase + [System.IO.Path]::DirectorySeparatorChar, [System.StringComparison]::OrdinalIgnoreCase) -and
|
||||
([System.IO.Path]::GetFileName($resolvedFixture) -like 'kalsa-lore-tools-*') -and
|
||||
(Test-Path -LiteralPath $resolvedFixture)) {
|
||||
Remove-Item -LiteralPath $resolvedFixture -Recurse -Force
|
||||
}
|
||||
}
|
||||
73
scripts/lore/verify-seed.ps1
Normal file
73
scripts/lore/verify-seed.ps1
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
param(
|
||||
[string]$ManifestPath,
|
||||
[string]$SeedRoot
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
if (-not $ManifestPath) {
|
||||
$ManifestPath = Join-Path $repoRoot "seed\manifest.md"
|
||||
}
|
||||
if (-not $SeedRoot) {
|
||||
$SeedRoot = Join-Path $repoRoot "seed\original"
|
||||
}
|
||||
|
||||
$manifestFull = [System.IO.Path]::GetFullPath($ManifestPath)
|
||||
$seedFull = [System.IO.Path]::GetFullPath($SeedRoot)
|
||||
if (-not (Test-Path -LiteralPath $manifestFull -PathType Leaf)) {
|
||||
throw "Seed manifest not found: $manifestFull"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $seedFull -PathType Container)) {
|
||||
throw "Seed directory not found: $seedFull"
|
||||
}
|
||||
|
||||
$manifest = Get-Content -LiteralPath $manifestFull -Encoding utf8
|
||||
$entries = @()
|
||||
foreach ($line in $manifest) {
|
||||
$match = [regex]::Match($line, '^\|\s*`(?<file>[^`]+)`\s*\|\s*(?<bytes>[\d,]+)\s*\|\s*`(?<hash>[0-9a-fA-F]{64})`\s*\|')
|
||||
if ($match.Success) {
|
||||
$entries += [pscustomobject]@{
|
||||
File = $match.Groups['file'].Value
|
||||
Bytes = [int64]($match.Groups['bytes'].Value -replace ',', '')
|
||||
Hash = $match.Groups['hash'].Value.ToLowerInvariant()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($entries.Count -eq 0) {
|
||||
throw "No seed entries were parsed from $manifestFull"
|
||||
}
|
||||
if (($entries.File | Sort-Object -Unique).Count -ne $entries.Count) {
|
||||
throw "Seed manifest contains duplicate filenames"
|
||||
}
|
||||
|
||||
$errors = @()
|
||||
foreach ($entry in $entries) {
|
||||
$path = Join-Path $seedFull $entry.File
|
||||
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
|
||||
$errors += "missing: $($entry.File)"
|
||||
continue
|
||||
}
|
||||
$item = Get-Item -LiteralPath $path
|
||||
if ($item.Length -ne $entry.Bytes) {
|
||||
$errors += "size mismatch: $($entry.File) expected $($entry.Bytes), found $($item.Length)"
|
||||
}
|
||||
$actualHash = (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||
if ($actualHash -ne $entry.Hash) {
|
||||
$errors += "hash mismatch: $($entry.File) expected $($entry.Hash), found $actualHash"
|
||||
}
|
||||
}
|
||||
|
||||
$expected = @($entries.File | Sort-Object)
|
||||
$actual = @(Get-ChildItem -LiteralPath $seedFull -File | Select-Object -ExpandProperty Name | Sort-Object)
|
||||
$unexpected = @($actual | Where-Object { $_ -notin $expected })
|
||||
if ($unexpected.Count -gt 0) {
|
||||
$errors += "unmanifested seed files: $($unexpected -join ', ')"
|
||||
}
|
||||
|
||||
if ($errors.Count -gt 0) {
|
||||
throw "Seed verification failed:`n- $($errors -join "`n- ")"
|
||||
}
|
||||
|
||||
Write-Output "Seed verification passed: $($entries.Count) immutable witnesses match size and SHA-256."
|
||||
51
scripts/quartz/quartz.ps1
Normal file
51
scripts/quartz/quartz.ps1
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
param(
|
||||
[ValidateSet("build", "dev")]
|
||||
[string]$Command = "dev"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$sharedQuartzRoot = if ($env:GAMECULT_QUARTZ_ROOT) {
|
||||
$env:GAMECULT_QUARTZ_ROOT
|
||||
} else {
|
||||
Join-Path (Split-Path -Parent $repoRoot) "GameCult-Quartz"
|
||||
}
|
||||
$portableNodeRoot = Join-Path $repoRoot ".tools\node-v24.15.0-win-x64"
|
||||
$portableNode = Join-Path $portableNodeRoot "node.exe"
|
||||
|
||||
# Prefer the bundled Windows runtime when present, then fall back to Node on PATH.
|
||||
if (Test-Path $portableNode) {
|
||||
$node = $portableNode
|
||||
$env:PATH = "$portableNodeRoot;$env:PATH"
|
||||
} else {
|
||||
$nodeCommand = Get-Command node -ErrorAction SilentlyContinue
|
||||
if (-not $nodeCommand) {
|
||||
throw "node was not found. Install Node.js or restore the portable runtime under .tools."
|
||||
}
|
||||
|
||||
$node = $nodeCommand.Source
|
||||
}
|
||||
|
||||
$env:npm_config_cache = Join-Path $repoRoot ".npm-cache"
|
||||
|
||||
if (-not (Test-Path $sharedQuartzRoot)) {
|
||||
throw "GameCult-Quartz was not found at '$sharedQuartzRoot'. Clone it beside this repo or set GAMECULT_QUARTZ_ROOT."
|
||||
}
|
||||
|
||||
$buildScript = Join-Path $sharedQuartzRoot "scripts\build-site.mjs"
|
||||
|
||||
if (-not (Test-Path $buildScript)) {
|
||||
throw "GameCult-Quartz build script was not found at '$buildScript'."
|
||||
}
|
||||
|
||||
$scriptArgs = @(
|
||||
$buildScript,
|
||||
$Command,
|
||||
"--siteRoot", $repoRoot,
|
||||
"--overlayDir", "site",
|
||||
"--contentDir", "Kalsa",
|
||||
"--outputDir", "quartz-site/public"
|
||||
)
|
||||
|
||||
& $node @scriptArgs
|
||||
Loading…
Reference in a new issue