Enclose Kalsa author material behind spoilers

This commit is contained in:
Meta Vens 2026-08-22 19:40:31 +02:00
commit 8eae0bdd16
100 changed files with 816 additions and 552 deletions

View file

@ -26,7 +26,7 @@ if (-not $contentFull.StartsWith($repoFull + [System.IO.Path]::DirectorySeparato
}
$errors = @()
$reserved = @('seed', 'workshop', '.epiphany', '.voidbot', 'site', '.github', 'scripts', 'quartz-site', '.quartz-build')
$reserved = @('seed', 'workshop', 'spoilers', '.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)"

View file

@ -0,0 +1,73 @@
param(
[string]$VaultRoot
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
if (-not $VaultRoot) {
$VaultRoot = Join-Path $repoRoot "Kalsa"
}
$vaultFull = [System.IO.Path]::GetFullPath($VaultRoot).TrimEnd('\', '/')
if (-not (Test-Path -LiteralPath $vaultFull -PathType Container)) {
throw "Kalsa vault root not found: $vaultFull"
}
$errors = @()
$allowedDirectories = @('Public', 'Spoilers', '.obsidian')
$allowedFiles = @('index.md')
foreach ($item in Get-ChildItem -LiteralPath $vaultFull -Force) {
if ($item.PSIsContainer) {
if ($item.Name -notin $allowedDirectories) {
$errors += "unexpected top-level directory: $($item.Name)"
}
}
elseif ($item.Name -notin $allowedFiles) {
$errors += "unexpected top-level file: $($item.Name)"
}
}
$readerIndex = Join-Path $vaultFull 'Public\index.md'
$spoilerIndex = Join-Path $vaultFull 'Spoilers\index.md'
$rootIndex = Join-Path $vaultFull 'index.md'
foreach ($path in @($readerIndex, $spoilerIndex, $rootIndex)) {
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
$errors += "required vault entrance missing: $path"
}
}
if (Test-Path -LiteralPath $rootIndex -PathType Leaf) {
$rootText = Get-Content -Raw -LiteralPath $rootIndex -Encoding utf8
if ($rootText -notmatch '\[\[Public/index(?:\||\]\])') {
$errors += "root index does not lead to Public/index"
}
if ($rootText -notmatch '\[\[Spoilers/index(?:\||\]\])') {
$errors += "root index does not mark a deliberate Spoilers/index path"
}
}
$obsidianRoot = Join-Path $vaultFull '.obsidian'
foreach ($sessionName in @('workspace.json', 'workspace-mobile.json', 'workspaces.json')) {
$sessionPath = Join-Path $obsidianRoot $sessionName
if (Test-Path -LiteralPath $sessionPath -PathType Leaf) {
$sessionText = Get-Content -Raw -LiteralPath $sessionPath -Encoding utf8
if ($sessionText -match '(?i)Spoilers[/\\]') {
$errors += "Obsidian session state bypasses the spoiler gate: .obsidian/$sessionName"
}
}
}
foreach ($note in Get-ChildItem -LiteralPath $vaultFull -Recurse -File -Filter '*.md') {
$relative = $note.FullName.Substring($vaultFull.Length).TrimStart('\', '/') -replace '\\', '/'
if ($relative -ne 'index.md' -and
-not $relative.StartsWith('Public/', [System.StringComparison]::OrdinalIgnoreCase) -and
-not $relative.StartsWith('Spoilers/', [System.StringComparison]::OrdinalIgnoreCase)) {
$errors += "Markdown outside the reader or spoiler sections: $relative"
}
}
if ($errors.Count -gt 0) {
throw "Vault-layout verification failed:`n- $($errors -join "`n- ")"
}
Write-Output "Vault layout passed: casual exploration is limited to Public, Spoilers, and the navigation-only root index."

View file

@ -7,7 +7,7 @@ $ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
if (-not $ContentRoot) {
$ContentRoot = Join-Path $repoRoot "Kalsa"
$ContentRoot = Join-Path $repoRoot "Kalsa\Spoilers"
}
function Measure-Branch {

View file

@ -45,6 +45,44 @@ try {
}
Remove-Item -LiteralPath $staleOutput -Force
$vault = Join-Path $fixtureFull "KalsaVault"
$vaultPublic = Join-Path $vault "Public"
$vaultSpoilers = Join-Path $vault "Spoilers"
New-Item -ItemType Directory -Path $vaultPublic, $vaultSpoilers -Force | Out-Null
Set-Content -LiteralPath (Join-Path $vault "index.md") -Encoding utf8 -Value "# Vault`n`n[[Public/index|Readers]]`n`n[[Spoilers/index|Spoilers]]"
Set-Content -LiteralPath (Join-Path $vaultPublic "index.md") -Encoding utf8 -Value "# Readers"
Set-Content -LiteralPath (Join-Path $vaultSpoilers "index.md") -Encoding utf8 -Value "# Spoilers"
& (Join-Path $PSScriptRoot "check-vault-layout.ps1") -VaultRoot $vault
$exposed = Join-Path $vault "Foundations"
New-Item -ItemType Directory -Path $exposed | Out-Null
Set-Content -LiteralPath (Join-Path $exposed "Hidden.md") -Encoding utf8 -Value "# Hidden"
$caughtExposedDirectory = $false
try {
& (Join-Path $PSScriptRoot "check-vault-layout.ps1") -VaultRoot $vault | Out-Null
}
catch {
$caughtExposedDirectory = $true
}
if (-not $caughtExposedDirectory) {
throw "Vault-layout checker failed to reject an exposed author directory"
}
Remove-Item -LiteralPath $exposed -Recurse -Force
$vaultObsidian = Join-Path $vault ".obsidian"
New-Item -ItemType Directory -Path $vaultObsidian | Out-Null
Set-Content -LiteralPath (Join-Path $vaultObsidian "workspace.json") -Encoding utf8 -Value '{"main":{"file":"Spoilers/Foundations/Hidden.md"}}'
$caughtSpoilerSession = $false
try {
& (Join-Path $PSScriptRoot "check-vault-layout.ps1") -VaultRoot $vault | Out-Null
}
catch {
$caughtSpoilerSession = $true
}
if (-not $caughtSpoilerSession) {
throw "Vault-layout checker failed to reject spoiler-bound Obsidian session state"
}
$broken = Join-Path $content "Broken.md"
Set-Content -LiteralPath $broken -Encoding utf8 -Value "# Broken`n`nSee [[No Such Note]]."
$caughtBrokenLink = $false
@ -89,7 +127,7 @@ try {
}
Remove-Item -LiteralPath $brokenEscape -Force
$forbidden = Join-Path $content "workshop"
$forbidden = Join-Path $content "Spoilers"
New-Item -ItemType Directory -Path $forbidden | Out-Null
$caughtBoundary = $false
try {
@ -99,10 +137,10 @@ try {
$caughtBoundary = $true
}
if (-not $caughtBoundary) {
throw "Publication checker failed to reject a nested workshop directory"
throw "Publication checker failed to reject a nested spoiler directory"
}
Write-Output "Lore tool tests passed, including broken-link, broken-anchor, escaped-link, stale-output, and publication-boundary negative checks."
Write-Output "Lore tool tests passed, including broken-link, broken-anchor, escaped-link, stale-output, exposed-vault-directory, spoiler-session, and publication-boundary negative checks."
}
finally {
$resolvedFixture = [System.IO.Path]::GetFullPath($fixtureFull)